|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Outputting PWM on the Digital Sidecar Digital I/O
I'm most familiar with Arduino's PWM interface - basically,
Code:
// Usage: analogWrite(pin, value 0-255) analogWrite(1, 255); Our situation is that we use a LOT of motors - to the point that we have few (if not zero) PWM slots! Therefore, we are using the Digital I/O GPIO instead, which technically can also output PWM. We are trying to drive a 12 V LED ring that we bought using PWM and an op-amp to ramp the 5 V PWM output to 12 V. We haven't gotten the op-amp nor LED ring yet, so we're currently testing it using the breadboard and a small LED. At the moment, the code looks like this: Code:
// robotInit DigitalOutput doutput = new DigitalOutput(1); doutput.enablePWM(0.0); // testPeriodic doutput.updateDutyCycle(1.0); I would appreciate any help! ![]() ** I am probably too tired to think/remember, but it *might* be that it did light up - we went from 0.00 to 1.00 by 0.05 increments, going up and down. However, instead of a fading LED, it was just 100% on. |
|
#2
|
||||||
|
||||||
|
Re: Outputting PWM on the Digital Sidecar Digital I/O
Have you tried calling setPWMRate also?
|
|
#3
|
|||||
|
|||||
|
Re: Outputting PWM on the Digital Sidecar Digital I/O
Did you have a dropping resistor in series with the LED (if it was 100% lit all the time)? If not, put one in there. ALL LEDs require a dropping resistor (12V pre-made arrays usually have one in there...)
|
|
#4
|
|||
|
|||
|
Re: Outputting PWM on the Digital Sidecar Digital I/O
We used your PWM code to run a strip of RGB LEDs. And it Worked. I don't understand why you are using an op-amp. We used a PWM channel and connected the signal wire to the base of a BC547 NPN transistor and grounded the circuit along with the PWMs black ground wire.(The Red Wire was unused). We used the PWM signal with three transistors, each one controlling the different colors of the RGB LED strip, and we were able to create many combinations of colors. The following schematic attached to this post is what the circuit looks like for 1 channel for controlling a string of LEDs. The 12 volt supply is from the power distribution board and we put a 20 amp breaker for that slot. Note that this is for 1 channel. Also, Thanks for the code! It really helped us make some cool colors!
[IMG]/Users/13hong_jeremy/Downloads/schemeit-project.png[/IMG] ![]() |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|