HI,
I have just tried to put this chart together logically without looking at examples, basically all I want to do is alter the brightness of an LED via a pot, now I have enabled PWM1 and I can change the duty cycle via the pot, then connected an LED to the ccp1 pin, but the LED does not light, I have checked that the PWM is the right output, so what am I not doing ?
Thanks
Acestu
Hardware PWM LED
Moderator: Benj
- acestu
- Posts: 1720
- Joined: Thu Dec 01, 2011 9:36 pm
- Location: Macclesfield UK
- Has thanked: 783 times
- Been thanked: 223 times
Hardware PWM LED
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.
Computers are like air conditioners. They work fine until you start opening windows.
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Hardware PWM LED
1st I would place the PWM before the loop and not within the loop.
Then I would use a delay of say 100ms between ADC and PWM macros.
The PWM frequency is set at 19.KHz are you sure it needs to be that high?
1- 5KHz for example should be fine for your LED
Martin
Then I would use a delay of say 100ms between ADC and PWM macros.
The PWM frequency is set at 19.KHz are you sure it needs to be that high?
1- 5KHz for example should be fine for your LED
Martin
Martin
- BChappy
- Posts: 15
- Joined: Fri Jun 19, 2009 11:03 pm
- Location: Lincoln, UK.
- Has thanked: 13 times
- Been thanked: 7 times
Re: Hardware PWM LED
Hi Acestu,
I have moved PWM Enable out of the loop, this only needs to be called once.
As long as the PWM is enabled the port will be set correctly (no C Code). Not sure about the PWM / LED component simulation working!
I've not used the '877 for a long time but it should work on hardware.
I've attached a modified program. All the best
Regards
Brian
I have moved PWM Enable out of the loop, this only needs to be called once.
As long as the PWM is enabled the port will be set correctly (no C Code). Not sure about the PWM / LED component simulation working!
I've not used the '877 for a long time but it should work on hardware.
I've attached a modified program. All the best
Regards
Brian
Is your Project Not Working? - Help and General Advice Click here!
Flowcode v8 forum topic - Click here!
Flowcode v8 forum topic - Click here!
- acestu
- Posts: 1720
- Joined: Thu Dec 01, 2011 9:36 pm
- Location: Macclesfield UK
- Has thanked: 783 times
- Been thanked: 223 times
Re: Hardware PWM LED
Hi,
Thanks Martin and Bchappy, is the only way to change the frequency Martin to change the crystal ?,
also I take it Bchappy that this is not going to simulate anyway ?
Thanks
Acestu
Thanks Martin and Bchappy, is the only way to change the frequency Martin to change the crystal ?,
also I take it Bchappy that this is not going to simulate anyway ?
Thanks
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.
Computers are like air conditioners. They work fine until you start opening windows.
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Hardware PWM LED
No its very simple to change the frequency.acestu wrote:is the only way to change the frequency Martin to change the crystal ?,
Acestu
Right click PWM component thats on the control panel and select ext properties.
Change Prescaler divide to adjust course frequency.
Change the Period register to adjust finer frequency.
Martin
Martin
Re: Hardware PWM LED
Hi Stu
you can change the frequency by changing the period register and prescaler divide, or by using your adc made a quick change to your chart added 2 adc channels to change the frequency just to show a quick way to change it
Regards
Dazz
you can change the frequency by changing the period register and prescaler divide, or by using your adc made a quick change to your chart added 2 adc channels to change the frequency just to show a quick way to change it
Regards
Dazz
- Attachments
-
- HARDWARE_PWM_LEDtest.fcf
- (11 KiB) Downloaded 305 times
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php
- acestu
- Posts: 1720
- Joined: Thu Dec 01, 2011 9:36 pm
- Location: Macclesfield UK
- Has thanked: 783 times
- Been thanked: 223 times
Re: Hardware PWM LED
Hi,
Thanks for the info guys, I understand the PWM better now, I take it that the LED does not simulate then, the only reason I ask is that the RGB LED does simulate fine.
Cheers
Acestu
Thanks for the info guys, I understand the PWM better now, I take it that the LED does not simulate then, the only reason I ask is that the RGB LED does simulate fine.
Cheers
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.
Computers are like air conditioners. They work fine until you start opening windows.
- 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: Hardware PWM LED
Hello,
Hardware PWM doesn't really simulate as it would hammer the system due to the high frequency output toggling. You can generate software based PWM using a timer interrupt and a counter, this should at least try and simulate though will probably flicker more then change brightness.
Hardware PWM doesn't really simulate as it would hammer the system due to the high frequency output toggling. You can generate software based PWM using a timer interrupt and a counter, this should at least try and simulate though will probably flicker more then change brightness.
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