Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA read and write controls become unresponsive after there are no more lines to read

Solved!
Go to solution

Hello all,

 

I am trying to develop continuous serial communication between an Arduino Uno microcontroller and LabView. The issue I am having is the controls for "Write" and even "Stop" become unresponsive after all the intial read lines are read in. I pretty sure this is because the read line prevents the full completetion of the while loop, suspending the entire loop until it reads something else in. I've tried a number of boolean operations and I can't seem to work around the issue. The code itself needs a way to detect there is no longer anything to read and skip the read statement and continue looping until the user enables the write command and writes something. Then the read command would would have more to read and again wait for user input.

 

Any suggestions and help would be great! Thanks!

 

*Note I have been using labview for all of 2 weeks. I'm getting used to it but I'm not a pro for sure.

 

Also I would like to give credit to physicslight @ https://physicslight.wordpress.com/2014/07/14/arduino-labview-serial-write-read/ for supplying an arduino auto detect sub vi for easy initializing of the VISA commands

 

 

Download All
0 Kudos
Message 1 of 4
(5,210 Views)
Solution
Accepted by topic author jamcshan

Looks as if I've solved my own problem. By using the Instr:Bytes at Port function the read error is fixed. Adding a few more cases to see written input and that it is recieved and a delay just incase seems to have my code fixed! If anyone has a similar issue check out my code attached

0 Kudos
Message 2 of 4
(5,199 Views)

One comment here.  Do not use the Bytes At Port to determine the number of bytes to read.  Let the termination character do the job of stopping the VISA Read.  So you still want to tell the VISA Read to read more bytes than you would expect from a message.  You are doing the right thing in looking to see if a message has started to come in, but you are creating race conditions with the serial bus by using the Bytes At Port to say how many bytes to read.

Note: I have a 10ms wait in the "0" case so that the loop does not become greedy.


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 3 of 4
(5,174 Views)

Thanks for the reply!

 

Okay. I see what you mean. I really appriciate the help!

0 Kudos
Message 4 of 4
(5,150 Views)