04-24-2021 09:13 AM
Hi,
I faced a problem to convert ASCii code to decimal number .
ASCii code getting from Bluetooth receiver.
Refer to "result" picture, the "output" i can get is 123. This is not correct.
The expected result should be x.xxxx (refer to "expected result decimal" picture).
Attached my program file and image file (diagram picture) for your study.
Please provide me your Labview file if you able to solve it.
I can use your file to try out.
thank you.
best result.
Solved! Go to Solution.
04-24-2021 10:10 AM - edited 04-24-2021 10:18 AM
Please run your VI once more until the received string contains actual data, stop the VI and make current values default (Do you know how to do that?). Save and attach. Now we have a correct string to play with.
And no, I would not call this "ASCII code" (A character encoding standard). It is just a random binary string to be interpreted as a sequence of bytes.
Casting a long string to a U8 will drop all information except one single byte, so whatever you are doing now is incorrect. Do you have information about the received string? How long is it (looks like ~16bytes)? What's the structure?
So you seem to expect floating point values. It could be that you need to cast to SGL or DBL or some multibyte integer that needs to be scaled. No way to tell. Do you have the manual for this device?
04-24-2021 05:26 PM
Hi, Altenbach,
Thanks for your reply.
i changed the "ASCII code from Bluetooth receiver port" display style property to Hexadecimal. Please refer to "result_R1'.
I try to use other application software to find more data information. Refer to "information" picture.
best regards.
04-24-2021 06:17 PM
The default value for the string is still blank in your VI.
04-24-2021 08:11 PM
Hi, Altenbach,
How to get the default value ? Please teach me.
Before i start the program, there is nothing in "ASCII code from Bluetooth receiver port" display box.
Once i start, i can see hexadecimal number keep going to change.
I try to attached a video file, unfortunately, not succeed due to file size is too big.
best regards.
04-25-2021 08:30 AM
What device are you using to get this data? You need to know what kind of data to expect. Is there a data sheet or any documentation?
04-25-2021 09:20 AM
The data is transmit from strain gauge Bluetooth transmitter.
Data format is in ASCII format .
The 'information" image file shows 2 information.
1st) ASCII code (0D 0A are the header and footer), balance are data.
2nd) 3.xxxx is the final decimal value that i want to get.
Example: 33 2e 32 37 32 36 after convert become 3.2726
So i want to build up a program to convert ASCII code to decimal value.
best regards.
04-25-2021 10:13 AM - edited 04-25-2021 10:16 AM
From what you posted earlier, the data displayed from VISA read is garbage. Maybe the baud setting is wrong? In your VI, remove the Bytes at port, just wire a value larger than you expect to see and when the newline character (0xA) is read Visa read will return the data up to that character. (That is the default settings for visa configure port)
If all the port settings are correct (data bits, stop bits, parity and baud) the VISA read will return the the ascii data.
Enable Term. char and the linefeed (0XA) are the default settings.
04-25-2021 10:21 AM - edited 04-25-2021 10:23 AM
@Jeffrey_Oon wrote:Example: 33 2e 32 37 32 36 after convert become 3.2726
.
Well, this is quite different to the received string shown in your first picture, which had basically no printable characters!
Now you just show us a formatted string, which, (using ASCII convention) consists of numeric an delimiter characters describing the number you want. You can scan that into a numeric datatype as needed.
To answer the question how to make a value default:
04-26-2021 01:32 AM
Hi, Altenbach
The root cause is the baud rate wrong selection.
Thank you for your advice.
best regards.