PopCARD: Pop Machine Cash Card  

Posted by technology2day

PopCARD: Pop Machine Cash Card


The machine is made by Dixie Narco, and it turns out the machine is quite common and very capable, although by vending standards it is now considered "out of date". But it's good enough for my needs. I put it in the hallway of my building and use it to sell a variety of drinks to my neighbours.
Just 6 days ago, as I was fishing around for change to buy a drink from my own machine, I wondered how difficult it would be to add a key-override for myself, so I could buy drinks without having to put money in. That idea quickly ballooned into building a full-fledged cash card system that all of my neighbors could use. But, what was the best way to make the machine think that money had been inserted without actually doing it?
Digging through the service manual for the machine, I found and then quickly ruled out using the "modern" protocol that coin changers and credit card readers use to interface with the machine. This protocol is called MDB, short for Multi Drop Bus. It's a powerful protocol, but it has an irritating 9-bit word with an 11-bit transmission protocol, and it seemed to be much too complicated for what I really needed. So, I turned my attention to the mysterious port on the machine's main board, labeled "P8", designated for dollar bill acceptors.

 

In this photo, you can see the port circled in red. It is labelled "Bill Validator Interface" and has 8 pins. However, no other information about the connections was forthcoming. The service manual only contained information about compatible changers, but that didn't get me far. I spent hours digging around on the internet as well as speaking to the authorized distributer for Dixie-Narco in Canada, with no luck.

The big break came when a phone call to 'Dennis', a tech rep at Crane (the company that bought Dixie-Narco), was able to find me the pinout of the port. Here's what he gave me:

1 - Vend NO
2 - Vend COM
3 - Low Level Inhibit COM
4 - AC HOT
5 - AC Neutral
6 - Low Level Inhibit 2
7 - Low Level Inhibit 1
8 - High Level Inhibit 1


So, those pinouts looked about as greek to me as I'm sure they do to you. And with 110V right on the same connector, I wanted to be really sure of the wiring before I put any connections to them! With help from my friend Justin, we were able to figure out that shorting Vend NO and Vend COM twice caused the machine to add a credit of $1.00. In addition, I discovered that when 5V is present on Low Level Inhibit 2, the machine is ready to accept money, and otherwise it is not.

Armed with this information, I bought a new Arduino, an Adafruit ethernet shield, a Wiznet ethernet module, an LCD screen, and an RFID reader. Here's the initial set up:

The basic operation of the system is like this: A user scans their card, which is read via the RFID reader. The ID is sent to a piece of software running on one of my servers, which compares it to a database and retrieves the user name and their current credit amount. This is then displayed. If the vending machine is ready to accept money, pressing a "buy" button subtracts $1 from the account and places it in the machine. The user can then use that money to make a beverage purchase.

The final setup before it was mounted into the pop machine. I added a speaker to provide audio feedback. It plays the "1-up" sound from Mario!

Inside the machine, the relay board and the Arduino were mounted into a plastic case.
Since we don't have dollar bills in Canada, my machine doesn't have a bill changer. So I used the bill changer opening as an access hole for the LCD display, RFID reader, and pushbutton. The alligator clips are temporary -- I need to buy some spade connectors.

Here's that 8-port connector on the back of the vending control board. I found that a 6-pin PCI-E power cable matched the bottom 6 holes perfectly, while also leaving the 110V AC holes not connected.

On the front of the machine, I create a (crappy) template to display instructions and tell people what to do:

This is probably one of the more complicated Arduino-based builds I have done, and I am very happy with how well it works!

View the Arduino source code for the pop machine interface here.

Here's a schematic of the electronics. Click to enlarge.

Standard Arduino Works With Android Open Accessory  

Posted by technology2day


Standard Arduino Works With Android Open Accessory
A lot of people have been put off by the price of the reference hardware kit, which is roughly $390. What’s worse, they appear to be sold out until end of May, and Microchip’s cheaper ($80) alternative doesn’t arrive until July. So instead of waiting I decided to write a guide on how to get an ADK-capable Arduino for about $55.
Since the ADK reference design is based on Arduino and Oleg Mazurov’s excellent USB host shield, it stands to reason that we should be able to build our own hardware kit from these components. I already had these parts lying around from my work on MicroBridge, so I decided to ‘port’ their code, which in reality means just changing a couple of pin definitions.
disclaimer: Since I don’t have a phone that supports accessory mode I have no way to verify that this actually works. What I can see however is the output from the Arduino which seems to indicate that everything is working as it should be. If anyone has actual Android hardware that supports ADK and would like to help me test this, let me know!
Hardware
In order to replicate this you’ll need two things:
  1. An Arduino board or compatible. You can get an Arduino from places like Sparkfun, although cheaper clones can be had on Ebay for as low as $20.
  2. A USB host shield. You have the choice of either Oleg’s USB host shield, which will run you $40, or Sparkfun’s cheaper variant which sells for $25.
You can either get a ‘regular’ 328p-based Arduino or an Arduino Mega. The higher price of the Mega gives you extra IO pins, which you might actually need since the host shield occupies pins 7-13.
Sparkfun’s shield is cheaper but has some drawbacks. Firstly it does not work with Arduino Mega variants because these boards have their SPI pins in a different location. Oleg’s 2.0 shield solves this by connecting to the ICSP header on the Arduino, which is in the same location on all variants. Second, Sparkfun’s shield requires an external power source to be connected the the Arduino board. Finally, it’s not stackable, which is really annoying when you’re trying to drive servos, motors, and so forth.
Here’s a picture of the setup I use. As you can see, I use Sparkfun’s shield and an Arduino Uno. Note also the external power supply to power the phone. If you get this combo from Sparkfun, it’ll cost you about $55 ex shipping.

Firmware
While the ADK reference software includes Oleg’s USB library, they slightly modified the code, hardcoding the pin assignment to the max3421e chip. Unfortunately this breaks compatibility with the Arduino shields, so I had to patch their code a bit to make it work again. All I really had to do is add some #defines and it worked pretty much out of the box from there.
To try it out for yourself, download the ADK software package and follow the installation instructions on the ADK page. Instead of installing the USB host lib from their package, get the patched version here and copy it into the libraries directory of your Arduino installation. Remove all the stuff from demokit.pde that uses the demo shield (joystick, RGB leds), and you should be good to go.
You should see the following output on the serial port:
Start
Device addressed... Requesting device descriptor.
found possible device. swithcing to serial mode
Data packet error: 5could not read device protocol version

Device addressed... Requesting device descriptor.
found possible device. swithcing to serial mode
Data packet error: 5could not read device protocol version
Et cetera. This means that the electrical wiring to the shield is in working order and the max3421e is finding the phone. The ‘Data packet error: 5′ means that my phone is not responding to the non-standard control request, which it shouldn’t, since it’s not an accessory-capable device (yet).
Conclusions
As far as I can tell following this guide should give you a slightly more economical Android accessory device compared to the reference kit. Until I get my hands on a phone I cannot test it, so if anyone out there has a capable device or knows how to hack support for it onto a rooted ZTE Blade, let me know. When ADK makes it into Cyanogen mod I’ll certainly flash it on one of my blades and let you know how it goes.
Finally, if anyone out there has one of those cool ADK demo kits and wants to lend me one, feel free to contact me. I’d like to port MicroBridge to it so that it can be used it with pre-2.3.4 devices.
update: much thanks to RobotFreak and Follower for confirming that this setup works! Apparently some versions of avr-libc require ‘PORTB1′ instead of ‘PB1′ to compile correctly