LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sending sequential strings to NI VISA

Solved!
Go to solution

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.

0 Kudos
Message 1 of 10
(3,893 Views)

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.

0 Kudos
Message 2 of 10
(3,868 Views)
You really need to take some of the free tutorials. This is pretty basic as RavensFan said. Another way to write commands sequentially is to place the VISA Write inside a for loop, create a string array with the commands, place the array outside the loop, wire the array into the loop. That is called auto-indexing and is a basic feature of LabVIEW.
0 Kudos
Message 3 of 10
(3,851 Views)
0 Kudos
Message 4 of 10
(3,840 Views)

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.

0 Kudos
Message 5 of 10
(3,836 Views)
there is some fundamental problem in your code for sending string
some of your code will not be send any way for example in "Preetapa" case
KG comment will not be send any way
also for fast solution try to increase your wait time by to by until your hardware could response well I think it should be near 100 ms for pump but you have to try it your self
but it is not best way to use
try to make algorithm based on your codes that are not relate to time to make your hardware connection in best mode
0 Kudos
Message 6 of 10
(3,813 Views)
Can you attach an image? I'm posting from my phone.

And I said for loop. A while loop is not the same.
0 Kudos
Message 7 of 10
(3,797 Views)
Solution
Accepted by topic author rdgsnm

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.

 

 

 

Download All
Message 8 of 10
(3,771 Views)

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.

0 Kudos
Message 9 of 10
(3,733 Views)

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.

0 Kudos
Message 10 of 10
(3,708 Views)