I’m loving the spark core but the hardware side is very much an unknown to me, can someone please point me in the right direction as to how I could wire up this new motor and driver to the spark core. The tiny motor I had before only needed 4 wires connecting. I accept that I will need to power the driver board externally using a mains adapter…
Please see pictures of the inputs and wiring, I’ve tried much googling but can’t seem to find the info I need.
@Brungle, the specs on the control board are not very good. There isn’t even a connector diagram or input control timing diagram! If you can provide the exact motor details, we may be able to recommend an alternate stepper motor controller you could use.
Your motor can be configured in either series or parallel - it looks as though it has already been configured for series which should be fine for your application and so it looks as though the following connections have already been made: yellow-to-blue and orange-to-brown. Then each phase is identified by: red/black and white/green.
I’m assuming you really do need a stepper (i.e. to be able to accurately position a shaft and the ability to turn through multiple turns), they do have the drawback that you need extra hardware (limit switches) to set the initial position.
Alternatively, you could consider whether an RC servo is suitable though this does have limited rotational travel (typically 0-180 degrees) but multi-rotation ones (sail winches) are available.
perhaps a servo will work actually this is the cereal dispenser I need to turn, it doesn’t matter if I turn it alternate ways as it will still dispense dog biscuits.
Are servo motors easier to wire up? do they not need a control/driver board?
Yes, that’s an ideal application for a servo. They’re cheap, geared and positional. Very easy to wire, 3 wires: +ve, GND and signal. To the signal wire apply a PCM logic signal of width varying from 1ms to 2ms repeating every 20ms, or thereabouts. Officially they are 90degrees rotation, but you can usually push this by going below 1ms and above 2ms.
Arduino supports driving these through built in library:
One thing to be aware of…most servos are designed to run on (nominally) 5V. I’ve found that most will work down to 3V but (obviously) slower and less powerful, or you could run the supply at 5V and try the logic signal at the Spark’s 3.3V…or level translate the Spark’s O/P up to 5V
That looks nice and high torque, but you might want to determine how much torque you need to dispense food - attach a lever to the knob, and then use pull scales (e.g. fishing or luggage scales) or hang a weight just heavy enough to make it move, work out the moment required and normalise this to the servo torque spec. You probably need a servo capable of at least 2 times the required torque. Alternatively, get the servo and give it a go! You might need to consider things like stalled servo if a biscuit gets stuck.
One thing to consider is current monitoring of the motor to detect jamming. I’ve used these dispensers in hotels and occasionally it jams and I have had to reverse it to get it to work again. You might need to consider this as a control option. This will be easier with some kind of DC motor. Stepper motors are a little more involved to do this.
A powerful servo should work but watch out for current drawn at 5V. It could be quite high for some of the more powerful servos and as I said, include some form of current monitoring.
I’ve just ordered that to try it out. I actually trimmed the rubber inner of the cereal dispenser already when I was trying to get my original tiny motor to turn it so I’m hoping the jamming will be minimal. I suppose that will be part of the fun when testing it :).
Thanks again for your prompt and informative responses. I will post an update when I’ve tried it out.
Well its a bank holiday so I thought I’d come back to this project today.
You were right about the dispenser jamming, it only just works when there is about half a dozen tiny biscuits in there. When you add more it barely moves.
hmm its really working great its very unreliable in that it sometimes appear to jam or just gives out a constant noise from the servo after its finished… its pretty loud too annoying to ignore.
I’m not sure what else to try now, does my code look ok? I thought detaching the servo after use would stop the noise but it doesn’t.
int pos = 0; // variable to store the servo position
void setup()
{
//myservo.attach(D0); // attaches the servo on pin 0 to the servo object
Spark.function("feedControl",feedControl);
}
void loop() {
}
int feedControl(String command)
{
Servo myservo; // create servo object to control a servo
myservo.attach(D0);
if (command == "FEED") {
for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
//for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
//{
// myservo.write(pos); // tell servo to go to position in variable 'pos'
// delay(15); // waits 15ms for the servo to reach the position
// }
myservo.detach();
return 1;
} else {
return 0;
}
}
It sure sounds like it is mechanically jamming in that video. The space between the arms of the rotor and the tube versus the size of the kibble bits seems to be a problem.
Detaching the servo in software means that the core is no longer driving a valid servo control signal. From the servo’s perspective, this indicates a failure since it wants to be controlled all the time and different servos respond to this kind of fault in various ways. Some cheaper servos might want to go back to 0 degrees while some nicer servos (particularly those for model aircraft) are designed to return to a middle position (90 degrees). Finally there are some digital servos where the fault position is actually programmable and you need a “servo programmer” to set them up, but these are expensive.
So I would leave the servo attached in software. They do hum sometimes as they find their control position. A better way to eliminate the hum when not in use is to cut power to the servo (relay, transistor etc.) and normally the gearing for the motor inside the servo is such that the servo can be turned by hand with no power but it takes some force and so it holds position unless pushed.
Cool project!
The servo seems powerful enough, considering the meter-high biscuit launching at the start of the video.
I’m using a cheap mini-servo in my project. It’s small yet very powerful. I’ve tested this servo using both the 3.3V pin from the Spark Core as well as the 5V Vin pin. The steering wire is connected directly to an analog output. It worked in both cases, but using 5V the movement was quicker and more direct.
In my project the servo also moves when powering the Spark on, so I initialize it in the setup() and keep it powered during the rest of it’s lifetime. So far it’s working perfect, always returning to its same position. (Note that it doesn’t move spontaneously after a reset, only when powered on).
I’ve tried about 4 different types/sizes of dog treat and not really found anything that works. I think part of the problem is that the arms of the rotor are rubber so they are flexing too much?
hmmm back to the drawing board with the dispenser hardware I think… such a shame as I’d got the spark code running great within minutes!