Go Down

Topic: Digital pin turning off spontaneously when driving a 12V motor (Read 415 times) previous topic - next topic

jimboj525

I have the attached circuit using an Arduino UNO to control a 12V motor via a MOSFET:



It uses a HC-06 bluetooth module to receive commands, and when instructed it activates pin 13. Pin 13 is connected to an N-Channel MOSFET (FDP8880), which then switches on the motor. Both the arduino and motor receive power from the same 12V input.

The problem I have is when controlling the motor with pin 13 (ie not the switch), it will nearly always turn off after a few (1-10) seconds. The LED for pin 13 on the Arduino board also turns off whenever this happens, suggesting that pin 13 is refusing to stay HIGH, and for some reason is switching back to LOW.

What could be causing this? I have tested the circuit without the motor (just an arduino and bluetooth module) and it works fine, with pin 13 staying high for as long as needed. So I'm confident it's not a coding problem, but a problem with the circuit. When using the switch the motor operates fine, so I'm also confident I don't have a dodgy motor. I have made two of these units and had the same problem on both, so I also don't think it's a defective arduino board etc.

TheMemberFormerlyKnownAsAWOL

Quote
Installation & Troubleshooting
For problems with Arduino itself, NOT your project
Please don't PM technical questions - post them on the forum, then everyone benefits/suffers equally

jimboj525

For problems with Arduino itself, NOT your project
My arduino digital pin is not staying HIGH, is that not a problem with my Arduino?

CrossRoads

Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

jimboj525

Does your code include pinMode (pin13, OUTPUT); ?
Yep. I'm confident it's not an issue with the code as without the motor in the circuit the pin stays HIGH fine.

I'm assuming (ie guessing) it must be something to do with the power of the motor travelling into pin 13 and causing it to go haywire?

sterretje

Maybe I'm totally mistaken but to my knowledge motor should be between power and drain and souce should be connected to ground; see e.g. https://www.gammon.com.au/motors
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

CrossRoads

I think your MOSFET is miswired.
Drain should go to Motor- (anode of diode) and Source to Gnd.
That way the MOSFET acts as a low-side switch for the motor.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

jimboj525

Thanks, I will try that. I originally thought it didn't matter whether the MOSFET was at the positive or negative side of the circuit. But why would it result in the Arduino pin turning itself off?

MarkT

Your circuit shows a MOSFET connected as if its a p-channel FET, with source to +12V.

That, however, cannot be driven without a level shifter from the Arduino as the gate would
have to be at +12V to turn the motor off.

So:

Is your MOSFET n-channel or p-channel?  What actual device is it?

Its far more common to use an n-channel MOSFET, and it would need to be logic-level to
be driven direct from an Arduino pin.

An n-channel device would be used as a low-side switch, source->GND, drain->motor -ve
[ I DO NOT respond to personal messages, I WILL delete them unread, use the forum please ]

sterretje

@MarkT

from opening post
Quote
N-Channel MOSFET (FDP8880)
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

Idahowalker

You can prove the pin is turning itself off by disconnecting the motor and connecting a LED and resistor to the pin, set the pin to HIGH, and wait till the LED turns off on its own.
Receiving partial information does not help me help you and wastes my time.

TheMemberFormerlyKnownAsAWOL

You can prove the pin is turning itself off by disconnecting the motor and connecting a LED and resistor to the pin, set the pin to HIGH, and wait till the LED turns off on its own.
It's a Uno; there's already a LED there
Please don't PM technical questions - post them on the forum, then everyone benefits/suffers equally

Idahowalker

Receiving partial information does not help me help you and wastes my time.

Go Up