Coin acceptor sends a single pulse upon powering

Hi there good people,
I am re-doing the project I've made a while ago. It's DUE + coin acceptor + LCD + SD shield + keypad = a coin operated phone.

The problem(s) is that every time upon powering on my coin acceptor would send a single pulse (0.10€) would be showed in the LCD. I've tried to add a pull up resistor, but it would not solve the issue. Previously I've tried to determine the pulse frequency by using millis(). This approach is pretty unreliable when the machine must work for years in the future, sometimes the coin acceptor would be changed with a different model.

Another problem is that LCD displays all pixels as black, unless I am restarting the Arduino. Which is pretty simple, I've made a reset button for that reason. Still, weird.

Adding a photo of my wiring (if it helps, I know it's messy).

Any ideas? Thanks!

If it happens every time, just ignore it in your software.

The hardware as shown isn't very fit for that. I assume it will be rebuilt in a more solid fashion that is more likely to stand up to the anticipated abuse that a coin-operated machine sees over its lifetime.

All of this sounds like you've got startup problems associated with your power supply. It would help if you provided a full schematic of your system and specifications of the modules used, particularly the power supply and display.
Have you tried the obvious workaround of starting your Arduino code with a delay(1000); before anything else happens? This should enable all peripherals to power up, after which you can start initializing stuff. Maybe your Arduino is up and running before all the rest arrives in an operational state.

Does this happen if you disconnect the coin pin?
Does this happen if you only reset the board?

The simple solution would be to ignore all signals for a few seconds when starting up. You can put a delay in the setup to accomplish this. Do this after you have configured the port pins. You can also put a message on the display saying calibrating or whatever you like.

1 Like

Thank you for your help!
I have manually adjusted accumulated coin value, delay() would not give me the desired outcome in the setup.

void setup() {
  // debug output at 9600 baud
  Serial.begin(9600);

  //My LCD is 16x2
  lcd.begin(16, 2);
  lcd.createChar(0, euro);
  lcd.createChar(1, phone1);
  lcd.createChar(2, CAPITAL_YA);
  lcd.createChar(3, CAPITAL_BE);
  lcd.createChar(4, phone2);
  euroCoins();
  SD.begin(10);
  //for DUE - any digital pin as Interrupt pin
  pinMode(coinInt, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(coinInt), coinInserted, RISING);
  coinsValue = coinsValue - 0.10;  //Manual adjustment for a single (0.10€) pulse when powering the coin acceptor
  lcd.home();                      // go home
  lcd.setCursor(0, 0);             // go to start of 1 line
  lcd.print(coinsValue);

  DACC->DACC_CHDR = DACC_CHDR_CH1;  //disable DAC1

Though maybe there is a better solution, I am experimenting with millis now to just listen for input after a second or so.

Does this happen if you disconnect the coin pin? NO
Does this happen if you only reset the board? YES

LCD only behaves like this (all pixels filled) when powered through the external power source (220V->12V). Also delay(1000); gives no effect, sadly.

The wiring of course will be changed for the final setup, all the connections will be soldered and the machine sealed in an IP55 container.

If it's in void setup() , consider the following (cut out what you don't need):



void setup() {
  Serial.begin(115200);
  while (millis() < 3000) {
    for (int i = 0; i < 1; i++) {
      lcd.clear();
      Serial.println("hotdog or hamburger?");
      delay(250); 
    }
  }
}
void loop() {
  Serial.println("hamburger, please.");
  delay(1000);
}
1 Like

Using an interrupt to detect activity on the coin acceptor is unnecessary. You could treat it as a push button, polling it, and add debouncing. In some cases, the attachInterrupt() function can immediately trigger if there is already an uncleared interrupt pending at the time it is called.

2 Likes

Thank you all for helping! I've used a proposal by hallowed31 and added some loading animation:

void startCoinLCD()
//This function just shows animated dots while LCD is being calibrated and resets coin value to 0 to avoid stray pulses when powering the system
{
  while (millis() < 3000) {
    for (int i = 0; i < 1; i++) {
      lcd.print(".");
      delay(200);
      lcd.print(".");
      delay(200);
      lcd.print(".");
      delay(200);
    }
    coinsValue = 0.00;  //An adjustment for a single (0.10€) pulse when powering coin acceptor
    lcd.clear();
  }
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.