Money Slot detector (IR / combining analog inputs)

Greetings, fellow tinkerers!

I've been forced by the conditions of my employment to undertake a rather daunting task of figuring out a way to create general-purpose detector, used to trigger sounds every time money is dropped into the slot. The problem with this particular one is that it has to accept money of any form - coins, rolled banknotes, regular banknotes, crumpled checks, diamonds, deeds to long-forgotten properties and similar.

As for the general design, I've gone with a box, with a slanted bottom, heading down towards an open edge. This way, no matter what's thrown in, coins, bank notes or otherwise, it'll fall flat while sliding down, means it'll reach the edge with maximum surface area.

Now, as for detection, the current idea is to have row of infrared LEDs lined up at the top of the edge and a row of infrared phototransistors lined up at the bottom of the edge. When the object passes through, it disturbs the beam on at least a couple of these. The disturbance is detected and the sound is played. As far as the circuitry goes, I've managed to get a single photoresistor running (according to these schematics). Where I fall flat on my face is doing it for several photoresistors. The problem is, I'm going to have something close to 20 of photoresistors, but Arduino only has 6 analog inputs to read from (and I need the analog input, as in some cases, the change in voltage is not big enough to pass on digital input, for example with thin banknotes).

The idea I've had is to somehow couple them together on one read line, i.e. four per analog input pin. This way, when there is nothing in the way, the reads are given at 100%, if one from the group is covered, the reads are at 75%, if two, 50% and so on. However, in my rather limited knowledge, I have not managed to design a circuit to allow such reads - everything I've wired acts as 0% if every phototransistor is covered, 100% otherwise. Would you be able to lend me your thoughts on that?

Alternatively, the idea of using an analog multiplexer has occured to me, though I have no experience using such components, so I'd need some guidance, if it seems better option than to wire the phototransistors in groups.

With best regards,
Mick

You could have a line of LEDs illuminating a load of cheap LDRs connected in series.

If you use white LEDs rather than IR, it would light up the slot ?

The top LDR is connected to Vcc ( 5v ) and the bottom one to a 220k preset pot that goes to ground.

With nothing breaking the beam ( all the LDRs at low resistance ) set the preset so that the voltage at the bottom of the LDRs is 2.5v

Connect this point to one of the analog inputs of the Atmega 328 - or arduino board - with a 100 nF capacitor to ground to smooth out any noise.

With you thinnest bank note in the way ( which should weaken several of the beams ) measure the voltage on the analog pin, and write your sketch to detect an object if the voltage drops below this level ( leave a margin spare for ambient light noise )

The idea is that with all the LDRs illuminated, ( say there are 10 of them with 3 kOhm resistance illuminated ) , the total resistance will be 30k.
As soon as even one of the LDRs is shaded, it goes up to perhaps 100k resistance, making a series resistance of 127k, more than enough to detect.

I've been forced by the conditions of my employment to undertake a rather daunting task of figuring out a way to create general-purpose detector, used to trigger sounds every time money is dropped into the slot. The problem with this particular one is that it has to accept money of any form - coins, rolled banknotes, regular banknotes, crumpled checks, diamonds, deeds to long-forgotten properties and similar.

Do you just have to detect something inserted into the slot or determine what the object is that's inserted into the slot? If it's the latter then that's a big ask of even a super computer yet alone an Arduino.

Is there any restriction on the type of thing you need to detect? (Presumably you aren't being asked to detect specks of dust etc.) How important is it to avoid false positive or false negative detections? Is there any requirement to determine what type of thing has been inserted? How physically robust does this solution need to be - does it just need to work once in the lab, or does it have to keep working day after day in a dusty shed with half-bricks being lobbed into it and so on? Do you need to detect everything in a single detector? If not, you could consider using the sort of lever switch used to turn paper shredders on to detect paper-based things, and have everything else dropped down a 'coin slot' type of thing, which can now use simpler mass-based detection since you have removed the need for it to detect paper.

Do you need to count each item separately? If so, what do you do with the IR beam in the case of say a coin sliding down on top of a flat bill? You'd only get one detection.

Since you have such a wide variety of items this device will accept (diamonds to old property deeds, who are you working for... Snidely Whiplash?:slight_smile: ) as others have mentioned I really think you should have multiple recepticles. At the very least one for paper cash, one for coins, one for documents that can be folded into a standard envelope, and another for miscellaneous. The first three have been solved multiple times for applications like vending machines, ATMs, etc... and you can occasionally find some existing hardware in surplus stores, junk yards, or even hobbyist electronics stores (e.g. Adafruit). That is if having multiple slots or purchasing pre-existing sub-assemblies doesn't twirl your boss's mustache the wrong way. :wink:

To your specific question about groups of LDRs giving you a range from 0% to 100%, I've never done something like this but I can give you a or two suggestion to try.

First if you are going to have a microcontroller, let it do the math by using four (or how ever many groups of LDRs you end up with) analog inputs with byte-sized flags for each in your code. That way when the group of LDRs drops below a threshold value, the its flag is set to "1". Then all the flags are summed so the sum can be divided. If you don't want to permenatly take up space for a float variable, you can just use nested if statements to dividing from the total number of LDR groups down to 1. Pseudo code below:

If totalFlags/4 = 1 then
  object's size is between 75% and 100% of the slot
Else
  If totalFlags/3 = 1 then
    object's size is between 50% and 75% of the slot
  Else
    If totalFlags/2 = 1 then
      object's size is between 25% and 50% of the slot
    Else
      If totalFlags/1 = 1 then
        object's size is between 0% and 25% of the slot

You could also use a switch case block but you'd have to use a lot of cases or a quite a bit of compound conditions ( using boolean operators like "&&" and "||") for most cases.

Second, you can use a multiplexer but unless there's a lot of other I/O required in the design I'm not sure it's worth the effort. In any event, it wouldn't hurt to look at some of examples in the Playground because they it includes information about how to use specific MUXs with Arduinos.