1

I have a max3232 hooked up to the RX and TX pins of the Arduino Due. I'm trying to write a simple program to relay messages received from USB and output as RS232 through the chip. Here is my code:

char readbyte;

void setup(){
  Serial.begin(115200);  
}

void loop(){

  while (Serial.available() > 0 ) {
    readbyte = Serial.read();
    Serial.print(readbyte);
  } 
}

This program works when I don't have the MAX2323 hooked up (e.g. I send "123" and get "123" echoed back), but when I hook up the MAX2323, the Arduino isn't sending back. I've written another test program that sends random data and it seems to work fine. I'm at a lost at what is wrong with my simple program, can anyone help?

Here is the schematic: Circuit

  • You tag by two different boards with different serial port implementations. Is it a Due or Deumilanove? Also be more specific about the hardware connection. What pins on Arduino are connected to what pins on MAX? – jdr5ca Sep 12 '14 at 6:10
  • Please post the circuit diagram – geometrikal Sep 12 '14 at 9:12
  • @jdr5ca Oops, sorry I thought they were the same thing. I have the Deumilanove, I have corrected the tags. – user2218339 Sep 12 '14 at 15:52
  • @geometrikal I've added the schematics to my question. The RXD line goes to pin 0 (RX) of the Duemilanove, and the TXD goes to pin 1 (TX). This circuit is straight from the datasheet. – user2218339 Sep 12 '14 at 16:02
  • I did some more testing. I've hooked up a ft312d (usb to rs232) to the max3232, so my system now is like this: Android tablet <--> USB to RS232 <--> MAX3232 <--> Arduino Duemilanove <--> PC via USB. If I send commands with the tablet, the PC can receive the commands just fine, but sending commands from the PC to the tablet doesn't work. – user2218339 Sep 12 '14 at 17:03
1

With your final comment, the behavior is understandable. The schematic will help

enter image description here

You have wired two devices to the single UART on the processor.

The TX pin (output) on the ATMEGA8 is connected to the input pins of both your MAX2323 and the FT232 chip on the Ardiuno. That works okay because 1 output pin can easily drive 2 inputs.

The RX pin (input) on the ATMEGA8 is connected to the output pins of both your MAX and FT. The two transceivers are both attempting to drive the single input -- this is a bad thing. When one output pin tries to drive logic 1 and the other is driving logic 0, one of the devices will win and one will lose. Whether any of the devices is physically damaged depends on whether one device can source enough current to damage the other.

But you haven't broken anything because of the wise series resistors, R8, you see on the schematic. The series resistor limits the current to 5 mA even if you short the RX pin to ground. The series resistor is what creates the unequal behavior:

  • The ability of the FT chip to source current and drive a logic 1 is limited. So when the FT chip tries to drive logic 1 and the MAX is output 0, a 5 V drop will be seen across R8. The RX pin is on the MAX side, so the Arduino sees 0.

  • The MAX chip is not limited. When it drives 1 and the FT is at 0 there is still 5 V across the resistor. But the RX pin is on the MAX side and sees the 1's (data).

If you want the Arduino to receive from two devices you need to "add" the data correctly with a circuit. There are several ways, here are two:

  • Use an OR gate to combine the data. The serial bus is idle at zero. When data comes across it is a sequence of 1 bits. Remove R8 and connect the M8RXD side to the OR input. Connect the MAX to the other OR input. Connect the OR output to the RX input.

  • Cheap and small is "wire or'd". Remove R8 and replace with small diode, pointing at RX. Connect small pull down resistor (10k) from RX to ground. Connect external MAX with diode pointing at RX. In this arrangement, either chip will source current towards the RX ping to drive a logic 1, but neither chip can sink current to drive the logic 0. Only the pull down resistor creates the 0.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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