Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

2 loops accessing the same serial port

I use a serial port to control the stepper motor, and I want to know the position of the motor at any time, so I can know when to stop captuingr image with a CCD.

There is only a serial port, if I accessing the serial port with two loops, the step motor will buzzing.

So, I want to know if there is method to solve the problem.

0 Kudos
Message 1 of 6
(5,151 Views)

search for LabVIEW and action engines. in google.

There was an article from Ben Rainer that handles this perfectly

greetings from the Netherlands
0 Kudos
Message 2 of 6
(5,132 Views)

The Action Engine is probably the easiest way.

 

Another way would be to make a Producer/Consumer so that you have another loop that hanldes all of the talking to the stepper motor.  The other loops just send commands to it via a queue.  You can send data back using notifiers or user events.


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
0 Kudos
Message 3 of 6
(5,128 Views)

Do you have any examples that can help me out ?

0 Kudos
Message 4 of 6
(5,125 Views)

One simple change you can try is to just put the code from the second loop into a timeout event. It will read whenever one of the other events is not running.

 

And please, get rid of all of those VISA Bytes at Serial Port with the fixed delays. Since the device appears to recieve and send a termination character, you don't need either of them.

 

Also, clean up your wiring.

0 Kudos
Message 5 of 6
(5,116 Views)

I have used Semaphors in the past, see my attachment here:

Upper loop polls for data at regular intervals.

Lower loop sends configuration commands as needed.

This is just sandbox code I was playing with to prototype a larger app.

 

https://forums.ni.com/t5/LabVIEW/User-specified-DAQ-interruptions-instrument-control-through/m-p/260...

 

-AK2DM

~~~~~~~~~~~~~~~~~~~~~~~~~~
"It’s the questions that drive us.”
~~~~~~~~~~~~~~~~~~~~~~~~~~
0 Kudos
Message 6 of 6
(5,103 Views)