Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Instituto Politcnico
Nacional
Students:
Escudero Snchez Juan
Laboratory
Antonio
Pia Nieto Erik Javier
Romero Rubio Gerardo
Daniel
Pulse Counter
Pulse Counter
Objective
Make a counter pulse with an infrared led and a receiver diode
(phototransistor), count a pulse when the voltage is greater than or
equal to 3.3V and reset the count of pulses by pressing a push button.
Introduction
Diode LED
A diode is an electronic device with two electrodes, cathode and anode,
which has the property of being a driver in the sense catodo-anodo, but
not the reverse. (From the English Light EDiode) LED is a diode capable
of emitting light to be polarized in the direct sense. It produces a
monochromatic light, has low power consumption and is widely used as
an element of signaling devices and electronic circuits.
The LED must be always respecting the polarity, otherwise please does
not illuminate.
Since the LED is very small, the anode and cathode are designated by
the length of the legs.
The long leg (A) corresponds to the anode to the pole (+) and the short
leg (C) corresponds to the cathode to the pole (-).
Capsules of LED colors can be: red, yellow or green, and the most
common diameters are 5 and 3 mm.
Phototransistor
The phototransistor is a photodetector that works like a classic
transistor, but normally does not have connection base.
These transistors in base is replaced by a photosensitive Crystal when it
receives light, producing a current and unlock the transistor.
The phototransistor current flows only in one direction and the blocking
of the transistor depends on the light; the more light there is more leads.
The principle of the phototransistor is apparently the same as that of the
classic transistor. But if we look at the component that only has two legs,
an issuer and a collector, but the base is missing.
The base is in fact replaced by a layer of photosensitive Silicon. If this
layer is illuminated appears at the base a current which grows with the
light, which puts up the transistor.
The phototransistor reacts with visible light and infrared rays are
invisible. To distinguish it from the LED his capsule is transparent.
In the phototransistor, like the led, polarity is given by the length of their
legs, but with one important difference; the phototransistor in the long
leg is the negative (-), unlike in the LED, which is the positive (+).
Development
Circuit Diagram
We made a circuit to connect a infrared LED and other circuit with a
phototransistor for connect both to an arduino and to count a pulse
when the phototransistor receive light of infrared LED. The following
diagram shows the way in which the circuits are connected.
Code
We made the following code for count the pulses, so counts a pulse
when the state infrared is in high and write high in phototransistor but if
the state of push button is in high resets the count.
const int pinSensor = 11;
const int pinLed
= 9;
int conta = 0;
void setup() {
Serial.begin(9600);
pinMode(pinLed, OUTPUT);
pinMode(buttonPin, INPUT);
pinMode(pinSensor, INPUT);
void loop(){
estadoSensor = digitalRead(pinSensor);
buttonState = digitalRead(buttonPin);
if (estadoSensor == HIGH) {
digitalWrite(pinLed, HIGH);
}
else {
digitalWrite(pinLed, LOW);
conta++;
Serial.println(conta);
delay (1000);
}
if (buttonState == HIGH) {
conta=0;
Serial.println("");
delay(10);
}
}
Performance tests
The following pictures shows a part of performance of the circuits when you put
a barrier between the two circuits (in this case the usb) and when it is
removed, that is when you mark the pulse.
Conclusions