LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I need To Understand the "Type Cast Function"


@JÞB wrote:

@suzanneocallaghan wrote:

I'm still not getting exactly what Typecast does...........it seems to convert short strings into concatenated ones? I'm searching the forums for a way of converting my incoming data (which is in hexadecimal format) into text.

 

For instance I have 4 sensors on a pcb. The data is received by Visa serial as 41 31 20 33 31 37 30. This is just one line of data coming in. I want to convert that to text which is A1 3170. I then want to take the value of 3170 only (read from the A1 sensor)  and store it in an array with all the other A1 values. I then want to output all the sensor values in a waveform. 

 

I'm still at the stage of trying to figure out how to do the hex to text conversion and not sure if Typecast will work here? 


EDIT Not keeping up with new information.  That looks like a "Chatty Cathy" UART with an insane FW developer on the other end.  What is the device we'll need to go to the manual for this.


That is just nasty. Jeff is right about an insane firmware developer.

 

I'm assuming that the read buffer indicator is set for normal display since it shows regular characters, no \codes, no \00 or anything that looks like escaped hex codes.

 

So the original statement of 41 31 20 33 31 37 30 is not actually 7 bytes like I first thought, but 20 actual ascii characters. that represent hex digits and separating spaces, which then need to be converted to hex numbers that represent the ascii characters of the A1{space}3170 which you actually want to then have converted to a string?

 

That's something like 2 or 3 or 4 conversions going on really blurring the lines between hex data and ascii data.

 

Can you throw this device away and buy a different one where the programmer had a clue as to what they were doing?

Message 11 of 26
(3,173 Views)

Its a prototype board using broadcom ble chip. The sensor pcb sends data via bluetooth to the Broadcom Wiced SDK board, which is connected via usb to my pc. It was designed in-house by one of my colleagues. I am a pHd student and he supplied it to me for my work, which involves testing the device in a number of wearable applications. I have used Labview in the past just for reading data direct from intruments etc but this current application is proving challenging. 

0 Kudos
Message 12 of 26
(3,171 Views)

See also this old discussion.

 

Please attach a small VI that contains the raw data as received from the instrument as e.g. a diagram constant. (run your VI connected to the instrument so the indicator contains data, stop the VI, right-click the indicator terminal...create constant...copy the constant into a new VI, save and attach it here).

0 Kudos
Message 13 of 26
(3,152 Views)

@suzanneocallaghan wrote:

It was designed in-house by one of my colleagues.


Ok.  So the solution is simple.  Go find this colleague and SLAP HIM SILLY.  Why does he do this weird conversion.  Tell him to just send you the ASCII data straight.  Then their code will become simpler and so will yours.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 14 of 26
(3,146 Views)

 My protype device stopped working a few hours ago. I need to get another one stuffed and programmed. Prob be a couple of days. I will come back to you with the requested VI once I have it working again. Thanks for your help.

0 Kudos
Message 15 of 26
(3,142 Views)
By saying send the ascii data straight, what do you mean? Isn't the data here coming in in straight hexadecimal? Doesn't ascii refer to any type ; decimal;hex;oct;char etc? He has said that is straight ascii. Clearly you both mean something different.

I will get the full protocol from him tomorrow and see if I can figure out the answers to your questions. I didn't realise that what he has given me wud be as complicated as you say.

Perhaps Labview is not the best tool for this? Dare I ask is a matlab environment more suitable? My supervisor requested a Labview Interface.
0 Kudos
Message 16 of 26
(3,130 Views)

@lolasue wrote:
By saying send the ascii data straight, what do you mean? Isn't the data here coming in in straight hexadecimal? Doesn't ascii refer to any type ; decimal;hex;oct;char etc? He has said that is straight ascii. Clearly you both mean something different.

I will get the full protocol from him tomorrow and see if I can figure out the answers to your questions. I didn't realise that what he has given me wud be as complicated as you say.

Perhaps Labview is not the best tool for this? Dare I ask is a matlab environment more suitable? My supervisor requested a Labview Interface.

Based on the screen shot you gave us, what you are being sent is what I call "ASCII Hex", that is hex values converted into an ASCII format so that it is readable in a text editor. "41 31 20 33 31 37 30" is the ASCII Hex string.  ASCII would would give you "A1 3170".

 

Spoiler
This looks like another ASCII Hex string.  I really hope you are not doing a double ASCII Hex conversion.

 


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 17 of 26
(3,117 Views)
Ah OK. I see why he wud have done that....the values can also be read via Bluetooth in an android app. When I use the app I see the values exactly as you said A1 3170. OK I need to get him to change that back to straight ascii for the Labview Interface.

Thanks for that clarification.

Guys, your help and advice is very much appreciated.
0 Kudos
Message 18 of 26
(3,109 Views)

ASCII is just a convention to assign bit patterns to readable characters and control characters, etc. It is irrelevant for the discussion here.

 

The string either represents formatted values (hex, decimal, floating point, etc.) or it is a binary string to be cast to the correct data type (after considering byte order, etc.).

 

Did the programmer write a document detailing the structure of the received string? If not, stop until he does. This is just silly!

0 Kudos
Message 19 of 26
(3,106 Views)

@lolasue wrote:
Ah OK. I see why he would have done that....the values can also be read via Bluetooth in an android app. When I use the app I see the values exactly as you said A1 3170. OK I need to get him to change that back to straight ascii for the Labview Interface.



Did you just change your forum name?

 

Did he write the bluetooth app as well?  Did he do extra conversions in there?  Because your VISA read doesn't show A1 3170, so I don't know how the bluetooth app would do it without doing multiple conversions.

0 Kudos
Message 20 of 26
(3,092 Views)