Power up GPIO glitch

 Here's an ATtiny85 driving a mosfet switch.   The LED draws too much current for the GPIO to drive it directly.

I soldered this circuit up on a proto board, with pin 1 (gate) floating in the air connected to nothing.   When I tap the gate with my finger, the LED turns on, or off, or stays the same, seems kinda random.   But if I touch ground with my other hand the LED turns off every time.   What seems to be happening is the gate capacitance is large enough to hold whatever voltage it was driven to last.   There is 60 Hz hum on my finger, turning the transistor on and off.   The gate remembers what phase of the 60Hz hum it was at when we disconnected.   And it remembers it for at least several minutes.

Now I connected gate to an ATtiny85 MCU general purpose IO pin.   On power up, the gate goes high, and there's nothing to push it low again.    The LED is on.  I can turn it on or off by touching a 100K resistor between the mosfet gate and +5 or ground.   Apparently the gate capacitance is high enough to hold the state, the ATtiny85 GPIO does not leak enough to change it, and neither does my soldered perfboard prototype construction.

I added code to setup().
   pinMode(3, OUTPUT);
   digitalWrite(3, LOW);
On power up, the gate goes high briefly, then low.   The LED flashes briefly.

I added a 2K pull down resistor.   The LED stays dark at power-on.
Seems to be an initialization issue with the ATtiny85.   




Comments

Popular posts from this blog

RAID1 array for our home theater. LVM + md + ZFS or XFS

Software product web sites suck.