vm_exists
Posts: 27
Joined: Thu Mar 04, 2021 7:03 pm

Control a 24v 40amp DC motor with RPi Pico

Thu Apr 22, 2021 5:00 am

Hello,

I have a 24v 40amp DC motor I need to control using my RPi Pico. The motor will be connected to a series battery setup to accommodate the voltage and amps required.

Now, I want to be able to switch this motor on/off using some sort of relay or transistor.
Given the high load voltage amps, I am unable to find a suitable Solid State Relay; min required voltages typically exceed the Pico’s 3.3v capacity on the pins. The SSRs also require a max input current around 15ma which makes it difficult to use a DC voltage booster connected to the GPIO pins. These boosters usually have more than 20ma and 5v output.

Here is a SSR line I was considering:
https://www.mouser.com/datasheet/2/657 ... 371031.pdf

I need some recommendations on how to properly and effectively switch the motor. I did some research and it seems maybe a transistor can work but I am unfamiliar with these.

Any help is appreciated and thank you.

gordon77
Posts: 5685
Joined: Sun Aug 05, 2012 3:12 pm

Re: Control a 24v 40amp DC motor with RPi Pico

Thu Apr 22, 2021 6:09 am

I would expect the max input current is the maximum it will draw , it will take what it needs, so providing up to 20mA from the booster won't be a problem.

VitalSpark
Posts: 51
Joined: Fri Dec 11, 2020 12:14 pm

Re: Control a 24v 40amp DC motor with RPi Pico

Thu Apr 22, 2021 6:50 am

Chain relays.

Use a 3.3v relay say capable of handling a couple of amp across its contacts. Use the NO contacts to energise a second relay that's capable of taking the 24v40a load.

May be worth your while fitting a flyback diode on the second relay coil to protect the first relay contacts.
There are only 10 types of people in the world: Those who understand binary, and those who don’t!

ghp
Posts: 1970
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany
Contact: Website

Re: Control a 24v 40amp DC motor with RPi Pico

Thu Apr 22, 2021 6:56 am

schema.png
schema.png (26.51 KiB) Viewed 1010 times

vm_exists
Posts: 27
Joined: Thu Mar 04, 2021 7:03 pm

Re: Control a 24v 40amp DC motor with RPi Pico

Thu Apr 22, 2021 7:32 am

ghp wrote:
Thu Apr 22, 2021 6:56 am
schema.png
Interesting. So basically the transistor here will use the battery to also power the SSR? Most of the SSRs for these requirements need at least 3.5v to switch. The listed transistor is obsolete, can I use let’s say https://www.adafruit.com/product/355

User avatar
rpdom
Posts: 18725
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Control a 24v 40amp DC motor with RPi Pico

Thu Apr 22, 2021 7:40 am

You don't need anything as chunky as the transistor you listed.

The SSR isn't going to need a lot of current to drive it, so pretty much any general purpose NPN will work. The PN2222A is still available and common, it is the plastic case version of the 2N2222.
Unreadable squiggle

ghp
Posts: 1970
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany
Contact: Website

Re: Control a 24v 40amp DC motor with RPi Pico

Thu Apr 22, 2021 10:10 am

The SSR you mentioned in the link needs "Minimum Turn-On Voltage" 3.5V with additional margin needed when cold. The pico GPIO run at 3.3V, could work, but may also fail. The transistor allows to use the battery voltage for the input of SSR, just be sure battery is not more than 32V,

drgeoff
Posts: 11942
Joined: Wed Jan 25, 2012 6:39 pm

Re: Control a 24v 40amp DC motor with RPi Pico

Thu Apr 22, 2021 10:45 am

Think about how the starter motor in a car is turned on and off.
Quis custodiet ipsos custodes?

gordon77
Posts: 5685
Joined: Sun Aug 05, 2012 3:12 pm

Re: Control a 24v 40amp DC motor with RPi Pico

Thu Apr 22, 2021 1:33 pm

ghp wrote:
Thu Apr 22, 2021 6:56 am
schema.png
I think I'd connect pin1 from the U1 SSR to 5v from the pico, to give full opto isolation. You may need a resistor in series to limit current.
Last edited by gordon77 on Fri Apr 23, 2021 5:41 am, edited 2 times in total.

lars_the_bear
Posts: 204
Joined: Thu Jan 28, 2021 8:13 pm
Contact: Website

Re: Control a 24v 40amp DC motor with RPi Pico

Thu Apr 22, 2021 1:34 pm

There's a stack of power MOSFETs that will switch 40A with relative ease, and they aren't expensive, and come in modestly-sized TO220 cases. Vishay SUP60N10 is one example, but there are many others. You'll need a bit of heatsinking, but probably not much if you're only switching occasionally.

The problem with parts like this is that they really, really, really have to be turned fully on, to get the low drain-source resistance that is needed to prevent overheating. The ~3V or so of a Pico GPIO won't come even close to turning one of these devices fully on. It's possible to get "logic level" power MOSFETs, that are designed to turn fully on with a 5V gate voltage, but I don't know if there are any that will handle 40A continuously.

Consequently, circuits like the one shown here are widely used:

https://quadmeup.com/raspberry-pi-mosfe ... er-switch/

If you're running with a 24V motor, you already have a supply capable of switching the MOSFET gate properly -- in fact, you might have to divide this down because a gate-source voltage of 24V will probably be too much for most MOSFETs.

Relays that can switch 40A are widely available, but be careful that you're looking at relays with a 40A _DC_ rating. Most have lower ratings for DC than AC, for boring reasons that I can explain if anybody's interested.

The problem with a relay is that you won't be able to do speed control with it. With a MOSFET you can do speed control using PWM.

If you want something ready-made, with a handy I2C interface, specifically designed for Raspberry Pi logic levels, I can recommend this:

https://www.piborg.org/motor-control-1135/diablo

I've used their power control products a bit for robotic stuff, and they work quite nicely. The Diablo is a bit pricey, though -- overkill, perhaps, if you just want to switch the motor on and off.

Kevin

vm_exists
Posts: 27
Joined: Thu Mar 04, 2021 7:03 pm

Re: Control a 24v 40amp DC motor with RPi Pico

Thu Apr 22, 2021 4:40 pm

Thank you everyone this is very helpful.

Just a bit of context...I only need to switch the motor on to full power and don't need speed or direction control. Simple full power on and off.

For short durations will the pn2222a need a heatsink?

For production, can these through hole transistors work by soldering onto PCB or go surface mount and add a small heatsink for safety?

ghp
Posts: 1970
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany
Contact: Website

Re: Control a 24v 40amp DC motor with RPi Pico

Thu Apr 22, 2021 6:20 pm

No need for a heatsink.
You can place the transistor and resistor on a pcb or a perfboard as shown here https://www.instructables.com/Breadboard-to-Perfboard/

If you power your pico from a stable 5V supply, then follow gordon77's advice to power the SSR high side from 5V instead from the battery.

vm_exists
Posts: 27
Joined: Thu Mar 04, 2021 7:03 pm

Re: Control a 24v 40amp DC motor with RPi Pico

Thu Apr 22, 2021 9:45 pm

ghp wrote:
Thu Apr 22, 2021 6:20 pm
No need for a heatsink.
You can place the transistor and resistor on a pcb or a perfboard as shown here https://www.instructables.com/Breadboard-to-Perfboard/

If you power your pico from a stable 5V supply, then follow gordon77's advice to power the SSR high side from 5V instead from the battery.
I am going to power the RPI from the same 24v source battery using a step-down/buck. I am getting a stable 5v using the buck right now and enough amps for everything else attached to it.

I will figure out if I can use a separate 5v supply for the Pico based on my use case, but what are the risks of using the same 24v supply to power the Pico using a buck at stable 5v?

Also, will the PN2222A support the minimum 10ma required from the SSR for on state? I believe it supports 600ma if I am not mistake?

https://www.digikey.com/en/products/de ... A/11655004

gordon77
Posts: 5685
Joined: Sun Aug 05, 2012 3:12 pm

Re: Control a 24v 40amp DC motor with RPi Pico

Fri Apr 23, 2021 6:09 am

The PN2222 , or any similar eg BC547C, will be fine.

ghp
Posts: 1970
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany
Contact: Website

Re: Control a 24v 40amp DC motor with RPi Pico

Fri Apr 23, 2021 6:31 am

I am going to power the RPI from the same 24v source battery using a step-down/buck. I am getting a stable 5v using the buck right now and enough amps for everything else attached to it.

I will figure out if I can use a separate 5v supply for the Pico based on my use case, but what are the risks of using the same 24v supply to power the Pico using a buck at stable 5v?
To make things simple: the SSR provides opto isolation internally and if you would have separate power supplies then it would be a good idea to keep the things separate.
As you already power the pico from a buck converter, you have the choice to take high side of SSR input fromeither 5V of the pico or the + pole of the battery. I'd propose then to use the 5V of the pico. Reason is that there is only one Vcc-Line close to the pico, making wiring simpler.
Also, will the PN2222A support the minimum 10ma required from the SSR for on state? I believe it supports 600ma if I am not mistake?
The 600mA are the max possible load the transistor can provide without damage. It is no problem to operate the transistor at lower currents. (remark on this: transistors capable of handle high currents are usually more expensive, need more space and quite often need more elaborate driving circuitry. So usually the 'best fit' device is used. The 2N2222 is a common small signal/ switching transistor and suitable for this application).

A comment on the battery: a charging batteryhas higher voltage than expected. So have a look at your buck converter that it is able to handle the max voltage with some safety margin. (If you operate things in a vehicle things are even worse.)

vm_exists
Posts: 27
Joined: Thu Mar 04, 2021 7:03 pm

Re: Control a 24v 40amp DC motor with RPi Pico

Wed May 12, 2021 12:43 am

Thank you everyone again. I seem to be having some issues. I hooked the relay to a 24v LED to test the switching using my RPI 4 (Not PICO yet). Using the 3.3v GPIO, I can't seem to get it to switch. The LED also is just permanently on/lit using the recommended wiring.
Please see image of wiring and code below. When GPIO.output(2, False). I get 25v reading on the transistor pin 3 using my meter. And when TRUE, 0v.

Code: Select all

  

import RPi.GPIO as GPIO
import time

GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)

#LED
GPIO.setup(2,GPIO.OUT)
GPIO.output(2, False)

while True:
 
    GPIO.output(2, True)
    time.sleep(2)
    GPIO.output(2, False)
    
Wiring image attached.
Attachments
wiring.png
wiring.png (42.02 KiB) Viewed 636 times

danjperron
Posts: 3790
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: Control a 24v 40amp DC motor with RPi Pico

Wed May 12, 2021 3:06 am

@vm_exists

The 2N2222 switch the signal to ground! On your schematic you have the input of your SSR inverted.

The collector of the transistor needs to be on the negative input! Pin #4 and the +24 should be on Pin #3

User avatar
davidcoton
Posts: 6258
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK
Contact: Website

Re: Control a 24v 40amp DC motor with RPi Pico

Wed May 12, 2021 9:00 am

danjperron wrote:
Wed May 12, 2021 3:06 am
@vm_exists

The 2N2222 switch the signal to ground! On your schematic you have the input of your SSR inverted.

The collector of the transistor needs to be on the negative input! Pin #4 and the +24 should be on Pin #3
Relay module output is also reversed. :!:
Location: 345th cell on the right of the 210th row of L2 cache

BillTodd
Posts: 2
Joined: Sat Apr 17, 2021 11:01 am

Re: Control a 24v 40amp DC motor with RPi Pico

Wed May 12, 2021 11:58 am

You might want to isolate and screen your ground paths, 40A pulsed will likely cause considerable interference and could trip up your pico.

Bill

danjperron
Posts: 3790
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: Control a 24v 40amp DC motor with RPi Pico

Wed May 12, 2021 12:53 pm

@Bill good catch. I just look at the input , found a problem and stop there.


N.B. Please you really need a heatsink on this SSR. At least < 2C/W

vm_exists
Posts: 27
Joined: Thu Mar 04, 2021 7:03 pm

Re: Control a 24v 40amp DC motor with RPi Pico

Wed May 12, 2021 3:43 pm

I followed what GHP posted earlier in the forum, unless if I misread something.

Is it possible someone can please post a rough wiring diagram just so I am clear. I would hate to destroy another pi. And as far as a heatsink, the runtime for the 40amps to motor, will only be about 2 minutes once a month at most. So this will not be running very much at all. Will I still require a heatsink nonetheless?

Thank you very much.

danjperron
Posts: 3790
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: Control a 24v 40amp DC motor with RPi Pico

Wed May 12, 2021 4:26 pm

40A_SSR.png
40A SSR
40A_SSR.png (17.71 KiB) Viewed 508 times
My schematic is a little bit different since I isolate the Pi from the 24VDC.

Also you will need a big diode to counteract de back emf from the motor. at least a 10A diode.
the diode are inside the PDF document page 2. It is needed for any inductive load.

2 min is long on electronic. I got some transistors burned in less than 5 sec.
Maybe screw the SSR on a big metallic plate.

vm_exists
Posts: 27
Joined: Thu Mar 04, 2021 7:03 pm

Re: Control a 24v 40amp DC motor with RPi Pico

Wed May 12, 2021 7:22 pm

Ok thank you. I will eventually be using this using a RPi Pico which is limited to 3.3v (the RPI4 was just for testing), which is why I wanted to use the 24v source to trigger the SSR. The SSR needs at least 3.5v to engage. I do have a step down converter for the 24v to 5v to power the Pico and there was a suggestion to use that as well. I am curious if there are other ideas to trigger these relays. Unfortunately there are not many options for SSRs capable of high voltage and high amps and trigger with 3.3v. I do not think there is any other efficient way to trigger this 24v 40amp motor using Pico, and why I though this SSR would work.

I assume using step down buck or 24v direct source changes how this should be wired. Will it still require a fly back diode also?

danjperron
Posts: 3790
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: Control a 24v 40amp DC motor with RPi Pico

Wed May 12, 2021 10:56 pm

If you are using a step down regulator from 24v to 5v then you have your 5v to trigger your SSR with a pico.

Yes the diode is needed!

vm_exists
Posts: 27
Joined: Thu Mar 04, 2021 7:03 pm

Re: Control a 24v 40amp DC motor with RPi Pico

Thu May 13, 2021 1:28 am

danjperron wrote:
Wed May 12, 2021 10:56 pm
If you are using a step down regulator from 24v to 5v then you have your 5v to trigger your SSR with a pico.

Yes the diode is needed!

Ok so in the diagram you have, instead of "RPI 5v" it would be be "buck 5v" and the rest should be the same? Thank you.

Lastly would you please point me to a proper flyback diode? Maybe on Digikey, Mouser, Amazon.

Return to “General”