Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
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
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.
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
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).
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
/*
la versione PDF del programma potrebbe non essere aggiornata. Usare il
// Arduino: gettoniera – 616 type multi coin selector
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
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 */
//
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
}
}