A VERY cheap and simple alternative to MAX232?

Go To Last Post
16 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Coming from the PICAXE world, it is interesting to see that they have a very simple approach to RS232 interfacing between the PICAXE series of microcontrollers - which are Microchip PIC devices at heart - and PCs

See pages 21 and 22 of http://www.rev-ed.co.uk/docs/picaxe_manual1.pdf

These circuits are used exclusively in the PICAXE world (especially the 'advanced' circuit) and seem to be very robust - I've never heard of a PC or PICAXE failure caused by them

So would they work with AVRs and/or do they have any serious drawbacks?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think you'll find the same with AVR.

Probably the most serious drawback is that the UART is positive logic, and RS232 is negative logic. You need an inverter. (You can fix this in a "software UART", but you need hardware for the others.)

They do use the PIC internal protection diodes to limit overvoltages; that's more common in the PIC world than in the AVR world. Not sure why this is.. The voltages aren't actually legal RS232, which didn't seem to matter on older PC's, but sometimes doesn't communicate with certain newer laptops.

Look at the AVR Butterfly schematic, they use a similar idea. The Butterfly circuit provides the inverters.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mneary wrote:
The voltages aren't actually legal RS232, which didn't seem to matter on older PC's, but sometimes doesn't communicate with certain newer laptops.

There are other RS232 specs that it also won't meet; eg, slew rate, impedances, etc...

So the questions are:

* are you really that desperate to go without a proper RS232 transceiver?

* is "didn't seem to matter" good enough for you?

* are you happy that it might not communicate with "certain newer laptops"?

* if it's known to have problems with "certain newer laptops", are you happy to take the risk that there will be other gremlins waiting to bite you?

In short, if you want to know that it'll work - use a proper transceiver; if minimum cost is your overriding concern (even above guaranteed operation) - go for a bodge like this.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You could possibly use the circuit that is used on the AVR Butterfly:
http://www.atmel.com/dyn/resourc...
page 36

Arthur

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You also might want to check out the circuit in the ATAVRISP. I seem to remember some spirited discussions in threads on this Forum on the merits of the approach. IIRC the circuit allows the ATAVRISP to work with varying target voltage levels.

Lee

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

At a glance, it appears to me that the ATAVRISP circuit is nearly identical to that of the Butterfly. (cf schematic of 17-Aug-2001 10:46:33)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The $1 or so in a max232 or similar is well spent. If you've got to go cheap and simple, I'd hardly think it makes sense to just use resistors, the extra cost of the usual 2 transistor setup isn't much, and it's a lot more reliable.

Alan

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you've got to go really cheap and simple, then make a separate adaptor with a max232 or similar on it, and connect this to the logic-level signals on your cheap-and-simple target board.

Or maybe something like this:

Logic-level connection on your target; USB on your PC.
http://www.avitresearch.co.uk/usb_to_ttl.htm

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Outchh

The new FTDI Module seems a lot cheaper
http://www.ftdichip.com/Products...

The schematic is here , and you can just leave out the U2 (TTL->RS232 converter)
http://www.ftdichip.com/Document...

The "Bare" chip costs $4.51 in single quantities

/Bingo

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've been meaning to try out this circuit some time: http://www.sparkfun.com/datashee...

Seems like a definite winner, as long as it works.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
http://www.sparkfun.com/datashee...
Seems like a definite winner, as long as it works.

Please explain the differences from this circuit and the apparently identical Butterfly and ATAVRISP. :oops:

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I once did a temperature controller for a truck cabin using one of the 18 pin DIP PIC micros back in the late eitghties. It was a very minimalist design using a dual-slope ADC contructed from external valtage comparators and an R-2R DAC. The 2 ADC chnnels were for temperature sense and temperature setpoint POT.

Anyway, my point here is the the design was very minimalist. For factory check I used the remaining DO pin and bit banged a uart with interverted bit sense. The test person would attach an 18 pin DIP IC clip that was wired up to an ADM 3A RS232 terminal. The 0-5V output voltage swing was good enough for the terminal to pick up as a valid RS232 signal. The cable run was short and baud rate slow. The PIC did its ADC chore and then wrote out a text string with ADC values for testing. It worked nicely.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The SparkFun version as compared to some of the circuits shown earlier on in the thread generates the negative voltage swing for the TXD pin by capturing a negative voltage from the RXD pin and storing it on the capacitor. The RS232 impedance spec and slew rate spec are still being violated, but the TXD signal has a better chance of travelling long cable runs. That negative voltage may also be important to some RS232 interface chips out there. Hence compatibility may b improved.

Remember you can play games like these if the cable runs are short and the baudrates low. The original RS232C spec only allows a cable run of 50m at 9600bps. LOL. Today everyone violates that baudrate at distance spec anyway, hence my laughter. Bit rates as high (and higher) of 115k200bps are frequently used, and cable runs at that speed can be extended by using low capacitance cable.

To no one in particular: Know the difference between 'Baud Rate' and 'Bit Rate'?. Bit Rate is what you expect it to me. The number of bits per second. 'Baud Rate' refers to the signalling rate. With RS232 the bit and baud rates are always the same since its binary signalling.

However, when more than one bit is transmitted at a time (as in PSK or PAM pr QPAM on a phone line) the bit rate is much higher than the baud rate. 'Baud' refers to the signalling rate. So as in the case of PSK the signal changes from one of 4 values thereby encoding 2 bits per change in signal. For PSK Bit Rate= 2 X Baud Rate.

I guess I'm in a pontificating mood tonight, New Years Eve. I miss my daughters - have had no contact for months now. Freakin Divorce!!!

A happy New Years to all my AVR friends!

DFR

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yeah, the Sparkfun one is great, until someone connects a circuit made from resistors instead of a proper MAX (or similar) device. Then you're a good way into all the trouble awneal have listed above.
Consider what'll cost more, a <1$ MAX chip or several hours of hair ripping fault finding.

/Jesper
http://www.yampp.com
The quick black AVR jumped over the lazy PIC.
What boots up, must come down.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mneary wrote:
Quote:
http://www.sparkfun.com/datashee...
Seems like a definite winner, as long as it works.

Please explain the differences from this circuit and the apparently identical Butterfly and ATAVRISP. :oops:

butterfly board: 14 components
sparkfun board: 5 components
so to answer your question: the difference is 9 components.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

jesper wrote:
Yeah, the Sparkfun one is great, until someone connects a circuit made from resistors instead of a proper MAX (or similar) device. Then you're a good way into all the trouble awneal have listed above.
Consider what'll cost more, a <1$ MAX chip or several hours of hair ripping fault finding.

For me, personally, it's not the cost that makes the sparkfun design attractive. Instead - I see 2 very nice advantages that it has:
1. it can operate at most any supply voltage.
2. it consumes very little board space, less than half of what a 232 consumes.