Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Control multiple LED with PWM

Solved!
Go to solution

I'm designing an application that sequencely turn on 6 LEDs, each LED operaters in periodes of 10ms, and then is off the rest of the time. To control the intensity of the LED in the 10ms periode I want to use a PWM signal. 

Any suggestions? 

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

Dear kjschmidt,

 

It is not a 100% clear to me what you mean by your post.

What is the Duty cycly of the PWMs you want to create?
What is your switching frequency? (10 ms?)

Please share the following informatoon:
- the code you currently have written.

- the hardware you are using to do sent out the digital signals.

- A description of your HW set-up and how everything is connected with eachother (DAQ device, LEDs, wires, ...)

Kind Regards,
Thierry C - CLA, CTA - Senior R&D Engineer (Former Support Engineer) - National Instruments
If someone helped you, let them know. Mark as solved and/or give a kudo. 😉
Message 2 of 9
(6,085 Views)

I found this example, which solves my issue with controlling the intensity of the LED with PWM signal. 

The example also contains a timer, but I don't how to use it correctly. To satify my needs, the timer should shiftly turn one LED on in 10ms when the others are off. 

 

Hopes this makes sense

 

Also I'm using a USB-6351 DAQ with 4 LEDs connected to Digital OI port 0:3

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

Hello kjschmidt,

 

Do you fully understand what the example code does?

Or in other words:
Do you understand what each of the steps in the example code does and why it is necessary?

If I understand correctly, then you want to have something that:

  1. Turns LED1 on and the others Off for 10 ms.
  2. Turns LED2 on and the others Off for 10 ms.
  3. Turns LED3 on and the others Off for 10 ms.
  4. Turns LED4 on and the others Off for 10 ms.
  5. Go back to bullet 1 and repeat.

Is this what you mean?
The reason why I am asking is because your 2 posts contradict eachother (4 LEDs vs 6 LEDs).

 

Have you followed any DAQmx Data Acquisition related training?

 

Kind Regards,
Thierry C - CLA, CTA - Senior R&D Engineer (Former Support Engineer) - National Instruments
If someone helped you, let them know. Mark as solved and/or give a kudo. 😉
0 Kudos
Message 4 of 9
(6,038 Views)

Hello kjschmidt,

 

Do you fully understand what the example code does?

Or in other words:
Do you understand what each of the steps in the example code does and why it is necessary?

If I understand correctly, then you want to have something that:

  1. Turns LED1 on and the others Off for 10 ms.
  2. Turns LED2 on and the others Off for 10 ms.
  3. Turns LED3 on and the others Off for 10 ms.
  4. Turns LED4 on and the others Off for 10 ms.
  5. Go back to bullet 1 and repeat.

Is this what you mean?
The reason why I am asking is because your 2 posts contradict eachother (4 LEDs vs 6 LEDs).

 

Have you followed any DAQmx Data Acquisition related training?

 

Kind Regards,
Thierry C - CLA, CTA - Senior R&D Engineer (Former Support Engineer) - National Instruments
If someone helped you, let them know. Mark as solved and/or give a kudo. 😉
0 Kudos
Message 5 of 9
(6,038 Views)

Yes I understand each step, except the counter/timer part. 

 

And sorry for the misunderstand about the numbers of LEDs. The final code should be able to control 6 LEDs, but currently I'm am testing on 4 LEDs.

 

Regarding your bulletpoints that is exactly what I'm looking for.

 

And no, I haven't followed any DAQmx related training. 

 

I've attached what I made so far. As you can see I'm controlling which LEDs that is one with a indicator, and this is where I need help. 

 

Thanks in advance. 

0 Kudos
Message 6 of 9
(6,036 Views)
Solution
Accepted by kjschmidt

Hello kjschmidt,

 

I have made a simple example to illustrate what happens.

Please let me know if everything is understood from this example.

 

I have tried to document verything that seemed to require an explanation.

 

Any attached Code is provided As Is. It has not been tested or validated as a product, for use in a deployed application or system, or for use in hazardous environments. You assume all risks for use of the Code and use of the Code is subject to the Sample Code License Terms which can be found at: http://ni.com/samplecodelicense

Kind Regards,
Thierry C - CLA, CTA - Senior R&D Engineer (Former Support Engineer) - National Instruments
If someone helped you, let them know. Mark as solved and/or give a kudo. 😉
Message 7 of 9
(6,024 Views)

Thanks you very much!

 

I wasn't familiar with the Append Digital Samples - that is usefull

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

No problems!

Kind Regards,
Thierry C - CLA, CTA - Senior R&D Engineer (Former Support Engineer) - National Instruments
If someone helped you, let them know. Mark as solved and/or give a kudo. 😉
0 Kudos
Message 9 of 9
(6,000 Views)