08-15-2017 01:47 PM - edited 08-15-2017 01:47 PM
Hello Ravensfan,
Okay so here is what is happening. When I run the VI, it will hang on VISA read until I reset the micocontroller. Upon reset of the microcontroller, my firmware transmits "Hello World!\n" In high execution mode, I can see the word "Hell" followed by "o Wo", "rld!" passed through the buffer. These string values change to 1.14314E+27, 6.65785E+28, 7.73929E-19 which are written to the text file attached. This makes sense as it's passing through the unflatten from string function. This of course is not what I would like. The issue I think at hand is that the unflatten from string function doesn't like the input "\n" from the VISA read.
08-15-2017 02:10 PM
You are reading the strings as you expect, and then you try to convert them to single precision floats? Can you explain why?
08-15-2017 03:34 PM
Hello gregoryj,
so currently, I would like to start my firmware off by sending a string "Hello World\n" Upon receiving the character 'g' from labVIEW, I have my microcontroller output the numbers 0 to 255. Is there a way to read a string first then switch to reading numbers?
08-15-2017 04:17 PM
I don't do much with visa serial communication, but I think it would be up to you to know what kind of data you're expecting. If you send your "g" command, then read back your data as a string. If you send a command where you expect a SGL numeric back, unflatten it to a SGL. If you send a command where you expect a boolean back, unflatten to boolean, etc.
08-15-2017 04:26 PM
Ahh this makes sense, I think I will try this. I was wondering for the write to text file, is there a way to have a it "\n" each write so I can have my numeric data in a single vertical column? Also, so far, when I am passing 0 to 255, labVIEW outputs out of the unflatten string function values very close to 0 each time. I feel like I must have wired something incorrectly.
08-15-2017 06:19 PM
Update on what I have so far. So I was able to implement a simple true/false case structure where if the character I wrote to the buffer was a 'g' it would attempt to VISA read data in the float32 format and if the value was anything (excluding nothing in write buffer) the labview program would VISA read the string directly.
The LabVIEW program will also hang if there is nothing written the write buffer. My only issue now is in my firmware, I have a case where if I write a k, it will change a flag in the firmware program; however, it will not write anything to the VISA read. This is causing my program to time out at VISA read as it doesn't read any values. Is there a way that instead timing out, have it loop back to the VISA write loop?
08-16-2017 02:19 AM - edited 08-16-2017 02:21 AM
Just make the VISA read conditional. Put a case structure around it and only execute the case when you need to.
Alternatively, you can send a response to every command so you can be sure it executed.
08-16-2017 05:38 PM
Hi everyone,
I'm still having issues converting my float data into the proper values to be written to my textfile. I have a simple program where I am using the flatten to string function to simulate a visa read. The issue seem to be appearing at the unflattent to string function saying that there is a memory or data corruption.
08-16-2017 09:17 PM
Pay attention to the data types you wire into the Unflatten from String.
You can't flatten a single precision number and expect it to unflatten without error if you say you are unflattening a double precision number. Refer back to message #2