I Would like to count widgets.:)

Hello! I'm trying to figure out how to make a counter (not tach, i've seen many tach tuts.) that will count up from 0 to a designated number, say 30 when an IR beam is broken by a Widget. This would be positioned at the end of a conveyor and the count would be displayed on some sort of display as well as sending an interrupt signal to the Conveyor to stop and prompt for manual input in order to restart conveyor /reset the counter. I have googled as much as I can and have come up completely dry. Your collective expertise is appreciated and I look forward to the responses.

/int

counters are not hard. just toggle an input and add the values.

once you reach a value, then output.

also, look at blink without delay.
change the value to your count and use the input from your sensor.

you should be able to put this together for use with a button in short order.

alas, you will probably want to change the value at some point. there are LCD's that have buttons attached. should make the final unit easier.

Dave, i’m in NJ as well! Thanks for your prompt and concise response. I was thinking a rotary encoder to set the interrupt value (as in when to stop the belt/number of widgets counted) and something like two Lumex LDD-C513RI’s. One to display current count and one to display set count. Also, i’ve seen that tutorial. I can understand how the counter works I guess my problem is how to integrate the intterupt of the IR beam. Thoughts?

There's a trick to beam interrupt. Don't make the light (IR is light) a beam. Put the detector in or behind something that only lets light in from a small angle.

A tight beam of light to an open detector means that stray light can false the detector. A tight beam of light to a restricted angle detector is a real pain to align. The only part that matters is the detector and it is restricted angle then only light rays from that angle get detected. One light can then source multiple detectors.

But it's up to you. Just either avoid lasers or make expensive protective eyewear mandatory.

I would go with not just IR but with high frequency pulsed IR like that used by TV remotes. That would be an extra level of protection. Fluorescent lights pulse and moving parts may cause light to flickers but way slower than IRDA frequencies of 30k to 40k.

You could just put the detector far enough down the line that it would take 30 items to reach.

I was thinking that the final assembly would be enclosed/covered. I like the idea of the High Frequency IR bulb. The way I was planning on managing the window for the “beam path” was to have an enclosed area for the receptor with a small hole drilled on one side facing the emitter, then recessing the receptor far enough back where only a “direct hit” would register. Maybe finding some sort of filter that would only allow IR in and deflect fluorescent or natural light. Thoughts>?

You’d want to use an IR receiver like the TSOP4038. You blink a light on one side at 38KHz and the IR receiver will lock onto that light; any ambient light will be ignored. It’s foolproof.

You can also get this sort of thing in a handy little package.
http://yourduino.com/sunshop2/index.php?l=product_detail&p=86

damn. that's some nice kit. I like those. makes life a heck of a lot easier.

Again, the only thing needing to be enclosed is the sensor.
Check the view from down the inside of a cheap pen barrel if you want extreme tight.

For IR remote speed you probably want to buy IRDA modules but if reading a frequency or not is almost all it's doing then an AVR chip with a regular IR detector (phototransistor with a black bulb that cuts all but IR out, costs about 10 cents ea, if that, in 50 to 100 qty) can do fine. Heck use your own frequency about 20k and no TV remote made will be able to screw THAT up.
The emitter can be a cheap clear bulb IR led that a different AVR chip flashes.

"AVR chips?" you say? Yes. Arduino is a DEVELOPMENT BOARD. You can program cheap, $2 and under, AVR chips with it (or even with simpler programmers) to stand alone and run your device, as in how many do you need?

Is there any way to put sensors on whatever mech drops the widgets on the belt? The more mechanical-touch you get, the more sure you might be.

When you do have "a solution", don't stop looking. You've only scratched the surface here.

That's all great advice! I really appreciate it. The final goal of this little project is to save the 5k it would cost for such a counter that bolts onto this conveyor. I know I can make it for under a hundred dollars, i know i can. I don't think I need anything fancy, just accurate counts. My plan was to install a relay to turn the belt on and off when the button is pressed, resetting counter, etc. etc. I found the sketch at arduino info wiki and it's really good, now to figure out how to set limit (count) and how to make user definable via encoder. really the hardest part for me will be actually programming this thing as i'm very new to the IDE.

I have cheap 240VAC/10A rated relays, they cost less than $2, 1 pin and a resistor to use. XD.
You could go with some logic gates and a counter-timer or an array logic chip that I don't how to program. ATMEL has a 20 pin DIP package series that runs about $1 ea that you'd need a custom display as you want now. That might shave the parts price down.

Here's Nick Gammon's excellent blog on programming a 328P (UNO chip, $2-$3 ea in singles) or a 1284P (more pins/ports, 16K RAM, 128K flash, $7 ea in singles).

And here's MIT High/Low Tech on programming ATtiny45/85 8 pin chips that cost maybe $1.50 for 1 or 2, $1.25 ea for 10 if not less. They have 256/512 bytes of RAM and a couple to a few K of flash but the CLOCK can still go to 20 MHz but it's cheaper to run on the internal clock at 8 MHz and save 2 pins out of 8 and the need for a crystal and resistors in the process. It works. I've done it.

The tiny's are industrial controllers more at the sub level. If your display panel uses serial or I2C then the tiny can run it, it has 5 free pins, reset, power and ground. If not then a 328P should have the pins to run it. Sensors/buttons cost a pin each unless you multiplex/make a grid. The thing will need a start/stop button(s).

You can get a board made but for prototype try mounting you chip in an extra-length machine pin socket that you have pre-wired with the extra capacitor/resistor bits and wires to led, sensor, display, 5V (ir 3.4V) regulated power supply... I use jumpers with female ends to slide onto pins for connecting, some spliced. Led and resistor leads plug right into socket holes. A socket is a small cheap 2 row breadboard. Get the circuit right, put a strip of metal across any parts that get warm/hot and pot it in hot glue (can be melted back off) or other non-conductive material and it can take vibration, etc. Just bolt the heat sink to a bigger heat sink and you have it mounted as well.

LCD display costs more than the rest, are you sure you couldn't get by with something else like a progress bar made or leds? With cheap RGB leds (5/$1 or less in 100's) you can have 2+ colors so there's no doubt how many to go. There's led strips that might do, they might come in I2C or SPI bus. On the smaller end, there's bar graph chips with rows of 8 to 10 leds as level displays for audio boards, etc.

As to the code, do you count learning curve?
I suggest that you learn real time multifunction code, which is far simpler than the name sounds.
You write every step needed to stand on its own and only run when it's needed, on time, event, or internal flag.
Loop() goes round and round and each task gets moved like a piece of a machine so fast it might as well be all at the same time. And that starts here, again with a Nick Gammon (give him KARMA!) web page:

Because hey, you don't want to read more than 1000 or 100 times per second, do you? How fast is this belt?