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....
dimming a led using PWM
Moderator: Benj
-
- Posts: 23
- Joined: Tue Jun 24, 2014 11:38 am
- Has thanked: 7 times
- Been thanked: 1 time
- Contact:
dimming a led using PWM
- Attachments
-
- i want to work like this!.png
- (13.62 KiB) Downloaded 5431 times
-
- 1. ADC Controlled PWM 16F88.fcf
- (5.5 KiB) Downloaded 304 times
- 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
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.
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.
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: 23
- Joined: Tue Jun 24, 2014 11:38 am
- Has thanked: 7 times
- Been thanked: 1 time
- Contact:
Re: dimming a led using PWM
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!....
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!....
-
- 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
Hi ardiles,
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
If you look at the chip diagram (View menu, Chip)ardiles wrote:i connect leds on PWM?
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
-
- 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
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!
that PIC16F877A, have only two pinout with PWM! RC1 & RC2...
thanks!
in my mind was broken info: all pinout of PIC have PWM = incorect!
-
- 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
i maked a protheus simulation...
i connect twoo leds on CCP1 & 2...
Pot-HG, i connected to RA1/AN1...
not works...
i connect twoo leds on CCP1 & 2...
Pot-HG, i connected to RA1/AN1...
not works...
- 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
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.
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.
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: 23
- Joined: Tue Jun 24, 2014 11:38 am
- Has thanked: 7 times
- Been thanked: 1 time
- Contact: