05-11-2019 01:22 AM
I have a code in labview which reads data from the Arduino MEGA ADK board and is supposed to display it on waveform chart. One of the photodiodes' value is being read and another is not but the data is appearing in the serial monitor of arduino. Can anyone help me out with this?
05-11-2019 11:34 AM
You don't have a waveform chart, you have a waveform graph. The difference is a chart maintains a history of what was written to it before, a graph does not.
It looks like you might be building up your own history with some feedback nodes and array functions, but that whole bit of code seems like a confusing mess. Why are you searching for a zero?
Why aren't the arrays numeric so that you do the string to numeric conversion once when you receive it, and not every iteration on the entire array?
You are using Decimal String to Number which will only provide integer values. I would expect that your data probably has fractional parts as well.
(I actually think that function is confusingly named because is has Decimal in the name, but that means decimal vs. binary, octal, hexadecimal. Not decimal like most people think of as data that exists after a decimal point.) Try using Fractional String to Number.
Your arduino code is confusing and doesn't align well with your LabVIEW code. As a result, I think your data can easily get out of sync, particularly since you clear the buffer every iteration and have a 5 second wait in there. You have a serial println followed by a serial print. One is going to give a termination character, the other is not. And it is weird that the first value written gets the termination character. VISA Reads will end on a termination character since you have it enabled. You have two VISA Reads in there, both as 5 bytes. Is the data sent always 5 characters long?
Here is what you need to fix on the serial.
1. Arduino code. Do a single serial.println of a value that is Value1&","&Value2 so that is will come out like 11.111,22.222<LF>
2. LabVIEW code. Do a single VISA Read of 100 bytes.
3. Take the string value and do a scan from string of %f,%f. You'll get two output values.
4. Those two case structures should be combined.
5. Use Waveform Charts instead of Waveform Graphs.
6. Get rid of the confusing array building code.
See attached.