Connecting a pump for 5-10 seconds

Adafruit's tiny microcontroller platform. Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
jaxelsson
 
Posts: 10
Joined: Mon Nov 27, 2017 11:06 am

Connecting a pump for 5-10 seconds

Post by jaxelsson »

I'm trying to run a simple mini water pump for 5-10 seconds every time someone presses the button. I know simple, right? But I can't figure out how I need to wire it, or what I'm doing wrong with my current logic. I've hooked it to a MOSFET ...but with the Trinket not having debugging, I have no idea what's going on. Can anyone give me some advice on what I'm missing?
Attachments
Screen Shot 2023-02-16 at 8.00.28 PM.png
Screen Shot 2023-02-16 at 8.00.28 PM.png (182.72 KiB) Viewed 191 times
61o7M8ybUXL._AC_SL1500_.jpg
61o7M8ybUXL._AC_SL1500_.jpg (37.07 KiB) Viewed 191 times

User avatar
adafruit_support_bill
 
Posts: 88136
Joined: Sat Feb 07, 2009 10:11 am

Re: Connecting a pump for 5-10 seconds

Post by adafruit_support_bill »

If you post the code you are using, we can have a look.

User avatar
jaxelsson
 
Posts: 10
Joined: Mon Nov 27, 2017 11:06 am

Re: Connecting a pump for 5-10 seconds

Post by jaxelsson »

Code: Select all

#define SWITCH 0
const int PUMP =  1;      // the PIN number of the pump control MOSFET


// the setup routine runs once when you press reset:
void setup() {
  // initialize the SWITCH pin as an input with a pullup 
  pinMode(SWITCH, INPUT_PULLUP); 

  // initialize the PUMP control MOSFET pin as an output
  pinMode(PUMP, OUTPUT);
  digitalWrite(PUMP, LOW);   // Pump off

}

// the loop routine runs over and over again forever:
void loop() {
  if (! digitalRead(SWITCH)) {  // if the button is pressed
    digitalWrite(PUMP, HIGH);   // Pump on 
    delay(5000);
  } else {
    digitalWrite(PUMP, LOW);   // Pump off
  }
}

User avatar
adafruit_support_bill
 
Posts: 88136
Joined: Sat Feb 07, 2009 10:11 am

Re: Connecting a pump for 5-10 seconds

Post by adafruit_support_bill »

And how are you powering the Trinket?

Driving a motor of any size from the Trinket's 3.3v pin is a bad idea. The 3.3v regulator on the board is not designed for high current loads.

You also should have a kickback diode wired in parallel with the motor to protect the rest of your circuitry from the inductive kickback from the motor. The diagram below shows the diode.
Attachments
arduino-motor.png
arduino-motor.png (71.05 KiB) Viewed 186 times

User avatar
jaxelsson
 
Posts: 10
Joined: Mon Nov 27, 2017 11:06 am

Re: Connecting a pump for 5-10 seconds

Post by jaxelsson »

I was hoping to power it off the USB via the 3v pin since it's a mini pump (and will only run for a moment) as shown in my Fritzing. And plug it into a wall based USB adapter. The pump is DC3V with a load rated current of 0.18A.

I'm only getting some tiny jerks, but can't tell if the problem is my wiring/thinking or something else. Is my wiring diagram/thinking even correct? Is this not doable at all off the board's 3V? How critical is the diode to testing this out?

User avatar
adafruit_support_bill
 
Posts: 88136
Joined: Sat Feb 07, 2009 10:11 am

Re: Connecting a pump for 5-10 seconds

Post by adafruit_support_bill »

I was hoping to power it off the USB v
Then you should power the motor from the USB pin.
I'm only getting some tiny jerks
You are likely overloading the 3.3v regulator, and the lack of a diode is pumping negative voltage spikes back onto the 3.3v rail. Either condition is likely to cause processor resets and eventual damage to the circuitry
Is this not doable at all off the board's 3V?
Probably not. And it is totally unnecessary if you are powering from USB. Use the 5v from the USB pin.
How critical is the diode to testing this out?
Only as critical as preventing the negative voltage spikes from destroying your MOSFET and Trinket.

User avatar
jaxelsson
 
Posts: 10
Joined: Mon Nov 27, 2017 11:06 am

Re: Connecting a pump for 5-10 seconds

Post by jaxelsson »

Thank you. Now that you point out the USB pin I feel silly for not even noticing it. Makes sense. So other than that, the Diode is the key? Can you tell me what type it should be for this? See new diagram attached.
Attachments
Screen Shot 2023-02-16 at 9.27.26 PM.png
Screen Shot 2023-02-16 at 9.27.26 PM.png (196.95 KiB) Viewed 168 times

User avatar
jaxelsson
 
Posts: 10
Joined: Mon Nov 27, 2017 11:06 am

Re: Connecting a pump for 5-10 seconds

Post by jaxelsson »

I’m guessing an IN4001 1 amp 50 Volt diode is the right choice?

User avatar
adafruit_support_bill
 
Posts: 88136
Joined: Sat Feb 07, 2009 10:11 am

Re: Connecting a pump for 5-10 seconds

Post by adafruit_support_bill »

Diode selection is not super-critical. It just needs to be rated for at least the voltage and current it will be seeing. 50V @ 1A is plenty.

Locked
Please be positive and constructive with your questions and comments.

Return to “Trinket ATTiny, Trinket M0”