Photo Interrupter Item Counter

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 364 times
Been thanked: 716 times
Contact:

Photo Interrupter Item Counter

Post by JohnCrow »

Photo Interrupter - Item Counter

This project is a simple item counter using an infrared photo interrupter.

Equipment :

EB006 Programmer – Standard configuration with PIC 16F877A
EB002 - Screw Terminal Board
EB 005 - LCD Display Board

The sensor is a Sharp GP1A57HRJ00F Photo interrupter
Gap = 10mm

It is mounted on a Sparkfun PPBOB-09322 Break-Out Board
This has a 220-ohm resistor and the 3 connections on a small PCB

This assembly was mounted on a small Protoboard along with a reset switch
(This is configured in the same way as the switches on the EB007 switch board)
The sensor and BOB were obtained from Proto PIC in the UK

Program :

The program used here is a simple test routine to verify the hardware

The sensor is connected to ADC0.
With no objects between the Tx & Rx the output is high, when something passes through the gap the output goes lows.

This is read and the count value incremented by 1.
I have used an integer variable for Count, as it may well need to go passed 255
NOTE
In FC5 I have actually used an unsigned integer, this is because
1 It will never have to be a negative value
2 It allows a much bigger count value to be used.

The reset switch is connected to Port A bit 1.
A decision at the start of the loop checks the state of the bit.

Low – No action
High – Reset count to zero.

The version posted here is in Flowcode 4.

Operation :

By moving an object though the gate, the count will be seen to increase.
The speed of the objects through the gate and the delay statement may need adjustment to suit a specific application.

It will not detect transparent items.

The direction of travel through the gate does not have any effect on the reading (i.e. in from the top or the bottom)
I believe the sensor is fairly well insulated, but care should be taken if using it to count metal items.
Sensor - Close Up
Sensor - Close Up
Sensor 2.JPG (133.84 KiB) Viewed 2603 times
Test System
Test System
System 1.JPG (135.03 KiB) Viewed 2603 times
Photo Interrupter Counter V1 - FC4.fcf
Test Program FC4 Version
(9 KiB) Downloaded 235 times
1 in 10 people understand binary, the other one doesn't !

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times
Contact:

Re: Photo Interrupter Item Counter

Post by dazz »

hi john
nice read, i love using photointeruptors i used to use them to build simple fishing bite alarms, they are so versatile and used extensively in the photocopier industry from simple things like paper detection to timers and speed control(scanner position detection speed and movement control), one thing i would say is if you know anyone who services photocopiers see if they can get you a couple, as a variety are used from 5 to 24v and also positive and negative triggered, and a variety of mounting options the most common being two prongs on the front and 2 clips on the back, with a seperate 3 pin connector. they will be fine for counting metal parts as long as the connections are well insulated
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 364 times
Been thanked: 716 times
Contact:

Re: Photo Interrupter Item Counter

Post by JohnCrow »

HI Dazz

Thanks for the comments.
This is the first time I've used one of these. I was ordering some other components and just spotted the PI on the website, so I ordered on to have a play with.
Just knocked up a simple test program today to try it out.
1 in 10 people understand binary, the other one doesn't !

Post Reply