ATMega_v1.5.sch (438653Bytes)
Update 06/11/2016
Hey guys,
I sort of got the motor working. Adding a small resistance(about 2-3ohms) in series with the motor seemed to stop the Atmega reseting whenever Pin 3 was pulled HIGH (still don't know for sure what was causing this!). I'll still continue t troubleshoot this problem and completely figure out what exaclty was causing the Atmega to reset, since the resistor is not a permanent solution (wasteful energy loss). I'm really grateful for the huge amount of help from here guys!! Thanks alot! :)
Cheers!
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Hey guys,
I'm having trouble regarding motor control in a project I'm working on.
It uses an ATMega328 DIP package on a PCB. The motors I'm using are small coreless motors and I'm trying to control them using Si2302ds N-MOS FETs. For the power supply I'm using a 3.7V(4.2V on full charge) Lipo. I've tested this setup on a promini before and the motors turned on and off just fine.
This time I'm having problems with controlling 1 motor out of the 4. I've attached 0.1uF caps across each motor terminal (see schematic). Them control pins used for the motors are pins 3,5,6,9. The problem occurs at pin 3. I tried running the blink program on pin 3 to pulse the motor on and off through the FET but all I get is a bit of clicking from the motor.
Things I've already checked relating to the circuit :
- FETs are soldered on correctly and made sure they aren't defective.
- Motor works fine prior to connecting it to the circuit.
- Disconnected the FET and motor from pin 3 and checked the output. It works fine on its own.
Is the problem occuring due to noise generated by the motor? What could be the problem? I've attached the schematic to this post. Thanks in advance :D
Here is the code I'm testing. (Simple blink program)
#define motor1 5
#define motor2 3
#define motor3 6
#define motor4 9
void setup()
{
pinMode(motor1, OUTPUT);
pinMode(motor2, OUTPUT);
pinMode(motor3, OUTPUT);
pinMode(motor4, OUTPUT);
digitalWrite(motor1,LOW);
digitalWrite(motor2,LOW);
digitalWrite(motor3,LOW);
digitalWrite(motor4,LOW);
delay(1000);
}
void loop() {
digitalWrite(motor1,HIGH);
delay(10);
digitalWrite(motor2,HIGH);
delay(10);
digitalWrite(motor3,HIGH);
delay(10);
digitalWrite(motor4,HIGH);
delay(10);
delay(1500);
digitalWrite(motor1,LOW);
digitalWrite(motor2,LOW);
digitalWrite(motor3,LOW);
digitalWrite(motor4,LOW);
delay(1000);
}