Reputation: 225
I'm working on some idea connected with RS-232 interface manipulation. I can open this port, configure it, write or read data and do some other things with WinAPI. But I don't know how to control individual pins. Well I can take control of DTR and RTS lines via EscapeCommFunction
function. But I need to manipulate with TxD and RxD lines ("turn" them "on" or "off", binary). Is this possible in Windows 7?
Upvotes: 0
Views: 3216
Reputation: 29219
You can't manipulate the RxD line as it's an input.
You can set the TxD line to be continuously ON or OFF by playing with the com port's break state. SetCommBreak
and ClearCommBreak
would be the API functions that let you do that.
If only one output has to be activated at a time, you can expand your 3 outputs to 8 outputs by using a decoder chip, such as the 74137. Beware of transient outputs while switching inputs.
You can also use a shift register chip (such as the 74164) to expand 2 outputs (one clock and one signal) into 8 outputs. You can get even more outputs by daisy-chaining shift registers.
If you decide to use these ICs, make sure you don't overload their inputs. RS-232 voltage levels are not the same as TTL voltage levels. Check the spec sheets. You might have to use clamping diodes, or a RS-232 transceiver.
Another alternative is to use the parallel port. The parallel port has 8 bidirectional lines plus a small handful of other control lines. Check out the Inpout and Uniportio libraries on how to access the parallel port from Windows.
Seeing that serial and parallel ports are now obsolete, I think your best bet is to use an USB I/O board. You can find some that are cheaper than a parallel cable. Some of them have terminal blocks that make it easy to interface with your experiment.
Upvotes: 4