Hi all,
I am trying to use a RS232 port to test if a key switch is turned off/on so I can enable/disable the sending of E-Mails from my ZoneMinder system.
I have done a lot of research and some experimentation and I thought I had if fugured out, but it appears I burned out my UART on the motherboard.
Here is what I was doing, could you take a look and see if I am way off base, or maybe suggest another idea.
First some documentation...
I used a Key Switch, a 6.8K Resistor, and a RadioShack (276-0041) 2.6V - 28 maA LED in this circuit.
When the Key Switch is open, the LED is lit and I consider the system "Armed".
The current flow and voltages are:
I am using Linux and have written the following program to test if the switch is Open/Closed (Armed/Disarmed).
It works just fine. The LED flashes off every two seconds when the port is being read. The voltage and current readings seem to be well within tolerance.
However, as I said at the top, it ran for a while but now the serial port no longer works. So, can you spot something I have overlooked before I go and burn out all my COM ports?
Thanks, Keith
I am trying to use a RS232 port to test if a key switch is turned off/on so I can enable/disable the sending of E-Mails from my ZoneMinder system.
I have done a lot of research and some experimentation and I thought I had if fugured out, but it appears I burned out my UART on the motherboard.
Here is what I was doing, could you take a look and see if I am way off base, or maybe suggest another idea.
First some documentation...
Rich (BB code):
___________
\1 2 3 4 5/ Looking at pins
\6 7 8 9/ on male connector
------
Pin # Acronym Full-Name Direction What-it-May-Do/Mean
9-pin
1 DCD Data Carrier Detect<-- Modem connected to another
2 RxD Receive Data <-- Receives bytes into PC
3 TxD Transmit Data --> Transmits bytes out of PC
4 DTR Data Terminal Ready--> I'm ready to communicate
5 SG Signal Ground
6 DSR Data Set Ready <-- I'm ready to communicate
7 RTS Request To Send --> RTS/CTS flow control
8 CTS Clear To Send <-- RTS/CTS flow control
9 RI Ring Indicator <-- Telephone line ringing
When the Key Switch is open, the LED is lit and I consider the system "Armed".
Rich (BB code):
RS232 6.8K Key Switch
1 CD ______/\/\/\___________/ ___________
| | |
^ | | |
| |_____>|_______| |
|4.49V LED |
| |
|
4 DTR ___________________________________|
Rich (BB code):
Switch Open Switch Closed
---------------------- --------------------
Resistor : 2.67V .373mA 3.75V .524mA
LED : 1.82V .373mA 0.0V 0.0mA
Pin 4 to Pin 1 : 4.49V .373mA 3.75V .524mA
Rich (BB code):
#include <string.h>
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <unistd.h>
main()
{
int fd, status;
while( 1 ){
sleep( 2 );
fd = open("/dev/ttyUSB0", O_RDONLY);
if (ioctl(fd, TIOCMGET, &status) == -1) {
printf("TIOCMGET failed: %s\n", strerror(errno));
}
else {
if (status & TIOCM_CAR) {
puts("TIOCM_CAR - Alarm off!!!");
}
else {
puts("TIOCM_CAR - Alarm is armed!!!");
}
}
close(fd);
}
}
However, as I said at the top, it ran for a while but now the serial port no longer works. So, can you spot something I have overlooked before I go and burn out all my COM ports?
Thanks, Keith