LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview + xbee read sensor, uncoding the hex string

Hey guys 🙂

Before i start i apologize for my bad English, i'm a student in Portugal in Eng. of Eletronics and Computers, and i have this last project to make, while working on an interprize here in Portugal that manufacters eletronic components for cars, home machines, etc.

Without going into much details that doesnt matter, my project is basicly read some valors from some sensors, and send that data with xbee to the Labview, so i can manage to register every data, and later make warnings about it, cause those sensors are currently used to control and monotorize one line of machines that use a lot of liquids with diferent temperatures and pH

Right now i'm just using the DS18B20 sensor from One-Wire, just to make things simple
I've manage to put the code on the arduino, that is connected to my xbee label as router AT (transmitter), and i have another xbee connected with my pc, label as coordinator API (receiver of information).

I've already managed to configured the 2 xbees with no problem, and they are currently passing info from one to another, as i show you in the pic of x-ctu.
I even managed to read the data on the Labview
my real problem now is that i dont really have a clue how to parse the string, or divide it so i can read only the valors that i need, in this case, temperature valours. As i hope you are familiar, the xbees send their data em Hex or ASCII code (correct me if i'm wrong but those are the ones i'm getting), and so my string kinda starts with a start byte (7E) so i managed to find the beggining and ending of my string sended, and even managed to identify the Hex code that holds the information of the valours of temperature received.

My real real issue is how to manipulate the string, so i can pull only the data i want (temperature numbers) and discard all the rest.

Here i'll send you some shots, my currently VI.
If you need any more details, like the configuration of the xbees i can provide it, although i dont think its relevant since they are working fine.

cheers to all!

0 Kudos
Message 1 of 28
(5,447 Views)

Is the area in green the data you want? Does it always come in the same place in the data string?

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 2 of 28
(5,406 Views)

Yes, it always come in the same location, i'll try to explain here:

the code for 1 reading is like this one

7E 00 13 90 00 13 A2 00 40 A2 3A 63 C0 DD 01 32 32 2E 36 39 0D 0A 85

this is received in labview as ASCII code, so basicly the information i want is the 32 32 2E 36 39, that corresponds to 22.69 for example (its the valor of my temperature). basicly 2 numbers for each character in ASCII code

but if i right click on the buffer (string readed) and change the mode to Hexadecimal it appears to me like this:

7E00 1390 0013 A200 40A2 3A63 C0DD 0132 322E 3639 0D0A 85

 

and i'm afraid that without the spaces it may even damage my information

 

what i really want is to learn how to clear everything else but those 5 pairs of numbers

 

from 7E00 1390 0013 A200 40A2 3A63 C0DD 0132 322E 3639 0D0A 85, extract this: 32 32 2E 36 39 and convert it to: 22.69

thanks in advance for you time, if you need more details please tell me so I can provide it the best way i can

🙂

 

0 Kudos
Message 3 of 28
(5,402 Views)
  1. Get rid of the Bytes at Port and rely on the Termination Char. Your device seems to end each message with x0D x0A (Chairage Return/Line Feed). Use the default Termination Char (x0A) to only read in one complete line at a time.
  2. You are checking the string after the Feed Back node so you are only rechecking the beginning of the srting. Rechecking same OLD first line each time and not the NEWEST line. Check the string that is returned from the VISA read.
  3. Init the Feed Back Node to an empty string or each time you run it the old data will still be there.
  4. Will the temperture ALWAYS be in the XX.XX form? What does the xbee manual say? Does the xbee manual tell you if there is information in the message telling you how many digits are used to send the temperture? What happens if the temper is over 99.99 or under 10.00? Like 100.00 or 9.99?
Omar
0 Kudos
Message 4 of 28
(5,401 Views)

Also, i forgot to mention

since its in a while cycle it continues to read the valors, so i also need to find a way to stop it, or do a reading, register it into something (an array would be great, but since i cant even extract nothing from it, dont know how to do it), clear the buffer, and do the reading again

 

the final propuse of the program is to do 1 reading per minute for example, from the sensor that flows trough the xbee

0 Kudos
Message 5 of 28
(5,399 Views)

First of all, thanks again for the great help 🙂 you rock mate!

as for the type of reading of the temperature, yes it does always comes like XX.XX, at valors like 9.99, it would be displayed like 09.99, again, always like XX.XX. as for the 100.00 dont worry about it, the place where i'm working would only reach a max temperature reading of 75-80ÂşC. 

And yes, it will always be as XX.XX 

this kind of reading is from my program in arduino that is connected to my xbee router AT. I can change it to only have 1 decimal number, or even more than 3, so it would be like XX.X or XX.XXX doesnt matter, because the xbee only codes like 1 number or char at a time in ASCII code, so for each number it will always have a XX code

 

 

0 Kudos
Message 6 of 28
(5,395 Views)

the part of my VI that displays those elements, it was my failed atempt to check the index of the string (as if it was an array) to pull the numbers i did want

0 Kudos
Message 7 of 28
(5,391 Views)
A simple String to Byte Array can be used. If you use a termination character, the read will automatically terminate, you will read the entire data that is transmitted, the buffer will be cleared.

p.s. The word is values, not valors.
0 Kudos
Message 8 of 28
(5,388 Views)

Thanks for the help, learning everyday :)!

 

the problem to make a terminal char at the end of beginning of the information i want, and pull it out with a string, is that it cant be modified within the xbee, the xbee creates its own type of string ( xx xx xx xx xx... and so on), the last byte is always called the checksum, right before those 2 pairs of values that you spoke, but even it seems to change, and it should not (thats what the manuals say, so not sure of it)

but i'll try to do something more, thanks again for everything

0 Kudos
Message 9 of 28
(5,375 Views)

@Raknugar wrote:



7E 00 13 90 00 13 A2 00 40 A2 3A 63 C0 DD 01 32 32 2E 36 39 0D 0A 85


0D 0A marks the end of the message. 85 is the start of the next message.

 


@Raknugar wrote:

but if i right click on the buffer (string readed) and change the mode to Hexadecimal it appears to me like this:

 

7E00 1390 0013 A200 40A2 3A63 C0DD 0132 322E 3639 0D0A 85

 

and i'm afraid that without the spaces it may even damage my information


The spaces are not really there. The spaces are only in the display and not in your string. The spaces are only there to make it easier for YOU to read them. 

 

 

Omar
Message 10 of 28
(5,374 Views)