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
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.
@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.
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.
@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
@ScruffR yes I figured that out 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
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.
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 )
Measure your voltages. Measure the current draw of the motor while running on battery.