Board index » delphi » addressing serial port?

addressing serial port?

hi all!
I took Pascal in High School and now i want to use Pascal to program some
robotics that i wish to control via the serial port of an old laptop of
mine. I will be using Turbo Pascal 7 for DOS (unless theres a better pacage,
Borland is what i have) and i want to address the actual pins independantly
and use the voltage across the pins as triggers for actions. is this remotly
posible in pascal? is there a command or way to program a single pin to
'turn on' or 'off'?
Please help i couldnt find any websites that were any help.
thanks all for any thing that you can tell me.
ben hengs...@osu.edu
 

Re:addressing serial port?


Hi,

on Sun, 23 Apr 2000 at 03:45:10 o'clock, suzzi wrote:

Quote
> I took Pascal in High School and now i want to use Pascal to program some
> robotics that i wish to control via the serial port of an old laptop of
> mine. I will be using Turbo Pascal 7 for DOS (unless theres a better pacage,
> Borland is what i have) and i want to address the actual pins independantly
> and use the voltage across the pins as triggers for actions.

Then I see no reason for you to use the serial port. As the name
implies, it was constructed for serial I/O, which requires some kind
of UART on the other end. Use the parallel port instead.

Quote
> is this remotly
> posible in pascal? is there a command or way to program a single pin to
> 'turn on' or 'off'?

Yes, you only have to write it :-) Let's say, your parallel port is at
$378 (a common address, but old notebooks are a chapter for
themselves), then you can set the state of the 8 data lines (pin 2-9)
by writing a byte to this port. A sketch:

   const Par = $378;
   var state : Byte;

   procedure SetBit(BitNum : Byte);  { zero-based }
   begin
      State := State or 1 shl BitNum;
      Port[$378] := State;
   end;

   procedure ClrBit(BitNum : Byte);
   begin
      State := State and not (1 shl BitNum);
      Port[$378] := State;
   end;

   begin
      State := 0;
      :
      :
   end;

And this is pure Pascal!

Quote
> Please help i couldnt find any websites that were any help.

Try, if it still works, <http://www.senet.com.au/~cpeacock/>

 - Sebastian

Re:addressing serial port?


Hi,

Quote
>> and i want to address the actual pins independantly
>> and use the voltage across the pins as triggers for actions.

I forgot to mention somthing important: Do *not* use the voltage
directly, not even for small circuits. The computer's chipset is not
supposed to supply high currents. Instead, you should always use a
bus driver such as the 74245. This is also not supposed to drive large
circuits, but remember that a laptop chipset may be expensive and hard
to get hold of (if it is replacable at all), while a 74LS245 costs EUR
0.79 at Conrad Electronic and can be put in a socket. In case of an
emergency, the bus driver sacrifices its life to protect the computer.

Experience shows that a 245 can drive a couple of LEDs, but *not* a
motor or something like that. In this case, you will have to use
transistors, possibly in combination with relais.

 - Sebastian

Other Threads