Strange behavior between arduino micro an Xbee S1 API


hello.
i send 6 analog , 2 digital inputs 1 arduino micro computer via xbees1 last firmware , xbee explorer usb. everythig's ok exept values of sample.

the problem is:
when s1 (value of sensor 1 on analog arduino input) matches 125(0x07d) or 381 (0x17d) or 637 (0x27d) or 893 (0x37d), transmitted value of payload[2] (s2 msb) jump 0x93 or 0x94 in xctu (or should 10 bits value<1023).
s2 input grounded.

here arduino squetch arduino micro (equal leonardo):
code: [select]
#include <xbee.h>
/*
sends tx16  request value of 6 analog input , 2 digital , checks status response success
note: in testing took 15 seconds xbee start reporting success, i've added startup delay
*/
xbee xbee = xbee();

unsigned long start = millis();

// allocate 16 bytes hold 10-bit analog reading
uint8_t payload[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

// series 1 can use either 16-bit or 64-bit addressing

// 16-bit addressing: enter address of remote xbee, typically coordinator
tx16request tx = tx16request(0x10, payload, sizeof(payload));

txstatusresponse txstatus = txstatusresponse();

unsigned int s1 = 0;        // value read pot
unsigned int s2 = 0;
unsigned int s3 = 0;
unsigned int s4 = 0;
unsigned int s5 = 0;
unsigned int s6 = 0;
unsigned int d1 = 0;
unsigned int d2 = 0;

void setup() {
  serial1.begin(57600);
  xbee.setserial(serial1);
  serial.begin (9600);
}

void loop() {
   // start transmitting after startup delay.  note: rollover 0 not best way handle
    if (millis() - start > 15000) {
      // break down 10-bit reading 2 bytes , place in payload
      s1 = analogread(0);
      serial.print ("s1: ");//debug
      serial.print (s1);//debug
      s2 = analogread(1);//debug
      serial.print (" s2: ");//debug
      serial.print (s2);//debug
      s3 = analogread(2);
      s4 = analogread(3);
      s5 = analogread(4);
      s6 = analogread(5);
      d1 = digitalread(7);
      d2 = digitalread(8);
     
      payload[0] = (s1 >> 8) & 0xff;
      payload[1] = s1 & 0xff;
      payload[2] = (s2 >> 8) & 0xff;
      payload[3] = s2 & 0xff;
      payload[4] = (s3 >> 8) & 0xff;
      payload[5] = s3 & 0xff;
      payload[6] = (s4 >> 8) & 0xff;
      payload[7] = s4 & 0xff;
      payload[8] = (s5 >> 8) & 0xff;
      payload[9] = s5 & 0xff;
      payload[10] = (s6 >> 8) & 0xff;
      payload[11] = s6 & 0xff;
      payload[12] = (d1 >> 8) & 0xff;
      payload[13] = d1 & 0xff;
      payload[14] = (d2 >> 8) & 0xff;
      payload[15] = d2 & 0xff;
      serial.print (" payload s1 msb: ");//debug
      serial.print (payload[0]);//debug
      serial.print (" payload s1 lsb: ");//debug
      serial.print (payload[1]);//debug
      serial.print (" payload s2 msb: ");//debug
      serial.print (payload[2]);//debug
      serial.print (" payload s2 lsb: ");//debug
      serial.println (payload[3]);//debug
      xbee.send(tx);
      delay(10);

    } 
    }


here arduino serial monitor:

code: [select]
s1: 124 s2: 0 payload s1 msb: 0 payload s1 lsb: 124 payload s2 msb: 0 payload s2 lsb: 0
s1: 125 s2: 0 payload s1 msb: 0 payload s1 lsb: 125 payload s2 msb: 0 payload s2 lsb: 0


but here what's received on macbook air xbee/xbee explorer

when s1 124 (0x27a), value of s2 good:


when s1 125 (0x27d), s2 corrupted.


same behavior other inputs:
when s2 reach 125, s3 msb jump 0x93, when s3 reach 125, s4 msb jump 0x93. etc...
for other values, behavior normal exept never value of 126 (0x07e) in xctu.

could me please?



Arduino Forum > Using Arduino > Networking, Protocols, and Devices (Moderator: fabioc84) > Strange behavior between arduino micro an Xbee S1 API


arduino

Comments

Popular posts from this blog

invalid use of void expresion in FlexiTimer2 library

error: a function-definition is not allowed here before '{' token

LED Strip Code