I am new to microcontrollers. I am going to build my first project "Push button controlled PWM" using PIC12F675 for dimming LEDs.
I want to control the duty cycle of 100Hz pulse from 0-100%.
Two pushbuttons, one for increment and another for decrement of duty cycle.
Resolution required is in steps of 2%.
Kindly help me with code.
Don't have knowledge and experience of programming.
Thx. 🙂
ashwal.patel@gmail.com
Sounds like an assignment for an electronics or microprocessor lab class.
Phil
The trick is to approach this in stages. First get the LED to blink. Then add PWM dimming at a constant rate. Then add the code to change the dim value (ramp it up and down at a slow rate for testing). Finally, add the buttons and debouncing code.
If you have specific code questions, post the code and someone may be able to help out (sorry , I'm an Atmel person myself).
/mike
P. Short wrote:Sounds like an assignment for an electronics or microprocessor lab class.
I would guess you are right. Considering the number of posts of the user, it appears assistance with homework is the goal here.
HA, somebody else is putting up my lights this year.
ashwal wrote:I am new to microcontrollers. I am going to build my first project "Push button controlled PWM" using PIC12F675 for dimming LEDs.I want to control the duty cycle of 100Hz pulse from 0-100%.
Two pushbuttons, one for increment and another for decrement of duty cycle.
Resolution required is in steps of 2%.Kindly help me with code.
Don't have knowledge and experience of programming.
Thx. 🙂
ashwal.patel@gmail.com
Why have you decided to use a 12F675. What was your selection criteria for this chip?
stellascapes - LED lighting solutions for the Prosumer, Commercial and Entertainment Industries.
Doing pixels first since 2009 with just another megatree.
Follow us on Facebook at www.facebook.com/stellascapes
web: www.stellascapes.com
Considering this appears to be posted across multiple forums it's nothing more than an assignment.
forum.allaboutcircuits.com/showthread.php?t=24126
http://www.microchip.com/forums/tm.aspx?m=426681&mpage=1&key=񨊹
Mods what do you think?
2012:
Software: LightFactory Personal
Hardware: J1Sys Pixel controllers . Http://www.j1sys.com
Lights: 6000+ Pixels and 20k+ LEDs
Channels: around 20,000 channels
You know where to find me.... 🙂
LOL Nice Phil!
Hello everyone! I'm doing this as a personal project but I need some assistance. I had to do some reading and research of my own before asking any questions because many terms weren't clear to me. After my study, I wrote this code:
/* PROGRAM WRITTEN BY TAIWO FOLU. PWM CONTROL OVER BLUETOOTH WITH DTMF TONES. INPUT ON ATTINY2313 PINS PB4 TO PB7. PWM SIGNAL OUTPUT ON PB2 (OC0A) AND PD5 (OC0B) USING TIMER0. TWO EXTRA I/O PINS ON PB0 AND PB1*/
#include
void initPWM()
{
TCCR0|=(1<<WGM01)|(1<<COM01)|(1<<CS00);
//Freq=FCPU, phase correct pwm, non inverted PWM (mode3)
DDRB|=0xE0; //Set PB0, PB1 and PB2 for output and the rest for input
DDRD|=(1<<PD5); //Set PD5 for output
}
void SetPWMOutput(Uint8_t duty)
{
OCR0A=0; //Set dutyA to 0%
OCR0B=127; //Set dutyB to 50%
}
void main()
{
Unsinged int f;
while (1)
{
f=PINB;
switch (f)
{
case 0x04: //when key 4 is pressed
{
OCR0B++; //increment OCR0B
break;
}
case 0x05: //when key 5 is pressed
{
OCR0A++; //increment OCR0A
break;
}
case 0x06: //when key 6 is pressed
{
OCRB--; //decrement OCR0B
break;
}
case 0x0A: //when key0 is pressed
{
OCR0A--; //decrement OCR0A
break;
}
}
}
I intend to use the dtmf tones to control the duty cycles of pwm channels A and B on timer0. Please look through the code and help me if i've made any mistakes or unnecessary statements or he there's a better way to implement this. Here, i've not used the PB0 and PB1 pins yet so I don't get confused, I want to get the duty cycles control right first.
Cheers
Another "assignment" 🙂
Make no mistake between my personality and my attitude.
My personality is who I am.
My attitude depends on who you are.
lol! Really, its not. I read all this stuff on my own:
https://picasaweb.google.com/taiwofolu?feat=email
i'm not in school yet. Any help?
