Controlling coin-acceptor with relay.

Hello!

I am using "generic" coin-acceptor in my project, that can accept 5 coins. It's accepting coins as long as it is powered on. It should accept only when appropriate screen is displayed on my LCD. When I remove power from it - it is rejecting all coins. So simple solution is to use relay to turn on and off this acceptor whenever I need it to accept coins. So far, so good.

Problem is.. when I supply power to coin acceptor it imediatelly send some random pulses to coin-wire before it's ready to go. Those some random pulses are already counted as some coin-value and that shoudnt be.

How to properly detach interrupt (or simply saying disable pin2 for about 1000ms so this coin acceptor gets ready)

In Void setup I have code:

	pinMode(2, INPUT_PULLUP); 
	attachInterrupt(coinInterruptPin, coinInserted, FALLING);

When apropriate screen is displayed on my LCD screen I have folowing code that must turn-on coin acceptor.

		detachInterrupt(digitalPinToInterrupt(2)); //trying to detach interrupt while coin-acceptor turn on.
		delay(400);
		digitalWrite(38, HIGH); // Turning on relay that supply +12V to coin-acceptor
		delay(1500); //waiting for coin acceptor to become ready
		attachInterrupt(coinInterruptPin, coinInserted, FALLING); //attaching interrupt and coinInserted function

But this solution don't work as expected - one pulse is added anyway.

Another thing - whenever I plug/unplug coin-pulse wire to/from Arduino pin2 - it counts this one pulse. Maybe I need to attach some resistor?

(deleted)

Adding 10k resistor didn't help. With that it even stop counting pulses. I came up with simple solution by adding boolean coinAcceptorRdy=false; And in function that actually counts pulses I added if block that checks this boolean state before counting anything. And in code part where I turn on relay I added simple delay 1500ms before setting coinAcceptorRdy to true.
That simply solves all this mess with startup.
Huh.

(deleted)

Eifel:
Adding 10k resistor didn't help. With that it even stop counting pulses. I came up with simple solution by adding boolean coinAcceptorRdy=false; And in function that actually counts pulses I added if block that checks this boolean state before counting anything. And in code part where I turn on relay I added simple delay 1500ms before setting coinAcceptorRdy to true.
That simply solves all this mess with startup.
Huh.

can you share the code?

Hi,
Does your code do anything else?
Is there really a need for interrupt?
If all you are doing is looking for an input to change that is not strictly micro second dependent?

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom.. :slight_smile: