LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Visa write/read delaying data

Hello,

 

I am having a problem with a VI that should be simple. I am just testing an arduino code in which I am storing the number 4 on its positions of  EEPROM memory and when I sent an a from LabView to Arduino by VISA Write it should start reading the many 4 I stored in its memory but it's very delayed to read the data. It only shows up a 4 in like 20 to 20 minutes and I don't realize the error.

 

I think the error is in how I used Visa Write maybe because I used practically the same codes only removing the VISA write part and it works alright, showing the data constantly/non-stop. But the project I want to develop needs the VISA Write that's why I am trying to get the tests right using it.

 

If someone can help me with this, please.

 

Picture of my VI:

lbv.png

0 Kudos
Message 1 of 4
(4,229 Views)

1.  You probably want your code to be running in a loop with the initialization and the closing of the port outside of the loop.

2.  On the Arduino side, you should be using "WriteLine" or something like that (I'm not completely Arduino literate here) which automatically appends a Line Feed to your message.  This is important because this allows you to use the Termination Character on the serial port and eliminate the need for the Bytes At Port node (which has been a constant source of interesting race conditions when it comes to serial communications).  Just use a "large" number for the VISA Read and it will stop reading when the termination character is found.


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
Message 2 of 4
(4,213 Views)

In addition to the comments above, you also need to fix the other race conditions. There is absolutely no need for the local variables. Just branch the wire going to indicator "x", check if it is not zero, and then wire to the chart inside the case. Currently, the local variable at the bottom is read at a random time, most likely well before the new value is written to the indicator.

 

Also please always attach the VI. We cannot see what is in the other cases, for example. What is the point of the case structure on the right? Under what condition is the "Boolean" control true or false?

Message 3 of 4
(4,186 Views)

Sorry for not attaching the VI file, but my false conditions at case structures are all empty anyway.

 

Thank you for the tips mates, my VI is more efficient now despite still having some problems but I think now it's just correcting stuff at Arduino and done. 

 

Edit: solved the arduino thing and now it works really fine, thank you for your both help with labview!

0 Kudos
Message 4 of 4
(4,123 Views)