- 29/09/2019 at 02:24 #5900AlGebraParticipant
Hello how are you, I’m from Ethiopia and I have a question:
I want build count down timer using pic16fxxxx micro controller, Lcd(16×2), button & mplab . For example cooking a food for 40 min by setting hour digit to zero and min 40 then by using some buttons for increment, selection (select a digit to be set hour or minute) and start/stop. Then when i press start button it starts counting down from selected time to zero then disabling relay used for powering cooking machine. I saw Some article on internet to use intterrup and Timer module on pic. I’m confused may be is it possible to use delay routine to make active for that selected time? please help me please!
- 29/09/2019 at 16:53 #5904Bitahwa BinduKeymaster
For simplicity you can use a delay routine it will work but here what you can expect:
- A delay routine is what is normally called as a blocking call function, once you start a delay, the microcontroller simply sits there doing nothing until you finish that delay. A program starts from top to bottom, once it reaches a delay, it stays there until that delay is finished, then goes down the line to execute the next statement.
- If for example you have a display to indicate the remaining minutes/seconds as your counter is counting down, it’s going to be difficult for you to do that because the microcontroller will be busy executing one delay line until finished. It can’t update the display (unless you create short delays and loop them continuously until you reach your final delay. then update the display in the loop after each short delay. It can work but the delay won’t be accurate).
- So the best option is to use a timer interrupt as this is not a blocking function. Your project can continue doing whatever in parallel like for example blinking a status LED, or displaying the delay count value while the timer runs in the background. Once an interrupt is generated let say every second, it will jump to the Interrupt service routine where you could update the count variable/display the count to display etc.
- 02/10/2019 at 16:04 #5915Bitahwa BinduKeymaster
- You must be logged in to reply to this topic.