From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Two offset pwm with python

Hi!
 
I'm in need of outputting two PWM signals such that they are never simultaneously high. They need to be same frequency, but with a small overlap in low. What's the best solution for this? I'm working with a ni9401 and programming with python. This is what I have thus far to run one PWM signal. 
 
counter_task_ni9401 = nidaqmx.Task()
counter_task_ni9401_exists = True
counter_task_ni9401.co_channels.add_co_pulse_chan_freq("cDAQ2Mod5/ctr1", freq=frequency, duty_cycle=duty_cycle)
counter_task_ni9401.timing.cfg_implicit_timing(sample_mode=AcquisitionType.CONTINUOUS)
counter_task_ni9401.start()
 
Is there any way of extending this to two offset signals?
All help are much appreciated!
0 Kudos
Message 1 of 2
(650 Views)

I can't help with the Python, just the counter capabilities.

 

Here's what you'll need to do:

 

1. Configure both tasks to use the same signal as a Start Trigger.  This should be a signal you control, perhaps as a simple DO line.

 

2.  Define the 'initial delay' property when configuring the pulse trains.  The very first low time (assuming you leave them in the default mode of low idle state) comes from 'initial delay', subsequent ones come from the regular pulse params (low/high time or freq/duty cycle).

    You can use 'initial delay' to set the pulse trains' relative offset.  Since they both will start simultaneously due to a shared trigger, it's the 'initial delay' property that will set the offset between their respective first rising edges.

 

3. Start both pwm tasks before asserting the trigger.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
Message 2 of 2
(628 Views)