I am attempting to communicate with my PC using one of the Serialx (Serial1, Serial2, Serial3) ports with very little success. The output on the PC is garbage.
I have tested both Serial1 and Serial3 with the same problems. I have atmega2560 and using a “USB to serial” cable converter. Following is my sketch:
Notice the only letter that is correct is the first one, the letter little ‘a’.
I have also tried Serial1.print() which produces the same results.
I have tried various Windows Device Manager and Putty port configuration settings. Different settings create different results, all incorrect. The test above is using 9600/8/N/1 and Flow Control: NONE
I am creating the hex view by cut/paste from the Putty terminal/window into a binary editor (MS Visual Studio).
Questions:
Has anyone successfully communicated with the PC using the Serialx ports?
What should the Windows Device Manager and Putty port settings be?
Can you control/set the prort settings in the Arduino sketch, and if so, how?
61 (decimal) is not the lower case letter 'a'. It is the equals sign '='. 62 is > and 63 is ?
If you want lower case a, b and c you need to use 0x61, 0x62 and 0x63.
You are correct about the character values. I have tried the (decimal) values 97, 98 and 99 as well as 0x61, 0x62 and 0x63 which produce the following hex values on the PC:
4F A7 4E.....repeated forever
As you pointed out, when sending the (decimal) values 61, 62 and 62, I should have received =>?
which are the hex values: 0x3D, 0x3E and 0x3F, but as you can see, I did not get these values.
You cannot simply connect TTL level serial lines to an RS232 serial converter and expect sensible results.
a) The signals are inverted
b) the signals are level-shifted.
You need something like a MAX232 to do the conversion for you.
What is the spec on your "USB to serial" cable converter? It's likely that the cable already has the electronics for the level conversion built into it.
jlb1:
or, are there devices that convert the TTL signals to USB directly?
Arduino clones that don't include a USB port are usually programmed via the SPI, aren't they? There is a common interface you can get that connects to the SPI and provides a USB interface. Perhaps you could use one of these instead of going via RS232?