08-20-2015 11:03 AM
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
Solved! Go to Solution.
08-20-2015 11:55 AM
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
08-20-2015 01:16 PM - edited 08-20-2015 01:17 PM
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.
08-20-2015 02:52 PM
Thanks for the reply!
Okay. I see what you mean. I really appriciate the help!