Page 1 of 1
PWM Issues
Posted: Tue Oct 06, 2020 12:13 pm
by beneee
I am trying to create a little circuit to fade an LED on & off without success so to test I have created a quick multi step pwm using the 10bit option and it works in the simulation but when running on the Chip (12F1501) it seems to only to step 2 then the led goes back to dim.
I am guessing I am doing something daft, please let me know.
In the end I would like all 4 PWM outputs ramping up and down smoothly at different rates but I am struggling at this point and also unsure how to do it using really efficient code as I am limited with this chip.
Thanks
Ben

- PWMSteps.PNG (34.63 KiB) Viewed 3023 times
Re: PWM Issues
Posted: Tue Oct 06, 2020 1:16 pm
by Benj
Hello,
The LED will often hit full saturation around 50% duty and you won't be able to tell if it's any brighter.
Here's a simple way to ramp up and down.
If you wanted it to ramp faster then you could reduce the delay or you could increase the step size from 1 to say 2, 4, 8, 16 etc.
Re: PWM Issues
Posted: Tue Oct 06, 2020 1:23 pm
by Benj
Here's another example showing a state machine approach. Here PWM2 will ramp at twice the speed of PWM1.
Re: PWM Issues
Posted: Fri Oct 09, 2020 11:30 am
by beneee
Thank you
Ben
Re: PWM Issues
Posted: Mon Oct 19, 2020 5:26 pm
by chad
Just to clarify a little of what Ben said. The optical output of the led will scale above 50% to 100%. It is actually our eyes that don't scale well. Past a certain brightness our eyes don't perceive the brightness difference well but if you measured the optical output the led is doing what it is supposed to. To add more complexity, that color saturation level changes with the wavelength, or color. Color perception is really interesting and can open a whole can of worms. There is also scoptic and photopic color perception depending on the ambient light level (light, dark) and our eyes are more or less sensitive to different colors.
Just a couple of little tid bits on color theory.
Chad