User avatar
owntheweb
Posts: 24
Joined: Tue Jun 16, 2015 1:51 am
Location: Colorado, USA
Contact: Website

coin hopper sensor: not detecting all coins dispensed (Pi GPIO too slow?)

Wed Jan 17, 2018 5:22 am

Hello gurus,
I'm attempting to get a Pi 3 to instruct a coin hopper to dispense coins using nodejs. So far I'm having some success. I have a relay hat that turns on the hopper from external power and a sensor output from the hopper is being read from a pin. Cool!

Challenge:
I can't seem to get accurate sensor readings from the hopper. The Pi GPIO input pin reads true/false values from hopper IR sensor output (cool), but not as many false readings as coins being spit out of the hopper. I've tried a couple of nodejs modules with similar/samish results. I get more than double coins for sensor readings (percentage varies).

Questions:
Is it possible that the Pi can't read sensor input fast enough for the hopper output signals? It seems like the Pi could be missing something.
Is it possible that my refurbished coin hopper may have a malfunctioning sensor (it looks great, so clean and new-like)?
I'm connecting hopper sensor output (Open collector-active low 25mA-35V ) directly to a GPIO pin. Is this an issue? See this post for discussion.

From the manual, here is the timeline of coin dispensing events. My hopper may be an older model (will update if I can find the exact manual again), but I remember the times being the same (interested in coin exit):
Screen Shot 2018-01-16 at 10.16.40 PM.png
Screen Shot 2018-01-16 at 10.16.40 PM.png (61.73 KiB) Viewed 683 times
I'm open to ideas!

Thanks for taking a look and let me know if I can fill in any gaps. It's late and this is looking pretty generalized at the moment.

Kind regards,

Chris
Worlds to explore. Worlds to create.

User avatar
owntheweb
Posts: 24
Joined: Tue Jun 16, 2015 1:51 am
Location: Colorado, USA
Contact: Website

Re: coin hopper sensor: not detecting all coins dispensed (Pi GPIO too slow?)

Wed Jan 17, 2018 2:56 pm

Updated idea:

I could solder in new wires for the IR sensor and connect directly to the Pi? That would at least remove uncertainty on a refurbished hopper and take out the middle man.
hopper-1.jpg
hopper-1.jpg (170.38 KiB) Viewed 642 times
From the numbers I could gather, it looks like this is the sensor.
hopper-2b.jpg
hopper-2b.jpg (201.62 KiB) Viewed 642 times
It has a little breakout board that has text on it, possibly "050-145A". (so 0.5-14.5mA??) Aside from those numbers, the sensor accepts "Maximum Collector Current" of 4ma.

Would you think this could connect directly to the Pi?
Worlds to explore. Worlds to create.

donmerch
Posts: 17
Joined: Mon Feb 15, 2016 8:47 pm
Contact: Website

Re: coin hopper sensor: not detecting all coins dispensed (Pi GPIO too slow?)

Wed Jan 17, 2018 4:35 pm

My guess is that your Pi is not registering all the pulses. If you have access to an oscilloscope or logic analyzer you could easily prove this out. I wouldn't modify anything on the hopper till you confirm it's working as expected.
By the looks of your schematic the coins are sensed by interrupting an IR beam then that signal is cleaned up and passed on to the open collector transistor. Very traditional circuit.
Before you tear your hair out you need to confirm the pulses are clean and as expected by using a scope or logic analyzer. A logic analyzer will show you the exact number of pulses and their inter pulse timing.
The best investment I ever made was to purchase a Saleae logic analyzer. It has saved countless hours of troubleshooting.
I work with coin and bill validators along with coin hoppers. Have never connected them to a Pi directly. I have always used an outboard simple microcontroller to control the devices (poll) and then just used a serial connection between the controller and Pi. The microcontroller is more deterministic in handling the device communication.

User avatar
owntheweb
Posts: 24
Joined: Tue Jun 16, 2015 1:51 am
Location: Colorado, USA
Contact: Website

Re: coin hopper sensor: not detecting all coins dispensed (Pi GPIO too slow?)

Wed Jan 17, 2018 11:21 pm

donmerch,
Thank you for your response. I'm more at ease as a result!

I'll definitely see if I can find an oscilloscope and/or logic analyzer. I'll look into a microcontroller as well. I've had good success with Arduino in the past, and this helps explain why I've seen Pis and Arduinos (or other microcontrollers) used together. Do you have a favorite microcontroller you use?

Thanks again for your insight,

Chris
Worlds to explore. Worlds to create.

donmerch
Posts: 17
Joined: Mon Feb 15, 2016 8:47 pm
Contact: Website

Re: coin hopper sensor: not detecting all coins dispensed (Pi GPIO too slow?)

Wed Jan 17, 2018 11:31 pm

I use the Parallax Propeller.

User avatar
joan
Posts: 13578
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: coin hopper sensor: not detecting all coins dispensed (Pi GPIO too slow?)

Wed Jan 17, 2018 11:54 pm

Try my piscope.

http://abyz.me.uk/rpi/pigpio/piscope.html

The needed pigpio library may be already installed if you are using Raspbian (sudo pigpiod to check, if no error is displayed it is installed).

User avatar
owntheweb
Posts: 24
Joined: Tue Jun 16, 2015 1:51 am
Location: Colorado, USA
Contact: Website

Re: coin hopper sensor: not detecting all coins dispensed (Pi GPIO too slow?)

Thu Jan 18, 2018 7:36 pm

Thanks all,
Due to current budget/available time constraints, I ordered a Trinket M0 as a start. It's cheap, small, lets me run Arduino sketches at a low level and has a built-in RGB LED I can flash as coin pulses are detected. If that works out well, I'll send serial communications to the USB-connected Pi (managing more human-facing complex items). It's still a gamble, but a small one.

From what I'm reading out there, it seems that Pis are better for communicating complex items, not as great at dealing with rapid, more intricate sensor data directly (with all things competing at the CPU). Microprocessors don't have all of the other junk in the way, allowing for better sensor readings. Does that seem accurate?
Worlds to explore. Worlds to create.

User avatar
joan
Posts: 13578
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: coin hopper sensor: not detecting all coins dispensed (Pi GPIO too slow?)

Thu Jan 18, 2018 9:23 pm

owntheweb wrote:
Thu Jan 18, 2018 7:36 pm
Thanks all,
Due to current budget/available time constraints, I ordered a Trinket M0 as a start. It's cheap, small, lets me run Arduino sketches at a low level and has a built-in RGB LED I can flash as coin pulses are detected. If that works out well, I'll send serial communications to the USB-connected Pi (managing more human-facing complex items). It's still a gamble, but a small one.

From what I'm reading out there, it seems that Pis are better for communicating complex items, not as great at dealing with rapid, more intricate sensor data directly (with all things competing at the CPU). Microprocessors don't have all of the other junk in the way, allowing for better sensor readings. Does that seem accurate?
Not really, the Pi will have no problem reading the pulses from a coin hopper.

Something is wrong either with the hopper or the wiring or the signal conditioning.

User avatar
owntheweb
Posts: 24
Joined: Tue Jun 16, 2015 1:51 am
Location: Colorado, USA
Contact: Website

Re: coin hopper sensor: not detecting all coins dispensed (Pi GPIO too slow?)

Thu Jan 18, 2018 9:41 pm

joan,
Good thoughts. Let me investigate further (perhaps with your tool!)

Kind regards,
Worlds to explore. Worlds to create.

Return to “Automation, sensing and robotics”