Reading digital impulse --> passed from coin acceptor

It's better to start a new topic because this is in end effect just read out of digital pin and has not so much to do with coin acceptor. So, i connect PIN 5 --> coin from the alberichi coin acceptor to digital pin 2 , and PIN 6 (inhibit ) do digital pin 4.

I use this to check for impulse:
//---------------------------------------------
int inPin = 2;
int val = 0;

void setup()
{
Serial.begin(9600);
pinMode(inPin, INPUT_PULLUP);
}

void loop()
{
val = digitalRead(inPin);
Serial.println(inPin);
}

//------------------------------------------
Now, the output is funny part and i dont know where this comes from.
Before i put any coin in i get 2,3 or some other number repeating itself all the time.
If i insert coin, i get different numbers of i dont get any changes.
It looks like that some number set repeat itself all the time and it look thats no time to read coin insertion...

Any ideas ?

I suspect you get allways '2' , don't you ?

void loop()
{
val = digitalRead(inPin);
Serial.println(inPin);
}

don't you see anything wrong here ?

:-). Correct that. Thank you.
Actually i found better code and this is the one that i tested before:

//-------------------------------------------
volatile int coin = 0;
void setup()
{
Serial.begin(9600);
pinMode (2,INPUT_PULLUP);
attachInterrupt(0, coinIN, FALLING);
}
void coinIN()
{
coin = coin + 1;
}
void loop()
{
Serial.print(coin);
delay(1000);

}
//-------------------------------------
Output: 12431 98374 76125 63530 etc.

But what i dont get is where is this coming from and is this "blocking" real impulse from coin acceptor.
Of course, there could be "noise " on the line but anyway, acceptor should detect change when the coin is in. Regardless what i put in coin acceptor i always get this continues set of numbers.
Btw. this +1 was from one other sample where the guy used this because he got wrong coin readings.
I can not get any :-).

I was thinking that maybe there is a problem with serial speed, but i test it on different speed, and the situation is the same...

once again :

pinMode (2,INPUT_PULLUP);
attachInterrupt(0, coinIN, FALLING);

'0' is wrong

maybe you should have a look here

It looks like i have to grab a beer :-). I corrected this too but the problem is the same.
How can i print out just pin change. ?

try without the coin acceptor first : put the pin2 input at 0V by hand 2 or 3 times and see what happens .

if it works, then the problem comes from the coin acceptor part
if not, read again the link I gave you before, draw a schematic of what you have done and post it here, also post a picture of your actual arduino and wiring, and the whole sketch .

Beer pack is ready, we can start the work :slight_smile:

try without the coin acceptor first : put the pin2 input at 0V by hand 2 or 3 times and see what happens

.
** Nothing happens. When i start program ( firstly without any connections ) i get 0,0,0,0,0,0,0,0 and so on. When i connect the wires, situation is the same.

if not, read again the link I gave you before, draw a schematic of what you have done and post it here, also post a picture of your actual arduino and wiring, and the whole sketch .

Testing HW is nhduino uno but target hw will be sainsmart mega board.
The code that i send is the whole sketch :slight_smile:

Link to pictures:
http://code.primaryblogs.net/wp-content/uploads/sites/14/2015/01/nhduino.jpg

OK,the '0 0 0 0 0' is normal but it should increase each time you connect pin2 to GND
now take a wire, put one side in pin2 ( the one just above the TX pin )
then put the other side in the GND pin (the one just under the AREF pin) , you should get a number, maybe more than
200 or 300 (because there is no debounce ) -

alnath:
once again :

‘0’ is wrong

maybe you should have a look here

sorry, my mistake here , ‘0’ is OK if pin2 is the “interrupted” input !

No problem !

Should i connect gnd somehow ? Maybe this is a problem in reading part for coin acceptor.
Because, now i connected just pin 5 from coin machine to pin2 of arduino..

If this will work , we can start to read out the pulses..

yes, the GND should be connected together, but I don't know your coin machine, there are several thing that must be checked (signals levels etc.... ) this part will come later !

first, you shoud do that, with the UNO only :

take a wire, put one side in pin2 ( the one just above the TX pin )
then put the other side in the GND pin (the one just under the AREF pin) , you should get a number

tell us what you get

but I don't know your coin machine, there are several thing that must be checked (signals levels etc.... ) this part will come later !

Just for easier understanding:

http://www.crownleisure.co.uk/Documents/Manuals/Alberici/AL05/05ing.pdf
Page 8.

I connected the coin pin with the gnd and i still get just 00000.
When i unplug / plug header connector to 10 pin flate cable connector i get some values, so the interrupt is checked ok. I get some changes for almost any pin (5/6/7/8/9 /10 ).

One more important thing.
When i put coin in, the coin is accepted and passed on the right coin acceptor exit.
I have no idea why can i get any pulse when the coin passes validation..

arnix:
I connected the coin pin with the gnd and i still get just 00000.
When i unplug / plug header connector to 10 pin flate cable connector i get some values, so the interrupt is checked ok. I get some changes for almost any pin (5/6/7/8/9 /10 ).

what does it mean ???

but forget the coin machine for now -
step by step .....
first of all you need to check if it works without the coin machine, as I told you before - When this part is OK, you can go to the next step and see how to wire the machine.... if you really need to use interruption etc....
It's late here, sorry, I'll be back tomorrow

what does it mean ?
-- it means that program reads some hw change ( as same as i tested before, without coin machine ).

without the coin machine, as I told you before - When this part is OK...
-- yep, this part is OK. I wrote this in previous post.
0,0,0,411,411,411,428,428,428...

Btw. just before i forget. Why is he repeading printout values ?

Anyway off for today :slight_smile:
I agree with you, its midnight and am also tired. Hear ya tomorrow.

arnix:
without the coin machine, as I told you before - When this part is OK...
-- yep, this part is OK. I wrote this in previous post.
0,0,0,411,411,411,428,428,428...

where ? I must have missed that one...

Btw. just before i forget. Why is he repeading printout values ?

because it is a counter - it counts how many times pin2 goes LOW

but..... here is the mistake :

It's better to start a new topic because this is in end effect just read out of digital pin and has not so much to do with coin acceptor.

no, IMHO, you should have continued on the other topic -
When I read the text above, I thought there was a signal you knew which was sent each time a coin was inserted in the machine.... but I had a quick look at your link and as far as I can see, there is not .
I think you should have stayed with the other topic, because it is all about setting up the machine, understanding how it actually works, and what it sends and when it does .
I've never used such a machine before, and I don't have much time to read more deeply the manual and really understand the different ways you can set up and use the machine.....so I'm afraid I can't help you with this, sorry.
But if you read again the manual, and the tutorial you linked to in your other topic (including the links inside it), You'll figure out how to set it up to work as you want it to. Then, if it doesn't work, I'm sure that some people here know enough about coin acceptors to help you.

Hi.

I have started new topic with more HW details.
If you can help out, please take a look.