12-29-2015 08:55 AM
Hi,
I'm building a device testing tool. And I'm using an arduino to read serial data. I've build a VI but the output of VISA READ is a string witch has a precision of 2 decimals. I need at least 3 decimals. Does anyone have an idea on how to achieve that?
I've posted the VI's I use as well as the arduino control program.
Solved! Go to Solution.
12-29-2015 09:33 AM - edited 12-29-2015 09:34 AM
1. Only initialize the port once BEFORE the loop.
2. Do NOT use the Bytes At Port to tell the VISA Read how many bytes to read. Instead, use a large number (larger than any message you would expect to recieve). The termination character will stop the VISA Read and return the entire message.
Here is a cleaned up version of your code with a few additional optimizations.
12-29-2015 09:37 AM
12-29-2015 10:50 AM
The Arduino code makes TO or TF (string) a 2 bytes package as far as I can tell. Reading in a longer message doesn't change the lenght that is read in at the VISA WRITE block.
Only thing is that after I changed the code to read in a char or even float its size doesn't increase either.
So truth be told I'm missing something or I do not know how to convert the data as said.
12-29-2015 10:57 AM
12-29-2015 11:29 AM
The sketch is the zipfile included in the first post. But I doubt it's the sketch. I think it has something to do with the conversion.
12-29-2015 11:33 AM
01-04-2016 02:31 AM
Very true. Bad choise of words.
The return count of VISA WRITE is depandant on the number of characters used in the strings before it. Both the bytes at port and VISA READ are at 6 bytes. Wich I thought should be enough for a more accurate number.
01-04-2016 02:41 AM
Hi Teun,
your received string reads "4.58 " - with a linebreak included! So you probably receive something like those chars: "4" "." "5" "8" CR LF !
That are exactly 6 chars and you receive a float with two decimals (after the decimal separator). What else do you expect?
When you want more "precise" floats you need to change your Arduino sketch to actually send them!
(Using a format code like "%.5f" with an appropriate "printf"-command should do the trick…)
01-04-2016 02:43 AM