using serial port

Siig Low profile pci serial (16550) para...
February 19, 2010 at 02:37:59
Specs: Windows XP

how can i send a command using the serial port of PC ,the width of command pulse must be 10 ms


See More: using serial port

Report •

February 19, 2010 at 05:41:02
Is this a programming question?

Report •

February 19, 2010 at 13:03:11
no just i want to know wether i can use the serial port of the pc to control a relay or not
if it is yes i want to know how i can do it


Report •

February 19, 2010 at 15:16:37
To be honest, I have no idea. What kind of relay are you talking about here?

Report •

Related Solutions

February 19, 2010 at 15:32:09
You can use the serial port to control a relay, it is, or was a very common practice at one time.

However, what you cannot do is control the width of the pulse. The only lines on an RS232 serial port that are pulsed are the data lines and the pulse width is determined by the baud rate.

All the other lines are simple on or off, true or false, high or low. If you want to control the pulse width to these lines your programme is going to have to do it. How you do it it entirely dependant on which programming language you are going to use.

I have moved this to Programming as it has nothing to do with Networking


Report •

February 19, 2010 at 17:10:42
I don't believe you can do it directly under Windows. With the
proper API you should be able to toggle the control lines. The
port may not be able to supply enough current to operate the
relay. With proper software and hardware you can also control
parallel, game, and USB ports.

Report •

February 19, 2010 at 21:55:35
suprisingly enough, XP (disdaining serial ports as too crude) allows conversation with serial ports where 98 and ME don't.
assuming com1 (3F8 = data):
LOOP 107
INT 20

the timing is a matter of experiment to get 10ms. (you might have to load CX instead of CL and do a CMP CX,0 : JNZ test to get longer times).
the voltage varies from about -8 to about 7 (15 volts diff). As Wizard remarked, the current is going to be low, so the type of relay is critical (as i'm sure you're aware of) The ns16550 is quite versatile and rugged driving 1489s but I haven't a clue how much current drain it will support for indefinite periods.
they make an off-the-shelf serial-port/relay interface that might be worth consideration, to handle current amplification. also (I'm sure) addressable versions.

Report •

April 6, 2010 at 11:10:02
Dear soli82,

i've made a small project that transmits serial data on PIN 3 (Transmit Data) with a delay of 10 ms.

Here is the source code:

#include <dos.h>
#include <conio.h>

#define COM1 0x3F8

void main()
outportb(COM1, 0x01);
delay(10); //10 ms

Is tested on Windows XP Professional SP2.
Hope you enjoy it!

Alex M.

Report •

April 6, 2010 at 13:37:34
Interesting thread. Are these proposed solutions relying on running under a DOS box (NTVDM)? I was under the impression that you couldn't take control of the serial port under Win32, and that you had to write a device driver and then have your Win32 application talk to that.

Report •

April 6, 2010 at 14:38:02
klint: I was under the impression that you couldn't take control of the serial port under Win32
MSDN: Serial Communications in Win32

Report •

Ask Question