tinkernick
Posts: 20
Joined: Thu Jan 10, 2013 5:10 pm

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

Thu May 13, 2021 5:37 am

regardless of any wiring/circuit issues the code you have posted would create the impression the motor was always on as it does not delay after setting the pin to false, it will loop round and set it to true again almost immediately.

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

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

Fri May 14, 2021 7:02 pm

Ahh the code snippet was cutoff in my post. Nonetheless I am not worried about the code, I that was just testing purposes. Of course there will be time delays and conditionals for my use case. I just need to make sure the wiring suggestions are correct and a recommendation for a flyback diode.

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

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

Fri May 14, 2021 7:30 pm

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.
yes!
Lastly would you please point me to a proper flyback diode? Maybe on Digikey, Mouser, Amazon.
Well any rectifier diode will do just check for 100V and more than 10A.
just use digikey and use the filter. I think you will have to go with the TO-220 case.

Something like that one.
15SQ100TR digikey #1655-1355-1-ND .

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

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

Thu May 27, 2021 12:58 am

danjperron wrote:
Fri May 14, 2021 7:30 pm
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.
yes!
Lastly would you please point me to a proper flyback diode? Maybe on Digikey, Mouser, Amazon.
Well any rectifier diode will do just check for 100V and more than 10A.
just use digikey and use the filter. I think you will have to go with the TO-220 case.

Something like that one.
15SQ100TR digikey #1655-1355-1-ND .
Thanks again danjperron and thank you everyone, this worked excellent and I appreciate the recommendations.

joeyb197
Posts: 11
Joined: Tue Aug 15, 2017 10:56 pm
Location: Québec, Québec, Canada

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

Fri Jun 11, 2021 6:57 pm

Hello, sorry to reopen the post,

I am a beginner with RPi and electronic in general, so maybe my question is kinda dumb.. but why would I need a transistor AND a relay given the transistor specs (can switch up to 60A and 30V with a 3.3V tension)

--> https://www.adafruit.com/product/355

Thanks in advance for any answer!

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

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

Fri Jun 11, 2021 8:34 pm

This is another possibility.

The SSR will have the same type of mosfet inside. It has more stuff to protect and it is enclose!

Advantage of the SSR.

- Bulky format! Easy to connect to Heatsink.
- If it failed you just need a screwdriver to replace it.
- it uses an optoisolator then it isolates output from input.


And the mosfet.

- Small format.
- Really need a good heatsink and special care to isolate the drain to the heatsink.
- Gate pin is not isolated . If the mosfet burns it is possible that the gate will go HIgh voltage.!!!!!!!
- Need to solder wire and not very long. For a professionnal job you need a PCB or very short wire with heat shrink tubing.
- If it failed than you need to unsolder and solder again.

I.M.O. the SSR assure you that you wont broke your pi be inadvertently. If you are an expert than go with a mosfet.

joeyb197
Posts: 11
Joined: Tue Aug 15, 2017 10:56 pm
Location: Québec, Québec, Canada

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

Sat Jun 12, 2021 7:06 pm

danjperron wrote:
Fri Jun 11, 2021 8:34 pm
This is another possibility.

The SSR will have the same type of mosfet inside. It has more stuff to protect and it is enclose!

Advantage of the SSR.

- Bulky format! Easy to connect to Heatsink.
- If it failed you just need a screwdriver to replace it.
- it uses an optoisolator then it isolates output from input.


And the mosfet.

- Small format.
- Really need a good heatsink and special care to isolate the drain to the heatsink.
- Gate pin is not isolated . If the mosfet burns it is possible that the gate will go HIgh voltage.!!!!!!!
- Need to solder wire and not very long. For a professionnal job you need a PCB or very short wire with heat shrink tubing.
- If it failed than you need to unsolder and solder again.

I.M.O. the SSR assure you that you wont broke your pi be inadvertently. If you are an expert than go with a mosfet.

Okay, I understand that!

But I don't seem to find any SSR that could deliver a 12V 40A current like I personally need that can be activated by a 3.3V GPIO, thus the transistor, is that it?

Adding to that, could I use an automotive relay instead of a SSR? It's far less expensive and I have a lot of them. I tried to activate one with a 3.3V GPIO but it wouldn't work with a voltage under 9V.

I was looking for a SSR on digikey, and I couldn't seem to find one that could fit correctly for a "descent" price. When buying a SSR, if I need to supply from a car battery a 12V 40A current through the relay, should I aim for a voltage input of for example 12V (if it is activated by the car battery that is itself "activated" by the transistor) a voltage load of 12V and a load current of 40A? Or should I aim higher for security purpose? I'm not sure that I understand all these cryptic specs.


My schema would look like this
Capture d’écran, le 2021-06-12 à 15.01.17.png
Capture d’écran, le 2021-06-12 à 15.01.17.png (125.14 KiB) Viewed 716 times
ghp wrote:
Thu Apr 22, 2021 6:56 am
schema.png
but I'd put if possible an automotive relay (192D -> https://www.truck-lite.com/192d-1.html) instead of a SSR and my transistor would be that one :

https://www.digikey.ca/en/products/deta ... k-pRQgalXC

with a 12V 40A AC motor.

From the others schema, I saw also the need for a diode. I'd buy this one :

https://www.digikey.ca/en/products/deta ... sPqWbsjSst

I am unsure of what I am doing to be honest. I am only beginning in this world and I am trying to learn a lot at the same time!
Last edited by joeyb197 on Sat Jun 12, 2021 8:37 pm, edited 1 time in total.

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

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

Sat Jun 12, 2021 8:20 pm

One of the features of an opto-isolated SSR is, of course, isolation, There is complete separation of the Pico and its GPIO from the high voltage high current world. If you have to use the motor supply to switch on the LED in the opt-isolator, that isolation is gone, and you have lost any advantage that the opto-isolator gave you.
You could use a low-power opto-isolator to drive a 12V switching element (MOSFET, relay, etc) to regain the isolation. Remember, the aim is a circuit with no path for the higher voltage to reach the Pico. If you get it right, you don't have to link the 0V across the opto-isolator either.

EDIT: Pico not Pi in this topic!
Last edited by davidcoton on Sat Jun 12, 2021 10:27 pm, edited 1 time in total.
Location: 345th cell on the right of the 210th row of L2 cache

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

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

Sat Jun 12, 2021 8:50 pm

On the mosfet chart, fig 3. , the max current is ~20..30A, so you will need to increase the gate voltage. Use MIC4422 from microchip.

Now the power consumption.

ON page 1.

Junction to case 2.3 C/W
Junction to ambiant 62C/W
Junction to sink 0.5 C/W
Operating junction Temperature (-55 to 175C). Hum I Normally calculate max temp to 125C

So 40A could not pass over 125C. My safe Temp.

Calculated from 25C ambiant. 40A * 0.5VDC ( check Figure 2). = 20W then

(125C - 25) = 20W( 2.3 + 0.5 + heatsink)
Then heatsink should be less than

100/20 - 2.3 - 0.5


Then you really need an heatsink less than 2.2C/W. If you could put a 1.5C/W


Because of the MIC4222 you could put an opto isolator. I calculate for static . If you pulse the signal then it is something else.
The MIC4422 will help to force the Gate to be high very fast otherwise the heat will kill the mosfet if the switch is too slow or it is not saturated.

joeyb197
Posts: 11
Joined: Tue Aug 15, 2017 10:56 pm
Location: Québec, Québec, Canada

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

Sat Jun 12, 2021 8:58 pm

davidcoton wrote:
Sat Jun 12, 2021 8:20 pm
One of the features of an opto-isolated SSR is, of course, isolation, There is complete separation of the Pi and its GPIO from the high voltage high current world. If you have to use the motor supply to switch on the LED in the opt-isolator, that isolation is gone, and you have lost any advantage that the opto-isolator gave you.
You could use a low-power opto-isolator to drive a 12V switching element (MOSFET, relay, etc) to regain the isolation. Remember, the aim is a circuit with no path for the higher voltage to reach the Pi. If you get it right, you don't have to link the 0V across the opto-isolator either.
Could a 10A diode isolate the pi from any high voltage just fine?

I'm still not sure to understand quite well how to use these components. I just read on the opto-isolator like 10 mins ago!

I understand that what I am trying to do will probably work, but it may not be the safest, maybe because of the mechanical relay instead of any other SSR.

I don't understand how the pi might be subject to high voltage with, for example, only a transistor, if the pi is only connected to the base while the 12V is only connected to the emitter and the collector?

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

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

Sat Jun 12, 2021 9:02 pm

Could a 10A diode isolate the pi from any high voltage just fine?
No . You need to prevent Voltage lower than 0V and higher than 3.3V.

Like I said the MIC4422 could limit since you could put a high value resistor with a zener or a diode connect to 3.3V. But I.M.O. Opto is the best.

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

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

Sat Jun 12, 2021 10:25 pm

joeyb197 wrote:
Sat Jun 12, 2021 8:58 pm
I don't understand how the pi might be subject to high voltage with, for example, only a transistor, if the pi is only connected to the base while the 12V is only connected to the emitter and the collector?
Normally, it's safe. If the transistor should fail with a collector-base short (not unknown), it's Bye Bye Pico.
Opto-isolators are unlikely to fail in an equivalent manner that would kill the Pico.
An opto-isolator also disconnects the two 0V lines, so that's another route blocked for potential (pun intended) problems.
Location: 345th cell on the right of the 210th row of L2 cache

joeyb197
Posts: 11
Joined: Tue Aug 15, 2017 10:56 pm
Location: Québec, Québec, Canada

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

Mon Jun 14, 2021 12:09 pm

The way I read and understand it, I should prioritize an opto and by doing so, I simplify a lot the final circuit. Could I stick to an opto and Bob's your uncle or I have to use a MIC4422 to drive the MOFSET that will then drive the opto and then add a 1.5C/W heat sink like @danjperron told me about? That's the part I'm not sure I understand. I think I understand how ton use every components we are talking about (while not being 100% sure) but I'm not sure if these are alternatives or if I have to use all of these for the circuit to work properly.

While talking about opto's, do you have any recommendation?

N.B. I'm using a RPi 4B to drive all of this, don't know if this simple fact could somehow help the case :?:

Thanks a lot!

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

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

Mon Jun 14, 2021 2:10 pm

The first step is to test it without High power. Something like 1A or 2A to see if everything works.

Good chance that an opto coupler alone could drive the mosfet without the use of the MIC4422.


You have this kind of shield using the ILD213T.
https://www.sparkfun.com/products/9118
https://www.vishay.com/docs/83647/ild205t.pdf

Then you could power the transistor side with 12V on collector and use the emitter on the gate with a 4K7 resistor to ground. On the Pi side limit the GPIO current to ~10 ma with a 220Ω resistor in series to GPIO.

This is a schematic (not base on sparkfun shield)
mosfet1.png
mosfet opto
mosfet1.png (7.13 KiB) Viewed 586 times
If you are using 24V then use two 4k7 and put the gate in center tap (between the two resistor to limit the gate voltage at 12V).

For the sparkfun shield you will need to provide VH lower than 20V because it is the VGS maximum of the mosfet. use a 12 V regulator.

P.S. when you do a first design , it is always good to buy extra components! ;-)

B.T.W. I assume that 40A is the maximum current of the load. For a motor this is when it goes from off to ON. The startup current could be 5X more at startup. Motor driver have some current limits to prevent over current at start. This design has nothing then if the motor is jammed there is nothing to prevent high current

joeyb197
Posts: 11
Joined: Tue Aug 15, 2017 10:56 pm
Location: Québec, Québec, Canada

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

Mon Jun 14, 2021 4:04 pm

danjperron wrote:
Mon Jun 14, 2021 2:10 pm
The first step is to test it without High power. Something like 1A or 2A to see if everything works.

Good chance that an opto coupler alone could drive the mosfet without the use of the MIC4422.


You have this kind of shield using the ILD213T.
https://www.sparkfun.com/products/9118
https://www.vishay.com/docs/83647/ild205t.pdf

Then you could power the transistor side with 12V on collector and use the emitter on the gate with a 4K7 resistor to ground. On the Pi side limit the GPIO current to ~10 ma with a 220Ω resistor in series to GPIO.

This is a schematic (not base on sparkfun shield)
mosfet1.png

If you are using 24V then use two 4k7 and put the gate in center tap (between the two resistor to limit the gate voltage at 12V).

For the sparkfun shield you will need to provide VH lower than 20V because it is the VGS maximum of the mosfet. use a 12 V regulator.

P.S. when you do a first design , it is always good to buy extra components! ;-)

B.T.W. I assume that 40A is the maximum current of the load. For a motor this is when it goes from off to ON. The startup current could be 5X more at startup. Motor driver have some current limits to prevent over current at start. This design has nothing then if the motor is jammed there is nothing to prevent high current

:D I think I understand pretty well with the schema! Wonderful!
Knowing that my AC motor is 40A and 12V, I won't need a 12V regulator, am I right? And only one 4k7 resistor between the gate and the ground.

I ordered
https://www.sparkfun.com/products/9118
https://www.digikey.ca/en/products/deta ... k-pRQgalXC
https://www.digikey.ca/en/products/deta ... sPqWbsjSst
https://www.digikey.ca/product-detail/e ... =367925558
https://www.digikey.ca/product-detail/e ... =367955725

And waiting for the order to arrive! I'll try this out and come back with the results!

I'm confident it'll work! Thanks again for all your answers guys!

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

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

Mon Jun 14, 2021 4:29 pm

Knowing that my AC motor is 40A and 12V
AC motor????
No this is for DC motor. AC motor is another beast!!!!

joeyb197
Posts: 11
Joined: Tue Aug 15, 2017 10:56 pm
Location: Québec, Québec, Canada

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

Mon Jun 14, 2021 4:52 pm

Good thing I waited for an answer before pressing "order" then !

I think it's an AC motor, but I'm not totally closed to buy a DC motor with similar specs if it's too complicated to make it work with an AC motor!

Tbh I re-read the thread title and just notice the DC. I've been looking at this thread for hours and always thought all of this was about an AC motor, that's kinda embarrassing if you ask me :| ahahah

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

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

Mon Jun 14, 2021 5:43 pm

joeyb197 wrote:
Mon Jun 14, 2021 4:52 pm
I think it's an AC motor, ... I re-read the thread title and just notice the DC.
Probably best to check and come back to us.
Location: 345th cell on the right of the 210th row of L2 cache

joeyb197
Posts: 11
Joined: Tue Aug 15, 2017 10:56 pm
Location: Québec, Québec, Canada

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

Mon Jun 14, 2021 6:06 pm

I've checked and it's a DC motor, which means I made an error but it didn't change anything, phew!

joeyb197
Posts: 11
Joined: Tue Aug 15, 2017 10:56 pm
Location: Québec, Québec, Canada

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

Sun Jun 20, 2021 7:10 pm

I've received my components and tried it. It seems that I indeed have 12V at the exit of the SparkFun Shield and at the Gate of the MOFSET, but right at the exit of the MOFSET, the tension drops to 0.3V which isn't enough to switch the power inverter that is suppose to switch on and off the motor.

I will try again from scratch just to see if I did something wrong the first time.

Also, I kind of can't put a diode on the motor directly, because I need to be able to invert the motor. Is it correct if I put it like, in series between the MOFSET and the power invertor?

I changed the plan for now. I tried with a 5V mechanical relay that I slightly modified.

The relay : https://www.amazon.ca/gp/product/B07K2W ... UTF8&psc=1

I've unsoldered the middle resistor on this relay and replaced it with another one in order to be able to switch the relay with my 3.3V GPIO despite the 5V requirements. It seems to work very well, and I may just use this relay cascade (5V relay switching a 12V relay switching a power inverter powering the motor) but I'd like to know how safe this solution is in reality, because it seems to me that it could potentially fry my raspberry in a heartbeat.

Do you guys think I should keep the relay cascade and just add like a diode or something to protect my pi?

Thanks a lot!

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

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

Mon Jun 21, 2021 9:44 am

Draw out your schematic and post it here.

If your relay is opto coupled then it should be fine if wired correctly and supplies isolated. Why do you need a 2nd relay ?
Last edited by gordon77 on Mon Jun 21, 2021 5:59 pm, edited 1 time in total.

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

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

Mon Jun 21, 2021 5:41 pm

the tension drops to 0.3V which isn't enough to switch the power inverter that is suppose to switch on and off the motor.
I look back t the post and it was never question about an inverter which drive a motor.

0.3V drop this is it! The mosfet won't go to 0V! Check figure 2 page 3, I already told you about it!,
https://www.infineon.com/dgdl/irlb8721p ... 6056732591

Loosing 0.3V on a 12V supply at 40A. You will have more loss on the wire itself. What is your wire gauge?
A picture of your setup will help.

joeyb197
Posts: 11
Joined: Tue Aug 15, 2017 10:56 pm
Location: Québec, Québec, Canada

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

Wed Jun 23, 2021 1:43 pm

As it is for the moment, the project had to be paused for a couple of days. I'll upload a schematic and a picture of the circuit ASAP when I'll be able to get back in it. Thanks a lot for your help guys! It is very kind!

Return to “General”