LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

example code for xbee/zigbee in API mode

Put the bool IN the for loop.  Duh, seems obvious now.  Smiley Surprised

 

At the risk of pushing my luck, if you wouldn’t mind helping me with at least 2 more steps, that would be great.  I’m thinking I need to segregate out the different API strings based on the different transmitters.  The source ID address in the string should be bytes 5 and 6.  This should work like a mail sorter taking the various transmissions and grouping like addresses.  I will have as many as 5 different transmitter addresses but if you can help me with at least 2, I should be able to do the rest.

 

Also, if you can help me with this next step, it will aim me in the right direction.  Byte 7 is the RSSI value.  I was thinking of using something like the “tank” indicator to update and display the signal strength.  Knowing how to get this byte out and doing the dec conversion to display will help me develop a strategy for dealing with the “pay load” bytes.

 

Thanks so much

Nobizz

0 Kudos
Message 21 of 33
(4,501 Views)

Ok, I am working with just one node right now and have data for three sensors and the signal strength in waveform plots, sort of. 

 

Signal strength graphs nicely and is giving me the right decimal value, just need to change signs.  Decimal value is right but I need to convert it to a negative value to get the accurate dBm value.  Right now, the value goes up when I move farther away, it should become more negative and go down. 

 

How do I make the decimal value negative?

 

I am also trying to use a numeric indicator like “Tank” to display the signal strength but am having trouble doing the conversion to decimal.  Not sure why this is so hard.  Maybe I just don’t understand how to convert ascii to dec or if I even need to.  Right now I have the “Hexadecimal String to Number” function wired up but it’s not doing the trick.

 

How can I take a string value like "3D" (in hex view) and convert it to decimal?

 

The rest of my sensor data is reading voltages but in between updates, the graph goes to zero so the line graph looks like a triangle wave bouncing between zero and the measured value.  I have no idea why.

 

How can I plot the measured values only, or stop plotting zero in between reads?

 

Also, still need help with a sorting array for multiple nodes.

 

Thanks much.

Nobizz

0 Kudos
Message 22 of 33
(4,476 Views)

Nobizz,

 

 

 

How do I make the decimal value negative? In the Numerics pallete there is a Negate function, has an (-x) sign on it.

 

I am also trying to use a numeric indicator like “Tank” to display the signal strength but am having trouble doing the conversion to decimal.  Not sure why this is so hard.  Maybe I just don’t understand how to convert ascii to dec or if I even need to.  Right now I have the “Hexadecimal String to Number” function wired up but it’s not doing the trick.

 

How can I take a string value like "3D" (in hex view) and convert it to decimal? No, the byte value you get should corrospond to the strength just try inserting that

 

The rest of my sensor data is reading voltages but in between updates, the graph goes to zero so the line graph looks like a triangle wave bouncing between zero and the measured value.  I have no idea why. Sounds like you are constantly updating the graphs, should only do this when you have data

 

How can I plot the measured values only, or stop plotting zero in between reads? I would have the graph in a seperate loop, consumer loop, pass all good data to this in a queue. Update the graph here. You should only have good data inputting to the graph then

 

Also, still need help with a sorting array for multiple nodes. Are you communicating RS-232 or 485, ie do you have to open a comm port for each node or is it on a multi-drop network. If you are opening a new comm port for each node then i would have the recieving loop i sent you duplicated for each comm port. The data from each of these loops should go to a single consumer loop. In this loop you can handle the data from each node. Send the data using a queue. Have the queue input a cluster with all the data you need to send plus some form of identification so the consumer loop knows what node the data came from. Have a go, if you get stuck post me what you have tried and i will point you in the right direction. Oh, if it is 485 and you are using 1 comm port for multiple nodes then in the single reciever loop you need to parse out what node you have recieved from and send this to the queue as i stated for the multiple reciever version.

 

 

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
0 Kudos
Message 23 of 33
(4,471 Views)

I know this should be easy but I’m still working on the one byte string to indicator wiring.  For the dBm output, the actual value increases as the distance to the receiver is increased.  The documentation says the value is actually a negative value even though it is not transmitted as such.  I need to show that the signal becomes weaker as the distance increases.

 

I’ve solved the data fluctuation problem from my sensors.  I needed to do a type cast because I was trying to graph 2 bytes.

 

All data will come in as RS232 (I believe) that is to say, each node’s API packet come in to the same buffer.  This is where the parsing we did earlier comes into play. 

 

I am satisfied that I understand how to manage my data from one node but now I have to get back to the middle of the program and sort multiple nodes.  So from you recommend I set up a single consumer loop, send data using a queue, have the queue input a cluster of address byte and payload bytes to a consumer loop? 

 

Does this sound reasonable?  Is it easier than it sounds? 

Thanks again for all the feedback.

Nobizz

0 Kudos
Message 24 of 33
(4,453 Views)

Nobizz,

 

I have sent you an example of what you need to do, its in the main folder, called 'xbee parser tester 2 Main'. Here is a pretty comprehensive example. I used the links you posted on here to simulate some dummy data you may get from 3 nodes. I then show how to parse the data and handle if for the seperate nodes.

 

The RSSI value will be negative as it is a measurement of dB loss. Your tanks should be configured to be 0 at the top and whatever the maximum RSSI reading you will get at the bottom. For the example i have sent a maximum value of 100 for a dB loss. You will see that i have converted the recieved byte into a signed integer and then negated it. I then feed this value into the tank. I have used an integer in case they are sending a loss up to 255, a signed integer can handle this. Are you sure it is definately a byte it sends and not a signed byte. if it is a signed byte you could feed this directly into a tank with its representation set to I8.

 

Have a look and see how you get on.

 

Rgs,

 

Lucither.

 

PS

 

If i do any more i will be sending a billSmiley Very Happy

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
Message 25 of 33
(4,443 Views)

Lucither,

 

Sorry for the late response, I have been away from my office.

 

After some tinkering, it is clear to me now that I was going about it the hard way.  Don’t ask me why I was trying to work with the string when I had the decimal array available.  By the way, I really do appreciate your help and am quite impressed with your coding style.  Your approach is different than mine I think mostly because I don’t have an approach  Smiley Sad  Frankly, I am beginning to feel bit guilty so perhaps you should send me the bill. Smiley Happy  I’m guessing however that you may just be enjoying this a bit as wellSmiley Tongue  ANyhow, I will look over and work with this latest bit of code and see if I can move this project forward.  Stay tuned, and thanks again for all your help.

 

CHEERS

Nobizz

0 Kudos
Message 26 of 33
(4,412 Views)
Hi Friends, This is rohit new for the ZigBee, i am trying to design the API commands in C++(visual studio)(initially), later i have to design GUI for the same...but i stuck at the initial stage.....i have to send the API command through the console to the co-ordinator serially,but i am not getting any response from the co-ordinator whether it received any command or not?? please guide me...
0 Kudos
Message 27 of 33
(4,235 Views)

Hello Rohit!

 

So you are using Visual Studio C++ to do this, and not LabVIEW as is discussed previously in this post? You might have better luck in a different thread. What kind of hardware are you using? Does it communicate via RS-232 or another protocol? Is your device expecting any sort of termination character? Usually this is '\n' or '\r', but may be different depending on what your device expects. I'm not sure too many people in the LabVIEW forums can really aid you with C++ specific questions... but best of luck to you!

Cheers!

TJ G
0 Kudos
Message 28 of 33
(4,217 Views)

Hey!! Thanks buddy....i got the solution on some other thread. thanks for your suggestion 🙂

0 Kudos
Message 29 of 33
(4,195 Views)

Hi guys im trying to learn wireless system . im using XBee RF for my wireless system alarm i would like to use zigbee wireless  smoke/motion sensors which will be conneced wirelessly to base unit using Xbee. I would like to simulate the system i tried to use matlab didnt work. May you give any ideas or have a project.

thanks

0 Kudos
Message 30 of 33
(3,676 Views)