LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

handling programmatic event from different loop than event itself

Solved!
Go to solution

Hello,

 

I am trying to drive a motor of mine using compactDAQ in labview. I have two parallel loop using queues. One is for reading motor out bits - READ LOOP - (executes more often), and the other is for writing to motor in bits - WRITE LOOP.

When I pull up a certain bit (DRIVE), the motor starts moving with a predefined pace and to a predefined position. Up to here everything is fine. So, when the motor starts moving, it changes two bits:

- sets BUSY bit (indicating movement)

- clear INP bit, indicating that the motor is not in position

As soon as motor reaches its final destination the BUSY bit is cleared and the INP bit is set.

The question is: how could I register for the BUSY bit (or INP or both) going high (or low) in WRITE LOOP, since the bit is read in READ LOOP? Is it possible to do this by using queues? I read something about events, but I don't exactly know how to incorporate them into queues. Is this design even OK for motor handling?

I attached a portion of my code where I have an event structure, where one condition is the change of busy indicator which is updated in READ LOOP. However the event structure never executes.

 

I would like that my RTO case executes once and then waits for BUSY to go HIGH, and then again for INP to go HIGH, and after that the next case executes (shutdown or whatever).

 

I know that my code isn't perfect, but I am fairly new to labview...

 

Thank you for any information that might help

0 Kudos
Message 1 of 4
(2,830 Views)

Hey Grega,

 

In LabVIEW we have something called User Events which allow you to create a programatic event in your read loop that will signal your event structure in your write loop.  User Events are commonly used to provide feedback from a consumer loop back to its producer loop, very similarly to what you are trying to do.  Check out these two links about using User Events and see if they sound right for what you are trying to do.  

 

Sending Data from Consumer to Producer Loop with User Events

LabVIEW 2012 Help: User Events

Regards,

Eric L.
Applications Engineering Specialist
National Instruments
0 Kudos
Message 2 of 4
(2,793 Views)

Thank you for the info. Just some questions.

As I see from the links you attached the consumer/producer loops use only one queue (I use two queues - one for reading and the other for writing). I am struggling how to use dynamic events with these two different loops. Also, the event is fired using a control (Enqueue element). I need to fire it using a boolean indicator. Should I be also using only one queue? But then I would loose the benefit of parallel loops.

Probably I just don't know how to get going with this...

 

Thanks,

Regards

0 Kudos
Message 3 of 4
(2,780 Views)
Solution
Accepted by topic author grega

User events are just another way to communicate between 2 loops.  Queues are also used to communicate between two loops.  If you already have a queue going from one loop to the other you could just keep using that.  I recommended the user events because of the event structure you've included in your producer loop.  User events can fire at any time you want.  You can have code in your block diagram that uses the Generate User Event.vi to cause the event structure in the other loop to go off.  Event structures usually are used to go off when a front panel control has its value changed, but they can also be configured to these user events. 

 

Really you can do this communication between your two loops a number of different ways.  If you are using LabVIEW 2012 I strongly recommended taking a look at the Producer/Consumer template that is available so you can see what this common architecture looks like and compare it to what you have now.  If you don't have 2012 try looking at the example In my last post about producer/consumer with user events.  You may find more success using architectures like these.  

Regards,

Eric L.
Applications Engineering Specialist
National Instruments
Message 4 of 4
(2,735 Views)