I have two Arduino Pro Minis that each have a MAX485 chip. Right now I have them set up on a single breadboard with about 3" between the MAX485 chips, so I am not using terminators.
I am seeing a lot of dropped characters, similar to what happens if my baud rate is wrong.
ÿÿHÿHÿHÿ
HÿHÿ
HÿHÿ
I am using AltSoftSerial, which could also be the problem. Pin 13 is wired to the RE+DE pins. If I take out the delay(1) I get nothing, so it looks like there’s some bouncing or something going on. It’s also possible that I am not handling half-duplex correctly. If I take out the MAX485 chips and just cross over pins 8 and 9 between the arduinos the setup works perfectely, so it’s something in how I handle the MAX485 chips.
My breadboard is wired similar to this:
Here’s my quick and dirty code (the output on the serial console is above). The code is running on each arduino.
#include <AltSoftSerial.h>
// AltSoftSerial always uses these pins:
//
// Board Transmit Receive PWM Unusable
// ----- -------- ------- ------------
// Teensy 2.0 9 10 (none)
// Teensy++ 2.0 25 4 26, 27
// Arduino Uno 9 8 10
// Arduino Mega 46 48 44, 45
// Wiring-S 5 6 4
// Sanguino 13 14 12
AltSoftSerial altSerial;
void setup() {
Serial.begin(9600);
Serial.println("AltSoftSerial Test Begin");
altSerial.begin(9600);
digitalWrite(13,HIGH);
delay(1);
altSerial.println("Hello World");
delay(1);
digitalWrite(13,LOW);
}
void loop() {
char c;
c=0;
while (altSerial.available()) {
c = altSerial.read();
Serial.print(c);
c=0xff;
}
if(c>0) {
digitalWrite(13,HIGH);
delay(1);
altSerial.println("a");
delay(1);
digitalWrite(13,LOW);
}
}