Hello. I am working on a simple PWM control. I have basic PWM working and able to control frequency and duty cycle in realtime. I still need to figure out how to:
(1) Add a button/control to start/stop the PWM generation.
(2) Method to control the PWM output manually when it is stopped.
For example. In my main while loop, I would like to have a "state" button that is either 0 or 1, and when I stop the PWM, it will stop the PWM generation and then force the output to the predetermined state. Seems like this should be able to be done, just can not seem to figure it out. FYI, I am pretty new to Labview [grin].
Attached picture is of working VI that allows real time change of duty cycle and frequency.
The basic ideas behind what you want to do are covered in this discussion here:
Basically you want to have something that will stop your task, and then start it again at the push of a button. This very simple method of doing this will work. If you want to have something that is more scalable long term if you plan to add more to this application, I would recommend having a producer/consumer architecture where the producer loop has an event structure that you use to register for the stop event. Then the consumer is your DAQ loop, that will stop and start the task when the message is received from the producer. See more on producer/consumer here:
Thank you for the reply and information. I have taken a look at your suggestion but I do not believe it really accomplishes what I am trying to do. I am trying to stop/pause the PWM and take over manual control of the pin and then restart. I have attached a quick picture that details what I am trying to do. Method #1 would be most desirable with Method #2 being a fallback plan.
I have made a possible solution with putting the whole PWM configuration in a Case True statement and manual pin control in the Case False. Think this might work but a little concerned about the quality of the PWM signal getting re-initialized all of the time. I will try to test this VI on the CDAQ hardware tomorrow.