Showing results for 
Search instead for 
Did you mean: 

Producer Consumer simultaneous operations at different frequencies

My goal is to do two operations simultaneously.

The desired end result is:

1)      Produce an output signal which oscillates at a specified frequency (1 to 10 hz)(using DIO NI-9403). This signal will cause a solenoid to vibrate at different frequencies.

2)      Monitor voltage on 3 lines in real-time (using analog input NI-9201). This will monitor system response to vibration.

3)      Produce an output signal which oscillates at a different frequency from (1) – producing 1-second HI values 5 seconds apart. This will cause the system to “pulse”; system response will be monitored.

4)      Have a front-panel user interface where: the signals in (2) can be monitored; frequency of (1) can be monitored and changed; and the output on (3) can be monitored and changed.


My efforts so far have been to build a producer-consumer structure. This is my first time using this structure so I may be completely misunderstanding its use. Feel free to correct me if I’m way off target.

The issue I have is the solenoid in the consumer loop (which handles item (1)) is not operating at the desired frequency. It is too slow. I used a 10ms timer for this loop, but instead it is operating about 1 cycle per second.


There may be a much better way to approach this, or maybe my program only needs some minor tweaks. Either way, thanks in advance for your help.

0 Kudos
Message 1 of 2

Hi BradleyDDC,


It seems from your program that you don't need a producer consumer loop. The only thing you are feeding from one loop to another can be put in one loop, I mean the simulator on button.
The timer does not determine how fast the loop runs in real time. To get more precise timings, we recommend hardware timed operations as opposed to the software timed ones.
Instead of using a digital output signal, you can use a counter output task, here is a knowledgebase, which has an example of what you may want.

Paolo F.
National Instruments
Applications Engineer
0 Kudos
Message 2 of 2