06-04-2012 03:56 AM
I made a code to synchronized my PWM with an external signal source. For instance, the PWM can only work with the duty cycle updated dynamically when the external signal is high, otherwise the PWM should be low. I can control the dynamic duty cycle update and I tried to used the pause digital pulse function of DAQmx Trigger. There is a little bit problem that the PWM just pause based on the external signal, so sometimes the PWM is still high when the external signal is not in the properly condition. What I want is the PWM immediately change to low when external signal is low.
I attach my code. Would you please give me any advice for modifying the code?
Thanks in advance.
06-05-2012 11:36 PM
The solution in the other thread seems to have worked out since the original poster was driving a stepper motor and the duration of his pulses wasn't too critical. In your case, perhaps the software control isn't what you are looking for (hard to say without more information).
It sounds like you are basically looking for an AND gate--it might be easiest just to add this externally. Could you elaborate a little more on the behavior you want? For example, what is the intended behavior if the external signal goes low when in the middle of generating a pulse? It would be also useful to know what hardware you are using and what other subsystems are available (are you using the other counters or the DIO?)
06-06-2012 05:34 AM
Thank you for your reply. I am using NI USB 6363. My application is to make the PWM that can control the LEDs.
I am using the Counter 0 to generate Pulse train. The external signal is connected to PFI0. I want to synchronized the PWM generated by the Counter0 with the external signal. If the external signal is low, I want the PWM immediately goes to low so that the LEDs will be turned off.
The program I made in the attachment using the Pause Trigger so I think it only pause and keep its value (0 or 1) when the external signal goes to low, that's what I do not expected.