low level device control

Ignacio Vazquez-Abrams ignacio at openservices.net
Thu Aug 23 05:27:20 CEST 2001


On Thu, 23 Aug 2001, Greg Saunders wrote:

> First, let me state that I am a python newbie but absolutely love the
> language and am having a great deal of fun with it. Hail to the BDFL.
>
> Here's the challage and I'm not exactly sure where to start.
>
> I need to control two pairs of pin outs on a hardward device. The device
> has four pin outs. PIN1 sends a 12 volt pulse and is returned to ground
> via PIN2 if the two are shorted. PIN3 and PIN4 are either shorted, or
> not, putting the device in ready/not ready state respectively. The pulse
> on PIN1 needs to be read and counted (one count per pulse).
>
> PIN1 - pulse
> PIN2 - used to return pulse to ground if shorted
>
> PIN3 - creates a circuit with PIN4 if closed
> PIN4 - as above and puts the device into READY if shorted with PIN3
>
> Here's what I want to do. I want to use python and a serial connection
> to read the pulses on PIN1 and be able to open and close the circuit
> programmatically on PIN3 and PIN4.
>
> I can hack together a custom cable to tie into the harness.
>
> My program knowledge is limited and my python knowledge is even more
> limited (but I'm learning quickly :-) but not quick enough). I've
> scanned throught the "termios" library reference but it does not appear
> to be what I'm looking for.
>
> Any help would be much appreciated.
>
> Greg Saunders

Unfortunately you have more than just a programming problem. You have the
additional problem that there is nothing in PC hardware that is even capable
of doing what you need. Serial ports use around +12 and -12 volts, and
parallel ports use 0 and +5 volts. You can do what you want through the
parallel port, but you need a few things first:

1) a circuit to connect to pin 1 that emits +5 volts when +12 volts is input,
2) a +12-volt source to connect to pin 2 via a relay or MOSFET, and
3) a relay or MOSFET(s) that can short-ciruit pin 3 to pin 4.

I can help you more with the hardware part if you'd like off-list.

For the software part I'd suggest write a module in C (it's not THAT hard...)
that will access the parallel port directly, possibly doing most of the work
of the application. I can help you with that as well.

Of course, the more you do in hardware, the less you'll have to do in
software.

-- 
Ignacio Vazquez-Abrams  <ignacio at openservices.net>








More information about the Python-list mailing list