So I have one of these PWM motor drivers to control the speed on a 12V DC motor.
I would love to figure out how to tap onto this thing and be able to control the speed with the sparkcore instead of manually turning the knob. Does anyone have any hints or suggestions on where I would even start without blowing something up? It took a month to get this thing shipped overseas, so I don’t want to take any unnecessary risks.
There’s got to be an oscillator on that board that varies its pulse width depending on the potentiometer. The trick would be to locate the output of this chip that feeds the MOSFET, cut the trace and add a Spark PWM signal on there. I will also recommend opto-isolating the signal to save the Core from any nasty feedback.
Attach a servo motor to the knob! The least invasive way
So looking at this board more, there is an 8 pin DIP on here that I’m assuming is the oscillator. It looks like any markings have been sanded off. It doesn’t look like there’s an easily accessible path to cut between the oscillator and the mosfets though. The trace between the output of the POT and the oscillator is very easily accessible.
Measuring the output of the POT, it ranges from 0V to 4.42V. So if I could bypass the POT and PWM into the onboard oscillator, that would be an easier solution. I do have some optoisolators that I could use to do that with.
This whole circuit looks so simple though. Maybe I should have just ordered some mosfets and big caps. I’ve never used a mosfet before.
pin 1 is tied to GND
pin 2 is connected to GND via a 6.8 nF ceramic cap (labeled 682).
pin 3 looks like it’s tied to the mosfet’s pin 1 via a 10 ohm resistor. (brown, black, black, gold, brown)
pins 4 and 8 are tied together and are connected to the positive side of a large 1000uf 50v cap and a TO-220 part that I can’t read the part numbers on
pin 6 is connected to the POT
pin 7 is connected to pins 6 and 8 via a 1k ohm resistor? (brown, black, black, brown, brown)
There’s also a MBR30100CT onboard, but I can’t figure out what it’s tied to yet.
I would measure the frequency that pin 3 is switching at, and voltage that it switches to… and mimic that with one of the spark core’s PWM outputs. You can even change the frequency to be whatever you want.
Depending on what you have this hooked to, you may want to add some safety interlocks.
Mohit’s opto idea is good, but you also need to consider the voltage needed to drive the mosfets, and the rise time. You’ll probably need to create a simple transistor push-pull driver/amplifier because the Spark only outputs 3.3V, unless you have the Shield Shield and you can then do 5.0V.
Honestly with all of this it’s getting close to just building your own MOSFET driver shield for the Spark.
I have some digital pots that I was looking to get running on the Spark Core. That would be a nice solution as well. What’s the POTs total value? (looks like 10k from the picture)
Bad thing about that controller with the 555 circuit, it only goes as low as 10% PWM… with the Spark Core you could turn off whatever you are controlling completely.
Ah! I even have some 555s around here. I’ve just never used them. I am starting to think that I might want to just build my own mosfet driver now. I really do like the idea of being able to turn the whole thing off completely. I was going to have to use a relay to control on/off, but if I’m controlling the mosfet directly, that would eliminate the relay.
At any rate, for this particular project that I got the PWM driver for, being able to remotely adjust the speed was more of a fun idea than a necessity, so I’ll probably back off this project so that I don’t have to modify my current board.
I do think I want to build a mosfet shield now though to control higher powered motors. How hard is it do control direction? I know you regularly need an h-bridge, but how does that work in a high powered scenario? Do you need an h-bridge that can handle higher current?
Give that @BDub a cigar! For the record: I knew it had to be a 555 when I asked where pin 3 went.
Just a thought: you can use the core to measure the period and duty cycle of pin 3 or you could just figure out the component values and get it close enough for the core to drive. +1 for the opto-isolator that mohit suggested–why risk the core on the $8 motor driver is the way I look at it.
Yes, I knew you knew as well @bko and you had much less to work with than me!
@Hypnopompia A full H-Bridge requires 4 quadrants of mosfets with a special way to drive the hi-side fets (because they ride on top of the motor voltage). The PWM signal is very important because you need to incorporate “dead-time” in between when a low-side fet turns off and a high-side fet turns on, so they are not on at the same time which would cause “shoot-through” current… possibly blowing your fets. Many uC’s are capable of generating these necessary PWM signals in hardware. I’m pretty sure the STM32F103 can do it.
The easier way, is to use a relay put your battery voltage on one side of your motor or the other… then just pull down the opposite leg with a bank of mosfets. You typically need clamping/free-wheeling diodes from this switching node to your battery voltage as well. This is called a Half H-Bridge if your Free-wheeling diodes are actually mosfets, which is even more efficient.