Candy Vending machine, how to limit the amount of servos needed?
I got all the plans laid out and i got most of it working already.
The problem is: I want to limit the number of servos this project is using. Servos are expensive and they take precious pins on the arduino i'm using for the project.
The question is: I have 9 spirals for candy and i would need 9 servos to turn them and release candy (nom nom).
Is there some ingenious way to limit the amount of servos and still be able to rotate all the spirals independently?
This is basically what i'm making, just smaller :)
http://labs.myrtlestreet.org/wp-content/uploads/2009/07/candy_machine_921kb_cp4d.jpg
I edited it to include a little flash file i made of a rail system using 2 servos and an aktuator.
candymachine.swf2 KB






























Visit Our Store »
Go Pro Today »




What do you need clearing up ? A walkthrough the circuit again, or how the darlingtons need wiring ??
Steve
If you use relatively thick gears, separated by their own width, then the servo can't engage two at once, and you get a fair bit of slop in the alignment tolerance.
Theoretically, you could use the tri-state output from a single pin to drive the actuator (+ == forward, 0 = center, - == backward), if it was set up that way.
What isn't obvious to me is whether this is cheaper than servos or not. A quick Google search found pneumatic actuators for $15-20, or $100 or more!
Switch on the transistor, for long enough that the spiral turns off the switch.
The relay latches ON.
Turn off the transistor.
Now the spiral will turn, until the bump switch is hit, this opens the relay, and the spiral stops.
The limit switch must be CLOSED until the spiral has turned once.
Steve
In this schematic a normal DC motor is used?
Is there a way to slow the motor down since it would otherwise be likely to fling out the items? Or is this already acounted for?
I've got some substantial experience working with resistors, capacitors, servos, arduinos and LEDs. I haven't worked with transistors, relays and diodes yet.
Speed ? Feed the motor from an LM317 adjustable regulator. I can add that to the diagram later if you like.
You can use a "ULN2803" to drive the relays, I'll add that too.
Steve
Try these for good motors:
http://www.rapidonline.com/sku/Electrical-Power/Fans-Motors/Gearboxes/Fixed-ratio-25mm-diameter-spur-geared-motors/82344/37-1088
Braking: Turn AA2 around, and put the common connection to the motor, the normally closed contact to the motor supply and the normally open to ground. Now its dynamic braked, and stops very fast.
You can't switch more than a few mA with an arduino pin directly, they have to drive transistors, or ULN 2803s to drive anything significant.
The servos are really simple for me since it's a matter of turning a servo on/of and specifying rotation through code.
The benefit of this, is that it requires me to have more knowledge of programming and less knowledge of electronics. I've controlled several servos before and interchanged between them without flicker no problem.
They are also accurate unlike any other motor i've worked with and seem incredibly stable. All i'd have to do is to buy 9 full rotation servos and turn one on when needed - then issue a command for a full revolution.
I'm aware the schematic you posted does the exact same thing for a much lower price at the cost of some extra work.
I think the problem for me is that i don't understand the circuit. I'm reading up on transistors at the moment, but i think by the time i'm done reading and i fully understand the circuit i'll be long over this project - no offence meant! It's just that i have a programmer background making the coding much easier.
I'm not sure what to do :S
Here's how the circuit works.
The transistor is a switch here. Switch it on - pulse it for half a second at most.
What happens ? The relay closes.
What happens ? The contacts AA1 and AA2 switch over. The limit switch stays closed.
What happens ? The motor turns, because AA2 is closed. The relay LOCKS on, because AA1 is closed.
Turn off the transistor switch.
What happens ? The relay STAYS energised, the motor STAYS on, because AA2 and AA1 stay closed.
The limit switch opens.
What happens ? the relay OPENS, AA1 opens, AA2 opens. The motor stops.
The cycle completes.
I was so lucky as to get a whole bag of candy machine spirals and appended motors. And guess what, the circuit as pretty much like the one you posted using a 12v dc motor, a switch and a few extra components.
Now the only thing i need is a way to combine that with my arduino. I'd really like to avoid using relays since they're pretty expensive (almost the same price as a cheap servo). Could a few transistors do the trick?
If you want i can post the circuit and a photo of the actual thing. Hope you're still getting these comments.
- Regards Eirinn
http://uk.farnell.com/multicomp/hrm1-s-dc12v/relay-pcb-dpco-12vdc/dp/9479953
http://elektronik-lavpris.dk/index.php?cPath=5802_5808&sort=3a&page=1
( http://elektronik-lavpris.dk/index.php?cPath=5802 <--- overview and more relays)
Would any of these do? I'm guessing i'll need 9x 12v DPDT 1A. The reason i'm listing that site is that i'm going to order some stuff from them anyway.
(I checked how many amps the motor was pulling and it seemed to me like it was drawing less than 0.1A using a bench power supply. I sadly didn't get to test with a multimeter).
Also what does double pole double throw mean? :)
Thank you again - Eirinn
http://elektronik-lavpris.dk/product_info.php?products_id=88723&language=en
If the uln2803 was laid out as a normal transistor i maybe could make heads and tails out of it. But it seems to have a shared pin and protective diodes in one package....which is probably great, but pretty confusing. Which is the collector, emitter and ground?....well i might have ground down.
I've spent a great deal of time searching for information about coupling an uln2803 to a standard 12v relay. But all the information i get is semi-confusing and the only thing i seem to have gotten down is that pin 9 goes to arduino ground. I simply can't find a decent page that lists a circuit using a arduino connected to a Darlington IC driving a relay.
http://blog.makezine.com/archive/2009/02/connecting_a_relay_to_arduino.html
Is the closest i've gotten, but that one uses a standard relay. Since i have no idea what's B/C/E on the Darlington i can't connect it like on the diagram and i'd rather not fumble and break something. Also there seems to be a diode connected parallel to the coil. Is that needed when the Darlington IC has them built in?
If i could just get one chain working and rotate the spiral for a full revolution i could easily make out the rest.
So excited :D
Double pole double throw - two switches, each with changeover contacts.
Steve
As i can tell i'd need 9 relays for 9 circuits right? - i tried reading the datasheet but couldn't find a pinout and the markings on the top doesn't seem familiar.
Would i still need transistors with this? It's all very confusing, but it's slowly getting there.
Steve
What i get so far:
As i can tell the need of relays is because the arduino can't drive dc motors off the pins due to a (presumably) 50ma max output from each pin. Therefore the motors have to be controlled externally, and be switched on and off by relays. This also should prevent from flyback electricity that could potentially go back into the arduino pins (the motor circuit seems to have diodes for this though).
That makes one relay per spiral/motor circuit. I'm not sure i know why the transistors have to be coupled to the relays (i know you've tried to explain it earlier).
I hope i'm right so far hehe.
because its not a good idea to put relay loads on processor pins. The 2803 contains all the transistors you need.
Steve
I've read a little about transistors and it seems the IC you linked is a darlington transistor pack containing several transistors.
I've googled transistors and this is what i found:
"Transistors cannot switch AC or high voltages (such as mains electricity) and they are not usually a good choice for switching large currents (> 5A). In these cases a relay will be needed, but note that a low power transistor may still be needed to switch the current for the relay's coil! "
However i'll be switching less than 1A and only 12V DC so i'm a little confused as to why a relay is needed. Couldn't i just use a high power transistor like the darlington paired ones?
Aaah hope i don't sound too stupid, i'm just trying to understand :)
Transistors are a great solution for currents up to several hundred amps, in the right conditions: this isn't one of 'em. An all transistor solution is possible, but here it would likely be more expensive and less reliable.
Steve
9x relays as linked earlier
2x darlington transistor packs
Would be all that is needed to control the motors circuits?
Also i'm going to run two ATMEGA328 together over I2C for this project - this is not a problem (tested and it seemed to work fine). However i want to add an RTC like this one (pre-packaged brick, it's easier):
http://www.let-elektronik.dk/index.php?page=shop.product_details&flypage=flypage.tpl&product_id=102&category_id=12&option=com_virtuemart&Itemid=76
However the connection type is also I2C and i'm already using those pins to connect both arduinos to each other. Is there a workaround or is there a way to do it?
The RTC is going to be used to add "currency" to the vending machine every day or week so the candy intake is limited to a fixed daily or weekly amount. It's not 100% needed since i could just beep an RFID chip and that would add a certain amount of "currency" to an "account". But having it doing it automatically would be nice :)
All your help is greatly appreciated!
Well, I2C is an addressed protocol, just change the address of your Atmega to make sure it doesn't clash with the RTC.
Steve
Couldn't one use an optoisolator for this? I'm sure there's a reason for why not, but i remember people using them to switch on/control 12v DC motors.
Well...i mean i kind of understand how a relay works. When energizing the relay it either switches on or off - a switch that changes ON or OFF depending on a state that can be changed by electrical current.
As i can understand the relay's two bottom pins are the coil pins and the three top ones are a normally open,a normally closed and a common pin? I'm not entirely sure about the wiring - especially regarding the transistor pack (never had to to with transistors before and certainly not darlingtons).
Any chance you could help me with the relay circuit again? I could probably put it together by schematic, but i really want to go through the learning process too.
Now the only thing i'm iffy about is the wiring since it has changed due to the new circuit.
I've got this so far:
The arduino pulses the transistor pack's pins (depending on which relay needs to be opened). Then the transistor opens the relay until the microswitch turns on again (i'm not sure of the switch type if it's OFF at default or ON).
- Then it dispenses one serving of sugary goodness.
What i'm unsure about is the actual wiring.
I'll be sure to document the entire process here on instructables, i'll of course have your name in it too :D
I've attached what i can make out regarding the circuit. I know it's not a real schematic, but it shows the physical connections and locations (connections top, physical components under) It's a one sided pcb.
I hope this helps to understand the spiral circuit.
I don't know what happens to a servo if you take the PWM input off, and tie it high or low ? Will it freeze, or will it just slam to one end or the other ?
Steve
I don't think you can limit the number of servos, not without some even more tricky (and control-pin consuming!) "gearshift" system. But you might be able to reduce the number of control pins from 9 to 4.
For the real electronics experts out there -- would a charlieplexing setup work for this application? (Charlieplexing allows n tristate controller pins to drive up to n2-n LEDs.)
Instead of LEDs, I'm picturing just regular diodes to restrict the current to just the desired channel, with the servo on the "output" side of the diode. The controller wouldn't need to do the fast-flicker POV stuff that charlieplexing ususally entails, just hold the output pins in the right state for the servo to make one rotation.
There is probably some obvious engineering reason why this is a bad idea, but I'm throwing it out there anyway.