Go Down

Topic: How to use an n-channel mosfet to reset multiple ICs (Read 328 times) previous topic - next topic

gusantor

Hello

I'm trying to build a board. It will integrate an ATMega328, an ESP8266 and an ATtiny85

I'd like to be able to do a reset over all three ICs using software to drive the reset line shared by the ICs

By now I'm having some success using a RFP30N06LE, mounted as in the image below

My question is regarding what is the ideal mosfet to do this ? and mounted how ? and or best practices

Will a 2N7002 do the job ?

With a RFP30N06LE (purchased at ebay), I have tried many values for R1 (from 100 ohms, to 300K ohms), resulting in no 100% predictable results, some times it reset all ICs, sometimes just ATMEGA328 and ATtiny85 but not ESP9266. Even tried without any R1. May be some of the mosfets are broken (defective) and then the different results ?

Please any help is appreciated, thanks


alesam

Why do you want a MOSFET especially with so high  current as a RFP30N06LE? A simple regular transistor will do this job better.

ReverseEMF

#2
Feb 27, 2019, 01:56 am Last Edit: Feb 27, 2019, 02:17 am by ReverseEMF
At 5V, the 2N7002 is well suited for this.  At 3.3V, borderline -- but it should still work [but I wouldn't trust it for a production design. I'd go with something like the FDV303N -- it's cheap and has a very low Gate Threshold voltage (0.65 to 1V) BUT, it only comes in an SOT23 package, so not hand-solder-friendly.  But, if that's an issue, then the 2N7002 is probably just fine.

R1 can be some large value, like 1M, and only acts as a control element before PD3 is configured as a Output [the initial state for an Atmega328 port pin, is Tri-State, which means it will float, and thus the Gate voltage could wind up in a state between "ON" and "OFF", which usually is not desired].  But, because the input impedance of a MOSFET Gate is so high, it doesn't take much to pin it to ground.

Both the FDV303N, and the 2N7002, have a 100nA forward leakage [at TC = 25°C], so 1M*100nA = 0.1V, so no prob since, at 3.3VCC, the VIL threshold is around 1.4V.  And, that goes up with higher VCCs.  Though, that assumes a Tri-State Hi-Z greater than the impedance of the MOSFET input.  I couldn't find a spec for what "Hi-Z" actually means, in the datasheet. 

So, the selection of the Gate Pull Down resistor is a trade off between reducing load current on the power source, and making sure the gate doesn't float the MOSFET into it's "active region".  If power conservation isn't an issue [for instance, the thing is not being powered by a battery], then use something like a 10k resistor.  If, it's battery powered then go higher, like 300k to 1M.

"It's a big galaxy, Mr. Scott"

Please DON'T Private Message to me, what should be part of the Public Conversation -- especially if it's to correct a mistake, or contradict a statement!  Let it ALL hang out!!

BJHenry

The circuit looks ok (aside from possible MOSFET gate voltages). I think the problem is that the reset line is being held low for long enough. To check this out, have a look at the modified schematic I've attached (please excuse the terrible MS Paint job, it is the best I can manage right now). This circuit will let you activate the MOSFET via a pushbutton rather than driving it via a microcontroller. My hope is that when you press the buthbutton it will reliably reset all the microcontrollers. That will at least show what the problem is.

DrAzzy

The problem with using software to drive the reset lines is that as soon as reset is asserted, all the I/O pins go high impedance; the line may rise again before it has been held low long enough to reset everything.

I would have one of the microcontrollers(probably the '328p) reset the others via an I/O pin, then reset itself with a WDT reset.
ATTinyCore for x4/x5/x61/x7/x8/x41/1634/828/x313 megaTinyCore for the megaavr ATtinies - Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts, mosfets, awesome prototyping board in my store http://tindie.com/stores/DrAzzy

MarkT

A pulse-stretcher might be another approach, using a monostable logic chip?  You certainly need something
in hardware to guarantee the pulse width is long enough for all of the chips.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

gusantor

Thank you all very much !

All comments are valuable

I'll start by trying a FDV303N

Thanks !

wvmarle

A pulse-stretcher might be another approach,
Capacitor in parallel with R1? Target RC maybe 100-500 ms. Should be able to keep the lines low long enough.

Smaller cap * larger R1 is preferred, faster discharge through the Arduino's pin.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

ReverseEMF

#8
Mar 05, 2019, 04:19 pm Last Edit: Mar 05, 2019, 04:37 pm by ReverseEMF
The problem with using software to drive the reset lines is that as soon as reset is asserted, all the I/O pins go high impedance; the line may rise again before it has been held low long enough to reset everything.

I would have one of the microcontrollers(probably the '328p) reset the others via an I/O pin, then reset itself with a WDT reset.
Good point!  And, how about this.  Have the 328P reset the others, and, if the 328P also needs a reset, then, for instance, the ATTiny85 can, following it's own reset, issue a Reset to the 328P.  How is that possible, you ask?

Let me explain:

There are a set of flags that can be used to determine what caused a particular Reset.  In the 328P these flags reside in the MCUSR register and are as follows:
  • PORF: Power-on Reset Flag
  • BORF: Brown-out Reset Flag
  • EXTRF: External Reset Flag
  • WDRF: Watchdog [Timer] Reset Flag


[I didn't look up the flags for the ATTiny or the ESP-12, so, don't know if such exists or how similar they are if they do, but I've never know an MCU to not have such flags]

So, assuming the ATTiny85 also has such flags, and for the sake of discussion, lets say they are the same [as they probably are], following the External Reset induced by the 328P, the ATTiny85, checks it's EXTRF flag, and if set, has a pretty good hankering it came from the 328P, so it clears it, and then issues an External Reset to the 328P, which also, following the Reset, checks it's EXTRF flag, and if set, is by-gosh sure the ATTiny85 was the instigator, so it goes on with whatever business should follow an external reset.  

And, at anytime, the code in either MCUs, can also use the PORF flag to double check, and know it just Powered Up.  In fact, probably a good idea to, during the initialization phase [called "Setup" in an Arduino Script"], check the PORF flag, and clear it if it's set.  That way, you avoid possible ambiguity, down the road.  

And, BTW: This solves the Reset timing issue, as the 328P can, programmatically, hold the Reset line low for however long it needs holding, for the Reset to properly register.  

Note: Be sure, if you decide to implement this crazy scheme, to rewire that Reset line [the one that currently goes to ALL the Reset inputs].

Note 2: Of course, this is not the correct solution if all three of these MCUs need an exactly simultaneous Reset.

"It's a big galaxy, Mr. Scott"

Please DON'T Private Message to me, what should be part of the Public Conversation -- especially if it's to correct a mistake, or contradict a statement!  Let it ALL hang out!!

Go Up