ATtiny output to MOSFET - Page 1
Forum section: electronics / beginners

author: IvoS
author_rank: Frequent Contributor
timestamp: June 05, 2015, 08:59:07 pm
content: From attached schematic, do I need R4, R5 and R14? Is it a good practice to use these resistors to hold the gate down even though the microcontroller output is LOW ?

author: mushroom
author_rank: Regular Contributor
timestamp: June 05, 2015, 11:20:37 pm
content: These resitors force the gate to LOW if the Attiny outputs are hi impedance (tri state). No ?

author: alsetalokin4017
author_rank: Super Contributor
timestamp: June 05, 2015, 11:42:32 pm
content: Yes. It's common practice to have such a resistor, close to the mosfet itself, connected from Gate to Source, to allow the Gate charge to drain off so that the mosfet switches off cleanly and rapidly.

author: Unknown
author_rank: Unknown
timestamp: June 05, 2015, 11:53:46 pm
content: Quote from: IvoS on June 05, 2015, 08:59:07 pmYes, you should use them to force a defined state when the mcu is not controlling the mosfets.PS: Don't want to be a smartass but all the capacitor values are "wrong" ex: C3 is 0.1M wich is Mega Farad but i think that the designer meant micro Farad ( uF ).Edit: just noticed that the reset pin of U5 is not connected, i think you should use a pull-up.

author: IvoS
author_rank: Frequent Contributor
timestamp: June 06, 2015, 01:01:15 am
content: Why would it be necessary to use pull up resistor on reset pin when I don't need to reset the micro? Just thinking....

author: Unknown
author_rank: Unknown
timestamp: June 06, 2015, 01:12:33 am
content: Quote from: IvoS on June 06, 2015, 01:01:15 amThe reset pin is a active low so you have to pull the pin high in order to run the micro. i don't have a lot of experience withe the avr micros so read the datasheet carefully.

author: janoc
author_rank: Super Contributor
timestamp: June 06, 2015, 01:17:53 am
content: The other reason would be that it is a good practice to put a defined logic level on unused pins - either ground them or pull them high. If you don't, the high impedance input will pick up all kinds of junk "from the air" and the circuitry may oscillate. If nothing else it will increase your current consumption, in the worst case it could prevent the circuit from working.Now, this doesn't need to be always done externally - many chips (including that AVR, just not sure whether for reset pin too) have integrated pull-up/pull-down resistors - use them!

author: matseng
author_rank: Frequent Contributor
timestamp: June 06, 2015, 02:02:27 am
content: Quote from: exapod on June 06, 2015, 01:12:33 amI can from experience attest that reading the datasheets carefully is important. I've been burned more than a few times when I by design left out the pull up on the reset pin thinking that this device has internal pullup just as the previous device.Most newer Microchip mcus have internal pull up and operate safely without an external resistor unless they are in extremely noisy environments. The slightly older PIC's *require* an external pullup or they will really act up.

author: IvoS
author_rank: Frequent Contributor
timestamp: June 06, 2015, 01:01:30 pm
content: Thank you. Yes, reading the data sheet is important, I agree.So, from the datasheet I can just set the fuse program (‘0’) RSTDISBL and no resistor needed. I will update the schematic and put a dummy resistor from RESET pin out anyway, for future use, if I ever need more I/O.

author: Neverther
author_rank: Regular Contributor
timestamp: June 06, 2015, 06:00:45 pm
content: Disabling reset will result in write once chip. So if you do it, program it first, then set the fuses to disable reset.Otherwise you need high voltage programmer as programming through ICSP will not work.

author: IvoS
author_rank: Frequent Contributor
timestamp: June 06, 2015, 08:34:38 pm
content: Oooohh, I see, better leave RESET pin as it is. I didn't realize that. Thank you.There is an option to disable individual pull up resistors for I/O pins for ATtiny84 somewhere?I have a push button connected from +5V to input pin and then with pull down resistor to GND.They say: As inputs, Port A pins that are externally pulled low will source current if the pull-upresistors are activated.So, I will either have to deactivate those resistors, or re-write the code debounce button function and flip the button from input pin to GND. Yes?

author: Dave
author_rank: Super Contributor
timestamp: June 07, 2015, 03:05:55 am
content: Quote from: alsetalokin4017 on June 05, 2015, 11:42:32 pmFar from it.The gate charge will mostly be depleted through the 1k resistor, as the output of the microcontroller is pulled to ground. MOSFET, 100 kiloohm and rapidly don't exactly belong in the same sentence.The only purpose for those 100k resistors is to keep the gates grounded when the outputs of the micro are in Hi-Z mode (while programming, during reset, etc.).

author: Psi
author_rank: Super Contributor
timestamp: June 07, 2015, 04:00:35 am
content: You don't need the external pullup on the reset pin. The MCU has one built-in which pulls reset to high.The only issue is that its a week pullup, 20k or so, so if you operate the mcu in a noisy environment (like a car) there's a chance noise might overpower this pullup and reset the mcu.So while it's good practice to add your own external pullup on the reset pin it's not required.

author: Simon
author_rank: Unknown
timestamp: June 07, 2015, 09:24:31 am
content: You need a pull-up resistor on the reset pin for the same reason you need to pull down resistors on the gate of the MOSFET. You can indeed disable the reset pin and use it as a port pin but then you will only be able to program the device once unless you use high-voltage programming. If you take a MOSFET and wire it up with nothing on its gate chances are it will just turn itself on even if partly. I have personally experienced this. Having to put the reset pull-up resistor in is a nuisance I don't know if it's possible to omit it but ultimately you will soon find that you want to be able to reprogram your chip any time. I have just built up some tiny circuits with a programming header and pull-up resistor for reset. Yet these things will be programmed once shipped and never touched again in fact they will be potted so I will not be able to access the header again. But from my point of view it is far easier to build the circuit up so that I can program it once it is built that way I know it has been soldered successfully and works. Of course there may be times where you want to preprogram the chip and then solder it and never touch it again but that would be in low-cost small designs where you can't afford space for the programming header.

author: matseng
author_rank: Frequent Contributor
timestamp: June 07, 2015, 10:05:32 am
content: Quote from: Simon on June 07, 2015, 09:24:31 amYes and no. A pull-up resistor is required - but not always anexternal pull-upresistor. Many microcontroller have them internally already. For instance most modern PIC's and almost all AVR's have them.Have a look at the datasheet for ATmega48A, ATmega48PA, ATmega88A, ATmega88PA, ATmega168A, ATmega1688PA, ATmega328, ATmega328P where you clearly can see that there is an internal pullup already at the reset pin.According to the graphs later on in the doc it will pull about 100uA when vcc i s 5 volts which would give it a ballpark value of 50k.

author: Simon
author_rank: Unknown
timestamp: June 07, 2015, 10:21:12 am
content: Quote from: matseng on June 07, 2015, 10:05:32 amOn the AVR they are there in case you use the reset pin as an I/O pin, it is not recomended to use them to pull the pin high because they need activating once the MCU has started but the MCU can't start if the reset is floating and reads low...... it's catch 22

author: matseng
author_rank: Frequent Contributor
timestamp: June 07, 2015, 10:34:30 am
content: Quote from: Simon on June 07, 2015, 10:21:12 amWhat? When the RSTDISBL fuse is blown the state of the pin is, by hardware, ignored irregardless of if the cpu is still in POR-sequencing or running normally.There is no way to enable/disable the reset pin by software during runtime, so there can't be any catch22 as you describe it.

author: Simon
author_rank: Unknown
timestamp: June 07, 2015, 10:41:47 am
content: No what I'm talking about is when you do use the reset pin as reset. The pullup that is needed to make the chip run can only be activated internally once the chip starts but it needs to start in the first place. Yes if you decide to use the reset pin as a an IO then there is a pullup as every other IO pin has.

author: matseng
author_rank: Frequent Contributor
timestamp: June 07, 2015, 10:52:46 am
content: Now you have confused me totally....First you said "On the AVR they are there in case you use the reset pin as an I/O pin, it is not...." and there was a catch22 in that situation. Now you say that the problem is when the reset is used as a reset pin.Which is it?But the block diagram of the reset logic from the datasheet shows that the 50 k pullup on the reset pin is permanently connected to the reset logic part, so it doesn't need to be activated internally. It's already there. Unless the block diagram is wrong of course.If the catch22 really existed then that pullup would be of no use at all. And I don't think that Atmel fscked up their designs on multiple generations of multiple chips. They are not that stupid.

author: Simon
author_rank: Unknown
timestamp: June 07, 2015, 11:21:08 am
content: I'll have to look the diagrams up but you have to enable the pullup in software in many AVR's so the AVR has to boot and run the program to turn the pullup on - catch 22. The pullup is there for the IO pin not as a pullup for the reset pin.

author: Psi
author_rank: Super Contributor
timestamp: June 07, 2015, 12:02:23 pm
content: The AVR reset pullup is NOT the same as the pullups on other i/o.If the reset pin is enabled (default fuse bits) then the reset pullup is always active, even in reset state.DatasheetQuote

author: Simon
author_rank: Unknown
timestamp: June 07, 2015, 07:41:51 pm
content: Quote from: Psi on June 07, 2015, 12:02:23 pmWhat ? ive been wasting resistors and space all of this time ? I thought I'd read it was a bad idea.

author: c4757p
author_rank: Super Contributor
timestamp: June 07, 2015, 09:55:24 pm
content: I've read lots of things, most of it conflicting and wrong.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: June 07, 2015, 10:03:10 pm
content: Simon,The diagram clearly shows a fixed resistor from VDD to RESET, no switch. It is not an optional pull-up.Note that this statement,Quote from: Psi on June 07, 2015, 04:00:35 amremains valid, so it is not unnecessary, but optional, and may be useful under some conditions.Tim

author: Simon
author_rank: Unknown
timestamp: June 08, 2015, 05:59:02 am
content: I've not actually found a diagram specific to the reset pin in an AVR datasheet.

author: matseng
author_rank: Frequent Contributor
timestamp: June 08, 2015, 06:37:42 am
content: Quote from: Simon on June 08, 2015, 05:59:02 amChapter 8.1 inhttp://www.atmel.com/Images/Atmel-2586-AVR-8-bit-Microcontroller-ATtiny25-ATtiny45-ATtiny85_Datasheet.pdfChapter 11.2 inhttp://www.atmel.com/images/atmel-8271-8-bit-avr-microcontroller-atmega48a-48pa-88a-88pa-168a-168pa-328-328p_datasheet_complete.pdf

author: Simon
author_rank: Unknown
timestamp: June 08, 2015, 06:54:37 am
content: aha thank you, so for all this time I've been wasting resistors.

author: matseng
author_rank: Frequent Contributor
timestamp: June 08, 2015, 06:58:48 am
content: Yup, you've wasted a few milllidollars per board- unless they had oldish PICs on them, because there they are needed.

author: IvoS
author_rank: Frequent Contributor
timestamp: June 09, 2015, 01:06:04 am
content: So, I will make the RESET resistor optional and populate it only if problems occur.