Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

how to generate PWM signal by using digital lines of NI PCI 6224

 

I am doing a project on Speed control of DC Motor. I want to use Labview to control the speed of dc motor. I am using NI PCI 6224 M card. It does not have ANALOG OUTPUT. It has just DIGITAL OUTPUTS.

 

I want to generate a PWM signal from labview by using digital output lines. This PWM signal will trigger the base of MOSFET/transistor. My issue is just that HOW I CAN USE DIGITAL LINES TO GENERATE PWM SIGNALS ???

 

Regards,
Ayaz

0 Kudos
Message 1 of 6
(5,392 Views)

There is an example called PWM-Counter Output.vi that uses analog input and the counter output. Just search for PWM in the example finder. It lists your 6224 as being supported.

 

Hope this helps.

Now Using LabVIEW 2019SP1 and TestStand 2019
0 Kudos
Message 2 of 6
(5,382 Views)

Ayaz,

 

I recently had to do something very much like what you are describing on a project I was working on.  I needed six analog outputs but I only had 3 on the card I was using.  Used a delta-sigma algorithm to turn my desired analog waveform into  a digital bitstream and fed it out the correllated DIO. 

 

You should be able to do the same as follows:

 

1) Make a sub-vi that converts the set  of 'analog' waveforms you want into a 2D boolean array (channels vs. time).

2) Use the 'Boolean array to Digital Waveform.vi' to convert the array into a digital waveform.

3) Use the normal DAQmx vis to send it (i.e. assign the task, set the clock-rate, etc.)

 

I know I glossed over most of the details, but I'm not sure where specifically you are having your difficulty. 

 

Let me know if you have a question on the specific implementation and I would be happy to help if I can,

Sean

0 Kudos
Message 3 of 6
(5,362 Views)

Hi Ayaz,

 

Like all of our M Series DAQ Devices, the 6224 has two on-board 32-bit counters.  I agree with GovBob that the PWM Counter output example would likely be the best place to start if you need to do feedback based off of an analog input.  Depending on your exact needs, using an on-board counter to generate your PWM signal would likely be the best solution.  You can also find more information and another example for PWM using the on-board counters here:

 

Pulse Width Modulation (PWM) Using NI-DAQmx and LabVIEW

 

 

You can also use Correlated Digital I/O of the 6224 to generate the PWM signal (similar to what Sean C described in his post).  The Correlated Digital I/O should be considered if you need more than 2 digital lines, or if you require exact transitions between PWM characteristics.  I would start with using the Counters, since they are intended for these types of applications and should be easier to program what you need.  If you need to go the Correlated Digital I/O route, the following example should be helpful:

 

NI-DAQmx: M Series Pulse Width Modulation (PWM)

 

 

More information about the hardware can be found in the M Series User Manual, which has a good section on Counters as well as Digital I/O.

 

 

-John

John Passiak
0 Kudos
Message 4 of 6
(5,354 Views)

Thanks a lot for your help. It is working fine but I am facing one problem with this example.

 

If I make SET POINT=0, then still the duty cycle of the PWM signal remain approximately 0.5 , whereas duty cycle should go to 'ZERO'. Can you please tell me why I am getting 0.5 duty cycle.

 

Thanks & Regards,

Ayaz

0 Kudos
Message 5 of 6
(5,312 Views)

Hi Ayaz,

 

The PWM-Counter Output example implements a PID control loop to adjust your PWM to try to keep the AI voltage at your setpoint.  A 50% duty cycle would correspond to the Set Point being reached.  In this case, set point is the voltage you are measuring on the AI channel.  If this is approximately 0 volts, then setting a Set Point of 0 should keep the counter's duty cycle around 50%.  The idea is to use feedback so the duty cycle always adjusts back to 50%, if there is no feedback then the Set Point doesn't make as much sense.

 

It sounds like you may want to simply ignore the PID control stuff and set the counter's duty cycle manually (or programmatically some other way).  You can simply remove this part of your existing code, or start with the example I posted earlier: Pulse Width Modulation (PWM) Using NI-DAQmx and LabVIEW.

 

-John

Message Edited by John P on 06-30-2009 12:53 AM
John Passiak
0 Kudos
Message 6 of 6
(5,300 Views)