dimming a led using PWM

Moderator: Benj

Post Reply
ardiles
Posts: 23
Joined: Tue Jun 24, 2014 11:38 am
Has thanked: 7 times
Been thanked: 1 time
Contact:

dimming a led using PWM

Post by ardiles »

good day dear friends of electronics!
i have an application that i can turn on a led when i turn a wheel...if i turn wheel in opposide irection, is turning on another led...
so, i want to modify my file to turn on a led(on full cycle), when the wheel is turning left(for ex.), and i want to dimm off that led when the wheel is go back to 0 position...
how can i take that? i have a .fcf file who can controll PWM with ADC....
Attachments
i want to work like this!.png
(13.62 KiB) Downloaded 5431 times
1. ADC Controlled PWM 16F88.fcf
(5.5 KiB) Downloaded 302 times

User avatar
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: dimming a led using PWM

Post by Benj »

Hello,

I modified the program slightly so it uses a 16F877A chip as it has 2 PWM channels rather than 1 on the 16F88. You could still use a 16F88 if you like and use a software based PWM approach by using a timer interrupt.

I also modified the PWM properties so that PWM0 points to CCP1 and PWM1 points to CCP2.

I then changed the PWM period property to 127 instead of 255.
ADC Controlled PWM 16F877A.fcf
(10 KiB) Downloaded 342 times

ardiles
Posts: 23
Joined: Tue Jun 24, 2014 11:38 am
Has thanked: 7 times
Been thanked: 1 time
Contact:

Re: dimming a led using PWM

Post by ardiles »

hi!
i dont understand how i connect leds on PWM? that i dont catch on...
thanks for the file, but, i want to modify the pwm from encoder!....

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: dimming a led using PWM

Post by medelec35 »

Hi ardiles,
ardiles wrote:i connect leds on PWM?
If you look at the chip diagram (View menu, Chip)
You will see CCP1 and CCP2.
These are the PWM output connections.
So you will need to calculate correct current limiting resistor value and connect it in series between CCP output and anode of LED.
The cathode of LED will connect to ground (0V)
You could take a look at the [urlhttp://www.matrixtsl.com/resources/getresource.php?id=510]Electronics Course[/url]
When in the electronics course, you can search for LED.

Martin
Martin

ardiles
Posts: 23
Joined: Tue Jun 24, 2014 11:38 am
Has thanked: 7 times
Been thanked: 1 time
Contact:

Re: dimming a led using PWM

Post by ardiles »

I understand!
that PIC16F877A, have only two pinout with PWM! RC1 & RC2...
thanks!
in my mind was broken info: all pinout of PIC have PWM = incorect!

ardiles
Posts: 23
Joined: Tue Jun 24, 2014 11:38 am
Has thanked: 7 times
Been thanked: 1 time
Contact:

Re: dimming a led using PWM

Post by ardiles »

i maked a protheus simulation...
i connect twoo leds on CCP1 & 2...
Pot-HG, i connected to RA1/AN1...
not works...

User avatar
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: dimming a led using PWM

Post by Benj »

Hello,

The Proteus LEDs might not be able to simulate analogue light and might only accept slower on or off so this could be the problem. A waveform analyser on the output should show if the CCP pins are toggling. If your still having problems then try the 1 second flasher test to see if you can get this to run in Proteus.

I've thought of a way to do the program using a single PWM channel and a standard I/O pin so you could use a 16F88 if you like.

ardiles
Posts: 23
Joined: Tue Jun 24, 2014 11:38 am
Has thanked: 7 times
Been thanked: 1 time
Contact:

Re: dimming a led using PWM

Post by ardiles »

Yes Benj, you're right, i resolved that problem...

Post Reply