Tell me more ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

I am trying to interface my ATmega chips to the computer using a serial interface. I have read that this can be done directly by connecting the appropriate pin between the chips and the serial pin. But it is advised that I use a MAX232 chip. What is the purpose of this chip and do I really need to use it?

I ask this because in a project I am making, there is a big size constraint and the chip might take up valuable space.

share|improve this question

4 Answers

up vote 10 down vote accepted

If you need to connect the AVR to the computer using the serial port and a "standard" DB9-DB9 serial cable, yes, you need to use an RS232 transceiver in circuit. The AVR's UART outputs 0-5V signaling. The RS232 spec is +/-15V signaling, and I believe it's also "inverted" with compared to UART signaling. You don't have to use specifically the MAX232, but you do have to use a RS232 transceiver. These chips (plus some external capacitors) handle the voltage level conversions (via charge pumping) in either direction as well as the signal inversion, and act as "line drivers" driving longer lengths of wire allowed by the RS232 standard.

Alternatively, you can use a cable that includes such a transceiver circuit embedded in the DB9 shell if you are space constrained on your board. Yet another alternative involving a cable is to use a cable that includes an FTDI FT232 chip in it, which has the advantage of making it look like a COM port over USB to the computer, but you're looking at upwards of $15 for that cable.

share|improve this answer
Hey, if I connected the MAX232 chip, it would still be a COM port but over serial right? I was thinking of using an FTDI but where I live it isn't available easily. – Rick_2047 Feb 18 '11 at 5:30
@Rick, yes it would still be a COM port, very likely COM1 or COM2 – vicatcu Feb 19 '11 at 5:07
1  
@Rick also a word of caution - beware of getting pins 2+3 (rx+tx) backwards :) – vicatcu Feb 19 '11 at 5:10

The RS232 specification requires a signal voltage of between -3 and -30V for a logical '1', and a signal voltage of between +3V and +30V for a logical 0, input impedance is around 3k and output impedance should be around 300 ohms.

If you're going to implement a fully complient interface then yes, you will need something like the MAX232 - or an alternative, like the MAX3221 which does come in a quite small TSSOP package.

Alternatively you could utilise one of the handshaking lines from the DTE (PC or similar) to supply the negative voltage and use a simple transistor level changer to handle the signal inversion (from the MCU) and level shifting. This does however require that the DTE is configured such that it's handshaking lines are in a suitable state.

Another option is to take advantage of the fact that most equipment these days implements RS232 using something like a MAX232 device. While these are fully complient with the specification they also extend things so that the input levels are basically +2.8 to +30 for a logical '0', +1.4 to -30V for a logical zero (from memory) - in other words the receivers actually include TTL signal levels. So you can just invert the signal on the UART pins and pass it out directly to the DTE device. This technique is used on quite a few devices including many handheld GPSes. I'm not saying you be 100% compatible but you'll find this works more often than not.

You still need to invert the UART signals (unless you're bit-banging the pins yourself), two inverters should be smaller than the MAX232 plus associated circuitry, but probably not by much.

share|improve this answer
I don't know about ATmega, but many PIC UARTs can invert the output. Read the datasheet. – markrages Feb 18 '11 at 15:36
It's actually +25V maximum, with +15V being a typical limit. – Thomas O Mar 6 '11 at 21:31

I am no AVR expert, but i believe there is a usb 'bitbanging' library to use it as an usb device. You might be able to use that to emulate a serial port.

share|improve this answer

As vicatcu said, you do need something to translate the signal levels from the mcu to something the PC's serial port expects. You don't have to use a MAX232 or similar -- Sparkfun has something that would work.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.