03-15-2011 11:45 AM
Hello,
I have a problem with Doppler radar via RS232. I get data from radar as ASCII chars. Protocol consists of 13 bytes. Bytes 2 and 3 in this protocol are responsible for measured speed value. Now is the question: how to convert that two ASCII characters into decimal value of speed? First I use String to Byte Array block and from two ASCII chars I get two decimal values. What should I do next to get one decimal value? From manual for radar I only know that:
I will be very thankful for help
03-15-2011 12:01 PM
Little confused by the formula there provided. But I think it would look like this:
03-15-2011 12:03 PM
Heh heh ... just realized that image looks bad. But I think you get the picture. You need to use a "Join Number" function to turn two 8 bit numerics into one 16 bit numeric.
Also a little unsure about the byte order. But if that doesn't work, try switching the order of Byte 2 and Byte 3.
03-15-2011 12:41 PM - edited 03-15-2011 12:44 PM
Take the two-byte substring and use unflatten from string with a type of U16 or I16. Adjust the byte order if needed.
(For more detailed help. can you attach a simple VI containing a raw example string as received as a diagram constant? Also indicate what the speed is supposed to be. Also indicate youtr LabVIEW version.)
03-16-2011 09:34 AM
Than You very much for help. Join Numbers works good and the speed values are OK. I have also the same problem with data bits responsible for distance value. According to manual:
One protocol consists of 13 bytes.
Bytes 3,4 - speed value
Bytes 5,6 - distance value (S1 according to manual)
bytes 7,8 - distance value (S2 according to manual)
Top speed on graph should be about 100kmph.
Thank You very much for help
03-16-2011 10:34 AM
I forgot, bytes 3,4,5,6,7,8 are correct if counted from 0.
03-16-2011 10:34 AM - edited 03-16-2011 10:37 AM
Please attach your VI directly here.
(I recommend to get all fields at once using a type cluster. Can you give a quick table of the meaning of all bytes?
Is the first byte called "byte 0" or "byte 1")
03-16-2011 10:40 AM
Code in attachment
03-16-2011 10:42 AM
VI in attachment (LV7.0)
03-16-2011 11:22 AM
Hi altenbach,
Could you explain what you mean by a "type cluster"?
I am writing a lot of code where I need to extract data from an incoming RS232 stream. I spend a lot of time decoding bytes and joining/splitting bytes. I am wondering if your technique could save me some time.