Zigbee Question

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times
Contact:

Zigbee Question

Post by acestu »

Hi guys,

I have an xbee router and coordinator that have both been set up in the X-ctu app, now Is there a way of just connecting to Tx and Rx of a pic and reading what is sent somehow ?, or do I have to use the Zigbee component and set up all the information on that the same as I did in X-ctu ?

cheers
Acestu

EDIT:


This is an arduino sketch that reads the serial info from the zigbee coordinator through the chip Rx and Tx pins so how would you do this in Flowcode ?

float temp;
void setup() {
Serial.begin(9600);
};

void loop() {
if(Serial.available() >=21) {
if (Serial.read() == 0x7e) {
for (int i = 1; i < 19; i++) {
byte discardByte = Serial.read();
}
int analogMSB = Serial.read();
int analogLSB = Serial.read();
int analogReading = analogLSB + (analogMSB * 256);
temp = analogReading / 1023.0 * 1.23;
temp = temp - 0.5;
temp = temp / 0.01;
temp = temp * 9/5 + 32;
Serial.print (temp);
Serial.print (" Degrees F");
}
}
}
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Zigbee Question

Post by Benj »

Hi Stu,

The RS232 component is probably the cleanest way to get at the UART comms and should allow you to talk to the XBEE modules without having to use the full Zigbee component.

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times
Contact:

Re: Zigbee Question

Post by acestu »

Hi Benj,

As far as I can make out the data frame from the xbee is 23 bytes long, 21 and 22 being the ADC data, in the youtube video the guy uses an arduino sketch to ignore the first 20 bytes and then he puts the next 2 bytes into int variables ie Msb and Lsb, my question is how would this be done in the rs232 component ?.

Thanks
acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Zigbee Question

Post by Benj »

Hi Stu,

Should just be a case of read 23 bytes and only use the data from the bytes you need. You might need a way of finding the start of a data frame which then allows you to be sure your collecting say the 20th value when you've read 19 bytes after the frame start.

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times
Contact:

Re: Zigbee Question

Post by acestu »

Hi Benj,

The guy in the Youtube tutorial says that he makes sure that he is reading the frame from the start by adding the line " if (Serial.read() == 0x7e) { " to the sketch which is the first Byte, basically I am trying to emulate the Arduino sketch but I will be using the MSB and LSB variables to output to an LCD and not just look at them in the serial monitor window. So I need to read the frame from 0x7e and then collect bytes 21 and 22, is this possible ?.
xbee.jpg
xbee.jpg (68.31 KiB) Viewed 13806 times
Thanks
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Zigbee Question

Post by Benj »

Hi Stu,

Yep this should be fairly straight forward.

Initialise the RS232 component and then go into a loop while the variable "in" is not equal to 0x7E. Inside the loop add a RS232 read byte component macro which puts the incoming value into the "in" variable.

As soon as you drop out the loop you know you have received the first byte.

Next create a loop that will run 20 times to collect bytes 1-20.

After this you can collect bytes 21 and 22 into new variables and then combine the two bytes into an int using bit shifting.

IntVar = ( MSB_byte << 8 ) | LSB_Byte

The repeat the process to collect new data, if you want me to create a quick demo in Flowcode then let me know.

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times
Contact:

Re: Zigbee Question

Post by acestu »

Hi Benj,

That would be great if you could do a demo chart for me, its all a bit confusing :?

cheers
acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times
Contact:

Re: Zigbee Question

Post by dazz »

Hi Mutley
you also need to bear in mind , that the sketch file relies on library files, so you would need to convert those over as well
Regards
Dazz
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times
Contact:

Re: Zigbee Question

Post by acestu »

Hey up Dazz,

Yes mate, that's why I said how do you do it in flowcode ?, if Benj does me a demo, I will see how I go on from there.....

cheers
acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times
Contact:

Re: Zigbee Question

Post by dazz »

Hi Mutley
can you link to the data etc might make it easier for Benj, play your lot soon :(

Regards
Dazz
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times
Contact:

Re: Zigbee Question

Post by acestu »

Hi Dazz,

Sorry I thought I had, this is it:

https://www.youtube.com/watch?v=rnBx2yqKn_E


and the cheat sheet is here:

http://tunnelsup.com/tup/2012/11/30/x...


cheers
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Zigbee Question

Post by Benj »

Hi Guys,

Right here is a quick example which should hopefully get you started.
ZigDem.fcfx
(9.17 KiB) Downloaded 308 times

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times
Contact:

Re: Zigbee Question

Post by acestu »

Hi Benj,

I tried your chart but I just get a blank screen, I had a mess and got this:

I changed the chart to accommodate my lcd and device then downloaded to chip but the numbers are not making much sense, I also changed the chart so it would show the MSB and LSB values on the lcd.

cheers
Acestu
zig2.JPG
zig2.JPG (157.24 KiB) Viewed 13775 times
Zigbee-demo.fcfx
(11.16 KiB) Downloaded 254 times
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Zigbee Question

Post by Benj »

Hello,

I've had a quick go at modifying your program so the numbers should be correct (not leaving old false values on the display) and so your floating point calculations are done via the float libraries.
Zigbee-demo2.fcfx
(12.6 KiB) Downloaded 256 times
Let me know how you get on.

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times
Contact:

Re: Zigbee Question

Post by acestu »

Hi Benj,

I downloaded the new chart and programmed the chip, as soon as the router started transmitting I got massive varied numbers on the screen, I have added a couple of pics....

thanks
Stuart
Floating1.jpg
Floating1.jpg (26.28 KiB) Viewed 13730 times
Floating2.jpg
Floating2.jpg (26.4 KiB) Viewed 13730 times
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times
Contact:

Re: Zigbee Question

Post by acestu »

Hi Benj,

I am not sure if the numbers on the display are right ,they seem to jump extremely as in the 2 pics above, I am trying to get something similar to this:
temps.jpg
temps.jpg (11.85 KiB) Viewed 13687 times
Thanks
Stuart
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Zigbee Question

Post by Benj »

Hello,

In the MPC9700 chart topic you posted some demo code and it looks like their loop to throw away bytes only throws away 18 bytes. In my program I was throwing away 20. If you change the parameter to the skipbytes macro to 18 then do the numbers start to make sense?
for (int i = 1; i < 19; i++) {
byte discardByte = Serial.read();
}
int analogMSB = Serial.read();
int analogLSB = Serial.read();

Rudi
Posts: 666
Joined: Mon Feb 10, 2014 4:59 am
Has thanked: 493 times
Been thanked: 187 times

Re: Zigbee Question

Post by Rudi »

Hi acestu,

I'm sorry that I meddle, maybe you can order what to do:
..
..
how you managed the RF Data from the Zigbee? Which Frame TYPE do you give your Datagram?
Do you send a "REMOTE AT Command Request" 0x17 and check the Digital ID that have the TEMP Sensor connected?
Do you "wait" for a Reply for checksum?

Example: You know, which Datagramm / Frame Type you send and what Message you will get.
You can check firsttime for a "OK reply in the ckecksum".. if ok, you know how long the Message is,
and allways will give you the Temp Value at same IDX in the Datagramm back.
If You send the Remote AT Command Request without a ACK need.. the Offset 4 (Bit 5 = Frame ID ) 0x00 = no response, 0x01 resonse..
then allways not 100 procent all RF Data - because you send the Request.. and Data comes ( with or without again a ACK ? ) ...
it can be a fail in the Datagramm Data..

Have a look in the API Docu your Device

Best wishes
Rudi
;-)

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times
Contact:

Re: Zigbee Question

Post by acestu »

Hi Rudi,

Check out the tutorials on Youtube, I have left you the link on my other post, also here is the xbee cheet sheet link:

http://www.tunnelsup.com/xbee-s2-quick- ... eat-sheet/

cheers
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times
Contact:

Re: Zigbee Question

Post by acestu »

Hi Benj,

I will re program and see if it is ok.

cheers
Stuart
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times
Contact:

Re: Zigbee Question

Post by acestu »

Hi Benj,

It is still coming up with crazy numbers, here are some pics:
18-skips.jpg
18-skips.jpg (99.98 KiB) Viewed 13657 times
18skips_2.jpg
18skips_2.jpg (101.06 KiB) Viewed 13657 times

cheers
Stuart
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

Rudi
Posts: 666
Joined: Mon Feb 10, 2014 4:59 am
Has thanked: 493 times
Been thanked: 187 times

Re: Zigbee Question

Post by Rudi »

acestu wrote:Hi Rudi,

Check out the tutorials on Youtube, I have left you the link on my other post, also here is the xbee cheet sheet link:

http://www.tunnelsup.com/xbee-s2-quick- ... eat-sheet/
cheers
Acestu
Hi acestu,

thank you acestu, i will have a look later - so perhaps i can help too.

I have start a Thread for making a Icon and others.

http://www.matrixtsl.com/mmforums/viewt ... 54&t=15204

btw, here is my simple Flowchart for the Xbee 868 Pro, perhabs this can help you too.
edit: this is a makro with parameter
->000 StringTyp : ATCommand_Frame0x13[3]
->001 ByteTyp : ATCommand_Frame0x17_PARAMETER

example call:
Frame_ID_0x17_indicates("D1",4)

will send a AT Command for the Digi port pin D1 with Parameter 4 ( set the D1 DIGITAL OUT, LOW )

all other is fix for Frame Type 0x17

I make for all Frame Types a Makro with fix parameter, only DATA Gramm must fill out in the Parameter.
This will be be a ICON for XBEE 868 Pro
;-)
.


The Temp Sensor is interessting! i have order too a lot of pieces ;-)

Best wishes!
Rudi
;-)
Last edited by Rudi on Thu Aug 21, 2014 9:11 pm, edited 1 time in total.

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times
Contact:

Re: Zigbee Question

Post by acestu »

Hi Rudi,

Thanks, I might have a go with 1 of the Pro Zigbee modules when I manage to get this sries 2 going.....

cheers
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

Rudi
Posts: 666
Joined: Mon Feb 10, 2014 4:59 am
Has thanked: 493 times
Been thanked: 187 times

Re: Zigbee Question

Post by Rudi »

acestu wrote:Hi Rudi,

Thanks, I might have a go with 1 of the Pro Zigbee modules when I manage to get this sries 2 going.....

cheers
Acestu
Hi Acestu,

one tip if you not know this ..
this helps me for understanding the zigbee/xbee DATAGRAM

http://ftp1.digi.com/support/utilities/ ... rames2.htm

the same is in the new X-CTU Config Tool .. V 6.. named "Frame-Generator" too in this

Best wishes
Rudi
;-)

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times
Contact:

Re: Zigbee Question

Post by acestu »

Hi Benj,

If you get chance could you have another quick look at this one please, still getting massive high and low numbers.

cheers
acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

Post Reply