Serial RS232 over DB25 question


I have a small problem with a with a little serial project I'm working on. I'm trying to send serial commands from an Arduino to a device which accepts a serial connection with a DB25 port. The program that controls this device (a video switcher) puts out a string of hex characters over the serial port to control it. I've captured the hex string and programmed it into the Arduino. The Arduino spits it back out over RS232 fine (under serial monitor it looks identical to the string output when I monitor the serial output of the program).

I have a Wulfden TTL to RS232 converter, which I assume works, although I haven't been able to test it under any other circumstance. I built a DB9 to DB25 cable using only the 4 wires that the converter outputs (TX, RX, Ground, and DTR). The cable works fine between a PC and the switcher, but I am having trouble sending with the Arduino.

I've tried hooking the TX and RX pins on the TTL to RS232 converter to pins 2 and 3 on the Arduino (using software serial) and to 0 and 1 using hardware serial, both polarities. I had the converter's 5V and GND hooked up, but I wasn't sure what to do with RTS pin, so I tried both 5V and GND. I also tried running straight out of pins 0 and 1 without the converter. Assuming the output is correct and the converter works, is there anything else I could be missing? Do I need to do anything in the code to initiate a connection, or do anything with the DTR?

Any help greatly appreciated! Thank you

What I would do is to look at the control lines on your video switch when you are driving it direct from the computer. That is CTS RTS DCD and so on. It is possible that it is the video switch that is not accepting the serial data because one of these handshaking lines is not correct. This always gives trouble with this sort of project. Note these lines being RS232 have to be connected to +12 and not +5 to activate them. Prod around with a meter or scope. Failing that an LED and resistor will do. See what you are not feeding it.

I thought that might be the case... seeing that the 4 wire cable works, it must be expecting DTR to be high, because the other handshaking lines aren't even connected when it works with the computer. I guess either the TTL to RS232 converter doesn't do that, or I'm not utilizing it properly. I'll poke around with a meter tomorrow. Thanks!

Hmm, sounds like you actually need to wire it as a null-modem cable instead of straight through. The computer is DTE equipment, but both the ttl/232 and your switcher are DCE equipment! You'll need to swap the RX and TX pins on one end, and likely attach the DTR to something else on that end.

Success! Actually, it turns out the switcher doesn't even care about DTR - I was able to get the computer to communicate with it on RX, TX and GND alone. Then I switched things up a bit and ran the RS232 output from the converter into the serial port on the PC and got a look at what was coming out of it. Here's what I believe happened:

The software that runs the switcher outputs ASCII. The serial port monitor program (as well as hyperterminal) converted the ASCII to HEX. Not knowing that, I programmed the Arduino to output HEX, which was showing up completely different when running back into the serial port monitor program.

I was able to get around this by looking up the HEX values it was expecting, finding the corresponding DEC values, then writing the DEC values as BYTE, which converted them back into ASCII, which the switcher understood perfectly.

So, now I guess my question is - is there an easier way to convert from HEX to ASCII that would work in a situation such as this, with a string of HEX commands?

Null modem with loop back handshaking
The simple null modem cable without handshaking shows incompatibilities with common software. The main problem with this cable is that there is a possibility for the software to hang if it checks the modem signal lines in a proper way. I.e. with this null modem cable, good written programs will perform worse than badly written programs.

To overcome this problem and still be able to use a cheap null modem communication cable with only three lines in it, a fake null modem cable layout has been defined. The null modem cable with loop back handshaking resulted from this.

The main purpose of this null modem cable is to let well defined software think there is handshaking available, with a null modem cable which has no provisions for it.

From this link