bernard_le_chevre
New member
Dear all,
I am building a wireless musical interface using three XBees and two Teensy 3.2s. When I try to send analog potentiometer values using the Arduino XBee Library, I run into huge (+10 second) latency and errors. Why is this happening? Has anyone encountered this problem before? My wireless hardware setup involves:
All XBee 3 modules are configured to run using 802.15.4 firmware. Everything works fine when I am simply running two modules in transparent mode and just printing serial values. Everything also works fine when I am running the two routers in transparent mode and one coordinator in API mode and send unchanging integer values using the Arduino XBee library. The latency/error issue arises when I am reading and sending a variable potentiometer value using the Arduino XBee library. Numbers received on my Macbook are totally mangled and often take 5-10 seconds to update and correspond to the physical potentiometer position. I've pinpointed the issue to the code running on the Teensy's. It seems to me as if the XBee library somehow can't keep up with the rate of transmission. Has anyone ever encountered this problem before? I'm going to wait a couple of days and then attempt to bypass the library and write my own packet sending functions on the Teensy to see if this solves the issue. Any advice is appreciated. My Teensy code is attached below for reference.
Thanks in advance,
Bernard Le Chevre
I am building a wireless musical interface using three XBees and two Teensy 3.2s. When I try to send analog potentiometer values using the Arduino XBee Library, I run into huge (+10 second) latency and errors. Why is this happening? Has anyone encountered this problem before? My wireless hardware setup involves:
- One XBee 3 module set up as a coordinator running in API 1 Mode (without escapes). This module is connected to a Sparkfun USB explorer which is connected to my Macbook.
- Two XBee 3 modules set up as routers running in transparent mode.
- Two Teensy 3.2's connected to the XBee routers via two Teensy XBee adapters
All XBee 3 modules are configured to run using 802.15.4 firmware. Everything works fine when I am simply running two modules in transparent mode and just printing serial values. Everything also works fine when I am running the two routers in transparent mode and one coordinator in API mode and send unchanging integer values using the Arduino XBee library. The latency/error issue arises when I am reading and sending a variable potentiometer value using the Arduino XBee library. Numbers received on my Macbook are totally mangled and often take 5-10 seconds to update and correspond to the physical potentiometer position. I've pinpointed the issue to the code running on the Teensy's. It seems to me as if the XBee library somehow can't keep up with the rate of transmission. Has anyone ever encountered this problem before? I'm going to wait a couple of days and then attempt to bypass the library and write my own packet sending functions on the Teensy to see if this solves the issue. Any advice is appreciated. My Teensy code is attached below for reference.
Thanks in advance,
Bernard Le Chevre
Code:
#include <XBee.h>
XBee xbee = XBee();
uint8_t payload[] = {0, 0};
int pot;
// 16-bit addressing: Enter address of remote XBee, typically the coordinator
Tx16Request tx = Tx16Request(0000, payload, sizeof(payload));
void setup()
{
//Startup delay
delay(5000);
//Begin HW serial
Serial1.begin(115200);
xbee.setSerial(Serial1);
}
void loop() {
//Break down 10-bit analog reading into two bytes and place in payload
pot = analogRead(A0);
payload[0] = pot >> 8 & 0xff;
payload[1] = pot & 0xff;
//Send to coordinator
xbee.send(tx);
delay(10);
}