02-26-2024 01:08 AM
I'm trying to generate PWM signal by using NI PXIe-6363 card and NI-DAQMX library and Python but not able to get PWM.
Can anyone help me for same.
Is it possible to generate PWM by using NI-DAQMX library and Python.
02-26-2024 02:40 PM
I'm no help with any of the specific Python syntax, but here's a general outline:
1. You should create a task for Counter Output to generate PWM
2. When you configure Timing properties for the task, you'll likely need to use "Continuous Sampling" and "Implicit Timing".
3. And now here's the tricky thing, at least under the LabVIEW API. I suspect this is a device and/or DAQmx quirk and that it will also be true under Python though.
PWM control usually involves a constant frequency with a potentially variable duty cycle. But under DAQmx, you must also write to the frequency property to make it "digest" anything you write to the duty cycle property. So you probably need to write the new duty cycle first and then re-write the same old frequency to get DAQmx to "digest" both values.
-Kevin P
02-26-2024 06:14 PM
You can refer to nidaqmx-python/examples/co_pulse_time.py at master · ni/nidaqmx-python. Use add_co_pulse_chan_freq and nidaqmx.types.CtrFreq instead.