LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

example code for xbee/zigbee in API mode

Hello All,

 

I am currently using python to collect data from an array of xbee nodes and I want to switch over to LabVIEW.

 

I’ve started by reprogramming one of xbee nodes (plus my coordinator) to work in API mode and I’ve verified that the coordinator is receiving transmissions by using the Basic Serial Write and Read example program.

 

I understand that the received API hex string needs to be parsed in order to identify the node and then pull the “payload” bytes before being converted.

 

I have only superficial experience with LabView so I am having trouble making this programming leap.  I have not had any luck with any of the forum threads on this topic.  I looked all over the web but it seems like this is uncharted waters.

 

Can anyone help me with example code to get me up and running for one of my nodes?  It has 3 sensors and I want to display graphically and save to file.

 

Thanks in advance for your help.

0 Kudos
Message 1 of 33
(8,077 Views)

Hi Nobizz,

 

I don't have any personal experience using xbee nodes, so I can't offer a whole lot of general help on getting up and running. Hopefully someone else in the commuinity will have an idea of a good starting point. If you have specific questions about LabVIEW programming for this project, feel free to post them here and I'll help point you in the right direction.

Andy H.
National Instruments
0 Kudos
Message 2 of 33
(8,035 Views)

Hi Andy,

 

Here is something I was able to find that modifies the Basic Serial Write Read example.  For the most part I was able to make the modifcations.  I just don't recognize the circled icons in the block diagram.

 

Any ideas?

0 Kudos
Message 3 of 33
(8,030 Views)

Hi Nobizz,

 

Those are Merge Signals functions, which are found under in the Signal Manipulation section of the Express sub-palette. Though not laid out all that elegantly, it looks like that code is adding a tick count value and the length of the read string into the signal data being written to the measurement file.

Andy H.
National Instruments
0 Kudos
Message 4 of 33
(8,007 Views)

Unfortunately I am still stuck on this problem.  I spoke to the prof who'se students wrote the code and he said they never actually got it to work so this may be a dead end anyway.  I am still looking for solutions and seeing that there are folks who have it, I guess I need more time.

0 Kudos
Message 5 of 33
(7,706 Views)

Hi Nobizz,

 

Sorry to hear you're still struggling with this. Let us know if you have specific issues you're getting stuck on, and hopefully someone will be able to help out.

Andy H.
National Instruments
0 Kudos
Message 6 of 33
(7,678 Views)

Ok, I think I have a better question.

 

I'm using the Basic Serial Write and Read.vi.  I am recieving 5 API packets every second into the serial read buffer.  I have my "delay before read" set for 1000ms.  This allows me to see approximately 5 string packets however the first string packet does not always start at " ~ " ascii, " 7E " Hex the "begin" delimiter and sometimes the last packet is incomplete.

 

So here is my question: How can I take the sample string of multiple packets from the buffer and display a single packet string that continually refreshes with the values pulled from the buffer? 

 

I want to find the first " ~ " and display the full packet.  There should be a way to set a bit count to error check that the packet is complete before displaying.  Then refresh with the next complete packet from the buffer sample.  Repeat this process by getting the next batch of packets from the read buffer.

 

I think this the crux of my problem.  Once I get a single complete refreshing string packets, I can use the Instrument I/O Assistant to parse the string, convert to Dec and plot.

0 Kudos
Message 7 of 33
(7,644 Views)

Hi Nobizz,

 

Here's a snippet of a quick little program I made that will take a large string input and parse out elements based on the ~ character. This program builds an array containing the five packets. You could then check the length of each string to make sure it's a complete packet before you display it.

 

If you have other questions like these (or any questions that aren't associated with the xbee/zigbee nodes), feel free to start a new forum thread. Have a happy new year!

Andy H.
National Instruments
0 Kudos
Message 8 of 33
(7,622 Views)

So this is how you build a shift register in labview.  I was learning that this was the direction I needed to go but didn’t have a clue how to go about it.  I have it wired up and it works great.  Thanks a bunch.  But as you can imagine I have more questions now. 

 

I don’t want to lose the ~ character of my string.  This will help reduce confusion later on in the program.  Is there a way to keep the ~ as part of the strings in the array?

 

Any suggestions on logic for testing string length?  I am guessing I need to loop through the array and check the cells with some form of bit count.  The problem is I am seeing that the array refreshes as quickly as the buffer read.  I am concerned there won’t be enough time to test all cells.  It isn’t super critical but I would like to collect as much of the data as possible.  Right now I have only one transmitter but plan to have multiples and need the flexibility to handle larger samples.  At first glance it appears at least 40% of the packets will be NG.

 

Finally, I want to display the strings that pass the test in a single window (cell) without too much blinking.  I’m hoping to just see the numbers change.

 

Thanks again, and happy new year to you too.  Cheers!

0 Kudos
Message 9 of 33
(7,608 Views)

Also, the last bit of each packet is a "check sum" bit for the packet.  It would be great to add this check to the string length test for each packet to filter out bad data.

 

Any ideas?

Thanks

0 Kudos
Message 10 of 33
(7,603 Views)