11-27-2010 10:13 PM
Hello,
Using LV8.6 I am working on a project in which I am getting Floating point data on serial port in ASCII form and I have to convert it into its appropriate decimal value.
I have tried the type cast to convert the data and succeeded when the data was only a decimal value.
But when these values are in floating point which is my actual data i.e. 1.63, 3.41. I am receiving it as 1.11 (if it is 1.63), i.e. getting only the first digit.
But the data is received correctly on String Display and hyperterminal that means the communication is perfect but the error lies in programing.
kindly guide me what I have to do.
Thanks
Solved! Go to Solution.
11-27-2010 10:44 PM
here is the file too
11-28-2010 12:49 AM
Whatever you are doing does not look right and is overly complicated?
11-28-2010 01:38 AM
Thanks alot.
I have actually altered the simple read write vi of examples to achieve my goal.
1- Since my data is like 1.63 means four digits (1 . 6 3). i think that these are recieved indivisually in the same order so i am running it 4 times to recieve them, Then converting the indivisual ASCII data into its appropriate decimal value in the for loop and this is the reason that the for loop is run four times.
2- As working on a previously develop example and to avoid any unwanted error.
3- i have connected the array constant and deleted the Case structure but its showing broken wire.(see attachment). i have used case here to only view the final result as one value.
4- Yes i am receiving the data in ASCII format and since if "1" is arriving in ASCII you can view it as "1" of decimal by subtracting 48 from converted decimal. (http://www.asciitable.com/).
One interesting thing that i want to share is that when the data is received it is seen as the complete measurement on the String Read on the first cycle. And i dont know its reason.
11-28-2010 01:52 AM - edited 11-28-2010 01:52 AM
@Intelligent wrote:
3- i have connected the array constant and deleted the Case structure but its showing broken wire.(see attachment).
String is pink, not orange! If this is confusing to you, please start with a few simple tutorials first.
Please do as follows (shown in the image), run the VI to get data, then convert the string array to a constant. Remove the broken wire.
Intelligent wrote:One interesting thing that i want to share is that when the data is received it is seen as the complete measurement on the String Read on the first cycle. And i dont know its reason.
Obviously, you are reading all bytes in the first read as I thought. How many bytes are on the port at the first iteration?
Remember, you are reading all bytes at the port, not just a single byte with each iteration. With each read, you are throwing away all bytes except the first. Your code so far is highly flawed!
11-28-2010 06:50 AM
The array is of four complete values. This means that in each cycle one complete ASCII value is obtained.
Strange but interesting.
11-28-2010 07:24 AM
it simply changed by format into string conversion.
Thanks for you guidence
11-28-2010 09:26 AM
The thing strange for me is that how a complete set of data is send while there is specific representation for each character in ASCII form. Anyone who has the idea of it. The data is send from 8051 and received on COM Port of the PC.
11-28-2010 11:57 AM
@Intelligent wrote:
The thing strange for me is that how a complete set of data is send while there is specific representation for each character in ASCII form. Anyone who has the idea of it. The data is send from 8051 and received on COM Port of the PC.
Why is that strange? What else do you expect???
You never specify to read a single character, else you would wire a "1" to the serial read count. Whenever you read, there are 5 bytes available and that's what you read. No need to jump through flaming hoops.
So, get rid of the inner FOR loop and simply take a serial reading, then use "scan from string" to get the number into an orange wire for further processing if needed. 🙂
You should also not mark your own comment as solution, it is NOT! Whatever you have marked now is not the solution to the original question and actually contains virtually no information that would help somebody in the future with a similar problem. So please un-mark your solution and mark the post that that best solved the problem as solution. Thanks!