I have a brand spanking new Mega 2560 and all I need to do is send one little command to a device at 9600 8,N,1. I'm using hardware serial 1 to send my command. When I look at the ouput on Hyperterm or RealTerm my command shows up and looks correct. If I look at it with the program "Serial Data Scope" I do not see my commands. When I connect the receiving device it does nothing.
However, when I use RealTerm to receive the commands from the Arduino on com1 and then echo them out to com2 (attached to my device), the device does exactly what it's supposed to.
Inbetween the Arduino Mega and my device I have a TTL converter that I have used for years and I know works well. I can connect other hardware and it works great... just not with this project. The equipment that I'm dealing with is also well known for having extrememly tight tolerances.
The compiler concatenates the strings. The result is "\x02A\x03". This is standard C and is commonly used to break long strings up over multiple lines for readability.
I thought of another helpful bit of information. The device I'm trying to talk to has two Com ports. Com1 is a standard RS232C port that I can connect directly to a computer and send and receive commands all day long. Com2 is a TTL serial port that also works with the converter that I have. Neither port will accept commands from the Arduino.
However, when I use RealTerm to receive the commands from the Arduino on com1 and then echo them out to com2 (attached to my device), the device does exactly what it's supposed to.
Is the Arduino running the code you presented in your first post?
When you say "echo them out" do you mean without you have to participate? RealTerm receives data from the Arduino then sends the same data out COM2 and your involvement is to watch the screen?
When you perform this test, is COM2 connected directly to the device? What is COM2? A USB-to-9-pin-RS232 converter?
Can you describe your hardware setup? Are you using the USB port, or connecting wires to the Tx/Rx pins? If so, what way around? Are you using a voltage-level shifter?
The code example I provided is exactly what is in the Arduino. The rest of my code is working fine so I took it out just to work on this issue.
The device I'm trying to control is an RF transmitter. I want to key it, then unkey it. Which I can do all day with a windows program or through RealTerm or Hyperterm. When I mentioned echoing the data, RealTerm is receiving the data from a TTL converter that is connected to the arduino via TXD1 and RXD1 and ground. RealTerm is set to echo what it sees from Com1 to Com2 automatically. Com1 and Com2 on my PC are USB to RS232 adapters. with this setup it works great. When I take out the TTL converter and plug directly to the transmitter's TTL RXD2, TXD2 and ground, I get nothing. Is there a timing issue I don't know about?
Yes, but the transmitter only uses TXD, RXD and ground for serial communication. The TTL converter can be turned around, hooked to the transmitters TTL serial line and I can program it with my PC. Keep in mind that when I connect directly from the arduino hardware serial 1 to the transmitters TTL serial lines and send the exact same command as the computer, it doesn't work.
brennan:
Keep in mind that when I connect directly from the arduino hardware serial 1 to the transmitters TTL serial lines and send the exact same command as the computer, it doesn't work.
How do you know it isn't working? The Arduino is sending the data, there is something else wrong.
Have you crossed TX/RX correctly? Are your grounds connected together? Is the other device 3v3 or 5v?
TXD2(TTL 5v) ---------> RXD1 (hardware serial 1)
RXD2 (TTL 5v) ---------> TXD1 (hardware serial 1)
GND --------------------> GND
I can tell when the transmitter is transmitting by a beep and a red TX LED.
I still don't understand why RealTerm and Hyperterm can see the commands but when I shut them down and use Serial Data Scope without changing any cabling, I get nothing. I'm going to test the output of the Arduino TXD1 going through the TTL level converter with a digital o-scope tomorrow and compare it to what's coming out of the computer's Com1 USB to RS232 adapter... Then I'll check it straight from the TXD1 output. I'll reply with what I find.
TXD2(TTL 5v) ---------> RXD1 (hardware serial 1)
RXD2 (TTL 5v) ---------> TXD1 (hardware serial 1)
GND --------------------> GND
I presume that is a typo with all arrows facing to the right. With async serial I like to be clear we have the data direction right.
Where is the level shifter in all this?
When I look at the ouput on Hyperterm or RealTerm my command shows up and looks correct. If I look at it with the program "Serial Data Scope" I do not see my commands.
I don't understand this bit. Are you saying the output sometimes reaches the PC and sometimes not? Or are you saying something else?
Can you post a link to the datasheet for the device in question? Can you give pin numbers please?
Problem solved... the Arduino apparently needed a 3 day weekend too. I tested the hardware serial timing and it's fairly consistent. To send “02 41 03” the computer takes exactly 3.062ms to send, the Arduino takes from 3.065 to 3.071ms to send likely due to the crystal oscillator. I hooked everything back up after the test and it all magically started working... I have no idea what the issue was. The programming is the same, the connections to the Arduino are via a string of 8 male header pins so it would be very obvious if it were backwards... I hooked it directly to the TTL lines of the XMTR just like before... I just don’t know.
Thank you to all who responded and offered advice. I do appreciate it.