Arduino 48V PWM Motor Speed Controller Questions

Hello,
This will be my first project working with a DC motor. Actually it seem pretty simple seeing as how the code is so easy to find but I’m not too sure about the actual wiring. I made up a schematics of the way I think it could be wired after looking at what other people were doing. I’d really appreciate if I could get some feed back about the way I will have it wired. I have posted the code and the schematics here so have a look. I’ll be ordering a few IRLZ44 mosfets if they will work for my motor. I ran the motor I have on a 12 volt utility battery and my amp meter showed it was consuming about 4 to 5 amps. I plan on running the motor on 48 volts so the amp draw should be really low with the higher voltage.
I wired up the circuit with a small pn2222 NPN transistor and it work good to dim an led so I’m thinking all is well with the code.
Any help will be really appreciated.
Thanks
jessey

Arduino PWM motor speed controller code.txt (588 Bytes)

The capacitor of 220uF across the motor terminals is utterly wrong, replace by a 100V 0.1uF ceramic disc
at most.

You should replace the 2k2 gate resistor with 150 ohms so the MOSFET has faster switching.

Otherwise its plausible single-quadrant motor driver. If your supply is going to be 48V then you
need:

Probably a higher voltage rating for the MOSFET - 80 or 100V

A 5.1V 1W3 zener across the gate-source terminals of the MOSFET to prevent capacitively
coupled spikes taking the gate voltage out of safe range. If the drain is switching between 0 and 48V it
doesn’t take much coupling to overwhelm the 150 gate resistor and overvoltage the Arduino pin and/or
puncture the MOSFET gate oxide.

Thanks MarkT,

I really appreciate your time and attention to the details of my circuit in your comments. I think I have addressed all your concerns and have since reflected the changes in the schematics here as well, could please you have a look at the updated schematics to see that I didn’t miss anything? I looked at quite a few Mosfets on the net and did make notes of a couple of Mosfets that have a higher voltage rating but there are so many of them available and not being an electronics engineer it’s hard for me to determine exactly what I need but as far as voltage ratings these two below are rated for 100 V. Do you think one of these Mosfets are up to the task?

https://www.digikey.ca/product-search/en?keywords=FDP3651
Drain to Source Voltage (Vdss) 100V Current -
Continuous Drain (Id) @ 25°C 80A
(Tc) Rds On (Max) @ Id, Vgs 18 mOhm @ 80A,
10V Vgs(th) (Max) @ Id 5.5V @ 250µA

https://www.digikey.ca/product-detail/en/IRF3710ZPBF/IRF3710ZPBF-ND/811260
Drain to Source Voltage (Vdss) 100V Current -
Continuous Drain (Id) @ 25°C 59A
(Tc) Rds On (Max) @ Id, Vgs 18 mOhm @ 35A,
10V Vgs(th) (Max) @ Id 4V @ 250µA

This variable speed circuit will be used as part of a heavy duty Welding Positioner my partner and I are building. I won’t know what kind of problems welding will pose to the speed controller circuit but I guess time will tell. Would you or anyone else here have any insight on that?

I’ll post some pictures of the Welding Positioner in a few days. It’s definitely been an interesting project to get together.

Thanks
jessey

The 1N4728A is a 3.3V zener - you need 5.1 or 5.6V zener or the mosfet won't turn on properly. Neither the FDP3651 or IRF3710 are logic level and won't work - you must use a logic level MOSFET if driving the gate at only 5V, otherwise you must use at least 10V.

You diagram doesn't distinquish between motor high current ground and Arduino ground - you need to ensure the high current paths don't go across the delicate parts of the circuit.

You also need to pay attention to layout which isn't given in a circuit diagram. High current wiring is usually best as twisted pair. The leads to source and gate from the Arduino should also be twisted pair or very short. Avoid loose wiring with big open loops as they give and receive magnetic interference (by induction)

You are drawing earth symbols instead of ground symbols. Earth means mains protective earth, which isn't the case here.

Thanks Mark,

I have updated my schematics again to reflect your concerns and it should be correct this time, hopefully. Except for the grounds that I don’t quite understand? I have to join the grounds of the two power supplies together in order for the mosfet to be able to turn on, I don’t know of any other way to accomplish that? I have now distinguished the high current ground in my schematic but I have never seen what I did in my schematics done on any other schematics, I would really appreciate any insights you have on that. Also how would I ensure the high current paths don’t go across the delicate parts of my circuit?

Thanks Again
jessey

jessey: I ran the motor I have on a 12 volt utility battery and my amp meter showed it was consuming about 4 to 5 amps. I plan on running the motor on 48 volts so the amp draw should be really low with the higher voltage.

Are you sure?

I would expect the current to be much HIGHER with a 48V supply.

Hi John,

Your absolutely right, the amperage did increase when I increased the voltage. I had 3 - 12 volt batteries hanging around the shop so I was able to get up to 36 volts for testing.

12 volts = 2.3 amps 24 volts = 3.6 amps 12 volts = 4.0 amps

This paragraph below is part of what I read on a site that sells motors for electric vehicles:

In an electric vehicle the motive power comes from the battery. Electrical power is volts multiplied by amps so that 40 amps drain from a 12v battery is 480 watts. But 480 watts is also given from a 24v battery by a current of only 20 amps. Therefore, for a particular power, the higher the voltage, the lower the current. --- Here is the URL for this paragraph: http://www.4qd.co.uk/faq/bmnc1.html

There's a lot more to this than I can understand at this time, I'm guessing there are a lot of factors that come into play to figuring it out. When I get my variable speed controller built then I'll know what the current is at 48 volts and it'll definitely be higher. I guess running the motor on the higher voltages will allow the motor to run cooler if the above statement is true according to those guys that wrote the paragraph above.

Thanks for bringing that to my attention. jessey

jessey: This is wrong... 12 volts = 2.3 amps 24 volts = 3.6 amps 12 volts = 4.0 amps

I made a mistake in my last post and just noticed it. The above should be:

12 volts = 2.3 amps 24 volts = 3.6 amps 36 volts = 4.0 amps

jessey

I was going to say "yes, that looks good to go", then I saw the -48V rail.

Do you mean -48V?

MarkT:
I was going to say “yes, that looks good to go”, then I saw the -48V rail.

Do you mean -48V?

Hi MarkT,

I’m not sure what you mean by rail? But yes it is typed as -48V. Like I said in my post: “I have to join the grounds of the two power supplies together in order for the mosfet to be able to turn on”.

I have been looking for what others are doing and I found one post where a guy was asking about using an optoisolator. I’m thinking that would definitely isolate the high voltage to save my arduino mega in case of a malfunction. The guy did make up a schematics which I’m including here for you to have a look at to see what you think. I’m wondering if I should be including an opto in my circuit?

Thanks Again
jessey

Optoisolator Motor Speed Controller Circuit.jpg

-48V is 48 volts below ground. You meant 0V, GND or 48V(-)

You can get opto-isolated gate drivers, standard opto-isolators may be too slow and weedy to switch a MOSFET gate for high power use (the switch off time is dominated by the photo-transistor charge-storage delay). Are you wanting PWM or just on/off?

How much power are you controlling BTW? In particular can vast currents flow in stall conditions and risk popping the MOSFET? In those circumstances you would want more protection circuitry (probably a gate driver chip with resitor/zener clamp on its logic input, or opto-isolated)

Hello Again MarkT,

MarkT:
Are you wanting PWM or just on/off?

Yes I will be using the PWM on my Arduino Mega.

MarkT:
How much power are you controlling BTW?

My motor was using 4 amps at 36 volts DC so I’m assuming it’ll probably be around 6 or so amp draw at 48 volts DC. I’ll know better when I get my 48 volt DC power supply delivered.

MarkT:
In particular can vast currents flow in stall conditions and risk popping the MOSFET?

I can’t foresee the motor stalling but it’s better to err on the side of caution so I’d say yes there is a risk.

I just got word that my digikey order has been delivered to my shop so hopefully I’ll be getting the circuit together later this afternoon with the Stp40nf10l Power Mosfet Logic N-channel 100V 40a. So now I have all the components that’s required to follow my latest schematics here and see it working, hopefully without any problems.

I would like to have the added protection of an opto for my circuit and like you suggested I’ll use a gate driver chip. I managed to find a fairly inexpensive MOSFET gate drive optocoupler part #IX3180 and digikey has some in stock and they are fairly inexpensive. There are a lot of these opto isolators with specs I don’t understand out there and I’d really appreciate it if you could recommend a chip if this one I found isn’t suitable.

Hopefully I’ll get back to you soon with some good news that my circuit is working.

Thanks Again
jessey

jessey: Hopefully I'll get back to you soon with some good news that my circuit is working.

Good & Bad news,

I got the PMW circuit working good on a spare motor we have that is identical to the one that's in the Welding Positioner we're building and although it works good the motor does hum at certain rpm's. It doesn't hum at the very low rpm's or the very high rpm's, it's strange. I'll try it on the actual motor we're going to be running it on in the Welding Positioner tomorrow to see if that motor hums as well. I wonder if the circuit is causing the humming? I guess I'll find out tomorrow...

jessey

Hello Everyone,

I ran my PMW circuit on the welding positioner yesterday and the motor was humming as well the same way it did on the spare motor. The humming is loud but it’s not too loud as the noise coming from the gear reduction, sprockets and chain mask the humming sound but at the very low rpm it is quite noticeable. The motor is a 10 to 50 volt dc brushless motor.

I have a few questions for anyone here that is reading this and cares to comment.

First off does anyone know what could be causing the humming of my motors?

Secondly, Id like to add an optoisolator to my PWM Motor Speed Controller schematics which is included below. MarkT recommended using a gate drive optoisolator and I managed to source one, part #IX3180 but I’m not sure if this one is best suited for my application. Can anyone recommend an optoisolator that stands a good chance of working in my circuit schematics?

Also I’d like to add reversing capabilities to the motor speed control. I did a schematics (the schematics is included below called “Motor Reversing Relay”) using a relay to reverse the motor and I included snubber diodes and caps in the schematics to protect the arduino board. I’m not sure if I have the snubbers wired correctly but it makes sense to me. Does anyone have any comments on this circuit, good or bad?

I’d like to add a normally open momentary push button to reverse the motor and at the same time it would light an led (1 of 2 led’s) to have a visual indication of the motor rotation, one led for clockwise and another led for anti-clockwise rotation. I was thinking I would write code to shut off the motor first before allowing the switching of the rotation. I’ll include the code when I get that portion done.
I’m hoping that someone here is in a position to help…

Thanks In Advance
jessey

Ok,

I tried the relay and it works good by itself to switch the rotation of the motor, I tried it without the snubber diodes and capacitors. I put together another schematics that ties the speed control and the rotation switching schematics together. I think I got it right. I’ll be trying this circuit I uploaded in a few days when I get the time. Can someone (hopefully) have a look at this schematics to see that I doted all the i’s and crossed the T’s or if I missed anything? It would be very much appreciated…

Thanks In Advance
jessey

Humming is the PWM. What PWM frequency are you using? Do you want it to be ultrasonic
so its inadible?

Hi MarkT,

Thanks for getting back to me. The frequency I’m using on pin 9 of my ATmega2560 is the default frequency which is 490 Hz. I did some searching and found this thread which sounds good if I am understanding it correctly.

This URL is where I found the information below: http://forum.arduino.cc/index.php?topic=72092.0

According to what I read the PWM default frequency for the ATmega2560 is 490 Hz for all pins, with the exception of pins 13 and 4 which is 980 Hz.

According to valerio_sperati, I can change the prescaller for pins 10 and 9 to change to the different frequencies that are available. First I have to clear the 3 bits in the prescaller using:

int myEraser = 7;
TCCR2B &= ~myEraser;

now that the prescaller is cleared I can include these two lines of code below to write a new value:

int myPrescaler = 3; // 3 = 490 Hz (default value)
TCCR2B |= myPrescaler;

changing myPrescaler value above from 1 to 6 will change the frequencies to the ones listed below:

prescaler = 1 —> PWM frequency is 31000 Hz
prescaler = 2 —> PWM frequency is 4000 Hz
prescaler = 3 —> PWM frequency is 490 Hz (default value)
prescaler = 4 —> PWM frequency is 120 Hz
prescaler = 5 —> PWM frequency is 30 Hz
prescaler = 6 —> PWM frequency is <20 Hz

So am I correct in thinking that all I have to do is put these 4 lines of code above into the void setup() portion of my sketch and set to whatever frequency I want to try? I’m at home today but will be going to the shop tomorrow to try this new code. I should try it as you suggested at 31000 Hz which would be an ultrasonic frequency and above the frequency humans hear at and hopefully that’ll fix my noise problem. Any insights you have on this subject will be very appreciated especially to hear that I got the code deciphered right.

Also could you have a quick look at the schematics I just uploaded here to see what you think. If you have the time I’d really appreciate it if you could advise me of what optoisolator you would consider to be compatible to isolate the mosfet in the schematics? You had advised me in a previous post that I quoted below:

MarkT:
-48V is 48 volts below ground. You meant 0V, GND or 48V(-)

You can get opto-isolated gate drivers, standard opto-isolators may be too slow and weedy to switch
a MOSFET gate for high power use (the switch off time is dominated by the photo-transistor
charge-storage delay). Are you wanting PWM or just on/off?

How much power are you controlling BTW? In particular can vast currents flow in stall conditions
and risk popping the MOSFET? In those circumstances you would want more protection circuitry
(probably a gate driver chip with resitor/zener clamp on its logic input, or opto-isolated)

In that Post you suggested that I possibly needed a gate driver chip with resistor/zener clamp on its logic input, or opto-isolated. I managed to find a fairly inexpensive MOSFET gate drive optocoupler part #IX3180 and digikey has some in stock and they are fairly inexpensive. There are a lot of these opto isolators with specs I don’t understand out there and I’d really appreciate it if you could recommend a chip if this one I found isn’t suitable.

Thanks
jessey

Arduino PWM motor speed controller code.txt (588 Bytes)

You might find that your MOSFET will get hot if you if you increase the frequency to 31kHz.

When a MOSFET is turned hard on, it doesn't dissipate much power. (low voltage x high current). When it is off, it doesn't dissipate much power either. (high voltage x low current).

However as the MOSFET switches between these two states, it goes through a high power state. (high voltage x high current).

Increasing the frequency causes the MOSFET the heat up more as it spends more time in this high dissipation state, hence the average dissipation increases.

You can overcome this by using a MOSFET driver such as Microchip's TC4422A. (Datasheet here.)

There is lots of useful information in this application note.

Thanks JohnLincoln,

I really appreciate your help with this. I re-did my schematics again to show the mosfet driver wiring I added. I wasn’t sure how to properly wire in the mosfet driver IC but I took a stab at it anyway using the data sheet schematics as a reference. If you could have a look to see what has to be changed in my schematics it would be very much appreciated.

Do you think I should have an optoisolator to feed the 2n3904 transistor as well? I couldn’t find a 5 volt relay with a suitable amp rating but I did have a couple of 12 volt ones with hefty points laying around so I used one.

Thanks Again
jessey

I have the same problem. If you use jessey's circuit, then the advice in front of MARKT is valid. That is, when the TC4422 is used between the MOSFET and the computer input, can a device such as a 150 ohm resistor be useful for the MOSFET? Is jessey's circuit fully implemented without problems?