LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert to number

Hi make…,

 

the communication protocol between sensor and microcontroller is irrelevant here.

 

You need to know the protocol between microcontroller and PC/LabVIEW!

Study the C code you attached above. Ask the author of that C code!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 11 of 36
(994 Views)

Hi! The program sends the data in float. It is something like this, but there are several headers being sent. 

0 Kudos
Message 12 of 36
(961 Views)

Noone here can tell you what your data means.  If you want to get pitch and yaw and such from a stream of data, you have to know which bytes of data contain the pitch, for example, and how many bits or bytes at what offset, etc.  Once you have that information, we can if necessary help you to convert that to a usable number.

 

In the "C" program, it looks like the key is the function serialCom.  This function looks like it handles several different kinds of messages though (one of them fills in rcDataSerial, which seems to be the data that you want).

 

Figuring out a data format by analyzing C code like this is a headache.  If you have been given the job of handling this data, someone should be able to provide you with the information you need to analyze it.  If not, you may have to sit down and analyze the C code.  But perhaps you can contact the company which makes the equipment you are using.

 

Avionics is my field.  If you were talking ARINC-429 protocol, for example, perhaps we could help you, as there are defined engineering units for different labels and equipment.  But serial communication is totally application dependent.  You can't get altitude, pitch, roll, yaw, from a stream of data unless you know where in that data these numbers are, and how they are encoded (for example, BCD, pure binary, or even ASCII digits for goodness sakes).

 

We would like to help you, but we don't know this information.

 

Batya

 

0 Kudos
Message 13 of 36
(938 Views)

I see! One question.. Is it possible to write a C program and just somehow put it in Labview? Since I have the code already.

0 Kudos
Message 14 of 36
(926 Views)

If you create a DLL you can access the functions using LabView's Call Library Function Node VI.

0 Kudos
Message 15 of 36
(923 Views)

Yes.  That is, if you create a DLL you can access the exported functions using LabVIEW's Call Library Function Node. 

 

You can also "import" the DLL, which will create wrapper functions for your exported functions.  Of course, you have to check them over and test them, but in many cases they can be used as-is.  If not, most functions require only a little tweaking.

 

Batya

0 Kudos
Message 16 of 36
(926 Views)

Hi! The program sends and recieves like this. It sends out 2 bytes of roll, pitch, throttle, yaw and servo.

and then it recieves a reply of roll, pitch, yaw in 4byte float and ultrasonic (altitude) in short.

 

 BfHXjdICMAAgWBg.jpg

0 Kudos
Message 17 of 36
(900 Views)

OK, that is very helpful.  To interpret the received data, you can, for each value, take an array subset of the right size ( two or four bytes) and then do a type conversion on it.  You'll have to see if the numbers come out right and possibly adjust the byte order; your scanned page doesn't mention that.

 

I'm supposing that you know what $ M > and 14 are so you can figure out the offests.  Are these bytes?

 

To extract a subarray and type convert, see here.

 

Batya

0 Kudos
Message 18 of 36
(887 Views)

Hi Batya,

 

"$M>" is clearly visible in the attachments of the first message, so here ASCII is meant. "14" seems to correspond to an U8 and could denote the number of bytes in that µC message (3 SGL + 1 U16)…

 

See my message #5 and the string in hex display. Here you will find the corresponding pattern "244D 3E0E"…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 19 of 36
(882 Views)

Could you please save your vi back to version 11 or earlier and I will help.

 

 

0 Kudos
Message 20 of 36
(869 Views)