LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using an Audino to read psi

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?

Screenshot 2023-10-23 182618.pngScreenshot 2023-10-24 175754.png

0 Kudos
Message 1 of 6
(826 Views)

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

Message 2 of 6
(798 Views)

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

 

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
Message 3 of 6
(777 Views)

Hi Tundra,

 

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

 

What's the point of that map() function in the Arduino?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 6
(759 Views)

@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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 6
(721 Views)

I highly recommend you watch this video: VIWeek 2020/Proper way to communicate over serial

 

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 6 of 6
(712 Views)