-1

I'm planning to send data from my laptop via Hyperterminal to Arduino's TX RX pins. Normally RS232 is around +12V -12V; but I will use a USB to RS232 converter as in the figure below:

enter image description here

And from a DB9 female end I will wire to Arduino TX RX pins. Eventhough the voltages at DB9 pins might be exceeding 5v, why cant I just use a Voltage divider and feed it to TX RX pins of Arduino?

user16307
  • 11,802
  • 51
  • 173
  • 312
  • 1
    While maybe feasible (with a diode as well) one issue is you won't be able to use the hardware UART on the AVR any more because TTL serial is inverted compared to RS232, so you'd need to use SoftwareSerial. – PeterJ Mar 09 '15 at 13:03
  • 3
    Apologies if I'm stating the obvious, but you do realize you can use the "programming" USB port on the Arduino for this type of communication? – Karl Bielefeldt Mar 09 '15 at 13:54

3 Answers3

2

Level translation needs to work in both directions. Think about the inputs and outputs you are dealing with.

Arduino --> PC
Bin   Ard. V   PC V   Notes
 0      0V     >+3V   Can't be done with a divider
 1      5V     <-3V   Can't be done with a divider

PC --> Arduino
Bin   PC V   Ard. V   Notes
 0    +12V     0V     Can't be done with a divider
 1    -12V     5V     Can't be done with a divider

You may find some one off way of doing this without a RS-232 level translator IC using discretes, but you won't accomplish this with simple resistive dividers.

M D
  • 1,277
  • 8
  • 8
  • but usb to rs232 converter cannot output 12V. isnt it sending and receiving 5V? – user16307 Mar 09 '15 at 12:33
  • you mean arduino tx rx is 0V 5V? – user16307 Mar 09 '15 at 12:34
  • 2
    There is a difference between a USB-to-TTL serial converter and a USB-to-RS232 converter. Both exist, but they have different output levels. – M D Mar 09 '15 at 12:35
  • do you mean after USB-to-RS232 converter, i need a rs232 to ttl conveter since arduino recieves as TTL level on pins TX RX? is that why they use MAX232?? – user16307 Mar 09 '15 at 12:39
  • Do you own/have access to an oscilloscope? – M D Mar 09 '15 at 12:40
  • yes old analog one – user16307 Mar 09 '15 at 12:43
  • Hook it up to the Arduino Tx and send some characters. Repeat for the PC at it's Tx pin. Check the voltage levels. Then, this should make more sense to you and you'll know better what you need. – M D Mar 09 '15 at 12:45
2

I have done this (not with an Arduino, but with something similar) recently. The voltage levels that RS232 uses (+12V, -12V) will break the Arduino. You need a MAX232.

The much better alternative is to skip the RS232 serial port and go straight to Arduino voltage levels with a USB-to-TTL cable:

USB-TTL cable

You can get these on Digikey, Adafruit, Sparkfun, etc... for roughly the same price as a USB-to-Serial cable, and then you don't need a 2-way converter. Much simpler if you don't really need the serial cable in the first place.

Greg d'Eon
  • 3,807
  • 4
  • 24
  • 50
  • i need rs232 to ttl because i will collect data from a device which only communicates with rs232. thats the goal. by the way i'm not sure if one uses a usb to rs232 converter one sees 12V. how can it be 12V when usb can only supply 5V? look at my diagram tne converter is powered from USB port. – user16307 Mar 09 '15 at 15:05
  • How does it communicate with RS232? If it's a generic USART line, then you can do this instead. RE: +12V, have you ever heard of a charge pump? If not, how do you expect the MAX232 to work off a 5V supply? – Greg d'Eon Mar 09 '15 at 15:26
  • im talking about this USB to RS232 converter. look at this link: https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR9j9VXVgpsUmV-0c6VvO6Zg1xp_KHyFFQHsxlD6WjrqGdzPvlY7GPobw0 – user16307 Mar 09 '15 at 15:37
  • so please tell me how can this output 12V when I send data from PC through USB port?? – user16307 Mar 09 '15 at 15:38
  • There is a decently sized enclosure attached to the RS232 end of that cable. There is a circuit in there that uses a 5V supply to produce +/- 12V for the RS232 outputs. – Greg d'Eon Mar 09 '15 at 15:45
  • how can 5V produce 12V? – user16307 Mar 09 '15 at 15:56
  • http://electronics.stackexchange.com/q/131595/49251 – Greg d'Eon Mar 09 '15 at 16:05
0

From the figure i can see you are using arduino uno. It has a inbuilt usb to serial converter so no need to use a rs232 converter just connect the arduino to your pc through its usb port. It will be detected as a serial port in your PC (I assume that you have the necessary drivers in your pc since you are burning program into the arduino with the same pc) .

ciril
  • 21
  • 2
  • i know im using arduino as a serial com source. in real i have another instrument which outputs TX RX. this is a model – user16307 Mar 27 '15 at 10:00