Anda di halaman 1dari 9

Arduino Vending Machine: 2 ­ Accepting Dollar Bills

Updated ­ (8/1/2012)!
Summary
This is a tutorial of how to use an Arduino to count the number of dollar bills accepted by a bill validator (BA­
30).

Description
This tutorial is about using an Arduino to count dollars that were accepted by a bill validator. This is a
common type of bill validator used in machines that take money and give something (vending machines).
 The goal is to connect the bill validator to the Arduino and be able to know when a dollar bill has been
accepted.

Specifically, we will use an Arduino to read pulses from a bill validator.  Normally, the pulses read from the bill
validator will be in the range of 8000 to 9000.  When we insert a dollar bill into the bill validator and the bill
validator accepts the bill, we will be able to read pulses above 12000 from the bill validator.  Given this, we
can tell when a bill is accepted.
If (duration > 12000)
{
     billCount++;
}

Before we begin
Divide and Confuse...
In many forums around the web, there is great interest in how to use an Arduino to accept cash.
 Unfortunately,  there is very little concrete information about how to it.  What's worse is that these devices,
bill validators and coin mechanisms, use different protocols.  Many devices that share a common protocol
share the Multi­Drop Bus (MDB) protocol [http://en.wikipedia.org/wiki/Multidrop_bus]   which uses a 9­bit word.
 Enough said.

Bill Validator explained
The bill validator takes dollar bills.  For the most part, all it does is take money in paper form, validate it (make
sure it is real), store it, and report that one piece of money (of a certain value) has been accepted.  The bill
validator is also known as a bill acceptor or that thing that takes dollars (or other appropriate local currency).

The idea for everything is simple, we are just listening for when the bill is accepted.  We are using the Arduino
to listen to the bill validator.  The bill validator has all of the logic to know when it has accepted the paper
currency.  In the case of this tutorial, we are using the BA­30, made by Coinco.  The nice thing about the BA­
30 is that it provides us with two ways to listen to it.  The first is using pulses and the other is using the MDB
protocol.  We will be using the pulses. 

Safety (always)
"You gotta play it safe around the power lines" ­ Louie T.L. Bug
Experimenting with the combined equipment of an Arduino, bill validator, and computer can cause harm to
you or your equipment under certain situations.  Here's some items to consider for some of the components
involved.

Bill Validator
In order to power the bill validator, you will need to hook it up to power from an outlet.  It is relatively simple
but if you don't feel comfortable, don't do it.  Find someone that has done something similiar and have them
help you.

D.) Other
This is the other category.  This is all meant to be fun.  When experimenting, there may be times you feel
uncomfortable or unsafe about doing something in a project.  At times like these, find a person, forum, or
group (Arduino forums linked) [http://arduino.cc/forum/]   to ask and make your situation safe at all times.

Steps
Control the ESC/Motor using an Arduino
1.  Setup the bill validator.
2.  Connect the bill validator to Arduino.
3.  Upload your sketch to the Arduino.
4.  Use a dollar and watch for the output.

Begin
1. Setup the bill validator.

 [http://1.bp.blogspot.com/­
WkaZFd5ETjY/TjO1Jc995EI/AAAAAAAAACw/f4i07peR7M0/s1600/coinco­mag50b­pins.jpg]
Figure 1.1 ­ The pins

We are going to work with the pins A through F {A,B,C,D,E,F} as these are for pulses.  Disregard the pins G
through K as they are for MDB and aren't covered in this tutorial. 

As you can see from Figure 1.2, I use a wire harness for the BA30.  You can find them on the internet.  If you
are looking for them, search for "BA30 wire harness" or "BA30 coinco wire harness". As long as one end goes
to the BA30, you don't really care what the other end goes to. 
 First we need power.  Power the BA30 with main (110V) power.  NOTE: Power from an outlet can kill you.
 Don't attempt this if you don't know how to be safe.  There is a picture below with all of the pins labeled
(Figure 1.1).  This picture is from the kegbot blog at: http://kegbot.blogspot.com/2004/11/coinco­magpro­
mag50b­pinout.html [http://kegbot.blogspot.com/2004/11/coinco­magpro­mag50b­pinout.html]   Take the line of a
power cord and splice the hot into "110VAC Hot" (on the picture it's pin F), and again splice the hot into the
"Hot Enabled" (on the picture it's pin E).  Take the line's neutral and splice it into "110VAC Neutral" (on the
picture it's pin C). 

 [http://3.bp.blogspot.com/­PcrF­
5jyaXA/UBnTrHP2IXI/AAAAAAAAAL4/9ic3k_Rj2PU/s1600/bValidatorPins.png]
Figure 1.2 ­ Sideview with pins labeled

 [http://4.bp.blogspot.com/­TC8H9uktWso/UBnURwXe6XI/AAAAAAAAAMA/­
HhBgbr5eFU/s1600/bValidatorPower.png]

2. Connect the bill validator to the Arduino
According to the diagram in Figure 1.1, the bill validators pin labeled "A" is the "cr­" line.  It is difficult to see
but the line is green.  Take this line from the bill validator and put it in the Arduino pin #7 (this is the pin used
in the sketch).  The next line we need from the bill validator is labeled "B" or the "cr+" line.  This line needs to
tie into the +5v as shown below (Figure 2.1) 

 [http://3.bp.blogspot.com/­
NalEkVBuqEU/UBnXP7iokII/AAAAAAAAAMY/iFoiAvwt6W4/s1600/arduinoBillValidator.jpg]
Figure 2.1 ­ Connecting bill validator to Arduino

3. Upload you sketch to the Arduino
The hard part is over.  Upload the following sketch to your Arduino:

/*
* Sean
* globalw2865@gmail.com
* 30JUL2012
* Bill validator/Arduino (second draft)
*/

/*
* RESOURCES:
* http://www.arduino.cc/en/Reference/PulseIn
* http://kegbot.blogspot.com/2004/11/coinco­magpro­mag50b­pinout.html
* http://www.coinco.com/coin/faq/servicematerials/921970_1.pdf
*/

/*
* Description:
* Arduino records and counts dollar bill received from pin 7 (billValidator).
*/

// Constants //
// pin for the bill validator's credit(­) line
const int billValidator = 7;

// Variables //
// recording the duration of pulse (milliseconds)
unsigned long duration;

// holding the total dollars recorded
int dollarCounter = 0;

void setup()
{
  // Pin setups for bill validator and button
  pinMode(billValidator, INPUT);
 
  // Initialize serial ports for communication.
  Serial.begin(9600);
  Serial.println("Waiting for dollar...");
}

void loop()
{
  // get the duration of the pulse
  duration = pulseIn(billValidator, HIGH);
   
  // Receiving a dollar bill will create a pulse
  // with a duration of 150000 ­ 160000.
  // NOTE: When there is no dollar bill pulse,
  // I will receive a pulse of 8400 ­ 8600
  // on every loop.
  // Dollar received
  if(duration > 12000)
  {
  // Count dollar
  dollarCounter++;
  // Checking for understanding
  Serial.print("Dollar detected.\n Total: ");
  // Display new dollar count
  Serial.println(dollarCounter);
  } 
     
}

4. Use a dollar and watch for the output

First dollar (Figure 4.1)
 [http://2.bp.blogspot.com/­
fur0MshLiVY/UBnZNs7vT3I/AAAAAAAAAMg/Kbv2t5Gls78/s1600/billdetected_1.png]
Figure 4.1

Second dollar (Figure 4.2)

 [http://2.bp.blogspot.com/­
mS5FPSou8so/UBnZVBHvP5I/AAAAAAAAAMo/LIq5ljUWM2I/s1600/billdetected_2.png]
Figure 4.2

5. Done
The tutorial is fairly simple.  Many thanks to anyone who has corrected me.  Also, if anyone is interested in
this, you will probably be interested in the posts on the Bounis Blog [http://blog.bouni.de/]  .  They go into detail
on the MDB protocol (well done). 

Posted 30th July 2011 by Sean OBryan
Labels: Bill Validator Bill Acceptor Arduino accepting bills

11   View comments

Organelle April 6, 2012 at 12:24 PM
Sean  ­  thanks  for  this  experiment.  I  was  wondering  if  there  were  any  updates  on  how  this  turned  out?  I'm
working on something similar with the BA30 acceptor and currently troubleshooting. Did you use the Credit (­
) or Credit (+) to input the pulse to an arduino pin? Your instructions and code were different. Any input would
be appreciated!
Reply

Sean OBryan April 6, 2012 at 1:01 PM
Good point! I'll have to correct that, thanks.

In the example sketch, I believe that Credit(­) goes to the gnd and the Credit (+) was assigned to pin 7. 

So from the example, this:
// pin for the bill validator's credit(­) line
const int bValPin = 7;

Should be:
// pin for the bill validator's credit(+) line
const int bValPin = 7;

Of course, I'll have double check in order to be sure. Thanks and good luck!
Reply

Replies

Organelle July 28, 2012 at 10:59 AM
Hi  Sean,  We've  been  troubleshooting  2  coinco  ba30s  over  the  last  few  months  with  your  setup,
code  and  a  arduino  uno  with  no  success  and  would  appreciate  any  advice  you  could  offer.  We
have the dip switches set properly (3 and 8 on) and have been reading (via serial monitor) a loop
pulse  of  about  8000  but  have  not  recorded  any  high  pulses  when  bill  is  inserted.  There  is
sometimes a blip of about 600 or so when a bill is inserted but its too small to be reliable. Trying
to figure out if its a hardware or software issue. What  type  of  wire  did  you  use?  Length  of  wire?
Any resistors, etc?

Sean OBryan July 30, 2012 at 7:41 AM
Given the interest, I'm working on a proper rewrite. Off the top of my head, I believe a 2k resistor
was used between the bill validator and arduino (pin 7 of example).

Reply

Bouni June 25, 2012 at 1:16 AM
Hi Sean,

i work on get MDB running on an Arduino.
So far i have a working version of a cashless device, but the code is very ugly (i'm not a programmer ;) )
The project is documented here:

https://reaktor23.org/de/projects/mate_dealer
Reply

Replies
Sean OBryan July 3, 2012 at 7:10 AM
Thanks Bouni,
Your project was part of the reason that I got as far as I did. It's really cool that you got that far.
Also,  the  diagrams  labeled,  "basic  wiring"  and  "experimental  setup"  are  really  helpful.  Also,  the
MDB  protocol  diagram  is  an  excellent  visual  aide  for  someone  who  is  trying  to  understand  the
vendor  MDB  protocol  document  (book).  I  intend  to  come  back  to  this  as  I  don't  like  to  leave
projects like this unfinished. Thanks for your work and sharing.

Reply

Vending Machines Wholesale July 16, 2012 at 12:14 AM
Oh really! I'm surprised by your post.Great and impressive work.Thanks for sharing.
Reply

John Shotton September 12, 2013 at 2:03 PM
Hi,  I  was  wondering  if  anyone  has  worked  on  the  reverse,  I  would  like  to  imitate  a  BA30  with  a  vending
machine. I want to swipe a rfid tag and add a dollar to the vending machine.

Reply

Replies

Sean OBryan September 12, 2013 at 6:09 PM
Hi John,
As  a  short  answer,  to  imitate  the  BA­30  (on  most  vending  machines)  you  would  need  your  rfid
reader to be a slave (just like the BA­30) that listens and speaks to the controller (master or vend
controller) using the MDB protocol. There haven't been many common/simple implementations.

There  have  been  people  that  have  worked  on  this  subject.  The  most  work  has  been  done  with
interfacing  payment  devices  with  an  Arduino.  The  least  amount  of  work  has  been  integrating  a
new peripheral into an existing vending machine system. 
In general, vending machines are slightly different when trying to develop for these machines. For
some  reason  (I  assume  proprietary  or  hardware  convenience  reasons),  most  implement  a  9­bit
protocol  known  as  Multi­Drop  Bus.  It  is  8­bits  of  data  with  a  mode  bit  (address  or  data).  This  is
where most people stop trying to integrate with the current system (MDB) and just replace it with
something else or just interface with the peripherals they want to use.
There is some equipment (like the ba­30) that is nicer to use. I've even read specs on some stuff
that  just  uses  regular  rs­232  serial  commands,  but  most  of  the  vending  machines  from  the  (at
least) past 10 years rely on this MDB conversation. 

Here is a good link of people figuring this out:
http://forum.arduino.cc/index.php?topic=64460.0

And  if  you  are  interested  in  more  material  about  how  this  all  works,  bounis  (comments  above)
has very detailed information on how this work. He also shows work for the matedealer.
http://blog.bouni.de/

Reply
Brian Henderson May 2, 2014 at 12:20 PM
Wow, this totally worked! It worked on the first time! I'm using an old Mag50BAB, but everything worked just
the way you said it would. Thank you for this tutorial!
Reply

Dizzle Jenkins December 8, 2014 at 6:04 PM
Worked like a charm. Great post!!!
Reply

Enter your comment...

Comment as:  Google Account

Publish
  Preview

Anda mungkin juga menyukai