Intro: Quick Circuits #00: the Infrared Counter
I've been making random circuits for a lot of time, I have a vast amount of them, and it is because it usually takes me only one to a few hours to design and assemble one of them, any excuse is valid to start working on a new one, and so I denominate them "quick circuits".
I hope to be able to make a series of instructables regarding this unique, bizarre and sometimes completely useless circuits. This series will be probably characterized by lack of actual pictures during the test or assembly phases, but a lot of information on how they work and how to build them.
I'll start the series with this little circuit I called the counter.
- 2x 3904 (I designed the circuit to work with this transistors, others might not work)
- 1x 2N2222 (you can also use a 3904 again)
- 7805 Regulator
- 2x 100nF
- Infrarred LED
- Infrarred sensor (Two legs)
- 2x 1M
- 3x 10k
- 150R 1W
Step 1: What Does It Do?
This circuit has an infrarreed LED and sensor, it's function is to count how many times an object has passed in front of it. Since he At-tiny lacks of the necessary outputs to drive a display, the number decomposed and sent out with a buzzer, this is, the buzzer beeps according to the units (thousands, hundreds,...) making a pause between each number. This is certainly not the best way to do this, but it is what makes this kind of circuits unique. An Attiny2313 would've been a better choice, but I don't have any at the moment, if you want, you can replace the microcontroller and use the same analog part, which is quite effective, it can detect an object from 3 to 5 centimeters away, increasing its detection capabilities with white or reflective objects.
I originally designed this circuit because I'm going to try to get into the world of Tesla coils and I hope this little device can help me keep track of the windings of the secondary, I plan to stick a piece of paper to the tube while I spin it to do so.
Pressing the button to read the number doesn't affects the actual number, you can keep increasing it as long as the power is on.
It could also be used to count the units coming out of a production line, for example.
Step 2: How Does It Works?
To know how it works we must take a look at the schematic, when an object is in front of the unit, the infrared light bounces off, hitting the sensor, changing it's resistance and thus creating a signal. This signal is amplified by two 3904 transistors, the signal is amplified so much that at the end it just looks like a square wave, going from 0 to 5 volts, allowing an easier analog to digital communication.
As I was saying, when an object passes in front of the sensor, this goes from HIGH to LOW, allowing the microcontroller of choice to register the change.
I designed this circuit to be portable, and powered by a 9 volt battery, the circuit uses around 60mA, most of which pass though the IR diode. Considering a normal 9V battery has around 200mAh, the circuit would remain in operation for around 3 hours, so it is important to have a fresh battery or connect it to a wall wart if you are going to make it work for long periods of time. The IR resistor has the value of 150 Ohms since it's being powered by a 9 volt battery, if you would like to use it with a 12 volt wall wart I recommend changing the resistor by a 220 Ohm or a 330 Ohm, since the LED is a bit overpowered.
I've added a sch. file, so you can edit it in Eagle.
IMPORTANT: I designed this circuit to work with 3904 transistors, other transistors might not work due to differences in gain.
Step 3: The Program
The program is quite simple, it just counts the number of detected objects, beeping each time that occurs, the second part of the program is destined to separate the whole number into the units and send them through the speaker.
Step 4: Considerations:
To make the sensor I used two solid cables for the LED and other two for the sensor, then I twisted them together and connected them in the right way, by doing this I can easily orient them in front of the object or objects I want to count.
I hope it's been useful, maybe not as a whole, but as a circuit that can be chopped and implemented to other circuits.
Thanks for watching, please let me know if there are any mistakes or if you have some doubts about the circuit.