03-11-2021 03:59 PM - edited 03-11-2021 04:28 PM
Hello everyone,
My goal is to be able to change the duty cycle of a PWM signal using the output from a PID controller.
I am working with this example provided by NI:
Change Duty Cycle on a Continuous Pulse Train of NI-DAQmx Task
This example works as was intended, I am able to change the duty cycle from the front panel. The problems begin when I substitute the Duty Cycle Control for the output of the PID controller.
How can I adapt this code so that the Duty Cycle is changed according to the PID output instead of the Duty Cycle Control as it is now? My guess is that the problem lies with the Event Cases. I have tried changing the Duty Cycle Control to an indicator and wiring it to the PID output and then that to the input at Create Channel vi but no success.
Thanks,
Junekers
Solved! Go to Solution.
03-11-2021 04:09 PM
You probably want to attach the actual VI, because it is very difficult to debug a picture. (e.g. what's in the timeout case? Are there other events?)
(Events are primarily for user interactions.)
03-11-2021 04:30 PM
Thanks for your response. I have attached the VI to the original post.
03-12-2021 04:32 AM
Sticking with a single loop for now to illustrate most simply, you'd need to change to a polling structure instead of being event-based.
Here's a bare outline. Your real PID function will need inputs (of course). You'll most likely want to set a different loop rate via the Wait timer. But the main idea is to update the task's duty cycle if and only if the desired duty cycle coming from the PID calculation changes.
-Kevin P
03-12-2021 06:05 PM