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.

OFF-the-wall idea for momentary ON switch

MrDEB

Well-Known Member
Looking to build a digital kitchen timer that shuts off after timing out and/or a 10 second delay waiting for user input.
Here is the screenshot of the on/off section of the kitchen timer. Going to use an 18Fxxxx pic
maybe need a diode on the pic output pin to prevent applying voltage to the unpowered pic.
Screenshot (38).png
unpowered pic?
 
MrDEB -
Did you leave the programmer connected? Was that the problem?

Mike -
That'll probably work 99.9% of the time, but since it only re-reads it once I think a version closer to what I have is:
Code:
uint32_t getMs(void) {
    volatile uint32_t retVal;       // so optimizer does not remove it
   
    do {
        retVal = tickMs;
    } while (retVal != tickMs);
    return(retVal);
}

In your case you likely won't have an issue using 1ms interrupts...
 
I think the off-the wall idea may be clever, but exposes the circuit to ESD SCR issues.
Let sleeping dogs lie with the PIC instead. ;) Use a normal sleep mode.
 
MrDEB -
Did you leave the programmer connected? Was that the problem?

Mike -
That'll probably work 99.9% of the time, but since it only re-reads it once I think a version closer to what I have is:
Code:
uint32_t getMs(void) {
    volatile uint32_t retVal;       // so optimizer does not remove it
  
    do {
        retVal = tickMs;
    } while (retVal != tickMs);
    return(retVal);
}

In your case you likely won't have an issue using 1ms interrupts...
That's the idea, if the read failed then an interrupt just happened so a reread will ensure it isn't interrupted as 1mS can't have elapsed.
Good call on the volatile but I only have the non optimizing free version (so far).

Mike.
 
It's kind of beyond belief that MrDEB , who asks for so much help, ignores direct (and often repeated) questions when people are (futily) trying to understand exactly what he's doing when he says "it doesn't work." So those foolish people attempting to help him have to guess at the problem.
 
...So those foolish people attempting to help him have to guess at the problem.
Would be nice. That's why I always try to shine up my crystal ball before embarking on these adventures!

Good call on the volatile but I only have the non optimizing free version (so far).

Mike.
If you're using XC8, even with optimizations set off (-O0) the compiler does some basic optimizations so it's always good to specify 'volatile' if there's a chance it might bite you. If the compiler thinks something's not used/has no effect it's free to remove it.

BTW - the free version allows optimizations up to -O2, which isn't too bad. I rarely find it useful to go past that level anyway... the optimizations can get pretty complex and hard to follow.
 
I thought the free version had no optimization at all. How do I set the level?

Mike.
Open 'Project Properties'

Select 'XC8 Compiler'

At the top is 'Option Categories', a pull down box - select 'Optimisations' from that.

Then select the optimisation required, from 0-3 or s, 2 is the highest you can go for free.
 
Sure thing! Let's break down how you could tackle building a digital kitchen timer with an auto shut-off feature. Imagine we're chatting about it over a cup of coffee:

So, first up, you'd need a brain for your timer, right? Think of something like an Arduino. It's like the conductor of your orchestra, coordinating everything.

Then, there's the part everyone will see: the display. Picture a little screen showing how much time is left. You can use an LCD or LED display for that.

Now, how are you gonna tell your timer what time to count down from? That's where your input method comes in handy. You could go with buttons or a twisty thing called a rotary encoder.

Oh, and don't forget the buzzer! It's the one that's gonna make all the noise when your pasta's perfectly cooked or your cookies are golden brown.

Next, you gotta make sure your timer has enough juice to keep going. That means sorting out the power situation. Maybe you'll want to plug it in, or maybe you'll throw in a battery for portability.

Alright, now for the clever part. You want this thing to shut off by itself, right? So, you gotta program it to know when it's time to call it quits. That's where the auto shut-off logic comes in. It's like teaching your timer when to say, "Okay, job's done!"

Safety first, of course! You're making something for the kitchen, so it's gotta be safe. That means using materials that can handle the heat and making sure all the electrical bits are tucked away nice and safe.

Last but not least, you gotta test it out! Make sure everything works like it should before you start using it to time your culinary masterpieces.

And for the software side of things, well, you'll need to teach your little Arduino brain a few tricks:

  • Tell it what time to start from.
  • Make sure it's showing the time ticking down.
  • Let it know how to listen out for your commands to set the time and control the timer.
  • And, of course, program it to give you a little beep when the time's up!
  • Oh, and don't forget to tell it to take a nap if nobody's been playing with it for a while.
Remember, there are tons of tutorials and resources out there to help you out along the way. Good luck with your kitchen timer project!
 
And once again WilliamsimC re-animates a dead thread.

JimB
 

Latest threads

New Articles From Microcontroller Tips

Back
Top