LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

PWM frequency problem

Hi,

 

I want to control 3 different LED drivers with my NI USB 6356. I found some examples online and modified them and PWM generation is rather nice. (attachments). Problem is that I need frequency of at least 100Hz and with this code i get less than 10. Maybe someone has an idea how to fix this. 

0 Kudos
Message 1 of 6
(3,794 Views)

Hello djoleve,

 

I thin it is best ot have a look at a hardware timed digital ouput example, something like the example: Digital (Pipelined Sample Clock) - Continuous Output.vi (example finder: hardware in and output, DAQmx, digital output). This is a good example (starting point) if you need to modify your PWM signal on the fly. With this example you can achieve the maximum specified dio speed of the daq card. If you need continuous the same PWM signal, just use a counter output task.

 

Goodluck!

 

Best regards,

 

Martijn

0 Kudos
Message 2 of 6
(3,745 Views)

First you need to define specs of your PWM signal like:

1. The pulse length (pulse width).

2. The pulse time (frequency).

 

Your code, seems to me, is an inefficient way to generate this kind of signal. There is better, simpler way to do it. 

 

a. Give a HIGH(1) signal to DAQ digital out.

b. Wait for sometime (This defines your pulse width-wait function).

c. Now go LOW(0)

d. Put the above story inside a loop, running at a rate which will define your PWM time period (Wait until next millisecond multiple).

 

You will need Flat Sequence Structure to go from a---->c, a while loop and required DAQmx resources.

 

 

Regards.


Message 3 of 6
(3,701 Views)

Know your Device!!!  I assume you have MAX installed on your PC -- open MAX while the 6356 is connected to it, and notice its inputs and outputs.  Do you see a Counter?  I've not used Counters much, myself, but I know that they can be set up to produce a Pulse Train of a specified frequency and duty cycle, and on this particular board, you should be able to output pulses at multiples of 1KHz (I think the basic clock is 1MHz).

 

I suspect that if you wanted to create three PWM signals, you could do most of the work with three DAQmx Write functions.

 

Bob Schor

Message 4 of 6
(3,687 Views)

a counter task is only a good solution if you don't need to change your PWM signal. If you need, the taskt needs to be stopped and restarted. The generation of your signal will be interrupted. I agree a counter task is much easier.

With a hardware timed digital output task you can change the output signal without stopping the task, so on the fly.

 

The 6356 is an X series, so one of the latest and has 4 counters and 1 MHz digital out. With both solutions you can achieve this speed.

Message 5 of 6
(3,650 Views)

I will try to do it with counter output. I found some good examples. Thanks for help everybody. 

0 Kudos
Message 6 of 6
(3,625 Views)