1
\$\begingroup\$

I connected a tactile switch to the AVR reset button according to the circuit below. every time I press the button the AVR resets itself but my question is: Is there a way to make this button acts after let's say 3 seconds? I mean press the button and hold it for 3 seconds and then the AVR resets itself. (some kind of resistor-capacitor circuitry)

enter image description here

\$\endgroup\$
  • \$\begingroup\$ The screen grab is pretty low quality and not a single text is schematic is visible as is it all blur. Can you please take care of that? \$\endgroup\$ – MaNyYaCk Jul 19 '18 at 8:40
  • \$\begingroup\$ @MaNyYaCk The image replaced \$\endgroup\$ – milad Chalipa Jul 19 '18 at 8:46
4
\$\begingroup\$

The circuit here will activate the AVR reset about 3 seconds after the switch is pressed. The AVR will stay in reset as long as the held pressed over the 3 seconds and will then come out of reset about 0.75 seconds after the switch is released.

(Edit: Replaced schematic with one showing LM393 comparator).

enter image description here

In this schematic the V1 voltage source is there to provide a voltage controlled action of the S1 switch. Obviously in your case the S1 is simply a switch that you press with your finger.

The 3 second delay can be tweaked to get it as close to 3 seconds as you want by adjusting the R4 value.

The comparator shown for U1 is a device with a push-pull output so it would not need the R2 pullup resistor. If you choose some other 5V compatible comparator it may have an open drain output so would require the R2 resistor.

\$\endgroup\$
  • \$\begingroup\$ It'll definitely work, but what about using cheaper comparator? something like LM393 \$\endgroup\$ – milad Chalipa Jul 19 '18 at 9:56
  • \$\begingroup\$ You can use any 5V compatible comparator that would function it the circuit. I pick the LT1721 because it has a reliable model in LT-Spice. \$\endgroup\$ – Michael Karas Jul 19 '18 at 10:02
  • \$\begingroup\$ What will be the purpose of R6? Noob here , but I understood that when switch is not pressed, there will be around 2.5 V on the + Pin and hence the output of the U1 will swing towards the +5 side. and when the switch is pressed , there will be around 3.4V on the - Pin and - pin has high volt on it , out put will swing towards the ground, so what does R6 do? \$\endgroup\$ – MaNyYaCk Jul 19 '18 at 10:08
  • 2
    \$\begingroup\$ The R6 resistor is used to establish hysteresis in the operation of the comparator. As soon as the comparator output pulls low the R6 couples back to the (+) input of the comparator and yanks it a little bit lower toward GND. The purpose of this is so that the slow rising waveform on the (-) input does not cause oscillation at the comparator output of there was some noise riding on the slow waveform. This also works in the other direction on the discharge of the capacitor when the switch is released and the comparator output goes back high. \$\endgroup\$ – Michael Karas Jul 19 '18 at 10:24
  • 1
    \$\begingroup\$ I was able to get a recent p-spice model of the LM393 to work in LT-Spice so I re-simulated the circuit with that model. That low cost comparator should work just fine. \$\endgroup\$ – Michael Karas Jul 19 '18 at 18:27
0
\$\begingroup\$

Without adding external components you can disable the reset pin function via fuses (watch out! you will lock yourself out of the chip if you don't have a HV parallel programmer!) and use it as a GPIO.

When the pin is configured as a GPIO you can just count in software how long the button has been pressed and issue a reset (eg. via watchdog).

You can also use every other GPIO to do a software reset.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.