HOME - - - - - - - - - Other material for programmers - - - - - - - - - Pascalite, "How To Use It" main page

Pascalite hardware: Using the RS-232 port


Using the RS-232 port



The following assumes you've got your Pascalite set up and working. If it gives you what you want, great. Be advised, however, that this page is subordinate to others. Visit my Pascalite, "How To Use It" main page if you came drectly here and there are things "missing".




(You can show numbers on the LCD if you have one, but the following programs will also send at least part of every number to the four LEDs for those of you without an LCD display.)

All along, we've been using the Pascalite's RS-232 port for communication with the development PC. Fine. But it can be used for other things, too... just not at the same time!

I have in mind setting up a Pascalite to monitor some weather sensors. The Pascalite will pre-process those signals, and then via the RS232 port, pass the digested data onto a bigger PC which will log the data on a hard disk, and plot a display. I'm sure you could also feed stuff INto the Pascalite over the RS-232, but that's a project for another day. (That tutorial has been drafted. Send me an email if you want to hasten it's appearance on the web....)

Here is the essentials of writing out via the RS-232.

Enter the following program. Your Pascalite will need a momentary switch on d4, as in IntTut2.

program IntTutRS232;
var bTmp:byte;

begin
def_out(d0);
write(LCD,255); {clears LCD}
repeat
reset(d0);{turns LED off}
repeat
  read(portd,bTmp);
  bTmp:=btmp and 16;
until bTmp=0;
write(RS232,"Hi");
write(RS232,13,10);
set(d0);{turns LED on}
delay(500);
until 4=5;
end.



When you run this program, it waits for you to push the button. When you push the button, it sends "hi" out on the RS-232 connection. It also sends 10 and 13, aka CR / LF, which will help with the appearance of the data on the receiving computer.... a new line is started after each "Hi".

"BUT!," I hear you cry. "Where does it GO?" It's all well and good me telling you the program works. Can you see it? Yes.

If your development PC doesn't already have Hyperterminal on it, put it on... Settings | Control Panel | Add/Remove Programs, Windows Setup tab.

Start Hyper terminal running. File | New Connection Name it "Pascalite" (or other of your choice) Skip over "Country code", etc, going to the last edit box on that pane, "Connect using", and make it "Direct to Comm 1" (or whatever Comm port you're using to send programs to the Pascalite.) Set the port as before: (For Pascalite Plus: 57600 / 8 /None / 2 / No handshake)

If you have already compiled and downloaded the program above, try pressing the switch on d4. You should get "hi" in the Hyperterminal window each time you do.

If you have to program (or re-program) the Pascalite, you must first disconnect Hyperterminal from the comm port. There's a button for this, or you can use Call | Disconnect from the Hyperterminal menu. THEN you can download the new program to the Pascalite... same cabel, same connections, just temporarily dedicated to program download. Once the program is downloaded, you need to REconnect Hyperterminal. Again, there's a button, or you can use Call | Connect. The first time you close Hyperterminal, it asks if you want to save the "session". You do: This is your Pascalite settings. The next time you open the Hyperterminal folder, you'll see Pascalite (or Pascalite.ht if you are not hiding extensions.) Doubleclick this to go straight into where you want to be.

The only "tricky" aspect of this is realising that the connection between the Pascalite software on the development PC cannot share the RS-232 with the Hyperterminal link. Only one or the other can be active at one time. The Pascalite connection turns itself on, if the RS-232 is free, when you ask to download a program, and turns itself off once the programmhas gone. You have to turn the Hyperterminal connection on and off "by hand". Note that you do NOT have to turn the Hyperterminal program on and off each time.

The Pascalite end of dumb, handshake-less RS-232 communication is pretty easy. For information of programming a Windows machine to talk with your Pascalite by something of your own creation in Delphi (as opposed to just using Hyperterminal) see my Delphi tutorial on the subject of serial communication.


To search THIS site.... (Go to the site's above, and use their search buttons if you want to seach them.)... Way to search this site without using forms
Search this site or the web powered by FreeFind

Site search Web search

Ad from page's editor: Yes.. I do enjoy compiling these things for you... hope they are helpful. However.. this doesn't pay my bills!!! If you find this stuff useful, (and you run an MS-DOS or Windows pc) please visit my freeware and shareware page, download something, and circulate it for me? Links on your page to this page would also be appreciated!
Click here to visit editor's freeware, shareware page.

Link to editor's (Arunet) homepage
How to email or write this page's editor, Tom Boyd