PIC Count down timer using lcd, button.

Home Forums MPLAB XC8 Project Discussions PIC Count down timer using lcd, button.

Viewing 2 reply threads
  • Author
    Posts
    • #5900
      AvatarAlGebra
      Participant

      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!

    • #5904
      Bitahwa BinduBitahwa Bindu
      Keymaster

      Hi.

      For simplicity you can use a delay routine it will work but here what you can expect:

      1. 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.
      2. 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).
      3. 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.
      • #5913
        AvatarAlGebra
        Participant

        Thanks bithawa Bindu. I will start using the best option you gave me (Timer iterrupt).  So in case if I face difficultise I will ask here.

    • #5915
      Bitahwa BinduBitahwa Bindu
      Keymaster

      Ok great!

Viewing 2 reply threads
  • You must be logged in to reply to this topic.
Select your currency
ZARSouth African rand
EUR Euro