To get this to work you need to apply white and black markings to the spindle, each covering half of the circumference. Next, mask off two electric eye devices (reflected light sensors) next to one another (approximately 10 mm apart). For secure detection both sensors should be positioned not more than 5 mm from the paint markings.
Dag-gerboard Position Detector Circuit Diagram :
The markings to be read by the sensor should be displaced laterally, so that the direction of rotation can be recognised in addition to the number of revolutions counted. At the heart of our circuit is a PIC16F628 from Microchip, which as usual can be bought ready programmed from Elektor or you can do this bit yourself by downloading free firmware (for details of both see ).
At pins 1 of the two reflected light sensors IC3 and IC4 we need to ‘see’ more than 2.0 V from the white segment and less than 0.8 V from the black mark (with an operating volt-age between 4.5 and 5.5 V). The two signals detected are taken to plug connector along with the operating voltage and ground. It’s convenient if you also provide a connector from the microcontroller as well, so that the sensor and the controller board can be linked by a test lead.
The multiplexing of the three seven-segment displays is programmed at a rate of 100 Hz.
Acceptable values for the revolution count are between 0 and 140. If the count exceeds or falls below these limits, then the counter is not incremented. The RESET key S2 sets the counter back to zero. Jumper K2 enables you to reverse the direction of counting. The count is retained if the operating voltage is removed and is loaded again when next pow-ered up.
The source code can also be downloaded from the website mentioned above, making it possible (for instance) to define alternative counter limit values (the maximum value is defined in the line #define max 140). For compiling the code you can use the CC5X compiler, of which there is a free version (www.bknd.com/cc5x).