Pages: [1]   Go Down
Author Topic: Eddy Current coin detector  (Read 2491 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello!

I'm new to the world of Arduino, so far I've only done a few simple blinking LED projects with buttons and such.

I'm looking to create a setup that will detect what type of US coin has been rolled down a ramp using a magnetic field and the eddy current interactions for a physics project. Basically, I want something pretty similar to this:

I was looking to use two IR photogates to determine the speed of the coin (simply the time difference between when photogate 1 and two are tripped) and then I was going to use an Adafruit 16x2 LCD display to show the time it took to travel from photogate 1 to 2 and then display what sort of coin it is by comparing the time to a known range of values.

My question is, how do I find an accurate difference in time between tripping photogate 1 and 2? The absolute time is irrelevant, I just need a good delta t. I've looked around and I'm not sure if loops will be fast enough, and I'm a little unsure of my other options.

I feel confident in doing the comparison and display of the type of coin once the delta t is calculated but I'm a little stuck on the first part.

Thanks in advance for any help!!
Logged

UK
Offline Offline
God Member
*****
Karma: 13
Posts: 903
Twitter: @simonmonk2
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

You can use the function millis()

This returns a long which is the milliseconds since the Arduino last reset (well pretty much).

So, in pseudo code:

Code:
when trigger1 tripped
    t1 = millis()
when trigger2 tripped
    t2 = millis()
    dt = t2 - t1
    display dt on LCD
Logged

--
My New Arduino Book: http://www.arduinobook.com

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You could use interrupt driven coding to get very accurate timing. smiley-cool
Attach your photo eyes to the interrupt inputs.  Use the micros() function to get times.
pseudo code kind of:

INT0 :
micros() > stack.
Count+

INT1:
if Count > 0
   Micros() > endTime
   Pop stack > startTime
   Set EventFlag
   Count -
Main:
If EventFlag
   do calculations
   clear flag
   ----
Other stuff like display

Pushing start times onto a stack would allow rapid drops, so long as your main loop is able to complete faster then a coin can get thru.
(Lots of error stuff missing here, but you should get the idea.)

Notes:
Most Arduino boards have two external interrupts: INT0 (on digital pin 2) and INT1 (on digital pin 3).   

FUNCTION:  attachInterrupt(interrupt, function, mode)
FUNCTION:  micros()

Returns the number of microseconds since the Arduino board began running the current program. This number will overflow (go back to zero), after approximately 70 minutes. On 16 MHz Arduino boards (e.g. Duemilanove and Nano), this function has a resolution of four microseconds (i.e. the value returned is always a multiple of four). On 8 MHz Arduino boards (e.g. the LilyPad), this function has a resolution of eight microseconds.

There are 1,000,000 microseconds in a second.

Good Luck

Richard
Logged

0
Offline Offline
Faraday Member
**
Karma: 24
Posts: 3495
20 LEDs are enough
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Interrupt driven code will only give reliable accurate timing if all interfering interrupts are disabled. Otherwise you get mostly correct timing. That is every once in a while your timing will be off the mark depending on the interrupts that are blocking it.
Logged

Check out my experiments http://blog.blinkenlight.net

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks! The interrupt inputs seem like exactly what I want. I was searching all sorts of terms but never found that and it seems like a perfect solution. Now to wait for all my parts to arrive...
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 633
Posts: 34513
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Are you sure that will work?

I did a coin counting project back in 1994 that used a linear CCD to measure the diameter of coins. Mind you they are English coins.
 
The words are here
http://www.doc.mmu.ac.uk/STAFF/A.Wiseman/Acorn/BodyBuild/BB94.html
and the diagrams here
http://www.flickr.com/photos/33177304@N03/3851893046/
Logged

Dallas, TX USA
Offline Offline
Faraday Member
**
Karma: 70
Posts: 2735
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm with Si.
There is no need to over complicate this.
All you need is enough accuracy & precision to be able to distinguish between the coins.

Notice that the induction is influencing the roll speed between the different coins
by more than a 100ms time difference between the coins.
That is all day long to the AVR.
Plus it does not require super precise timings in order to be able to distinguish
between the coins.


Based on a known timing range for the coins, you can figure out which coin it is.
i.e. don't look for an exact timing value of an individual coin, look for > or < some other number
relative to the other coins.
You can nest your comparisons so that you only compare to one timing value
for each coin.
In his case:
if ( dt > 1000) quarter
else if( dt > 900) dime
else if(dt > 700) penny
else nickel

You will probably have to experiment a bit to determine what times identify each coin
and potentially tune your detector by varying a a few things like the slope of the
ramp to control the entry speed into the magnetic field and the strength of the field
by varying the distance between the coin and magnets.


--- bill

Logged

0
Offline Offline
Faraday Member
**
Karma: 24
Posts: 3495
20 LEDs are enough
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It all depends on what you want to achieve. If you know in advance that you are measuring a coin that belongs to a fixed set of coins then the task is easy. If you have to judge by the measurements if you are actually dealing with a coin and if this coin belongs to a predetermined set of coins then the tasks becomes significantly harder.

For the current task it seems that you want to solve the easy problem thus bill's approach is definitely sufficient.
Logged

Check out my experiments http://blog.blinkenlight.net

Dallas, TX USA
Offline Offline
Faraday Member
**
Karma: 70
Posts: 2735
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So True about the problem scope.
Even when dealing with just USA coins there some "gotchya's" involved.

The metal composition of the coins has changed over the years.

There are actually 3 different USA pennies. 1943, 1982 to now and all the rest.
I'm wondering if a 1943 penny would even make it through the magnets without
getting stuck to one.

There are multiple dimes but for modern dimes it is  pre 1965 and post 1965.

Quarters also changed in 1965.


--- bill

Logged

Pittsburgh, PA, USA
Offline Offline
Faraday Member
**
Karma: 98
Posts: 4813
I learn a bit every time I visit the forum.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I kind of wonder, if you had a magnet with hall sensor at one pole, what change to the field would there be from the induction into a coin passed by the other pole? I think that by conservation there should be some change, one way or the other.

Logged

I find it harder to express logic in English than in Code.
Sometimes an example says more than many times as many words.

Pages: [1]   Go Up
Jump to: