Arduino to RS232 connection

Hi guys, I have been stuck with simple RS232 connection for few days. I think it is time to ask for the master…
I am trying to connect arduino mega 256 to computer’s RS232. I am using SERIAL1 TX1(pin 18), RX1(pin19) and ground to be attached to RS232 as seen in the picture. I am sending simple code below:

void setup() {
Serial.begin(9600);
Serial1.begin(9600);
}
void loop() {
Serial.write(“serial”);
Serial.println(3);
delay(1000);
Serial1.write(2);
Serial1.println(“serial1”);
delay(1000);
}

Everything goes well for the Serial port. However as i checked the serial monitor for the Serial1 port (COM16), I got really unexpected result (error pic).
As I tried to connect to hyperterminal, to open the corresponding port it even says “Unable to open COM16. Please check your port setting”.
Can anyone help me with my problem? Is it because of the wrong wiring? I am just following picture from the internet on how to connect RS232 and I dont really know how RS232 works.

error.jpg

Hi, welcome to the forum.

Stop whatever you are doing. A computer has a 'real' RS-232 port : http://en.wikipedia.org/wiki/RS-232#Voltage_levels A RS-232 interface could have voltage levels of -15 to +15V. Your Arduino board might already be damaged.

The Arduino uses 5V levels. To connect that to RS-232 you need a rs232-ttl-level-converter. Those use often a MAX232 or MAX2323 chip. Here is explanation : https://www.sparkfun.com/tutorials/215

Why do you need RS-232 ? A usb-to-serial adapter is much easier. Is the normal serial communication to the computer not enough ?

I got really unexpected result (error pic).

It is exactly what you would expect doing what you do.

Not only do you need to get the voltage levels right you need to get the logic sense correct. As it stands it is upside down. The MAX2323 chip will not only correct the voltage but invert the logic state.

mura1ma:
I am just following picture from the internet on how to connect RS232 and I dont really know how RS232 works.

Clearly.

What concerns us however, is from where on the Internet did you get such a fatally foolish picture of how to connect RS-232?

Thanks Peter for your explanation. Actually, what I found from the internet is the connection with MAX232 in between arduino and RS232. But I tought it will be alright as I am using RS232 to USB converter to be connected to the computer (as USB uses 5V). But after reading the article you posted about RS232 I feel abit stupid now lol...

Yes... I need two serial port. One is connected to the computer (sending certain signal) and another one is connected to the TM220 printer. I want the printer to be able to print without even turning on the computer. It would be even better if both of them are using USB :) Is there any way to get two USB port from arduino? Or is there any chip or adapter available to conver RS232 to USB directly?

If COM16 is not available, you need to go into Devices & Printers (Device Manager) and find what address your 232-USB is, if it's listed there at all.

If you want to use USB to the printer, you will almost certainly need a USB Host shield for the Arduino. You can find cables like these http://www.ftdichip.com/Products/Cables/USBRS232.htm that convert USB from PC to RS-232 to the outside world. If you wanted RS232 from the computer to USB-B or USB-B-mini or USB-B-micro to plug into the Arduino, I think that would be harder to find. Everything I've come across is USB from the PC to RS232. To go from RS232 on the PC, I would think you'd need the equivalent of RS232 into a TTL serial input on a uC, then USB Host capability going out.

The Epson TM-U220 printer ? I found that someone made it work with Arduino, but I can't find a documented project.

https://www.youtube.com/watch?v=JuIMXg15uEI

http://forum.arduino.cc/index.php?topic=13051.0