Crazy design!  I don't know if I could have figured that out.  Cool that you did!

> Date: Sat, 9 Apr 2016 18:57:16 -0500
> From: jake@spaz.org
> To: maltman23@hotmail.com
> CC: sudo-discuss@lists.sudoroom.org; adam@aperture.systems; organic_unity@yahoo.com; emmaselephants33@gmail.com; echoudhry@gmail.com
> Subject: RE: [sudo-discuss] vending machine homing switch mystery solved
>
> mitch there are 42 motors, arranged in a row/column grid
>
> this way there are no extra wires. you have to be able to detect the
> "home" state of each product independantly!
>
> the other vending machine, a "snackshop II" uses a totally different
> system. AC power is wired to all the motors through their homing switch,
> so they will automatically turn until they are at "home" position.
>
> Then there is a single wire from each motor to the appropriate button on
> the front of the vending machine, and when the meatbag presses the button
> of the product they want, current flows through the money-counting circuit
> (and through diodes corresponding to the 5-bit value of nickels to charge
> for the product!) and if the mortal has paid for its food, the circuit is
> closed and the motor runs despite its Home position - but only for long
> enough for the motor to leave "home" and then the home switch runs the
> motor until it gets home again - after the user has been served.
>
> we use this charlieplexed optocoupled-triac board for that machine:
>
> https://github.com/sudoroom/hackomat
>
> -jake
>
> On Sat, 9 Apr 2016, Mitch Altman wrote:
>
> > That is a bizarre way of detecting "home".  Since there's a switch, wouldn't it be easier to just connect the switch directly to the Arduino to detect "home"?
> >
> >
> > -----------------
> > > Date: Sat, 9 Apr 2016 17:42:06 -0500
> > > From: jake@spaz.org
> > > To: sudo-discuss@lists.sudoroom.org; adam@aperture.systems; organic_unity@yahoo.com; emmaselephants33@gmail.com; echoudhry@gmail.com
> > > Subject: [sudo-discuss] vending machine homing switch mystery solved
> > >
> > > so i've been working on the black sudoroom vending machine (vending1):
> > >
> > > https://sudoroom.org/wiki/hack-o-mat
> > >
> > > which had previously been hacked by students at UC Berkeley (i think)
> > >
> > > I believe it's a Snacktron like Emma and Ed's machine.
> > > (unlike our brown vending machine which is a snackshop II)
> > > pictures of their machine can be seen here:
> > > http://spaz.org/~jake/pix/vend/
> > >
> > > they had ripped out the original control unit, and wired it up with a
> > > bunch of reed relays and an arduino. The motors of the vending machine
> > > are wired as a grid of rows and columns, so the controller needs to be
> > > able to enable a single row and column in order to power one product
> > > motor.
> > >
> > > But it also needs to be able to detect when the product motor has rotated
> > > a full turn, and is back at the "home" position where it needs to stop.
> > > There's a "home" sensor on the back of the motor, but the way it's wired
> > > was a mystery for a while. Here's some pictures of the homing circuit:
> > >
> > > http://spaz.org/~jake/pix/vend/IMG_20160401_015211.jpg
> > > http://spaz.org/~jake/pix/vend/IMG_20160401_015700.jpg
> > >
> > > as you can see, the only difference between the button being pressed or
> > > not pressed, is that the 420nF capacitor is in parallel with the motor or
> > > not. Since the whole thing is in series with a diode (to protect against
> > > trying to turn a motor backwards) we were stumped as to how to detect
> > > whether a motor was homed or not.
> > >
> > > Thanks to Zach who donated some test equipment including this awesome
> > > signal generator (along with a nice power supply and bench multimeter):
> > > http://imgur.com/LTSFfOe
> > >
> > > I was able to connect an AC waveform in series with a 12VDC supply to one
> > > of the motors, and figure out how to detect whether the home switch is
> > > closed or not. Basically, you make a 31KHz (or similar frequency)
> > > squarewave in series with the power supply, and watch the current through
> > > the motor. If the button is open and the capacitor is not in-circuit, the
> > > motor's inductance absorbs the AC and the current draw is relatively
> > > smooth. But when the motor arrives at the home position (when you need to
> > > stop delivering product!) the capacitor gets switched in, and now you'll
> > > see a lot of the AC on the current path of the system.
> > >
> > > Here is a video showing the voltage across a 22-ohm series resistor while
> > > the motor is rotating with 12VDC:
> > >
> > > https://www.youtube.com/watch?v=xHIGDw5HRCg
> > >
> > > apparently it takes that motor about 11 seconds to dispense a product and
> > > finish returning to home position, assuming the product weighs nothing.
> > >
> > > by the way, you'll notice that i'm using the old analog oscilloscope.
> > > Unfortunately the LeCroy 9510 has started crashing, basically
> > > bluescreening. It probably needs to be opened up and cleaned, as it got
> > > wet after a fire before it was donated to sudoroom.
> > >
> > > Or maybe someone wants to donate a nicer oscilloscope to sudoroom?
> > >
> > > anyway, now I know how to detect the motor homing signal, and I just need
> > > to wire up this machine to its arduino to detect the signal and dispense
> > > product more accurately. If anyone wants to help, please let me know.
> > >
> > > by the way, if you are wondering how the UC students detected when the
> > > motors were finished dispensing product, the answer is absurd:
> > >
> > > they put a laser beam across the path where product would fall when
> > > dispensed, and they watched for the laser beam to be interrupted.
> > >
> > > did it work? I don't know. probably the semester ended and they got
> > > their grade and moved on, and then they donated the vending machine to us.
> > >
> > > -jake
> > > _______________________________________________
> > > sudo-discuss mailing list
> > > sudo-discuss@lists.sudoroom.org
> > > https://sudoroom.org/lists/listinfo/sudo-discuss
> >
> >