Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

60Hz input for timer

Status
Not open for further replies.

johnnyquest

New Member
Hi,
I wrote a program for a 16F628A that inputs a value selected by a 3x4 keypad and display the value on three seven segment leds with the internal oscillator set @ 4MHz. I have a compare routine that limits the input from 0-256. I have the leds displayed in a loop and an interrupt for keypresses. This is tested and works great. My question is about taking the number value that is less that d'256' that is saved in a variable and using a 60Hz AC clock and putting the output on a pin for that many cycles when a button is pressed. Which timer input could I use? I am somewhat confused on how to do this, I have looked at Microchip appnote but there is no code to follow as an example.

This is an example of what I would like to do. I input the number 160 I would like to press a button and get 160 line pulses out.

I have extensivly searched the web to no avail. Any guidance or direction would be most appreciated.

Many Thanks,
JohnnyQuest
 
so if u set the value as 120 , then the micro should a pin 120 times in 1(2??) sec(60Hz sync) right??
full wave rectify the 60hz wave , so u get a +ve going 120Hz wave, and give it as i/p to schmitt triggred i/p of micro.. so it becomes a pulse. use a counter variable(set to value X (160 as u said)) , and toggle an o/p pin according to the pulse

HTH :)
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top