Notifications
Clear all

Countdown timer triggered by pushbutton

7 Posts
4 Users
0 Likes
2,496 Views
(@davemorris)
Member
Joined: 3 years ago
Posts: 31
Topic starter  

Hey guys, I am working on a project for a friend and I am having trouble understanding how to program a timer triggered by a switch.  Here is the scenario:

Periodically, so not on a set schedule, my friend needs to run a maintenance routine.  He pushes a button and it shuts down some equipment for 40mins. That part is handled by a completely different and un-associated system.  He can set it up so that when he pushes the button, a 24vdc supply is turned on for any period of time that he wishes.  I want to use this 24vdc signal to trigger a 40min countdown display.  He needs to have a way to see where the 40min shutdown is at. My thought was to set it up so the 24vdc power would trigger a pin on the Arduino (voltage adjusted of course) to start a display counting down from 40mins.  Then he can see just by looking at the display how far into the process he is. Being able to set the minutes on the countdown would be nice as well. How would this best be accomplished?  The hardware is less of a challenge for me than the programming. I have found several timer setups but nothing that lets you set the number of minutes, if needed, and then starts once an input pin sees a voltage.

 


   
Quote
(@davee)
Member
Joined: 3 years ago
Posts: 1680
 

Hi @davemorris,

As a suggestion, try to imagine how you want the final system to look, then try to describe in step-by-step list form (like a recipe to cook something), exactly how the system would be used, and how you expect it to respond to each 'event'. 'Event' in this context, includes things like, like the 24V supply turning on, someone pushing a button, a timer reaching a certain value, and so on. You have already made a start by writing your question above, so this is really a suggestion to expand upon it.

For example, you say " I have found several timer setups but nothing that lets you set the number of minutes". So try to start to answer that problem. How would you like your system to behave and what controls might that need?If it helps, try to look around you to find something 'similar' as a guide.

e.g. My cooker has an alarm function to buzz after a time I set . To set the time, it uses three buttons, a timer display (minutes:seconds format) and a buzzer to indicate when the alarm has counted down to time 'zero'.

Button 1 Switches between "Set alarm time" and "Enable Alarm countdown". If the alarm is not presently in use, then the first press to "Set Alarm time" mode, initializes the time display to "10:00"

Button 2 (+) and Button 3(-) respectively increment or decrement the time on the display, enabling the user to select any time from 1 second (00:01)  up to 99 minutes, 59 seconds (99:59), simply by pressing and holding either the "+" or the "-" button as required.

Having used the buttons to set the required alarm time, I then press Button 1 a further time to start the countdown, usually immediately after putting something in the oven to bake!

Note, my example may or may not be the kind of interface and function you are looking for; that is your choice and responsibility. However, it should be clear that my example could be transferred to an Arduino, assuming you pick one with sufficient I/O, timing capability, display buttons, etc., then you can map the functions onto the hardware, and then progressively implement the functionality required a step at a time in software. Of course, my oven cooker didn't have a 24Vdc trigger signal, so you will need to think what part this plays in your system. And I am sure there are other aspects of 'user design' that will become apparent when you think about it.

You may wish to ask some more questions about the software, when you have firmed up the basic system design.

Good luck.


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2527
 

How about using an Arduino that gets powered by the 24V line. Add an RTC (real i.e. clock), 3 buttons and a cheap 1602 LCD display.

When the 24V line goes high, it powers up the Arduino which then powers the RTC and the LCD, sets an internal representation of 40 minutes and initializes the LED display for 40:00. and the RTC to midnight (date is immaterial).

I propose using a cheap RTC (to avoid the inaccuracy if the Arduino's mills() and micros() functions).

One button us used to start the countdown and will disable the other two buttons and use the RTC to get the elapsed time, calculate the time remaining from the 40:00 minutes at start time.

The other two buttons will serve as 1 minute up/down buttons and could be used to change the internal time variable and the original 40:00 display time up or down (although up is only good for times within the window that the 24V line is powered). When the timer is set to the desired time, then pressing the start button begins the countdown.

In the loop, it checks the RTC time and if the seconds has changed since the last loop, then reset the timer variable and update the LCD timer display to match.

So, an Arduino, RTC, 1602 LCD and 3 buttons gotta cost less than $20 even with a spare CR2032 or two).

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
MadMisha
(@madmisha)
Member
Joined: 4 years ago
Posts: 340
 

   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2527
 

@madmisha

 

I think you meant to use "long" for the times and target values.

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
MadMisha
(@madmisha)
Member
Joined: 4 years ago
Posts: 340
 

@will

I guess I made it too fast. Fixed it.


   
ReplyQuote
MadMisha
(@madmisha)
Member
Joined: 4 years ago
Posts: 340
 

   
ReplyQuote