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. unpowered pic?
It's rather confusing what you're trying to do - but I presume it's to turn the PIC on from a momentary button press, and then have it time out and turn back off after a specific time.
This is commonly what I do on most of our products, using this small circuit:
The power button connects to pwr1 and pwr2, PL3 is a 9V battery feed. Q3 and R3 are there specifically to allow the push button to be used elsewhere in the programming, and to work as an off switch as well if required.
It's dead simple - pressing the button turns Q1 ON, powering the 5V regulator, and the PIC starts running - first thing it does is set RB0 high, to turn Q2 ON and maintain Q1 ON. Then after a predetermined time (if you want) the PIC can turn RBO low, and turn Q2/Q1 off, removing all power. If you press the button while it's running, Q3 turns ON, pulling RB1 low, and this can be used as an OFF switch if you wish, or as a general purpose button - I generally use it for as both.
For a kitchen timer, you could use the button to set the required time, such as each press adds ten seconds.
Often users, developers, hobbyists need timed and qualified event generators, many resorting to 555 timers and the like. The venerable 555 has had a long run but its limited in accuracy and capability. This approach uses block language to create...
www.electro-tech-online.com
The blocks in right hand window you drag and drop out of second window which is function
blocks, and config. mBlock then converts that to Arduino code and programs the board or chip.
I ran this on low end 8 pin part, ATTINY85.
This generates pulses of user set width, and off time, and can trigger from a
pin state, or A/D value. Easy to add pulse width or frequency trigger.....
I don't know which PIC you are using, so I looked at five 18xxx datasheets. All have a SLEEP mode, but thinking things through I don;t think you need it.
External switch - between the PIC GND pin and the circuit
External NPN or n-channel transistor - between PIC GND and circuit GND
Button press:
1. enter debounce software or whatever decision logic you need.
2. when conditions are met, one GPIO pin goes high, turning on the external transistor
3. do other stuff
4. When tasks are completed, drive GPIO pin low to disconnect the PIC GND from the circuit GND, turning off the device.
I think it can all be done in software with very little hardware circuitry - possibly just two resistors, two diodes and the switch. Just use the onboard timer, the enable pin or the sleep function.
I think he also wants the switch to be functional as an input once the PIC wakes up so it needs a bit more than a simple bootstrap.
But I agree, the nanoWatt sleep on a PIC can, in theory, get years of service out of a small battery. However, actually getting years of service from a battery takes some level of understanding of how to shut down each peripheral and I/O setting of each pin.
I think he also wants the switch to be functional as an input once the PIC wakes up so it needs a bit more than a simple bootstrap.
But I agree, the nanoWatt sleep on a PIC can, in theory, get years of service out of a small battery. However, actually getting years of service from a battery takes some level of understanding of how to shut down each peripheral and I/O setting of each pin.
Here's a collection of latch circuits I have collected over the years. #4, #5, and #6 would meet your needs. There are links to the original sources, which I suggest reviewing for details. The pdf is below.
Your schematic is illegible. Your unique use of the bus feature makes the schematic indecipherable. Busses are typically used to gather signals that have the same start and end points, such as the four port pins between micro and LCD. It's an express bus, not a local making stops everywhere.
I can't comment on your circuit because I can't decipher it, but I will note you need bypass caps.
[Corrected schematic for latch circuit #4, 1/3/24]
Click to expand, or download schematic below. Argh. Somehow my numbers don't show up in the png images. #4 and #5 are the bottom two circuits on page 1, #6 is on page 2. The pdf does show the numbers correctly.
Attachments
Schematic_Latching Power Switch Circuits_2024-01-03.pdf
Circuits #4, #5 and #6 power up the micro for the period the button is pressed. The first and immediate thing the micro MUST DO is asset the power-on port pin to stay on after the button is released. Then the micro waits for some action, which in this case is one of the time buttons to be pressed. If this happens, the timer counts down, and the micro turns off the power-on port pin, shutting everything off.
If no timer button is pressed during whatever interval you desire, the micro shuts off the power-on port pin and everything is turned off.
I am certain the EEVBlog Dave explains this concept very clearly in the linked video.
Please note carefully that none of the timing functions will be amenable to using DELAY statements
And by the way, screen-shotting your schematic AGAIN still doesn't make it legible.. Do you even look at the stuff (not my first choice of words) you post to see if it's readable?
What I can see in your schematic is that the LCD has no ground connection, which doesn't much matter anyway since none of the control pins are connected. The backlight however is connected between +5 and ground, so it will always be on. It will be a nice nightlight, so all is not lost.
Squinting at the latest schematic, it looks like power is applied to the uC immediately when the button is pressed, through one driver transistor and one pass transistor. For that function, why not eliminate both transistors and simply ground the Vss pins through the switch.
To keep things running after the switch is released, put back the NPN transistor so that its collector and emitter are in parallel with the switch.
In the schematic, the button press initiates an R-C timer to hold the NPN control transistor on after the button is released. Again, this can be done inside the uC, which already has to have code to drive the uC pin 3.