Pages: 1 [2]   Go Down
Author Topic: XBee Arduino Library for API mode  (Read 9375 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 80
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Mike,

Yep, that's a bug.  Thanks for finding it.  For the time being you can call request.setApplyChanges(false).  This will set the byte to 0 and will be legal.  You can follow this with an AC (apply changes) command.

Andrew
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 73
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Andrew,
It would be nice to have a setFrameData(pos, byte) to parallel the getFrameData(pos) call.
Mike
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 80
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I can't get anything but FFFE for the 16-bit address (see below).  Can you send me the code you are using to produce that?

As for setFrameData(pos, byte), it's not really possible since there is no backing array.  getFrameData pulls from the object variables.  You can simply call request.setXXX to change anything:

      void setRemoteAddress16(uint16_t remoteAddress16);
      void setRemoteAddress64(XBeeAddress64 &remoteAddress64);
      void setApplyChanges(bool applyChanges);

You really shouldn't have to worry about what byte goes in what position  -- that's what the library is for.

I plan to add a GenericRequest class that will allow you to have full control over the packet.  This is intended for support any packet that the library doesn't support directly.


print(): byte is [0x7e]
print(): byte is [0x00]
print(): byte is [0x10]
print(): byte is [0x17]
print(): byte is [0x01]
print(): byte is [0x00]
print(): byte is [0x7d]
print(): byte is [0x33]
print(): byte is [0xa2]
print(): byte is [0x00]
print(): byte is [0x40]
print(): byte is [0x0a]
print(): byte is [0x3e]
print(): byte is [0x02]
print(): byte is [0xff]
print(): byte is [0xfe]
print(): byte is [0x02]
print(): byte is [0x44]
print(): byte is [0x30]
print(): byte is [0x02]
print(): byte is [0x33]
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 73
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

Delay - had to deal with government(takes time.)

How did you print those hexes out?
I must have made some kind of error last time. When I display your command using getFrameData() I see FF FE as well, but things are not escaped (yet) - I guess that happens at send() time.

Anyway, I have no working end device - am trying to track down the needed connections for a sensor without serial i/o. Manual is ambiguous.
Might have fried sensor xbee?
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 80
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I tossed the code in eclipse and put some debug in the send function.

What do you mean by connecting a sensor without serial i/o?  Most XBee pins can support either digital input or analog input.  With series 2 you can't measure more than 1.2V for some odd reason.

Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 73
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The sensor xbee is connected to only vcc, gnd and d0. There is no serial i/o connection (din/dout.) The d0 input is fed by a voltage divider to bring it down to a max of 1V.
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 80
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Your sensor circuit is correct.  You can go up to 1.2V to get the full 10-bit range.  I found that if you go over 1.2V, all the inputs read 1024.  So looks like you have everything at this point, right?
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 73
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, fantastic - I even solved my x-ctu problems (see under xbee issues thread).
Did you update your library so I can download new version? Then I'll have another go at it.

Forgot to mention - my problems were solved thanks to another posting of yours.

I'm getting a compiler error on Arduino v15 in the second statement:

RemoteAtCommandRequest remoteAtRequest = RemoteAtCommandRequest(remoteAddress, irCmd, irValue, sizeof(irValue));
remoteAtRequest.setApplyChanges(false);
 
error: expected constructor, destructor, or type conversion before '.' token

Tried casting but that didn't work either.
« Last Edit: November 13, 2009, 07:12:43 pm by maxmike » Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 80
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Mike,

You just need to move remoteAtRequest.setApplyChanges(false); inside a function, like setup or loop.

I release version 0.2.1 with a bug fix for apply changes, but I found that the example still works with the bug.  This means you don't need apply changes to enable i/o on a remote.  Here's what I receive at the coordinator after running the exmaple:

03:43:59.504 PM
Received Response apiId=ZNET_IO_SAMPLE_RESPONSE (0x92),length=20,checksum=0xe6,error=false,packetBytes=0x7e 0x00 0x14 0x92 0x00 0x7d 0x33 0xa2 0x00 0x40 0x0a 0x3e 0x02 0xaa 0x74 0x01 0x01 0x04 0x00 0x01 0x04 0x00 0x02 0x1d 0xe6,remoteAddress64=0x00 0x13 0xa2 0x00 0x40 0x0a 0x3e 0x02,remoteAddress16=0xaa 0x74,option=PACKET_ACKNOWLEDGED,digitalChannelMask1=00000100,digitalChannelMask2=00000000,analogChannelMask=00000001,dioMsb=00000100,dioLsb=00000000,D10=high,analog0=541

Remember to issue the WR command if you want to save the config to memory; otherwise it will be lost when you power off the xbee.

Andrew
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 73
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Andrew,

Looks like my problem is that I'm using an Xbee as a Zigbee when it should be a Znet 2.5 - Digi is driving me nuts. I also didn't pay attention to something you mentioned earlier because I didn't know the difference between Zigbee and Znet. This explains the error return from your calls. I am trying to write this (coordinator) file now:

Code:
XB24-B_ZigBee_1147.mxi
80
0
251
1147
0
[A]ID=234
[A]SC=1FFE
[A]SD=3
[A]NJ=FF
[A]DH=0
[A]DL=FFFF
[A]NI=
[A]BH=0
[A]AR=FF
[A]DD=20000
[A]NT=3C
[A]NO=0
[A]PL=4
[A]PM=1
[A]EE=0
[A]EO=0
[A]BD=3
[A]NB=0
[A]D7=1
[A]D6=0
[A]AP=2
[A]AO=0
[A]SP=20
[A]D0=1
[A]D1=0
[A]D2=0
[A]D3=0
[A]D4=0
[A]D5=1
[A]P0=1
[A]P1=0
[A]P2=0
[A]LT=0
[A]RP=28
[A]PR=1FFF
[A]IR=0
[A]IC=0
[A]V+=0

Note it's called Zigbee, but drop down in X-CTU calls it Znet 2.5. It just will not do the write - keeps coming back with an error for EE. Changing EE and E0 produces an error for BD, etc.
Probably time to talk to the X-CTU boys...
« Last Edit: November 15, 2009, 07:50:37 pm by maxmike » Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 80
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Mike,

ZNet is Zigbee.  ZNet 2.5 is based on Embernet 2.5.  Digi also provides ZB Pro, based on embernet 3.x.

Release notes for znet: http://ftp1.digi.com/support/firmware/93009374_C.txt

Release notes for zb pro:
http://ftp1.digi.com/support/firmware/93009373_C.txt

I can't seem to find any info on the version 1320 firmware.  The ZB Pro firmware is 2.x.6.4 but that is selected by choosing xb24-zb on the modem menu.

You're on the right track now by installing the 114x ZNet firmware.  What are you using to flash the firmware?  Have you tried a reset before the write?

Andrew
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 73
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Andrew,
I'm using a modified development board that I wire-wrapped; it has 3.3V ttl/RS232 level converter, led's and grounds, etc. Works well. I am keeping the wire-wrap between pins 9 and 10 on the Xbee on that board. I must say X-CTU presents a steep learning curve for a simple program, but...
NOW your libraries seem to work!!!!!!!! Got RemoteAtCommand.pde to work, anyway - proceeding with rest. I'll download your new version first. Thanks for doing that.

Yup, sampling works as well - good stuff!
« Last Edit: November 16, 2009, 06:49:36 pm by maxmike » Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 80
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ok, good to hear it's working for you
Logged

Netherlands
Offline Offline
Jr. Member
**
Karma: 0
Posts: 54
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Rappa/MaxMike,

I am also trying to setup two Xbee series 2 radio's for communication in API mode. I want to add more Xbee's later, but for now one coordinator and one router/end device is what I am shooting for. However, I am at the point where MaxMike was at reply 9:

Quote
I can see one problem - X-CTU did not write AP=2 as I thought it had.
I am having one hell of a time with it. I do a read, then show defaults, then set the value, then on write it fails during setting AT parameters,
then shows all errors. A subsequent restore sends it into a loop that requires it to be killed. I had to turn off the end device because it doesn't match new parameters and I get a complaint about network formation. Need to find a way of managing X-CTU.

I tried resetting the board just before hitting write, but it remains hanging on the "setting AT parameters". It this a timing thing where I should release the reset at just the right moment?

I have the xbee on top of an libelium xbee shield, which in turn is on top of an unchipped arduino duemilanove, connected to a windows laptop by USB. It seems after all the resets, write's etc there is a firmware for coordinator in API mode, but it is not retaining the NI and PAN ID. Also, is it correct that you cannot set the channel yourself?

I must be missing something, but I don't what and it is driving me crazy :-)

Any thoughts, hints or tips?
Regards,
Arno
Logged

Netherlands
Offline Offline
Jr. Member
**
Karma: 0
Posts: 54
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

My problem disappeared as soon as I toggled off the "always update firmware" when writing...
Logged

Pages: 1 [2]   Go Up
Jump to: