Reset and load defaults - Page 1
Forum section: electronics / projects

author: S. Petrukhin
author_rank: Super Contributor
timestamp: January 17, 2021, 06:05:36 pm
content: Hello, friends.Many people know about combining the Reset button with loading the default configuration with a long press. This is easy to do on discrete elements: send a signal to the nRESET input from a single-vibrator triggered by the Reset button, and in parallel, through the GPIO input, track the button hold in the processor code.Maybe there is some specialized driver for this? Please tell me.

author: Nominal Animal
author_rank: Super Contributor
timestamp: January 17, 2021, 07:09:35 pm
content: Do you mean, for microcontrollers and other embedded devices?If I had to do this (with an SPST(Mom) button), I'd probably use one of those Padauk MCUs, maybe aPMC150-U06 (Datasheet)– or any Padauk supported byfree-pdk. One output would be to the reset pin, another to the GPIO pin indicating if the reset button was held down long, and one input to the momentary reset button. I would make the firmware ignore really short spikes, so that at least 250ms push duration is needed to actually reset the device; with something like two or three seconds to assert the second GPIO pin (reset to defaults).I too would be interested if there is a dedicated IC for this, although I guess that at less than USD $0.09, it is hard to beat a Padauk...

author: S. Petrukhin
author_rank: Super Contributor
timestamp: January 17, 2021, 08:34:56 pm
content: Quote from: Nominal Animal on January 17, 2021, 07:09:35 pmPadauk is very attractive as an opportunity to make any functional chip out of it, a sort of FPGA, of a kind. But, I don't have the tools to work with it yet: no compiler, no programmer, I don't know its assembler... I'll probably get a lot stronger if I can program these inexpensive chips, but that's not available yet.

author: Benta
author_rank: Super Contributor
timestamp: January 17, 2021, 09:20:29 pm
content: Quote from: S. Petrukhin on January 17, 2021, 06:05:36 pmSorry, but I've never heard of this before (except perhaps in Tamagochi-like toys).A configuration reload should not be possible through someone leaning accidentally against a switch. Normally, a certain controlled sequence is necessary for safety.But I'm beginning to understand Chernobyl now...

author: CJay
author_rank: Super Contributor
timestamp: January 17, 2021, 09:36:09 pm
content: Quote from: Benta on January 17, 2021, 09:20:29 pmLots of domestic routers, set top boxes, gadgets like that exhibit that behaviour, the 'reset' switch is usually recessed or at least made difficult to 'lean' on by accident.I think it's mostly software, I've had devices that have hung to the point where the 'reset' switch didn't recover them, they needed a hard power off which would suggest it's not actually a reset switch but a switch attached to perhaps an interrupt pin and the interrupt handler code initiates a reboot.It'd thus be a simple matter to check for that switch being pressed during a startup and load factory defaults.

author: S. Petrukhin
author_rank: Super Contributor
timestamp: January 18, 2021, 12:00:49 am
content: Quote from: Benta on January 17, 2021, 09:20:29 pmDo you not permit me to make a child's toy with such a function, or do you think that this toy has a nuclear charge on board that threatens you?Specifically, in the case I need, this is to reset the accumulated data and start collecting it again, you do not need to encode this function with a secret sequence.And, sorry, your stupid joke about Chernobyl, it is completely inappropriate, because simple chatter is not on the topic.

author: rstofer
author_rank: Super Contributor
timestamp: January 18, 2021, 05:09:42 am
content: I haven't checked the datasheet or any other details but the first thing I would think of would be to use a differentiator circuit that would pulse high (probably need a directional diode) when the button output goes high and route the pulse to the Reset input. The switch signal itself could go to a GPIO. Following reset, the switch is still high so start timing before making a decision about loading defaults.Look at the 0.1 RC waveform near the bottom. Notice how the falling edge of the square wave creates a negative going spike. The directional diode would block this spike and pass the leading edge spike.https://www.electronics-tutorials.ws/rc/rc-differentiator.html

author: Ian.M
author_rank: Super Contributor
timestamp: January 18, 2021, 07:21:35 am
content: Its nowhere near as cheap as a MCU, but if you need to implement the long press does <action> after reset functionality entirely in hardware you could use one of L.T's (now Analog Devices) Timerblox series: theLTC6993-3non-retriggerable falling edge triggered monostable. For reliability it would need a simple RC debounce circuit to prevent false triggering on button release.If the MCU has Schmidt trigger inputs for /Reset and at least one GPIO, its possible to handle it without any extra ICs, entirely with RC+diode networks, including switch debouncing. See attached LTspice sim.

author: S. Petrukhin
author_rank: Super Contributor
timestamp: January 18, 2021, 10:43:40 am
content: Quote from: rstofer on January 18, 2021, 05:09:42 amThis is a simple and obvious solution. But I wonder if there are any special chips for this with some additional features like a power supervisor.And don't forget that the differentiating circuit works when the signal is bipolar or rail-to-rail. If the RC is connected to a button or circuit with an open collector/with an open drain, the capacitor will charge in one or more pulses and differentiation will stop at this point. At least one additional resistor is required at the input to discharge the capacitor.

author: S. Petrukhin
author_rank: Super Contributor
timestamp: January 18, 2021, 11:49:56 am
content: Quote from: Ian.M on January 18, 2021, 07:21:35 amThe LTC6993 is an interesting chip, but it does cost more than the MCU...I have not LTSpice.

author: S. Petrukhin
author_rank: Super Contributor
timestamp: January 18, 2021, 11:54:34 am
content: I have a somewhat more complicated task.After powering on or hardware Reset, a hwRreset is set for all hardware, and nReset pulse is generated for the MPU, when the MPU completes initialization, it removes the hwReset.I want everything to be frozen until the processor has started a reasonable operation, so that during the firmware, all the equipment was turned off automatically.

author: Ian.M
author_rank: Super Contributor
timestamp: January 18, 2021, 03:23:21 pm
content: That's trivial. Drive a buffer for hwReset from an I/O pin, with a pullup, or pulldown resistor to force the required 'In Reset' state while the MCU I/O pin is tristate, which (for most MCUs) it will be from and during any MCU reset, until your firmware decides to initialize it and drive it to 'Running' state. Your firmware can also assert hwReset as required.Its pretty unusual not to be able to run LTspice. If you have admin rights on an x86 or x64 PC running Windows >XP (preferred >=7), OSX or Linux, and *AREN'T* working for a semiconductor manufacturer competing with Analog Devices you can legally download and run it. However, for your convenience I've attached a screenshot. The complicated stuff in the dashed box is a switch-bounce 'generator' for the sim - ignore it!

author: S. Petrukhin
author_rank: Super Contributor
timestamp: January 18, 2021, 05:13:51 pm
content: I do something like this, but I use a transistor pulled up to Vcc - until the MCU forcibly turns it off, the hwReset signal hangs.I also used an RS trigger to save the pin, which was combined with the TX output of the management console. After all, when the processor has completed initialization, it writes the first message to the UART console port, which resets the trigger.As you can see, the solution on discrete elements is quite cumbersome, it requires about 12 places in the installation machine, 12 positions in the order, etc. I was hoping to light this to a single chip. Apparently, Puduk will win its place.Thanks for the analysis in LTspice, but I don't really trust analog system simulators.For an accurate simulation, you need to enter a lot of correct data, this is already fraught with errors in itself.

author: Nominal Animal
author_rank: Super Contributor
timestamp: January 18, 2021, 07:38:53 pm
content: How aboutATtiny9? Or ATtiny4, or ATtiny10?Mouser sells them for under 0.30€ apiece in singles, and the SOT23-6 should suffice (one input to the reset button, and up to three outputs – although if you use the reset pin as an output, you might have to use a buffer). It does use the newerTPI/PDI programming interface, but you can use e.g. a Pro Micro clone (as Arduino Leonardo) off eBay as the programmer; or get an AVR ISP mk2 (that can do both AVR ISP and TPI/PDI programming).I think you'd need one or two bypass caps for the MCU, and some pulldown/pullup resistors (to ensure correct state at initial power-up), but I imagine that should be it. Current avr-gcc should support ATtiny4/9/10, and this should be so simple you don't need help from the Arduino environment, just write a tiny firmware on bare metal.

author: S. Petrukhin
author_rank: Super Contributor
timestamp: January 18, 2021, 08:01:28 pm
content: Quote from: Nominal Animal on January 18, 2021, 07:38:53 pmAlso a good idea. I have Atmel-Ice it can program ATtiny. Although, I've never tried their programming interface.And have a pair of ATtiny10 in stock. I need to try it.Thanks for the reminder, this is much closer to me than Puduk.But it will still require a normally closed key to hold hwReset until the processor resolves - after all, Tiny also requires time to start.

author: Nominal Animal
author_rank: Super Contributor
timestamp: January 18, 2021, 08:35:33 pm
content: Quote from: S. Petrukhin on January 18, 2021, 08:01:28 pmI don't think so; aren't ATtiny pins tristate on startup? How about using a pullup/pulldown (physical resistor, I mean) on the line between ATtiny and processor /RESET line?I think this boils down to deciding what the processor /RESET (and DEFAULTS) line should be in the various situations:Initial power-up: should ATtiny interfere with the bootup at all, when power is initially connected?Short reset pulseLong reset pulsePersonally, I think ATtiny should not interfere with normal power-up at all, so using a pullup on /RESET and a pulldown on DEFAULTS, with ATtiny keeping the outputs tristated until it detects a push, makes most sense.However, if you want ATtiny to assert /RESET on power-up for a specified duration, then a pulldown on /RESET makes sense.Or is there something I'm missing?

author: S. Petrukhin
author_rank: Super Contributor
timestamp: January 18, 2021, 09:28:53 pm
content: Quote from: Nominal Animal on January 18, 2021, 08:35:33 pmIf describe it in detail, then the task is as follows:1. There are signals in the circuit-nReset: drops to 0 when pressing the button, from the programmer, is held to 0 by the power supply until powergood occurs or short pulse from RC. This is the input control signal.-hwReset: instantly drops to 0 at nReset, and release by a signal from the processor, RS-trigger. This signal keeps all hardware frozen until the processor decides to revive it.-mpuReset: drops to 0 from nReset, lasts 250ms when power is applied or a button is pressed, but lasts as long as the signal from the programmer. Resets the processor with a pulse (even if the button is held down), but completely repeats the signal from the programmer.This algorithm will not be implemented on a small processor in a single case without the use of autonomously stable keys due to the 3rd state of the outputs at the start of this small processor.Apparently, there is no special chip for such a reliable start, I will have to implement it on discrete logic. Directly for the nodes on my board there is no threat due to the third state of the MPU - they are all stable in the absence of a control signal in the default state. But external modules may be connected, which do not want to be in the active state at an undefined input.