Sei sulla pagina 1di 7

// Arduino: gettoniera – 616 type multi coin selector

62 gettoniera – 616 multi coin selector – (some notes at section end)


In questo progetto viene gestita sia la “programmazione”
di una gettoniera modello 616, facilmente reperibile per
poco piu’ di una decina di euro sui mercati cinesi, che la
sua gestione tramite Arduino uno.
La gettoniera

La gettoniera puo’ gestire sino ad un massimo di 6 diverse


monete ed alimenta il sistema di supporto (in questo caso
Arduino uno) emettendo una serie di impulsi. Gli impulsi
vengono interpretati da Arduino come degli “interrupt” e
come tali gestiti (l’argomento ”interrupt” e’ trattato in
questo progetto: http://giocarduino.altervista.org/e45-sleep-e-wake-da-interrupt-esterno.pdf )

La gettoniera funziona confrontando il materiale, il peso e le dimensioni delle monete acquisite con
il materiale, il peso e le dimensioni dei campioni forniti durante la fase di “programmazione” (vedi
piu’ sotto). Se una moneta non viene riconosciuta viene lascia cadere la fessura di ritorno, se viene
riconosciuta, invia ad Arduino un numero di impulsi pari al numero di impulsi programmato per il
tipo di moneta.
1) Selettore di paese, non utilizzato in
questo progetto
2) Connettore a 4 pin:
a. 12 v cc
b. Segnale (Impulsi) in uscita
c. Gnd
d. Non usato
3) NO(sempre on) – NC (sempre off);
4) Ampiezza dell’impulso: 20 oppure 50
oppure 70 millisecondi
5) Reset, non utilizzata in questo progetto
Figura 1 6) Porta di gestione del sistema di controllo
elettromagnetico, non utilizzata in questo progetto
7) Led indicativi delle monete (6 led, uno per ogni tipo di moneta)
8) Pulsante di settaggio
9) Display a due cifre
10) Pulsante “+”
11) Pulsante “-“
12) Fessura di accettazione delle monete
13) Pulsante di “restituzione” di eventuali monete incastrate
14) Area recupero monete non accettate
La programmazione della gettoniera
Prima di essere collegata ad Arduino la gettoniera deve essere “programmata” deve cioe’ essere
istruita sulle diverse monete che dovra’ riconoscere e sul numero di impulsi che dovra’ emettere
per ogni moneta.
La programmazione della gettoniera si compone di due distinte fasi: la fase di “istruzione” durante
la quale si definiscono sia il numero di monete che il numero di impulsi che dovranno essere
emessi per ogni moneta, e la fase di “calibrazione”, nel corso della quale verranno fatte piu’ volte
“assaggiare” alla gettoniera le varie tipologie di monete che dovra’ poi riconoscere.
Prima di procedere alla programmazione sara’ quindi necessario procurarsi alcuni campioni delle
monete che dovranno poi essere utilizzate nella fase di “calibrazione”. E’ opportuno procurasi un
certo numero di campioni (l’ideale sarebbero 20 monete per ogni tipo, ma in questo progetto ne
sono state utilizzate solo 4 per tipo, facendole passare piu’ volte).
// Arduino: gettoniera – 616 type multi coin selector

Sempre prima di iniziare la programmazione bisogna avere le idee chiare sul numero di impulsi
che dovranno essere emessi per ogni tipo di moneta. In questo progetto si utilizzano monete da
10, 20, 50 centesimi e da 1 e 2 euro e si e’ deciso di far emettere un impulso ogni 10 centesimi di
valore e quindi:
 10 centesimi: 1 impulso
 20 centesimi: 2 impulsi
 50 centesimi: 5 impulsi
 1 euro: 10 impulsi
 2 euro: 20 impulsi

Questa scelta ha il vantaggio che in caso di rapida


successione di monete la gettoniera non dovrebbe
perdere il controllo e generare tanti impulsi quanti
sono le decine di centesimi inserite, ma ha lo
svantaggio di essere piuttosto lenta nel riconoscere
le monete di taglio maggiore, poiche’ per queste
monete il “treno di impulsi” risultera’ piuttosto lungo
e richiedera’ un certo tempo (per riconoscere una
moneta da 2 euro occorreranno circa 2 secondi).
Sono ovviamente possibili alternative come ad
esempio la scelta di un numero di impulsi diverso per ogni tipo di moneta e quindi con un massimo
di sei impulsi per la moneta che si ritiene di utilizzo meno frequente.
La fase di istruzione
La gettoniera si programma utilizzando i tre pulsanti 8, 10 ed 11 ed osservando le comunicazioni
che appaiono sul display 9. Questi i passaggi:
 Selezionare “NC” facendo scorrere verso il basso l’interruttore 3;
 Selezionare “fast” facendo scorrere verso l’alto l’interruttore 4;
 Alimentare la gettoniera con 12 volt cc;
 Tenere premuti contemporaneamente i pulsanti "+" e "-" per circa 3 secondi, dopo di che
rilasciare. Apparira’ la lettera "A" sul display. Ora premere una volta il tasto "SET"; apparirà
la lettera "E";
 Utilizzare i tasti “+” e “-“ per indicare il numero di monete (in termini di tipi di monete, max 6
tipi di monete) che si vogliono programmare. In questo progetto e’ stato scelto 5, e cioe’ 5
tipi di monete: 10 cent, 20 cent, 50 cent, 1 euro e 2 euro. Al termine premere “SET” per
terminare; Apparira’ la lettera H seguita da un numero che identifica la moneta che si sta
programmando (H1, H2 , H3….).
1. Usare i pulsanti “+” e “-“ per scegliere il numero di monete di quel tipo (tipo 1 per H1,
tipo 2 per H2, tipo 3 per H3 … ) che saranno poi fatte “assaggiare” alla gettoniera In
questo progetto e’ stato scelto il valore 15 (max 20). Al termine premere SET per
terminare;
2. Apparira’ la lettera P seguita dal numero del tipo di moneta (P1, P2, P3…). Usare i tasti
“+” e “-“ per definire la quantita’ di impulsi che dovranno essere emessi per quel tipo
di moneta. Se si decide, ad esempio, che la moneta di tipo 3 (P3) e’ la moneta da 50
centesimi e se si decide di emettere un impulso ogni 10 centesimi di valore, il numero
da inserire sara’ 5. Al termine premere “SET” per terminare.
3. Apparirà la lettera "F" seguita dal numero del tipo di moneta (F1, F2, F3…). Usare i tasti
“+” e “-“ per scegliere il grado di sicurezza. Sono possibili valori da 1 a 30; piu’ il valore
e’ basso piu’ il sistema accettera’ solo monete di cui e’ certo (ma aumentera’ il numero
delle monete non accettate), mentre ad un valore alto corrispondera’ un basso indice di
sicurezza. In questo progetto e’ stato scelto il valore “8”, come suggerito anche dal
costruttore. Al termine premere “SET” per continuare
4. Apparira’ la lettera H seguita dal prossimo numero di moneta da programmare, per la
quale andranno ripetuti i passi da 1 a 4.
// Arduino: gettoniera – 616 type multi coin selector

 Dopo aver impostato i dati di tutte le monete, il LED lampeggerà, mostrerà "A" sul display e
dopo 4 secondi apparira’ il valore 0. Togliere l’alimentazione, rimetterla ed iniziare la fase di
calibrazione.
La fase di calibrazione
a. Premere il tasto "SET", verra’ visualizzata la lettera "A". Premere di nuovo il tasto "SET”;
b. verra’ visualizzato "A” seguito dal numero del tipo di moneta da “calibrare" e si accendera’ il
led corrispondente al tipo di moneta: per le monete di tipo 1 (A1) si accendera’ il primo led,
per le monete di tipo 2 si accendera’ il secondo led e cosi’ via;
c. Inserire monete di quel tipo (tipo 1 per A1, tipo 2 per A2, tipo 3 per A3 …) per 15 volte (15
poiche’ 15 e’ il numero scelto in fase di “istruzione, vedi precedente punto 1), cercando di
mantenere una velocita’ costante.
d. Dopo aver inserito il numero prescelto di monete di quel tipo, le luci led lampeggeranno, sul
display apparira nuovamente “A” seguito dal numero di un nuovo tipo di moneta e si
accendera’ il led relativo a quel tipo di moneta. Ripetere il passaggio precedente con
monete del tipo indicato, e cosi’ via.
e. Dopo aver terminato la calibrazione di tutte le monete, le luci a led lampeggeranno più
volte, ed apparira’ “0”.

A questo punto la gettoniera e’ stata istruita e calibrata; spegnere e riaccendere per poterla
utilizzare.
In questo progetto ci si limita ad esporre, sul monitor seriale, il valore delle monete lette ed
accettate dalla gettoniera.
Interessante, sempre in questo progetto, l’utilizzo del sistema di “interrupt” per il conteggio degli
impulsi e l’utilizzo di una resistenza di “pull up” per mantenere costantemente HIGH il segnale sul
pin 2 di Arduino.

Il filmato di questo progetto e’ reperibile qui: https://youtu.be/L4Rz0MgWYZ8


Nota: Questo esercizio e questa nota sono parte di una serie che vede protagonisti Arduino ed
alcuni dei componenti ad esso collegabili. Per la maggior parte degli esercizi e’ anche disponibile
un filmato su youtube:
 Esercizi facenti parte della raccolta
 Filmati presenti su youtube
 Informazioni su arduino e sui componenti collegabili (PDF scaricato nell’area di download)
 Breve manuale di programmazione (PDF scaricato nell’area di download)

Per eventuali chiarimenti o suggerimenti sul contenuto di questa scheda scrivere a


giocarduino@libero.it

Here some notes about this project, translated by google translator


This project manages both the "programming" of a model 616 coin selector, easily available for just
over ten euros on Chinese markets, and its use through an Arduino.
The coin selector

This coin selector can manage up to a maximum 6 different coins and feeds the support system (in
this case Arduino uno) by issuing a series of pulses. Pulses are interpreted by Arduino as
"interrupts" and as such managed (the "interrupt" argument is
covered in this project:
http://giocarduino.altervista.org/e45-sleep-e-wake-da-interrupt-
esterno.pdf )
Coin selector works by comparing material, weight and
dimensions of each coin acquired with material, weight and
dimensions of samples provided during the "programming"
// Arduino: gettoniera – 616 type multi coin selector

phase (see below). If a coin is not recognized it is dropped on return slot, if is recognized, it sends
to Arduino a number of pulses equal to number of pulses programmed for that coin type.
1) Country selector, not used in this project
2) 4-pin connector:
a to. 12 v cc
b. Output signal (pulses)
c. Gnd
d. Not used
3) NO (always on) - NC (always off);
4) Pulse width: 20 or 50 or 70 milliseconds
5) Reset, not used in this project
6) Electromagnetic control system, not used
in this project
7) Led indicative of coins (6 leds, one for each
type of coin)
8) Setting button
9) Two-digit display
10) "+" button
11) "-" button
12) Coin acceptance slot
13) "Return" button for any coins stuck
14) return area for not accepted coins

Setting the coin selector

Before connect to Arduino, coin selector must be "programmed", ie it must be instructed on


different coins that it will have to recognize and on number of pulses it will have to issue for each
coin. Coin selector programming consists of two distinct phases: the "education" phase during
which both the number of coins and the number of pulses to be issued for each coin are defined,
and the "calibration" phase, in the course of which the various types of coins which will then have
to be recognized will be "tasted" several times at the coin selector.

Before proceeding it will therefore be necessary to obtain some samples of coins to use in the
"calibration" phase. It is advisable to prepare a certain number of samples (the ideal would be 20
coins for each type, but in this project only 4 were used per type, making them pass more times).
Before starting programming you must define number of pulses that must be issued for each type
of coin. In this project 10, 20, 50 cents and 1 and 2 euro coins are used, and it was decided to
issue an impulse every 10 cents of value and then:
 10 cents: 1 pulse
 20 cents: 2 pulses
 50 cents: 5 pulses
 1 euro: 10 pulses
 2 euros: 20 pulses
This choice has the advantage that in event of rapid succession of coins, the selector should not
lose control and generate as many pulses as there are tens of cents inserted, but has the
disadvantage of being rather slow in recognizing the coins of greater cut, since for these coins the
"train of impulses" will be rather long and will require a certain amount of time (it will take about 2
seconds to recognize a 2 euro coin).

Alternatives are obviously possible, such as the choice of a


different number of pulses for each coin type and therefore
with a maximum of six pulses for coin which is considered to
be of less frequent use.

The “education” phase


The coin selector is programmed using buttons 8, 10 and 11
// Arduino: gettoniera – 616 type multi coin selector

and observing communications that appear on display 9. These are the steps:
 Select "NC" by sliding switch 3 down;
 Select "fast" by sliding switch 4 upwards;
 Power the coin selector with 12 volts DC;
 Hold down the "+" and "-" buttons simultaneously for about 3 seconds, after which release.
Letter "A" will appear on display. Now press "SET" button once; letter "E" will appear;
 Use "+" and "-" keys to indicate number of coins (in terms of coin types, max 6 types of
coins) that you want to program. In this project 5 were chosen, ie 5 types of coins: 10 cents,
20 cents, 50 cents, 1 euro and 2 euros. Press "SET" to finish; The letter H will appear
followed by a number that identifies the currency being programmed (H1, H2, H3 ....).
1. Use "+" and "-" buttons to choose number of coins of that type (type 1 for H1, type
2 for H2, type 3 for H3 ...) which will be "tasted" by the coin selector. In this
project the value 15 was chosen (max 20). Press SET to finish;
2. The letter P will appear followed by the coin type number (P1, P2, P3 ...). Use "+"
and "-" keys to define numebr of pulses that must be issued for that type of coin. If
you decide, for example, that the type 3 coin (P3) is the 50 cents coin and if you
decide to issue an impulse every 10 cents of value, the number to be entered will be
5. Press “SET " to finish.
3. The letter "F" will appear followed by the coin type number (F1, F2, F3 ...). Use "+"
and "-" keys to select the security degree. Values from 1 to 30 are possible. The
lower the value the more the system will only accept coins of which it is certain (but
the number of coins not accepted will increase), while at a high value it will
correspond to a low security index. In this project the value "8" was chosen, as
suggested also by the manufacturer. Press "SET" to continue
4. The letter H will appear followed by the next coin number to be programmed, for
which steps 1 to 4 must be repeated.
 After setting data of all coins, leds will flash several times, show "A" on the display and after
4 seconds the value 0 will appear. Deactivate power supply, reactivate it and start the
calibration phase.
The “calibration” phase
a. Press "SET" button, letter "A" will be displayed. Press "SET" button again;
b. "A" will be displayed followed by the coin type number to be "calibrated" and the
corresponding led will light up: for type 1 coins (A1) the first led will light up, for type coins 2
the second led will light up and so on;
c. Insert coins of that type (type 1 for A1, type 2 for A2, type 3 for A3 ...) 15 times (15 because
15 is number chosen in the "education" phase, see previous point 1), trying to maintain a
constant speed.
d. After entering the chosen number of coins of that type, led lights will flash, display will show
"A" again, followed by the number of a new coin type and relating led will light up. Repeat
the previous step with coins of the indicated type, and so on.
e. After finishing calibration of all coins, led lights will flash several times, and "0" will appear

Now the coin selector has been “educated” and calibrated; turn it off and on to be able to use it.
In this project Arduino shows on serial monitor, value of coins read and accepted by coin selector.
Interesting is the use of the "interrupt" for counting pulses and the use of a "pull up" resistor to
constantly keep HIGH signal on Arduino pin 2.
Here the project movie: https://youtu.be/L4Rz0MgWYZ8
Note: This project and this note is part of a series that sees, as main characters, Arduino and
some of connectable components. For most projects there is also a video on youtube.
 Projects collection
 Movies on youtube
 About Arduino and components (italian; pdf will be downloaded in your download area
 Quick programming guide (almost english; pdf will be downloaded in your download area)
// Arduino: gettoniera – 616 type multi coin selector

For any questions or suggestions about this note (and on its english translation), please write to
giocarduino@libero.it (simple words and short sentences, please)

Materiali
 Una gettoniera (coin selector) di tipo 616
 Una resistenza da 10 k ohm
 Un po’ di cavetteria

Schema

Download del programma via Dropbox


Programma Program download via Dropbox

/*
la versione PDF del programma potrebbe non essere aggiornata. Usare il
// Arduino: gettoniera – 616 type multi coin selector

download per ottenere l’ultima versione. Non e’ necessario disporre di


dropbox e tantomeno iscriversi.

Warning: this PDF version may not be updated. Use download to get the
latest version. It is not necessary to have dropbox, let alone sign up

Facendo il copia/incolla dal PDF all’IDE si perde la formattazione del testo. Per
rendere piu’ facilmente leggibile il programma e’ opportuno formattarlo subito dopo il
trasferimento nell’IDE, premendo CTRL+T.

Questo programma gestisce una gettoniera programmata in modo da mandare un impulso per ogni 10
centesimi acquisiti. Una moneta da 50 centesimi invia 5 impulsi ed una da 2 euro invia 20 impulsi.
Fare riferimento alla scheda del progetto per avere indicazioni su come programmare la gettoniera

cut&paste from PDF to IDE loses formatting. To restore it press CTRL + T.

This program manages a programmed coin selecor so as to send an impulse for every 10 cents acquired.
A 50 cent coin sends 5 pulses and a 2 euro coin sends 20 pulses. Refer to the project sheet for
instructions on how to program the coin selector */

float valoremoneta = 0.00;


float momentocorrente = 0;
float momentoprecedente = 0;
byte nuovamoneta = 0; // semaforo che indica l'arrivo di una nuova moneta
//
//*** routine gestione impulso proveniente da gettoniera - manages pulses from coin selector
//
void nuovoimpulso()
{
momentoprecedente = millis ();
valoremoneta = valoremoneta + 0.1; // 10 cent per ogni impulso - each pulse values 10 cents
nuovamoneta = 1; // e' arrivata una moneta - flag to sign a new coin
}
void setup()
{
Serial.begin(9600);
attachInterrupt(0, nuovoimpulso, RISING); // gestione dell'interrupt: se arriva un impulso sul
// pin 2 (che corrisponde al pin 0 dell’interrupt)si attiva la routine "nuovoimpulso"
}

//
void loop()
{
momentocorrente = millis ();
if ((nuovamoneta == 1) && ((momentocorrente - momentoprecedente) > 300)) /* Se e' arrivata una
nuova moneta e sono trascorsi almeno 300 millisecondi dall'ultimo impulso - If a new coin has
arrived and has passed at least 300 milliseconds from the last pulse*/
{
nuovamoneta = 0; // azzera ils egnale di nuova moneta - unflag new coin signal
Serial.print("moneta da: "); //coin
Serial.print(valoremoneta);
Serial.println (" euro");
valoremoneta = 0.00; // set zero to coin value, waiting for a new coin
}
}

Potrebbero piacerti anche