When I apply power to my breadboarded ATmega 328 with a small DC motor driven through a logic level mosfet, the voltage measures about 5v then drops to around 2v after 4 or 5 seconds. EDIT: I'm referring to the voltage between the output pin and mosfet gate. The rest of the circuit measures 5v where it should measure 5v.
Power:
I'm using 6 AA rechargeable NiMH batteries through a 7805 regulator decoupled with .1uF and 22uF on the input and .1uF and 10uF on the output. Edit: 1.5A regulator
Mosfet wiring and datasheet:
see attached photo. I also put a 100 Ohm resistor in series from output pin to mosfet gate per Crossroads and others in other posts.
http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Components/General/FQP30N06L.pdf ATmega 328 wiring:
http://arduino.cc/en/Main/StandaloneMotor:
http://www.pololu.com/catalog/product/77Code:
int StartSpeed=0; // you have to experiement to find the magic number.
int StopSpeed=255;//Again experiment ok
const int MotorPin=3;
int i=StartSpeed;
unsigned long TimeNow;
unsigned long PreviousMillis=0;
long Delay=10; // experiment with the value ok, the lower the value the steeper the gradiend of speed
void setup()
{
pinMode(MotorPin,OUTPUT);
digitalWrite(MotorPin,LOW);
}
void loop()
{
if (i<StopSpeed)
{
unsigned long CurrentMillis=millis();
if (CurrentMillis-PreviousMillis>=Delay)
{
PreviousMillis=CurrentMillis;
i ++;
}
}
analogWrite(MotorPin,i);
}
Things I have tried to fix:
1. 0.1uF capacitor in series with the flyback diode
no change
2. switching regulator
no change
http://www.murata-ps.com/data/power/oki-78sr.pdf3. changing output pins
no change
4. changing ATmega 328
no change
5. changing code to non-PWM using just digital write high
digitalWrite(motorPin, HIGH);
no change
6. Swapping out motor
no change
7. swapping LED and current limiting resistor for motor
works fine
8. using same code, same power, and same ATmega 328 plugged into the Arduino
works fine!
This is what puzzles me most because I assumed that I had damaged the two ATmega 328's that I am using, but this tells me that they aren't damaged.
Any suggestions are greatly appreciated. Thanks in advance.