Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Phase Correct PWMs

Hi, I am trying to develop a LabVIEW system to control a three-phase inverter board, and I plan on using a counter card (PCI-6601) to generate the three PWM control signals (one counter each) that I need for the three switching poles.  The three signals all have a fixed common period (10kHz) but variable duty cycles.  Due to the nature of the switching scheme the three PWM signals must be in what is known as "phase correct" form.  In this form the midpoints of the high-time pulses of each signal align as shown crudely below.  Is there a simple way to achieve this?

      __________      _________

60%____|                  |_______|                |_____

           ____   ____

25%_______|       |_____________|       |________

0 Kudos
Message 1 of 9
(6,522 Views)

Hello riplakish,

 

Try to modify this example to meet the needs of your application: DAQmx : Pulse Train Generation with Changing Pulse Specs (PWM) -- LabVIEW, C#.NET

 

Regards,

 

Jeff L.

0 Kudos
Message 2 of 9
(6,502 Views)

Hi Jeff,

 

I've actually been studying this example already, and while it does help me implement the variable duty cycles I am looking for, there is no easy/obvious way to get the pulses to be centered.  In the standard scheme all of my pulses are going to either start or end at the same time.  I need a way to make it so that my pulses are center aligned.  I've thought about using the delay input, but this only works until one of the duty cycles is changed.  In microprocessors i've used, this is achieved by using a true triangle wave reference (up and down counter) instead of a sawtooth reference (up and reset counter).  I can't find a way to implement this kind of low level control with my counters though.  Any ideas?

0 Kudos
Message 3 of 9
(6,491 Views)

I only have time for a brief outline now:

 

- Setup one counter as a master timebase at the freq shared by the 3 other pulses

 

- Each of the other 3 counters should be configured as retriggerable single pulses, using the master counter output as their trigger signal

 

- I would target the midpoint of the master frequency as the midpoint for the 3 pulses

 

- You'll calculate the corresponding low (delay) time and high (pulse) time for each of the 3

 

- I'm pretty sure that with most boards, you can change these pulse specs without stopping & restarting the task.  Watch out though

that attempting to change the pulse specs before the most recent ones were used to generate a pulse is likely to produce an error.

 

- Note also that since the re-programming of pulse specs is software-timed, when you *do* need to change duty cycles, the midpoints

may briefly be out of sync as one of the changes may kick in a cycle or two before another.  If the duty cycles don't change rapidly,

this effect should be minor.

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 4 of 9
(6,479 Views)

Sorry for the delay in my response.  I've been out of commission for awhile.  I've tried your method (using an RTSI pin to set the master counter output as the trigger for the others), and I believe it's working.  However I'm worried that this method may not work for my overall goals.

 

First off, to dynamically change these signals I am currently having to stop and restart the task.  This is because of the initial delay property, the others can be changed on the fly.  This I'm worried may create the possibility of pulses being missed.

 

An even bigger issue though, is that I need to be able to change the pulse parameters every cycle, and since the frequency of my PWMs needs to be 10kHz, this is not achievable using a software-timed loop.

 

It seems then that I'll need to use LabVIEW Real-Time.  I've seen that it is possible to set up these PCI DAQs as real-time targets, but I'm a little short on the know-how here, and I don't know how to set up these counters without DAQmx (which as I understand it cannot be used in real-time).  If this is necessary, could I get some help on how to accomplish it.  Otherwise I'm happy to hear other suggestions.

0 Kudos
Message 5 of 9
(6,439 Views)

Also I feel I should mention that I am not beyond changing my hardware choice for this project if it made things significantly easier/better.

0 Kudos
Message 6 of 9
(6,436 Views)

Hello

 

If you are really concerned about possibly missing pulses, and wanting to change the duty cycle without any data loss, I think R-Series cards are the way you want to go.  They have an FPGA chip on there that operate much faster than a PCI card or a Real Time target.  The base clock rate is 40MHz, but that clock speed can be greatly increased, depending on your application.  What is the frequency that you are trying to generate the pwm?

 

Ryan D

Applications Engineer
National Instruments
0 Kudos
Message 7 of 9
(6,426 Views)

I completely agree about the FPGA.  The research I've done has definitely pushed me that way for this application (specifically I've been looking at the PCI-7830R).  I'm trying to generate six independent 10kHz PWM signals, so 40 MHz gives me plenty of resolution for my variable duty cycle.

 

Looking ahead to the FPGA programming I was planning on setting up an up/down counter that toggles each PWM at a certain count value (on the way up and the way down) to get my centered pulses.  This would naturally need to be done in a single-cycle loop.  However the PI controller calculations that determine the duty cycle for each period (needs to be set each period) would happen in a 10kHz loop.

 

My question is, should I nest the counter loop within the 10kHz loop, or create parallel loops where the new duty cycle values are passed between somehow?

0 Kudos
Message 8 of 9
(6,423 Views)

I would probably put the sctl in a different loop and pass information between loops using a different mechanism, probably local variables.  All of what you describe is possible, the implementation will ultimately be up to  you.  Personally, I think the timing will be easier with two different loops.

 

Ryan

Applications Engineer
National Instruments
0 Kudos
Message 9 of 9
(6,417 Views)