Labview控制RS232驅動繼電器

各位大大您們好

我是用LABVIEW8.5的版本

我想請問我想要利用RS232來控制繼電器

LABVIEW程式要如何寫比較好呢?(觸發繼電器電壓為5V)

還有就是RS232要使用哪一種傳輸方法驅動繼電器比較好(EX:RS232轉USB,USB轉RS232)

這個部份通常需要外加硬體來驅動relay,例如加一張DIO卡(TTL信號輸出入),當接收到command則輸出high或low來驅動relay

以下文章有提到硬體的部份,至於軟體的部份則還要看如何撰寫

Get power out of PC RS-232 port

Driving relays using RS-232 port power

If the serial port is used for no other purpose then to operate one or two devices use the RTS and the DDR line. They can be set and reset by simple I/O commands to the serial port chip (UART).

Using a 3-8VDc Solid State Relay

If the solid state relay operates at 5 mA input current range you can run it directly using the following circuit:

        1N4148
 RTS-----|>|------[ + SSR input - ]---------GND

If the 5 mA is not enough for the semiconductor relay then you can can combine the power from two RS-232 output lines together using the following circuit

        1N4148
 RTS-----|>|-+----[ + SSR input - ]---------GND
             |
 DTR-----|>|-+ 

When using this combination circuit you must remember that both RTS and DTR lines are controlled at the same time. If you have only one line activated at the time there is no guarantee if the relay is activated or not if it takes more than 5 mA.