10-24-2023 06:01 PM
We have a psi sensor, that is connected to an Arduino. We think we have written the correct code for the Arduino, and also for Labview but whenever we run them we do not get a voltage or psi reading. Does someone mind helping me?
10-24-2023 07:55 PM
It is difficult to diagnose LabVIEW code from a "picture" of code, but the code is seriously wrong. You have wired the index of a While loop to the "Byte count" input of a VISA Read command. So the first time through the While Loop, it means "Read 0 bytes", the second time, "Read 1 byte", the third time "Read 2 bytes" ...
There are quite a few discussions on the Web and in the LabVIEW Forums dealing with using VISA for serial communication, including when dealing with the Arduino. I suggest you focus some effort there.
Bob Schor
10-24-2023 10:19 PM
Since you use Arduino and analog read, the Hobbyist Toolkit will be extremely useful and makes your life easy.
https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000019TmpSAE&l=en-US
10-25-2023 01:18 AM
Hi Tundra,
more problems with your LabVIEW code:
Please watch this video…
What's the point of that map() function in the Arduino?
10-25-2023 09:17 AM
@GerdW wrote:
more problems with your LabVIEW code:
- Remove that wait inside the loop! The VISARead will wait for new data, so there is no need for an additional wait function!
- Don't open the VISA port with each iteration, once before the loop is sufficient! You also don't need to open after the SerialPortInit…
- Use AutoCleanup…
Please watch this video…
All good points. But finally, tell the VISA Read to read more bytes than is expected in a message. In this case, I would probably just use a constant set to 50 to read the message. The termination character will end the read.
10-25-2023 09:46 AM
I highly recommend you watch this video: VIWeek 2020/Proper way to communicate over serial