LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

PWM signal generation using Digital lines (NI USB 6341)

Solved!
Go to solution

Hello,

 

i want to read Data stored on the PCB (Printed Circuit Board - DC motor).

To activate readout the following command has to be applied on Motor PWM-IN pin:

frequency 300 Hz :

    1. Duty cycle 80% (10 periods)
    2. Duty cycle 50%  (10 periods)
    3. Duty cycle 10% (10 periods)

 

how can genarate PWM signal using Digital OUT lines without unsing counter.

thank you very much in advance.

0 Kudos
Message 1 of 9
(4,782 Views)

Hi nbnnnbn,

 

create a (digital) waveform with needed PWM pulses, then output that waveform on a DO pin of the first digital port. (Waveforms are only supported on Port0, see the manual.)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 9
(4,779 Views)

thank you for your replay. i'm new in Labview, there's example for that? 

0 Kudos
Message 3 of 9
(4,768 Views)

Sure, under the menu Help-->Find Examples..., you can find one for Finite Digital Output that should run on your X-series board.

 

You'll have to figure out the correct digital data to feed to the example task in order to accomplish the spec you gave in msg #1.

 

It would be more straightforward to do this with a counter if you were willing / able.  Counters work in terms of freq & duty cycle more naturally so it'd be easier to define the data to generate.

 

 

-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
(4,756 Views)

thank you again for your help. i can easy create PWM signals with different duty cycle using counter.  Can you please give me a example how can i create a PWM Signal (300Hz) with 80% duty signal using waveform?

 

thank you in advance

0 Kudos
Message 5 of 9
(4,740 Views)

Hi nbn,

 

easy like this:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 9
(4,730 Views)

GerdW's post shows how you could approach it with an analog waveform.  And that might be a good first step for you because you could use the built in square wave generator function 3 times to build up your overall waveform with 3 distinct duty cycles that each last for a little while.   Here's what remains to be done:

 

- carefully think through the 'sampling info' input to that square wave generator.  More on this below

 

- as shown, you'll get a square wave that transitions back and forth between +5 and -5 volts.  You can easily change input parameters to make it vary between 0 and +5 volts

 

- you can also easily turn the analog data array from the waveform into a boolean array.  That's something you can use if you want to convert over to a DO task.

 

On 'sampling info':  For a 300 Hz square wave and a duty cycle *resolution* of 10%, you would need 10 samples per cycle.  That means 3000 Hz sample rate.  For a resolution of 1% on your duty cycle settings, you'll need 100 samples per cycle for a 30 kHz sample rate.   

    Then the # samples needs to representing the # cycles you want.  For 10 cycles, you'll need 10 * (# samples per cycle).

 

 

-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 7 of 9
(4,717 Views)

Thank you very much for your detailed explanation. it helped a lot.

i create a sub vi for generating PWM signal "generatePWMSig.vi". but i can not see the PWM signal over DO on an oscilloscope?

 is it timing Problem...Ports...or something else ??

 

thank you in advance

Download All
0 Kudos
Message 8 of 9
(4,685 Views)
Solution
Accepted by topic author nbnnnbn

Hi nbnnnbn,

 

do you get any error messages? If yes: which ones?

Does your hardware support a sample frequency of 100kHz?

You output just 1000 samples per waveform: that takes just 10ms. But you wait until 150ms multiple in the loop!?

Have you tried to create just one waveform by appending your 3 parts?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 9
(4,682 Views)