02-15-2016 05:57 PM
Hi everyone, good night.
I'm a beginner in labview and I'm having some trouble to send sequential strings to NI VISA.
Using NI VISA, I control a peristaltic pump, using RS232 USB converter, and I need to send one string to define the speed, one string to define the direction and one string to start the pump.
The major problem here is to send them sequentially, since I need the three of them.
I tried with local/global variables, but that resulted in race conditions.
Is there a better way to do that ?
Thanks.
Regards,
Rodrigo M.
Solved! Go to Solution.
02-15-2016 06:18 PM
You'd have to post your code. If you are using local variables, you are almost certainly doing something wrong or unnecessary, and the symptoms of a race condition are proving it. But it is hard to tell you how to fix it without seeing exactly how you are trying to do it wrong now.
But if you want to send multiple messages, you can try multiple VISA writes in order using the error wire to enforce the sequence of execution. Or just concatenate the string together and wire that result into a single VISA write.
02-15-2016 07:09 PM
02-15-2016 07:21 PM
Here is the code
02-15-2016 07:22 PM
I need it sequentially, because it's the only way that the pump accepts the commands.
I tried using while loop, but it doesn't works.
02-15-2016 08:00 PM
02-15-2016 08:42 PM
02-15-2016 10:57 PM - edited 02-15-2016 11:03 PM
Here is the image for Dennis to see. I showed the case that pretty clearly demonstrates the problem.
What Hatef is trying to say is in that one particular case, you have a problem because it can not send out both strings. Only the string present at the tunnel when the while loop ends will be passed onto the VISA write.
What Dennis is telling you is that with a for loop, (the way you have the while loop programmed is just a more complicated version of the For Loop, you'd have the VISA write inside the loop, and pass it an array of strings.
02-16-2016 08:21 PM
I've understood now the auto-indexing mode of for loop. It really make things easier.
Worked for me.
Here's the code, thank you very much.
I just don't understand yet why this didn't work with while loop.
Thanks everybody.
02-16-2016 10:12 PM
Data Flow.
Your while loop was set for an ordinary tunnel. Data doesn't leave the while loop until the loop has finished executing. At that point, the tunnel has the value that was calculated in the last iteration of the while loop.