Tuesday, 22 April 2014

XBEE works with my Modbus library with a minor software trick!!!!

After an afternoon checking either hardware and software, the XBEE didn't work with XBEE. It was able to send, but it didn't get any incoming message. The fact is that I was testing it with my PicoLogic1284 and the second RS485 transceiver is sharing Serial1 with XBEE.

So the problem was related to something inside Arduino. And I have found it:
  • Arduino RxD pins (any of them) seem to be declared as INPUT_PULLUP;
  • My PicoLogic1284 has a 1K resistor in series and it doesn't read anything coming from there.
The fact is that the XBEE is working with 3.3 V levels while the PicoLogic as the Arduino works with 5 V. A 1K resistor inbetween plus any pull-up may cut off the high level voltage required by the Atmega processor.

The solution has been to type something like this at the end of the setup routine:

void setup() {
  setupDisplay();
  setupRTC();
  setupIO();

  mb.begin(9600);
  mb2.begin(19200);
  mb2.setTimeOut( 2000 );
  u32wait = millis() + 1000;

  pinMode( RX2, INPUT );
} 
 
RX2 is defined as the PD2, which is used as RXD1 for Serial1. This makes this input work without its internal pull-up resistor.

No comments:

Post a Comment