LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

AI single scan and PWM

I'm developing a real-time control loop that reads an analog input to pulse width modulate a counter/timer. I've adapted the PID_control_pwm.llb example from the example database to use AI Single Scan in the continuous scan mode. Every time the counter/timer Counter Control VI runs, it throws a -10609 error (a transfer is in progress..). I think this happens because there is only certain times in the pulse generation cycle that the timer values can be updated.

How do I coordinate timer updates with analog data acquisition?

Rich
0 Kudos
Message 1 of 6
(3,405 Views)
Hey Rich,

In a pulse train generation application, error -10609 indicates that the first pulse train is still being generated. So basically you're updating the pulse specs too quickly. Your example originally used AI Sample Channel instead of AI Single Update. AI Sample Channel configures the analog input each time it�s used. It seems what happened is replacing this with AI Single Update speed up your loop causing the error. There are several ways to work around this. One suggestion would be to add a longer delay in the loop. Another possibility would be to check for the error and either clear it and go on to the next iteration or continue to try and change the pulse specs until you succeed and then proceed to the next iteration of the original loop. I�m att
aching a link to an example that checks for the error and if it occurs clears it.

Pulse Train Generation with Changing Pulse Specs (PWM)


Please post back if you have any additional questions.

Sarah Miracle
National Instruments
0 Kudos
Message 2 of 6
(3,405 Views)
Thanks for the suggestions. I was wondering if there was a way to tell if the counter/timer was in a state where the the pulse configuration could be safely changed?

There are several examples of coordinating the AI and AO clocks so that the AO can be updated with out conflicts. But when I try the same thing with AI clock and counter/timer clock in an attemp to synch up the operations, but the same 10609 error occurs. I've searched the doc's and haven't found anything to detect when the counter/timer is "busy". Do you have any ideas for this approach?

Rich
0 Kudos
Message 3 of 6
(3,405 Views)
Hey Rich,
I'm afraid I misunderstood initially. The program I attached earlier gets the 10609 error because it tries to update the pulse specs while a pulse is being generated. This error is just a warning and when the current pulse finishes the new pulse specs will take affect despite the warning. Because of this the program I attached checks for the 10609 error and when it occurs clears it. In the program you're using the counter is reprogrammed each time. The difference is that the Counter Control VI is set to program and not switch cycle. I modified the example program you referred to and replaced the AI Sample Channel with AI Read One Scan. I wired the iteration terminal so that the first time the loop iterates this will configure t
he analog input but afterwards behaves just like AI Single Scan. Using this setup I did not receive the 10609 error. Did you make any other modifications to your program? I�m attaching mine for you to take a look at. Please let me know if there�s anything else I can do to clarify.

Sarah Miracle
National Instruments
0 Kudos
Message 4 of 6
(3,405 Views)
Sarah,

It sounds like you modified "pulse width modulator.vi" but you only attached the pidcontrol_pwm.vi.

Can you clarify the difference between "program" and "switch cycle"? I've experiment with Counter Group Config.vi set to "retriggerable pulse generation" and in that mode using"switch cycle" always seems to error out.

Rich
0 Kudos
Message 5 of 6
(3,405 Views)
Hey Rich,

I only modified "pidcontrol_pwm.vi". I used the original "pulse width modulator.vi".

PID_control_pwm.llb

"program" configures and arms the counter again while switch cycle is used to change the frequency specs on the fly. Here's a link to a document that discusses "switch cycle" in more detail.

How Do I Change The Frequency Output Of My Pulse Train On The Fly?

I hope this helps.

Sarah Miracle
National Instruments
0 Kudos
Message 6 of 6
(3,405 Views)