AnalogWrite not working after supplying 5V to a motor

I tagged this as general since it’s indirectly related to spark. My motor always stop when on 3.3V from Spark. So, I fed in 5V from another power source that share the same ground with Spark. The problem is the analogWrite() from Spark core’s A1 pin stop responding (perhaps because it’s generating PWM at 3.3V peak).

Any recommendations? Something simple as in poking in a few resistors/diodes. My toy project is due in a few days :frowning:

You might want to tell is how is it hooked up to the core maybe?

Mosfet or transistor etc?

I hope you don’t mind a sketch @kennethlimcp

The original Vin was 3.3V and apparently not enough for the toy motor (it was an old motor inside a toy so it’s hard to pin point its spec voltage)

Thanks

For simplicity, I will test this with 5V on the pin using Vin and see if the motor spins.

Or try to kick start it a little with your hand at the beginning and see if it spins thereafter.

The motor spins, but will stop after a few spinning. I generally had to kick start it a little to keep it working.

This is a symptom that either the motor voltage or current (or both) is too low. Your low-side transistor switch looks OK for 100mA or so and as @kennenthlimcp said you can tie the base resistor normally connected to A0 directly to +3.3V to test it.

What values are writing with analogWrite()? I would start with the max (255) and work downward. If you are not trying to control the speed of the motor, just digitalWrite the pin HIGH to test it.

You can probably figure out what the motor voltage was by just knowing how many batteries the toy used.

1 Like

@bko the cradle holds 4 1.5V batteries, which make 6V.
I don’t quite get your point when you told me to work downward from analogWrite(255). I’ve tried everything you mentioned and the motor will just stop after a few consecutive spins, and I’ll have to take its shell apart to look at it (and maybe “kick start” it) every time. That’s bad.

Is there any chance I can use a voltage doubler with two capacitors and diodes to double up the 3.3V?

You can build a voltage doubler but it won't really help in this case--your motor will draw too much current. If you have a +5V supply to the motor as shown in your schematic above, then you have the best chance of running it on that. +6V or even +6.5V would be ideal.

What happens when you connect the motor directly to +5V and GND with no Spark core or transistor? Does it work correctly then?

It is a small motor? Can you measure the current with it running correctly?

The point of working downward from 255 or using digitalWrite() is to make sure you are turning on the transistor fully.

1 Like

Hi @bko. I have tried feeding in 6V to the motor, but it still isn’t moving. Either the toy’s gears are jammed or the analogWrite(), digitalWrite() from the core to the transistor’s base is just not working with the new power source. :frowning:

@metaculus, I thougt that question was already answered before on this other thread of yours.

If your motor stops after a few turns, after kick starting it, I'd guess as @bko suggested, that the power (voltage * current) supplied does not suffice to overcome the electrical and mechanical dissipation factors (e.g. internal/external friction, wire resistance, ...).
While the mechanical impulse added during kick start plus the electic energy are enough to turn the motor a while, with each turn the mechanical surplus exceeding the mechanical resistance wears off, till the energy provided does not overcome the mechanical resistance and the motion stopps.

You need MORE POWER!!! - as Tim Taylor (alias Tim Allen) would have suggested :wink:

@ScruffR yes I figured that out :blush: However, the scenario is a bit different. I have tried supplying more power (5V - 6V), but the input from the core’s pin to analogWrite(), digitalWrite() the motor through the transistor just isn’t working anymore.
If the signal from the core’s 3.3V pin to run the motor will not work with the new power source of 6V, then I’m doomed anyway :worried:

The 3.3V from the core is not really part of the problem now that you are using a separate +5-6V supply, particularly if the switching transistor can handle enough current (which is still in question).

What happens to the motor is if you just connect it to your +5-6V supply directly?

If that was OK, then what happens if you use the transistor and tie the base resistor to +3.3V?

If and only if that was all OK, then you might have a core problem.

1 Like

3.3V should be enough to fully switch a transistor as long there is enough current running base->emitter.
So you can do as @bko suggested and just test supplying the base from the +3.3 pin to see if the transistor does switch properly.
If not check your setup (correct transistor type NPN vs. PNP, correct pins C B E)
Then you could test your analog pin with a LED if it’s still alive and doing what it should (better tho’ if you have an oszillograph, use that :wink: )
Measure your voltages. Measure the current draw of the motor while running on battery.

2 Likes