Arduino Forum

Using Arduino => Project Guidance => Topic started by: tdirodis on Mar 05, 2013, 05:58 am

Title: Record Changes in Height of Book Stack - Best Sensor?
Post by: tdirodis on Mar 05, 2013, 05:58 am
For a school project I need to track the use of a study aid book.  Students can take 1 book home with them at the end of the day and are to return them the following day.  The dimension of the books is uniform and they are stacked vertically in a wooden box.   Access to them is from the top of the box only.  On the left and right inner sides of the box there is a 2 inch gap with vertical slats running the height of the box so as to keep the books neatly stacked on one another.   

In order to track the number of books that are taken and returned from day to day I am supposed to engineer a device that senses the height of the stack of books as it changes.  The only stipulation is that I cannot use any sort of scale or pressure system to determine the change.   I have some experience with the Arduino board and thought that I might utilize it along with a sensor to monitor the height of the stack as it changed from day-to-day.   

Maybe an IR sensor mounted on the left or right inner side of the box in the 2 inch gap?   I'm not sure if the 2 inch clearance on either side of the book stack would be enough distance from the IR?   Given that the point of the project is to monitor the change in height of a stack of books in a confined space would an IR sensor work or would another type of sensor work better?
Title: Re: Record Changes in Height of Book Stack - Best Sensor?
Post by: astrofrostbyte on Mar 05, 2013, 07:18 am
I'm also thinking a strip equal to the height of the box with (IR) reflective sensor every other inch (depending on book thickness)
          or,
Mount a strip of IR transmitters on left side of box,  and a strip with receivers on right side of box.

Control and enable each element seperatly and scan through the height of the box.

If you have got a bit of budget you can make custom PCB strips, and maybe coat them in a thick transparent resin for durability.
Title: Re: Record Changes in Height of Book Stack - Best Sensor?
Post by: spatula on Mar 05, 2013, 01:38 pm
The idea of two strips of transmitters/receivers sounds good, but if the box doesn't get moved you may also consider a ping ultrasonic sensor placed above the stack.
Title: Re: Record Changes in Height of Book Stack - Best Sensor?
Post by: PeterH on Mar 05, 2013, 03:00 pm
There is a type of plate rack often used at serving counters which consists of a vertical tube with a sprung platform in it. The spring free length is such that the platform is exactly level with the top of the tube when it is unloaded, and the spring rate is chosen so that the weight of a plate compresses it by exactly the height of a plate. This means that no matter how many plates it's holding, the top plate is just at the top of the tube.

You could do something similar for your book stand. As well as showing the curious some interesting physics, it means that you could sense the number of books from the bottom of the pile rather than the top, which you could do using a string/pot or whatever other type of distance sensor you like. Of course you could have read from the bottom of the stack anyway using a force sensitive resistor to measure the weight of the pile, and that would be my second choice, but that's far less fun.
Title: Re: Record Changes in Height of Book Stack - Best Sensor?
Post by: MarkT on Mar 05, 2013, 03:40 pm
Ah, that suggests an approach.

Rather than having to fish around for a set of springs that are just right, use a stepper? motor and screwthread drive
to raise and lower the platform so that the top of the stack is level with some dual light-beam detector.   By counting the
steps needed each time is changes you can count the number of books.

By using a screwthread drive the motor can be powered down between uses.  When both beams are blocked or neither
are blocked (for more than a few seconds), you power up motor and step till just the bottom beam is blocked, simple!

An alternative with less heavyweight engineering is to use one light beam detector than is motor driven.  To measure
the pile of books it just goes to the bottom and scans upwards till the beam gets through - even a simple DC motor can be
used if the speed is nice and constant - just time the motor travel!
Title: Re: Record Changes in Height of Book Stack - Best Sensor?
Post by: Retroplayer on Mar 05, 2013, 03:45 pm
If you go the IR route, you really only need two interrupters. You would just sense the direction of movement into and out of the box. Increment and decrement your count based on that.

As you described it, there is only one entry and exit point to the box.

My initial thought was more along the lines of Peter's and it sounds like the most fun and interesting, but probably the most complicated to build. If you did go that route, you could add a flag to the pedestal that gives a visual indication of the number of books as well.
Title: Re: Record Changes in Height of Book Stack - Best Sensor?
Post by: tdirodis on Mar 06, 2013, 12:18 am
Thanks for the ideas.  I'm really looking for something that fairly inexpensive, pretty accurate and not too challenging.  As I mentioned I need to track the height of the book stack as it changes in a confined space - a box.  With that said, it sounds like the two IR stips (transmitter and receiver) might be the way the go as posted by astrofrostbyte.  Can some recommend a manufacturer or perhaps provide a link for the stips?  Would they work with an Arduino board?  If at all possible can someone also suggest a link where I might find some sample code associated with using the IR stips?  I really appreciate everyone's input and advice.
Title: Re: Record Changes in Height of Book Stack - Best Sensor?
Post by: PeterH on Mar 06, 2013, 01:04 am
That would need a sender and receiver per book, wouldn't it? How many books do you plan to support?

If you don't fancy the suspended stack approach, I'd have thought weighing the pile of books would give you a simpler solution with lower part count. Force sensitive resistors don't cost much.
Title: Re: Record Changes in Height of Book Stack - Best Sensor?
Post by: Retroplayer on Mar 06, 2013, 01:37 am

The only stipulation is that I cannot use any sort of scale or pressure system to determine the change. 


I believe this is why, Peter.
Title: Re: Record Changes in Height of Book Stack - Best Sensor?
Post by: sonnyyu on Mar 06, 2013, 01:58 am
I offer 3 plans;-

Plan A.

Digital Calliper and Arduino, measure Height of Book Stack directly. modify Calliper as book holder

(http://www.electronics-lab.com/blog/wp-content/uploads/2010/08/Reading-Digital-Callipers-with-an-Arduino-USB.jpg)

Plan B.

Ultrasonic distance sensor and Arduino, measure Height of Book Stack indirectly by leftover Height.

(http://jasongollings.files.wordpress.com/2012/02/ultrasonic.jpg)


Plan C.

RFID and Arduino, get which books in the shelf, u could get height.

(http://i.msdn.microsoft.com/dynimg/IC126170.gif)
Title: Re: Record Changes in Height of Book Stack - Best Sensor?
Post by: astrofrostbyte on Mar 06, 2013, 06:14 am

Thanks for the ideas.  I'm really looking for something that fairly inexpensive, pretty accurate and not too challenging.  As I mentioned I need to track the height of the book stack as it changes in a confined space - a box.  With that said, it sounds like the two IR stips (transmitter and receiver) might be the way the go as posted by astrofrostbyte.  Can some recommend a manufacturer or perhaps provide a link for the stips?  Would they work with an Arduino board?  If at all possible can someone also suggest a link where I might find some sample code associated with using the IR stips?  I really appreciate everyone's input and advice.

You still haven't given us more detailed requirements about your system, like dimensions of book, box ,powersupply, userInterface, etc...

I'm afraid you can not buy IR ledstrips readymade, you also have certain requirements for  spacing etc..
You can make the strips fairly easy when you use 5mm led's. If you buy IRled's make sure to choose one's with small emmision angle.

For reliability I would not go for the book in/out detection with 2 led's  because you have to pay allot of attention to false triggers (people hands etc.
For reliablity i was also thinking of modulation, just to filter out ambient influences. Modulation would be simply switch led ON and off a few times and, checking if photodiode follows.
Do not underestimate receiving the IR signal with the photodiode. Adding an opamp and some filtering might be needed.

Idea was to use a 1->8 or 1->16 Digital Mux for your led's , and 8->1 or 16->1 analogMux for photodiodes depending how many led's(books-levels) you need/have.
I think this can fit on a Arduino nano/mini, but still unclear what your Userinterface is.

Title: Re: Record Changes in Height of Book Stack - Best Sensor?
Post by: PeterH on Mar 06, 2013, 09:42 am


The only stipulation is that I cannot use any sort of scale or pressure system to determine the change. 


I believe this is why, Peter.


Good point, I hadn't spotted that.

In order to know what other type of sensing might work, we need to know more about the characteristics of the books (size, thickness, number) and any constraints in the structure that holds them - does the holder already exist?
Title: Re: Record Changes in Height of Book Stack - Best Sensor?
Post by: tdirodis on Mar 07, 2013, 12:21 am
The box was custom built so that the books are stacked on one another so all sides are aligned.  There is a 2" slit in front of the box which allows you to see the spine of the book.  In other words you can see that there are still books in the box without looking into it from the top.  As I mentioned in my original post "on the left and right inner sides of the box there is a 2 inch gap with vertical slats running the height of the box so as to keep the books neatly stacked on one another."  It's in the gaps that I'd like to place the (still trying to determine the best) sensor.  I'm intrigued by astrofrostbyte's idea:
Quote
Idea was to use a 1->8 or 1->16 Digital Mux for your led's , and 8->1 or 16->1 analogMux for photodiodes depending how many led's(books-levels) you need/have.
I think this can fit on a Arduino nano/mini, but still unclear what your Userinterface is.
and I'm hoping it's not to complicated?  In terms of the interface I'm thinking an Arduino boad powered by a USB chord to which the sesnor(s) is/are attached (if that makes sense?)  I should have also mentioned that I cannot use a ultrasound sensor as the book box gets moved to different areas.  The books are all the same with the following dimensions: Front cover from left to right = 7.5", Front cover from top to bottom = 9", Front cover to back cover = 3/4".  The box can accomodate approximately 15 books. 
Title: Re: Record Changes in Height of Book Stack - Best Sensor?
Post by: astrofrostbyte on Mar 07, 2013, 10:32 pm
The Circuit is not to difficult but still needs attention.
First think of your circuit to measure a 1 book high stack with one IRled and one photodiode,  then look at extending it using a 'Analog 16channel Multiplexer' like the 74HCT4067 and others.

BlockDiagram would be a bit like this.  (  just was playing arround with schematics drawing tool on http://www.digikey.com/schemeit# (http://www.digikey.com/schemeit#)  )
(http://i46.tinypic.com/2lm9jqx.png)
Title: Re: Record Changes in Height of Book Stack - Best Sensor?
Post by: tdirodis on Mar 07, 2013, 11:49 pm
I think I'm just about convinced that this is the way to go on this project.  Astrofrostbye, would you mind providing a recommended parts list?  I'd like to get started ASAP.  Thanks for everyone's input to date. I'm sure I'll have more questions to follow. 
Title: Re: Record Changes in Height of Book Stack - Best Sensor?
Post by: GoForSmoke on Mar 08, 2013, 01:23 am
If the inside of the box is well illuminated then you only need detectors that the book spines would block or not. Maybe drill holes through the vertical slats and put the detectors in, but if the books are thin that would be a LOT of detectors needing to be wired. Good news is a bag of detectors might run 5 cents each.

I was looking at fiber optic cable, to feed the light from many to 1 phototransistor but wow, the cable I see costs more than detectors and wire!

You could try ultrasonic sensing from above the box. Check them on eBay, they're cheap.
http://www.ebay.com/itm/HC-SR04-Ultrasound-Wave-Detector-Range-Ultrasonic-Sensor-Distance-Module-/200896270284?pt=LH_DefaultDomain_0&hash=item2ec659cfcc
This looks the same as the ones I got from LC Tech. It's supposed to be good to 2mm but I didn't get that in quick testing. Getting it right should be a little problematic.

Quote
There is a 2" slit in front of the box which allows you to see the spine of the book.  In other words you can see that there are still books in the box without looking into it from the top.


That presents single detector possibilities but they would have to be positioned in front of the box.





Title: Re: Record Changes in Height of Book Stack - Best Sensor?
Post by: astrofrostbyte on Mar 08, 2013, 09:57 pm
Quote
Astrofrostbye, would you mind providing a recommended parts list?

Well since it's a school project this is probably a good moment to learn about the few components you're going to need.  Just take a day to read up on PhotoDiode/Transistor,  analog multiplexers, etc.

I would recommend Farnell for a bit of components selection, for example if you go to optoelectric section you can select IR emitters,  and select the key specs your looking for like 'emision angle','case' and 'sort on price'  you'll get a good selection.
Then buy a few components and start testing and prove to yourself that this is a good design approach.

maybe....
Since your bookthickness is defined, and relatively large, maybe it could be as simple as using a bunch of lever-switches ?
(http://www.me.umn.edu/courses/me2011/arduino/technotes/microswitch/187733.jpeg)
For robustness just mount them behind a steel strip with holes in where the little wheel sticks out.
Title: Re: Record Changes in Height of Book Stack - Best Sensor?
Post by: GoForSmoke on Mar 09, 2013, 01:37 am

Since your bookthickness is defined, and relatively large, maybe it could be as simple as using a bunch of lever-switches ?
(http://www.me.umn.edu/courses/me2011/arduino/technotes/microswitch/187733.jpeg)
For robustness just mount them behind a steel strip with holes in where the little wheel sticks out.


Do micro-switches cost less than phototransistors? Ceiling lights or a led in the box is enough illumination for those if not covered by a book.

But there is another way not prohibited, you may like.
Quote
The only stipulation is that I cannot use any sort of scale or pressure system to determine the change. 


If all the books have a strip of aluminum foil taped over the spine, they would have capacitance with other strips of foil close in the box. To check you quick charge a foil strip in the box through a resistor  for a millisec or 5 and then count microseconds (small resistor) until the charge bleeds to digital LOW.
You can multiplex pins. One goes HIGH, one goes LOW, the intersection has current flow. There, it rhymes even. You save on resistors multiplexing, they only need to be on the pins for rows or columns. Multiplex also works for phototransistors.

Title: Re: Record Changes in Height of Book Stack - Best Sensor?
Post by: tdirodis on Mar 09, 2013, 07:31 pm
Thanks for the additional ideas.  What do you guys think of maybe utilzing this type sensor: https://solarbotics.com/product/40253/ (https://solarbotics.com/product/40253/) in this application?
Title: Re: Record Changes in Height of Book Stack - Best Sensor?
Post by: astrofrostbyte on Mar 09, 2013, 10:45 pm
Looks cool, but my eye caught the Price $30,- ,  for that money you can buy 16x (IRled's+photodiode) and 2x Ana.multiplexers.
Remember that with the arduino you can do a bit of modulation also.
Code: [Select]
pseudocode:
for ( i = 0 to 200 )
{ Switch IR led ON
  delayus(  )
  varON += Read AnalogIn from PhotoDiode
  Switch IR Led OFF
  delayus(  )
  VarOFF += Read AnalogIn from PhotoDiode
}
val = (ValOn-ValOFF)

You need to test this because its hard to predict how strong your photodiode signal will be, and influence of Day/artifi. light.
Title: Re: Record Changes in Height of Book Stack - Best Sensor?
Post by: GoForSmoke on Mar 10, 2013, 01:25 am

Thanks for the additional ideas.  What do you guys think of maybe utilzing this type sensor: https://solarbotics.com/product/40253/ (https://solarbotics.com/product/40253/) in this application?


I don't think you will get range from those sensors good to know 1 book from 2 or 3. Also detection range is short,
Quote
a 3-direction object sensor, with a 4~6" (10.16-15.24cm) range.


Title: Re: Record Changes in Height of Book Stack - Best Sensor?
Post by: tdirodis on Mar 11, 2013, 11:04 pm
I've got to admit that this is much more overwhelming than I had orignally thought.   I'm far from an electronics whiz.  I like the idea that astrofrostbyte recommended but even after reading up PhotoDiode/Transistor,  analog multiplexers, etc. I don't even know where to begin in terms of purchasing the items for this project.  It be nice if I could keep the cost to less than $100.  I did look at the Farnell website but I'm not sure what would work with an Arduino board or even how I'd begin to hook it all up.  Any advice would really be appreciated. 
Title: Re: Record Changes in Height of Book Stack - Best Sensor?
Post by: Retroplayer on Mar 12, 2013, 12:23 am
For a mux, this is cheapest: https://www.sparkfun.com/products/9056 at $5, but this is probably easiest (well not really, it's really the same basic thing but with 3 of them): https://www.sparkfun.com/products/9832
That one for $5 will give you 16 inputs, should be enough, right?

You can set up a photo-diode to work with a digital pin so you don't have to worry about an analog mux at all. But, maybe kill two birds with one stone and just get these: https://www.sparkfun.com/products/9454

These are IR reflectance sensors. You would install them just on one side and they will reflect off a close object and you can detect the book. These will need to be fairly close though and you would get better results if you were able to put white (tape) on the spines of the book. But at $3 a pop, they are worth investigating. They are just plug and play. I forget how many books you said were total. 16 books would be $48 in sensors, but you don't need the mux.

Did you need a display for the count?

Title: Re: Record Changes in Height of Book Stack - Best Sensor?
Post by: GoForSmoke on Mar 12, 2013, 03:27 am

I've got to admit that this is much more overwhelming than I had orignally thought.   I'm far from an electronics whiz.  I like the idea that astrofrostbyte recommended but even after reading up PhotoDiode/Transistor,  analog multiplexers, etc. I don't even know where to begin in terms of purchasing the items for this project.  It be nice if I could keep the cost to less than $100.  I did look at the Farnell website but I'm not sure what would work with an Arduino board or even how I'd begin to hook it all up.  Any advice would really be appreciated. 



What sources do you have? Can you buy from eBay? Phototransistors there, I find as low as 5 to 10 cents US when buying as few as 20.

Get visible light detectors and room light in the box can trigger those not blocked by books as long as that part is not in shadow. To wire it up you can multiplex pins as rows and columns where row pins would be INPUT HIGH pullups and column pins would be one at a time switched to OUTPUT LOW to see which inputs get pulled down through detectors that "see light". The rest of the time the column pins would be INPUT LOW and draw such tiny current as to make no effect.

Worst case, you may need to mount a light on the back of the box. It maybe depends on how you point the detectors, something to experiment with before deciding physical arrangements.

The detectors will be in essence buttons and be debounced in software (give the same reading a number of times in a row, takes a few milliseconds unless very noisy).

US$100? I think less than US$5 to 10 is possible if you use a stand-alone 328P and no custom board. But that doesn't count your work and purchase any custom mountings. If you are willing to use sawdust and white glue you can make those.

Title: Re: Record Changes in Height of Book Stack - Best Sensor?
Post by: tdirodis on Mar 13, 2013, 11:08 pm
A few important things have changed specifically with the box and the book since my origianl post.  While the books still have to be taken from the top of the stack, the box itself has open sides, although it will still be easy to mount whatever sensor in 2" space on either side of the book.   Now my concern is that there might be too much light to use IR?  Also the books are black and I wouldn't not be able to put white tape on the spine of the book as was suggested earlier.  I still cannot use a pressure sensor and since the box is moved around the room I don't think an ultra-sound sensor would work either.  Will an IR solution still work this new information?
Title: Re: Record Changes in Height of Book Stack - Best Sensor?
Post by: GoForSmoke on Mar 14, 2013, 04:14 am
If you drill through the wood spacer(s) that the book spines will be set against and put the detectors in there then extra light from the sides will not be a problem but a help. Ask if the box can be tilted so the spines must always sit against the spacer(s).
Why spacer with an s? If holes will be too close in one spacer then stagger the holes across two so each has every other hole, farther apart than all in the same spacer.

Title: Re: Record Changes in Height of Book Stack - Best Sensor?
Post by: Retroplayer on Mar 14, 2013, 09:18 am

Now my concern is that there might be too much light to use IR?


That's the main reason for using IR. Visible room light has a fairly low IR content, so an IR LED appears very bright. Otherwise, your TV remote wouldn't work. So IR is still ok
Title: Re: Record Changes in Height of Book Stack - Best Sensor?
Post by: GoForSmoke on Mar 14, 2013, 04:49 pm
But why need to supply an IR source when you have free room light? Can room light penetrate a book? If a little might get around somehow, put a resistor on the detector input so it does not let the pullup go LOW.

A photodetector needs a certain amount of light to switch full on, the books should block that if the detectors are positioned right. It is already stated that the book spines will be set right against the spacers so where do you put the detectors?