measuring the length sum of multiple workpieces

Hi all!

This is my very first post - so please excuse me in advance if I step out of protocol or worse - don’t make any sense.

Just ordered an Arduino, photoelectric sensor, Display shield and two 'big arcade style slam buttons. I am currently waiting for these to arrive any day now, but I thought I would get some information while I wait, so I could hit the ground running when I receive everything.

My Project
I have an edge banding machine which applies ABS edging at a fixed feed rate of 11/mtrs per minute, to chipboard. Every time I finish a job, I have to manually measure each length of applied material so I can work out how many linear meters I used up (very time consuming and unreliable)

I would like to hook up my photo elecrtic sensor on the front of the machine so when a work piece is detected, the arduino would start counting (or measuring) and keep on counting ‘until’ the workpiece has completely entered the machine after which the counting would ‘suspend’ until the next workpiece would be inserted and the count would ‘continue’ from where it had left off (resulting in the sum of all the lengths of workpieces processed)

Oh yeah, I would also like to have the facility to erase the last fed workpiece count with the hit of my ‘big arcade style slam button’ in case for some reason the last workpiece doesn’t come out good (which happens from time to time) and has to be re-worked (re-inserted into the machine).

Any information regarding wiring and coding would be greatly appreciated!

Take care everyone and have a nice weekend!!


Parts list

1x LCD 1602 Display and keypad shield for Arduino Uno/Duemilanove
1x InfraRed IR Detector 5V DC Switch for Robotics Arduino Obstacle Sensor
1x Arduino UNO Rev3 ATMEGA328P
2x big arcade style slam button

lcd 1602.JPG

photot electric sensor.jpg

Arduino UNO Rev3 ATMEGA328P .JPG

big arcade style button.JPG

The problem is how do you measure the movement?

Is the feed rate consistent? If so you could time from start of detection to end.

If the rate is not constant you will have to add a wheel or something that can actually measure the length as the board passes.


He (or is ctrl_alt_del a she? ... hard to tell) said it operated at a fixed rate. If that is true it should be fairly simple. I would first get the photo sensor to work, initially just turn on an LED (there is a built-in one on pin 13) so that you can confirm the LED turns on when the wood is going through the machine, and off afterwards.

I would search this site for light detection or photo sensors, there will be lots of examples.

Something like a microswitch might be all you need:

Thank you Nick. My name is Edward.

I did consider using a micro switch but was afraid that it wouldn't be able to take the 'use and abuse'. Hence I opted for the photo sensor.

As you advised, I'll try to get the photo sensor working first. Do you think that I would have to insert debouncing code for the photo sensor or debouncing circuitry for that matter?

Thanks once again!


Debouncing suggests you are using a device with contacts, such as a switch. A photo sensor has no contacts so debouncing is not necessary. - Scotty

@ Scotty

Many thanks buddy!


Measuring the dimensions of the board as it is processed sounds tricky to me. Is there any possibility of measuring the amount of edging material that was dispensed instead? For example, if it comes on a roll you could measure the distance that is taken off the roll using a sensor to count the number of rotations of an idle roller.

Or weigh it?

But yes, a rotary encoder on the dispenser might be good. Or some sort of system like you have as a bicycle speedo, a magnet and a Hall sensor.

Rotary encoder for measuring the material to be processed is a real good alternative - never thought of that! However I'm just concerned of the 'use and abuse' aspect of things. I'm thinking that an encoder with a pinch roller would involve a little more mechanics - and being a pretty dusty environment I would have my reservations about using it.

The reason I opted for a photo IR sensor (which would be used faced down), is to avoid any moving parts- as from my experience, they are the ones to fail first.

May I ask why you feel that a photo sensor would be tricky? Is it because perhaps I might get false 'start and stops' with ambient light?? Cuz that did cross my mind too!

Thanks for your feedback and guidance guys - really appreciate it! Now only if my bloody parts would arrive from the UK already - I could get started.


I think that installing the photo sensor in a small length of tubing would eliminate any ill effects from ambient light. In the future a solution for that problem would be to use a modulated ir receiver and an ir led. A common use is a tv remote. Most use 38khz streams of ir light and the receiver is tuned to that frequeny and 'blind' to other light. There's a library available to generate the 38khz from the Arduino. - Scotty

Rotary encoder for measuring the material to be processed is a real good alternative - never thought of that! However I’m just concerned of the ‘use and abuse’ aspect of things.

Is it not dispensed from a reel? Count the turns of the reel in the way you count the turns of a bicycle wheel. No physical contact.

When buying cabling or wire at the local they put the reel on a simple mechanism that feeds the wire thru a counter (maybe a pinch roller) that is resettable and it winds it onto a collapsable spool so when the length is attained it is easy to remove as a coil of wire.

So why not have some kind of the same type of counting mechanism but make it a digital output.

The diameter of the coiled material is not constant, it decreases in size every revolution and not at a constant rate as the roll is not kept tight (if that makes any sense). The plate (reel) that it sits on doesn’t alway turn with the coiled material as there is a lot of slippage.

Liked the idea of the tube (in case of any ambient light).

Thanks guys!


I'd look for a solution along the lines of pinching the edging strip between a pair of idler rollers and count the number of revolutions of the rollers. It should be easy enough to make that part reliable, and with a reliable input signal the software part is simple.

I agree....Well said! :smiley: