[SOLVED] Arduinos Killed With Mosfet & Solenoid

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:

  1. The arduino sends a signal through a microswitch (MS1) - Is it ok having an inline microswitch? It interrupts the signal path.
  2. There's a gate resistor (R2) and finally to the mosfet gate - Is R2 220ohm too low of a resistor value?
  3. 10k Resistor (R3) between mosfet gate and source.
  4. Flyback diode on solenoid - Is this correct orientation?
  5. All grounds connected
  6. 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!)? :confused:
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)

The MOST important information is a schematic of how YOU, YOURSELF, have the wiring. Not the commercial diagram. Perhaps, also a picture of your project showing the wiring.

Paul

I drew that 'commercial' diagram myself.

I will get pics when i get home this afternoon, cheers

Here are some images of the wiring:

On closer inspection, it looks like there could be heat damage to the mosfet (tiny bubbles on plastic). I will replace it with a new one and see if that helps. Couldn't see it until I took a closeup picture.

T

Please explain the 2 orange LED circuit, what is the reverse voltage rating of the LEDs, when the MOSFET is not conducting, there will be 12.6V on the cathode side and 5V on the anode side.

The way your arduino got damaged is probably excessive voltage spikes on the supply. You are lacking decoupling on the 12V supply, which allows spikes due to stray inductance in the power wiring. If the free-wheel diode across the solenoid fails this could also have big repercussions.

Use at least 100µF across the 12V supply, more is probably better.

The ESCs are going to throw all manner of large spikes on their power, you should never be using that power source for anything sensitive.

I'd power the Arduino separately from the ESCs, and the solenoid.

JCA34F:
Please explain the 2 orange LED circuit, what is the reverse voltage rating of the LEDs, when the MOSFET is not conducting, there will be 12.6V on the cathode side and 5V on the anode side.

Note the LED's were not connected when I had issues. The LED's are 'muzzle flash', in that they turn on only when the solenoid is active, hence why they are connected to the drain of the MOSFET.

The reverse voltage looks like 5V. Datasheet attached.

So i did some research and 12.6V would reduce the lifespan of the led's since the reverse voltage is only 5V?

What if I add a diode in parallel to the LED in reverse direction as shown in modified schematic attached.

I'm still learning electronics basics

Thanks

LED - Data Sheet.pdf (196 KB)

Come on. Think a bit more about your project. You have lots of available pins on your Arduino. Use them to flash your LEDs in time with the firing of the solenoid.

Paul

What if I add a diode in parallel to the LED in reverse direction as shown in modified schematic attached.

DON'T DO THAT! That would backfeed 12V into the Arduino's 5V pin. BOOM! :o

Paul_KD7HB:
Come on. Think a bit more about your project. You have lots of available pins on your Arduino. Use them to flash your LEDs in time with the firing of the solenoid.

Paul

I thought about that, but the LED's are rated at 50mA continuous forward current. This will go over the Arduino Max 40mA per pin.

I could source lower power LED's, albeit a little dimmer.

Thanks

Clark3DPR:
I thought about that, but the LED's are rated at 50mA continuous forward current. This will go over the Arduino Max 40mA per pin.

I could source lower power LED's, albeit a little dimmer.

Thanks

That's why transistors are used to switch the higher voltage. Just have to change the logic in your code a bit.

Paul

JCA34F:
DON'T DO THAT! That would backfeed 12V into the Arduino's 5V pin. BOOM! :o

Oops! I've completely changed the LED locations now.

MarkT:
The way your arduino got damaged is probably excessive voltage spikes on the supply. You are lacking decoupling on the 12V supply, which allows spikes due to stray inductance in the power wiring. If the free-wheel diode across the solenoid fails this could also have big repercussions.

Use at least 100µF across the 12V supply, more is probably better.

The ESCs are going to throw all manner of large spikes on their power, you should never be using that power source for anything sensitive.

I'd power the Arduino separately from the ESCs, and the solenoid.

I've got the updated schematic, now with a 9V battery supplying Arduino separately. Should the grounds be common between 12.6V and 9V?

Would a cap go parallel to the 12.6V supply? Is it still needed if I have separate supplies?

Also I still have a slight problem with the LED reverse voltage being 9V.
I need to figure out how others use a simple LED with arduino while using external supply (7-21V). USB power is easy since thats 5V, but that doesnt apply in my case.

Paul_KD7HB:
That's why transistors are used to switch the higher voltage. Just have to change the logic in your code a bit.

Paul

In that case, I could do something like this:
https://www.lucidmakers.com/power-multiple-leds-single-arduino-pin/

MarkT:
The way your arduino got damaged is probably excessive voltage spikes on the supply. You are lacking decoupling on the 12V supply, which allows spikes due to stray inductance in the power wiring. If the free-wheel diode across the solenoid fails this could also have big repercussions.

Use at least 100µF across the 12V supply, more is probably better.

The ESCs are going to throw all manner of large spikes on their power, you should never be using that power source for anything sensitive.

I'd power the Arduino separately from the ESCs, and the solenoid.

I spoke to my knowledgeable colleague (Electrical Engineer) today, and he marked up the drawing to include a couple of caps across the Arduino supply, as well as a diode in line. Similar to what you suggested.

Schematic has been reverted back to original design, except now with protection caps and diode:

He explained that when the solenoid and/or motors draw current from the battery, there could be an initial voltage drop going to the Arduino power input (VIN). If the Arduino is crunching code while input goes below a certain amount, it could have caused issues.

He also said the LED's shouldn't have much problem with reverse voltage. If it blows it blows :stuck_out_tongue:
I will try this and see if it works.

So after successful testing, the problem seemed to be reverse voltage and / or voltage sag caused by heavy loads such as the motors and solenoid. This caused the Arduino VIN to receive fluctuating input voltage.

The solution was to add a couple of capacitors and a diode to the Arduino VIN.

See schematic below:

Thanks for the help everyone, and I hope this helps someone that stumbles across the same issue!