-
how to generate a signal whose on time (initially 1ms) and increments by .1ms everytime we push a button.i.e frst push gives 1.1ms then 1.2ms and so on upto 2ms using timer1 in AT89c51. can anyone suggest an idea??0
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a
member of our community. Consider creating an
account or login.
Replies
-
Member • May 20, 2014
I had one example code for PWM running on Timer 0. I will find that out and post here so you can get idea about the working.
Remember It is not giving you exact your timing you have to work on that code to convert according to your timing.Are you sure? This action cannot be undone. -
Member • May 20, 2014
unsigned char uPWMWidth; bit uPeriod = 0; void timer0() interrupt 1 { if(!uPeriod) { uPeriod = 1; P1_1 = 1; TH0 = uPWMWidth; TF0 = 0; } else { uPeriod = 0; P1_1 = 0; TH0 = 255 - uPWMWidth; TF0 = 0; } } void main() { TMOD = 0; uPWMWidth = 160; EA = 1; ET0 = 1; TR0 = 1; while(1) { //do your other work here Add routine to sense Key and change [B]"uPWMWidth"[/B] variable based on the switch pressed } }
This is the example code Pin 1_1 is used as a PWM pin, this code gives you fixed PWM width if you want to change it in real time then please add Key sense logic in while loop and update uPWMWidth variable and it will change the PWM width on PWM pin.
Hope this will help you #-Link-Snipped-#Are you sure? This action cannot be undone. -
Member • Jun 4, 2014
thanks...😁..for the helpAre you sure? This action cannot be undone. -
Member • Jun 4, 2014
Welcome ! You got it working?maya2012thanks...😁..for the helpAre you sure? This action cannot be undone.