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
PWM Issues
Moderator: Benj
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: PWM Issues
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: PWM Issues
Here's another example showing a state machine approach. Here PWM2 will ramp at twice the speed of PWM1.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 198
- Joined: Sun Nov 04, 2018 7:13 pm
- Has thanked: 27 times
- Been thanked: 33 times
- Contact:
Re: PWM Issues
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
Just a couple of little tid bits on color theory.
Chad