serial character mismatch/garble on duemilanove

newby here- Sorry, I couldn't find this problem mentioned before in forum. When I connect to duemilanove with console over USB and send characters, it responds back correctly. I connect to pins 0&1 with second computer via USB/serial dongle and monitor traffic from first computer through console. Arduino gets wrong character and second computer gets garbled response. I mapped the characters and it is repeatable and deterministic: sent char/ASCII hex: arduino sees hex: A 41 5F B 42 2F C 43 5E D 44 17 E 45 5D F 46 2E G 47 5C ... 1 31 67 2 32 33 3 33 66 4 34 19 5 35 65 6 36 32 7 37 64 8 38 0C 9 39 63 0 30 06

If you examine the entire ACSII list, there is method in the madness: every second char decrements by one, every fourth char decrements by one, every 8th by one, every 16th by one, etc. If I could figure out the mapping, I could translate with an algorithm, but it shouldn't be "doing" this! I tried a 232-TTL shifter between dongle and pins 0/1 and didn't make any difference (dongle might be TTL anyway?). 9600/8-n-1-no flow on both sides confirmed. Does anyone know what's going on? Thanks.

Does anyone know what’s going on?

We gave Karmac the Magnificent the night off. If you post your code, perhaps one of the non-psychic members can help.

Hi-
My apologies to Karmac. This is plain vanilla stuff:

#include <ctype.h>

void setup()
{
// initialize serial communication:
Serial.begin(9600);
}

void loop()
{
if(Serial.available() > 0)
{
int inByte = Serial.read();

sprintf(mystring, “got 0x%x = %c”, inByte, inByte);
Serial.println(mystring);
}

}
Entering “a” and “b” from console, console outputs looks like this:
got 0x61 = a
got 0x62 = b

Now plug in second computer and entering “A”, “B”, “C”, “D” from serial line from second computer, console looks like this:
got 0x4f = O
got 0x5f = _
got 0x2f = /
got 0x5e = ^

Thanks again.

I connect to pins 0&1 with second computer via USB/serial dongle and monitor traffic from first computer through console.

If I read this correctly, you have two computers connected to the serial port of the Arduino. If this is correct, what, exactly, is the Arduino doing? Both the first PC and the Arduino are trying to talk to the serial port on the 2nd PC. And, you are getting garbage on the port. And you wonder why.

Hello PaulS- Well, not exactly true. I infer by your statement that the USB port on the Arduino and pins 0/1 on the Arduino are in fact the same serial port, which I actually assumed. But when I have both comp1 and comp2 physically connected to Arduino simultaneously, comp1 doesn't see what comp2 is sending to Arduino, but both see what Arduino is responding. Comp1 sees reasonable characters, i.e. "got 0x61 = a", while comp2 sees garbage of the same response by the Arduino. If I power Arduino by power plug instead of the USB, so comp1 is not in the system at all, comp2 still sees the SAME garbage patttern as when comp1 is monitoring it, so I make the assumption that having comp1 in the loop is not affecting what Arduino sees from comp2. I am suspecting the dongle itself. What voltage range does Arduino 0/1 expect? If the dongle is providing TTL level, while Arduino expects 232 level (8-12), might that be doing it? Does the Arduino HAVE to have 232 levels on pins 0/1, or can it take TTL on pins 0/1, as it would if I was using pins 2/3, etc. for serial? Thanks for your patience.

I infer by your statement that the USB port on the Arduino and pins 0/1 on the Arduino are in fact the same serial port, which I actually assumed.

Pins 0 and 1 and the USB port are indeed connected.

I am suspecting the dongle itself.

If, without computer 1 in the picture at all, you still get incorrect data, that is a reasonable assumption.

What voltage range does Arduino 0/1 expect?

The serial output from the Arduino is 0 or +V (typically 5 volts).

If the dongle is providing TTL level, while Arduino expects 232 level (8-12), might that be doing it?

The Arduino expects TTL levels. There are two other possibilities. One is that the dongle is outputting RS232 levels (+12 or -12, not 8 or 12) which will fry the Arduino. The other is that the dongle is outputting 0 and +5, but inverted.

If the signal is 0, +5, but inverted, you could send it to another pair of pins, and use NewSoftSerial to create a software serial port. The NewSoftSerial class has an option to accept inverted signals.

If the dongle is outputting +12, -12 signals, you'll need to pass them through a MAX232 chip to get them converted to 0, +5 values.

Update: I resurrected an old laptop with a native serial port (Win95 and Hyperterminal 3.2!) so I would not have to worry about what the dongle was or was not doing correctly. Repeating the above tests, I got identical results, which exonerates the dongle. I will try repeating the tests on some other TTL pins and a MAX232, but I suspect that it will again be without change. I now suspect a bad Duemilanove, so I have ordered a new board (an Uno) and we'll see. Thanks for the support.

If you are connecting to a real serial port, the output on that port IS +12/-12V AND inverted from from the Arduino expects. You don't need a new Arduino. You need a MAX232 chip.

And maybe a new Arduino.

I am having the same problem. I am not sure how to properly read PIN-1 (TX->) on my UNO using another computer/com port.

My UNO is connected to my computer via USB and assigned to COM3

COM4 is another serial port.
I am getting garbled text on (COM4)

Very simple code:

/*

  • Hello World!
  • This is the Hello World! for Arduino.
  • It shows how to send data to the computer
    */

float pps_time=100110.000000;
void setup() // run once, when the sketch starts
{
Serial.begin(9600); // set up Serial library at 9600 bps
}

void loop() // run over and over again
{
Serial.println(“Hello World”); // prints hello with ending line break
delay(1000);
}

Serial Port Monitor COM3 Shows:

Hello World
Hello World
Hello World
Hello World
Hello World
Hello World

COM4 is showing the following:

?åë«::
?åë«::
?åë«::
?åë«::
?åë«::

Any suggestions?
:o

Have you followed all the steps in the thread and installeed an inverting level shifter, like a MAAX232?

The Arduino is talking to COM3, and the data is showing up correctly in the Serial Monitor window which is connected to the PC end of COM3.

Some unknown other device/process is connected to COM4, at some unknown baud rate, and the data it puts on the serial port is showing up garbled in the Serial Monitior window which is connected to the PC end of COM4.

And this is an Arduino issue how?

PaulS:

?åë«::
?åë«::
?åë«::
?åë«::
?åë«::
is generated by Arduino pin 1. It changes with a change in the “string” value of serial.println().

I will try MAX232 next. Hopefully I have not damaged by UNO.

Thanks.

is generated by Arduino pin 1.

I don’t see that. I see the Arduino using Serial.print() to send data to the serial port. I see that the Arduino is connected to COM3, and that what the Serial Monitor shows coming in on COM3 exactly matches what the Arduino is sending.

I don’t see that the Arduino is bit-banging pin 1 in any other way. I also don’t see what connection there is between the Arduino and COM4, or why you expect some other device’s/program’s output to show up in the Serial Monitor “correctly”.

PaulS:

Pin 1 (TX) is connected externally to COM4. Arduino Pin 1 (TX) --> Pin 2 (RD) COM4 RS232 Arduino GND --> Pin 5 (GND) COM4 RS232

Arduino is connected via USB (COM3)

COM4 is monitored using Tera Term

I think its most probable that I need to use MAX232 or convert the levels + polarity.

I think its most probable that I need to use MAX232 or convert the levels + polarity.

I seriously doubt that.

The Arduino's pin 0 and pin 1 are the hardware serial port pins. They are connected to the USB/serial port adapter that connects to the PC as COM3.

You can not use the same pin(s) for any other purpose.

COM4 is monitored using Tera Term

So what? The Arduino is not talking to COM4.

"Pin 1 (TX) is connected externally to COM4. Arduino Pin 1 (TX) --> Pin 2 (RD) COM4 RS232 Arduino GND --> Pin 5 (GND) COM4 RS232"

This is the reason you are receiving bad characters on COM4. The Arduino is sitting at 0V, when it starts sending data it goes High for a start bit and then proceeds with 8 data bits, no parity, 1 stop bit (low) and then stays low until the next bit.

Your COM port on the other hand is looking for a High level (such as +3 to +15V) as no activity, followed by a Low start bit (such as -3 to -15V), 8 bits of data, and a high stop bit then staying high for the next byte. You could try putting an inverter, such as 74LS04, on the arduino output, might be good enough transitions to be seen as good data. Or make your own with a transistor as I did with Q4 here, which change 0/+5 to +5/0. Transistor was just a simple NPN I had a little drawerful of.

Thanks crossRoards

I will try it out over the weekend.