Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

PWM pulses using Digital I/O

I m enable to get PWM pulses of the desired frequency using digital I/O ,bcoz of the software timer used.How to get PWm pulses of the freq of the range 5-10Khz????

0 Kudos
Message 1 of 18
(6,940 Views)

You need to get a device with hardware timed output.

 

Lynn

0 Kudos
Message 2 of 18
(6,929 Views)

Hello Mr. Aggarwal,

 

The capability to generate PWM pulses largely depends on the hardware you are using. Does it have on-board (hardware) counters? 

If your device allows correlated digital I/O you can use your AI clock as the source of your digital I/O clock. With correlated Digital I/O you will also be able to configure a counter to generate the desired DI clock or use an external signal as the source of the clock.

 

In short, verify whether your device has hardware clock for digital I/O (as rightly pointed out by johnsold) or check whether you have correlated DIO support.

 

In your code you have used single point generation inside a for loop which will not serve your purpose because of the inherent lack of determinism associated with general purpose OS.

You can refer to the PWM-Counter Output.vi available in your examples finder for further information on the correct method of programming for PWM generation if you have a compatible device.

 

Hope this helps.

 

Regards,

 

Navjodh Singh

National Instruments

India

0 Kudos
Message 3 of 18
(6,913 Views)

I m using PCI-6251 with NI elvis board.Wht did u meant by hardware clock?? Is it possible to get the desired freq by using that hardware clock???

0 Kudos
Message 4 of 18
(6,902 Views)

Hi J.H. Agarwal,

 

PCI 6251 has correlated DIO and also has 2 onboard hardware counters. Which means you can go ahead and use NI DAQmx VIs to generate PWM. You can refer to the following link for examples and description for doing the same.

 

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

http://zone.ni.com/devzone/cda/tut/p/id/2991

 

 

Regards,

 

Navjodh Singh

0 Kudos
Message 5 of 18
(6,897 Views)

I referred the link ,in which the VI given in Fig.3 seems to be usefull to me.Is it possible that the duty ratio can be controlled dynamically by using a signal  generated by a  program ? upto wht freq range we can go to ? 

0 Kudos
Message 6 of 18
(6,888 Views)

Hello Agrawal,

 

Yes you can dynamically change the duty cycle. You can either directly change the Frequency/Duty Cycle input value (see PWM Complete.vi code given in the example I shared previously) or use a property node (see example below) to do the same.

 

Counter Output PWM with Dynamic Duty Cycle Updates in DAQmx

https://decibel.ni.com/content/docs/DOC-13798

 

The maximum frequency of the counter output is dependent upon the card's maximum source frequency and the pulse width. In case of PCI 6251 which has a maximum source frequency of 80MHz, you can generate upto 40Mhz.

 

 

I hope this answers your question.

 

Regards,

 

Navjodh

0 Kudos
Message 7 of 18
(6,868 Views)

Sir,

    Thank u very much for ur response.I tried the "Counter Output PWM with Dynamic Duty Cycle Updates in DAQmx.vi" it dynamically changes the duty cycle ,but the the change in freq is not refelcted bcoz of the software timer used.What i need is to comapre a triangular (sawtooth ) waveform with a signal generated  from a program, and that signal changes continoulsy i.e. the duty cycly changes.So i need automatica updation of duty cycle as the signal changes.Awaiting a positive response from ur side.

Thanking You,

J.H Agrawal.

0 Kudos
Message 8 of 18
(6,857 Views)

Sir,

   In the "PWM update duty cycle VI." can be remove that update duty cycle control and make it such that when the duty cycle is changed it automatically responds to the change in duty cycle i.e making it automatic control rather than manual???

Thanking You,

Jaya Agrawal

VNIT,Nagpur

0 Kudos
Message 9 of 18
(6,852 Views)

Hello Jaya,

 

Yes, in place of the control you can use a local variable and update it directly from anywhere in your program.

 

For your requirement, you may have to write additional code which will translate the triangular waveform information into duty cycle values and update the PWM values accordingly.

It is possible to have a separate while loop for acquisition of triangular waves and update the PWM parameters in another loop, then use a local variable to pass the information from one loop to the other.

 

Regards,

Navjodh

0 Kudos
Message 10 of 18
(6,848 Views)