Programming the Coin Acceptor

The ATM uses a programmable HX-616 pulse coin acceptor. It must be taught which coins to accept and how many pulses to emit for each, before it is wired to the ESP32.

Warning

Adjust the output voltage of the step-up converter before connecting the coin acceptor — it runs on 12 V. Powering it incorrectly can damage the unit.

How pulse counting works

The coin acceptor signals each recognised coin by emitting a number of pulses on its “Coin” line (wired to the GPIO from the pin table in Wiring & Pinout). The firmware counts those pulses with a debounced interrupt and maps the pulse count to a cent value.

The mapping is fixed in the firmware (COIN_MAP in src/coins.rs) and it is not monotonic — a plausible-looking “natural” ordering will mis-credit coins by up to 200x. Program the acceptor with exactly these pulse counts:

Pulses

Coin

2

5 cent

3

10 cent

4

20 cent

5

50 cent

6

1 euro

7

2 euro

8

1 cent

9

2 cent

Warning

1 cent and 2 cent sit at pulse counts 8 and 9, immediately after 2 euro at 7. An acceptor programmed in ascending value order therefore credits 50 cent as 2.00 EUR and 2 euro as 1 cent, permanently and silently. A pulse count of 1, or of 10 or more, maps to no coin at all: the acceptor has already banked that coin, so it is lost — the firmware shows a “Coin not recognised” screen and logs it, but it cannot hand the money back.

Pulse timing

The firmware infers where one coin’s pulse train ends and the next begins from the gaps between edges, so the acceptor’s pulse timing has to sit inside a window:

  • Gaps within one coin’s train must exceed 35 ms. Anything faster is treated as contact bounce and merged, which drops pulses and credits the wrong coin.

  • Gaps must stay below about 190 ms. A longer gap closes the train, so one coin is split into fragments that each map to nothing and are swallowed.

Most acceptors expose this as a “pulse speed” or “signal speed” setting; the medium/slow setting is usually correct. If the firmware log shows Invalid pulse count or coins are credited at the wrong value, the timing is the first thing to check.

Programming guides

Follow one of these detailed guides to program the acceptor for your coins:

Once programmed, wire the acceptor and its blocking MOSFET as described in Wiring & Pinout.