receiving non TTL rs232

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
katesfb
 
Posts: 12
Joined: Mon May 07, 2012 6:37 pm

receiving non TTL rs232

Post by katesfb »

Hi,
I am in the process of migrating from the PIC architecture to AVR and using the Arduino development system and i am finding it very easy to use. I have just one question regarding receiving non TTL RS232 from a PC or other source (eg sensor) . On a PIC i would simply use software serial commands and connect the tx and rx lines to two pins designated as serial in and serial out. I did not need to use a line converter such as a max 232, all that was required was a 22k ohm series resistor on the serial input line and a 10k ohm resistor from the serial input line to ground. Nothing was required for the serial output line. This worked fine. Is it possible to do the same on the arduino?

Any help is much appreciated.

Cheers.

User avatar
floresta
 
Posts: 223
Joined: Thu Jul 31, 2008 10:27 am

Re: receiving non TTL rs232

Post by floresta »

... all that was required was a 22k ohm series resistor on the serial input line and a 10k ohm resistor from the serial input line to ground.
It looks like they were using a voltage divider to reduce the input voltage to a level that would not destroy the PIC. It also looks like they were counting on the 5 volt output being sufficient to be recognized as a high by the other receiver. I assume that the logic inversion was done in software.
Is it possible to do the same on the arduino?
If whatever you connected this to did not destroy the PIC it may not destroy an ATmega either. If whatever you connected this to recognized the high output from the PIC it should recognize the high output from an ATmega.

Don

katesfb
 
Posts: 12
Joined: Mon May 07, 2012 6:37 pm

Re: receiving non TTL rs232

Post by katesfb »

Hi Don,
And thanks for the reply. After looking into it a bit further it looks the purpose of the 10K resistor is to stop the rx pin "floating" when no signal is present. So therefore i can only assume that the 22k resistor is being used as a series current limiter to, as you suggest, stop things being potentially fried. I know from experience that if i dont use a 10k resistor, sometimes it works and sometimes it doesnt depending on the application eg significant timeouts are definitely affected.

So anyway i think i will give it a go and see what happens.

One last questions; how are timeouts handled eg wait for a character, if no character is received after a certain period of time (timeout) then goto a specific piece of code.

Typical picbasic code would be; serin pin,freq,timeout value,goto code piece,[wait(some character),variable] - this waits for a character, if character is received within timeout value then next character or string goes into a variable, if not, then program execution is redirected to code elsewhere.

Any help is much appreciated.

Cheers.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: receiving non TTL rs232

Post by adafruit_support_rick »

One last questions; how are timeouts handled eg wait for a character, if no character is received after a certain period of time (timeout) then goto a specific piece of code.
On the arduino, serial com is interrupt-based. Reads are non-blocking.
Also, there are two different serial libraries available. The standard is HardwareSerial, which uses the defined serial Rx/Tx pins. The alternate is SoftwareSerial, which can use an arbitrary pair of pins (with pin-change interrupts)

User avatar
floresta
 
Posts: 223
Joined: Thu Jul 31, 2008 10:27 am

Re: receiving non TTL rs232

Post by floresta »

After looking into it a bit further it looks the purpose of the 10K resistor is to stop the rx pin "floating" when no signal is present. So therefore i can only assume that the 22k resistor is being used as a series current limiter to, as you suggest, stop things being potentially fried.
That is not anywhere near correct. The two resistors work together as a voltage divider. When you remove the 10K resistor you now apply the full RS232 voltage, which can be as high as 25 volts, to the input of the microprocessor.
One last questions; how are timeouts handled eg wait for a character, if no character is received after a certain period of time (timeout) then goto a specific piece of code.
That would depend on your program code.

Don

User avatar
kewakl
 
Posts: 14
Joined: Fri Jul 20, 2012 6:49 pm

Re: receiving non TTL rs232

Post by kewakl »

<< <<After looking into it a bit further it looks the purpose of the 10K resistor is to stop the rx pin "floating" when no signal is present. So therefore i can only assume that the 22k resistor is being used as a series current limiter to, as you suggest, stop things being potentially fried.>> >>

<<That is not anywhere near correct. The two resistors work together as a voltage divider. When you remove the 10K resistor you now apply the full RS232 voltage, which can be as high as 25 volts, to the input of the microprocessor.>>

Check your sources... from Picaxe Manual 1 pg44 Manual Version 7.8 01/2012
Note that the two resistors are not a potential divider. The 22k resistor works with
the internal microcontroller diodes to clamp the serial voltage to the PICAXE
supply voltage and to limit the download current to an acceptable limit
. The 10k
resistor stops the serial input ‘floating’ whilst the download cable is not
connected. This is essential for reliable operation.
My Bold/Italics

User avatar
floresta
 
Posts: 223
Joined: Thu Jul 31, 2008 10:27 am

Re: receiving non TTL rs232

Post by floresta »

Check your sources... from Picaxe Manual 1 pg44 Manual Version 7.8 01/2012
The source was not specified in the original post and I forgot to turn my crystal ball on. All that was provided was a verbal description and I visualized the circuit differently than intended.

The original post said that the resistor ran "from the serial input line to ground." I interpreted the term 'serial input' as the input to the Picaxe and now that I have looked at the diagram I see that the Picaxe people have also identified this same location as 'serial in'.

With the resistor positioned as described in the original post, and as I envisioned it, the circuit most definitely would have been a voltage divider. With the resistor positioned as shown in the diagram the description given in the manual is correct.

That brings us to a whole new topic. In most cases it is not considered good practice to use the transient suppression diodes that are part of the input circuitry of a digital device as voltage regulators. Have you looked at page 45?

Edit: The original post talks about "non TTL RS232 from a PC or other source" which generally means 'real' RS-232 and voltages as high as +/- 25V. The picaxe manual which you (kewaki) have referenced is talking about input from a USB circuit so I guess your crystal ball isn't working either.

Don

User avatar
kewakl
 
Posts: 14
Joined: Fri Jul 20, 2012 6:49 pm

Re: receiving non TTL rs232

Post by kewakl »

I had a really boorish remark all typed in, then I remembered a line from the introduction when I registered on this forum.
That line went something along the lines of 'be excellent to each other.' :idea: :idea: :idea:
I will try. I removed the aforementioned remark.
If you found the reference material, I think that you may have misread the RED colored statement and assumed USB only.
Yes, I have read MOST of all three manuals. And I agree that it is NOT the *best* practice to use (or abuse) the internal suppression hardware in this manner.(...but it works for them.)
BTW, My crystal ball has a dead battery.

My source SPECIFICALLY indicates ... the AXE026 SERIAL CABLE
and shows a 9-pin *serial* connector. Definitely NOT USB.
Serial Download Circuit
The serial download circuit is identical for all PICAXE chips. It consists of 3 wires
from the PICAXE chip to the AXE026 serial cable. One wire sends data from the
computer to the serial input of the PICAXE, one wire transmits data from the
serial output of the PICAXE to the computer, and the third wire provides a
common ground. See the USB adapter section for details on how to use the USB
port adapter.

The minimum download circuit is shown here. This circuit is appropriate for
most educational and hobbyist work.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”