Hi all! I'm new here.
This is the first time I've had to ask for help since knowing nothing about arduino, mosfets, coding etc.
So the issue I can't get my head around is that after firing a solenoid through a mosfet for a few minutes the Arduino (Genuine Nano V3.2) heats up, and no longer accepts code to be uploaded.
After that, I got the Genuine Nano Every and this time the similar problem is that the on-board LEDs are no longer lit, as if the Nano is dead. Checked with multi-meter and the board is indeed receiving power.
This happens around the same time I upload code from Laptop USB. I made sure to never have USB power and Battery connected simultaneously.
I also do not push any microswitches while on USB power.
I don't believe static electricity killed it, and there is no stray solder shorting things out.
Too much to explain in words, so I've attached the schematic and code to look at. Note that I do not have any problems with the ESC's, Flywheels in the schematic, nor did i have LED's or reset switch connected when the problem happened. Please focus on the Arduino, mosfet & solenoid.
Schematic explained:
- The arduino sends a signal through a microswitch (MS1) - Is it ok having an inline microswitch? It interrupts the signal path.
- There's a gate resistor (R2) and finally to the mosfet gate - Is R2 220ohm too low of a resistor value?
- 10k Resistor (R3) between mosfet gate and source.
- Flyback diode on solenoid - Is this correct orientation?
- All grounds connected
- Is the mosfet gate somehow pulling too much current through the arduino pin D4 (40mA max)?
Code:
const int buttonPin = 2; // Micro Switch Rev Flywheels Pin number
int buttonState = 0; // Variable for reading the pushbutton status
int solenoidPin = 4; // Solenoid Mosfet Gate Pin number
#include <Servo.h>
Servo throttle;
int pos = 0;
int pin = 3; // ESC signal pin
void setup() {
pinMode(buttonPin, INPUT); // Initialize the pushbutton pin as an input
throttle.attach(pin);
pinMode(solenoidPin, OUTPUT); //Sets that pin as an output
// Arm the ESC
for (pos = 90; pos <= 91; pos += 1) {
throttle.write(pos);
delay(3700); // Wait for ESC to arm
}
}
void loop() {
buttonState = digitalRead(buttonPin); // Read the state of the pushbutton value
if (buttonState == HIGH) { // Check pushbutton is pressed, if so buttonState is HIGH
throttle.write(92); // <(92) = Motor off / (92) = Idle speed
} else {
throttle.write(97); // Motor on (92) = Idle speed / ~(120) = Max speed
}
if (buttonState == LOW) {
digitalWrite(solenoidPin, HIGH); // Switch Solenoid ON
delay(45); // Wait x Seconds
digitalWrite(solenoidPin, LOW); // Switch Solenoid OFF
delay(100); // Wait x Seconds
} else {
digitalWrite(solenoidPin, LOW); // Switch Solenoid OFF
}
}
Parts list:
Arduino: Genuine Nano Every - https://store.arduino.cc/usa/nano-every
N-Channel Mosfet: (Refer attached datasheet)
Solenoid: 12V 8A
Diode: 1N4001
Battery: Lipo 3S 11.1V (12.6V Max) 30A+ Discharge rate - 1300mAh
My main question is what could be causing the arduino to keep dying & overheating (70C!)?
Thanks
P.S. If you're wondering what project this is for, I'm controlling a solenoid and brushless ESC's for a Custom 3D printed Nerf Gun.
MOTOR CONTROL.pdf (27.9 KB)
Mosfet FQP30N06L - Data Sheet.pdf (624 KB)