Monday, October 21, 2013

Object counter using 8051

1 comment:

Object counter using 8051 microcontroller.

This article is about a simple object counter/visitor counter using 8051 microcontroller . AT89S51 belonging to the 8051 family is the microcontroller used here. This circuit can count the number of objects passing across a line , number of persons passing through a gate/door and so on. The can be simply divided into two sections i.e. the sensor section and the display section.


The sensor part consists of a ultra bright led (with focus), and LDR, opamp LM324 and the associated passive components. The LED is placed on one side of the door and the LDR is placed on the other side so that the light from the LED falls directly on the LDR.As you know, the resistance of the LDR has an inverse relationship with the intensity of the light falling on it. The preset resistor R14 is so adjusted that the voltage across the LDR is below 1.5V when it is illuminated. This voltage (labelled A in the circuit diagram) is connected to the inverting input of the opamp which is wired as a comparator with reference voltage 1.5V (set using R15 and R16).Capacitor C1 is meant for bypassing noise or anything like that which may cause false triggering.Resistor R13 is meant to control the current through the LED. 

Electronics  lab   ,     Created by Muhammad Irfan
When the light is falling on the LDR the voltage across it will be less than the reference voltage and so the output of the opamp remains high. When the light beam is interrupted, the voltage across the LDR goes above the reference voltage and so the opamp output goes low and it indicates a pass.

Display section.

The output of the opamp is fed to the INTO (interrupt 0) pin of the microcontroller. The microcontroller is programmed to count the number of negative edge pulses received at the INT0 pin and displays it on the three digit seven segment display.

Circuit diagram.


ORG 000H
ORG 003H  // starting address of interrupt service routine (ISR)
ACALL ISR // calls interrupt service routine

INIT: MOV P0,#00000000B
      MOV P3,#11111111B
      MOV P1,#00000000B
      MOV R6,#00000000B
      SETB IP.0     // sets highest priority for the interrupt INT0
      SETB TCON.0   // interrupt generated by a falling edge signal at INT0 pin
      SETB IE.0     //enables the external interrupt
      SETB IE.7     //enables the global interrupt control

      MOV B,#100D
      DIV AB
      SETB P1.0
      MOV A,B
      MOV B,#10D
      DIV AB
      CLR P1.0
      SETB P1.1
      MOV A,B
      CLR P1.1
      SETB P1.2
      CLR P1.2

ISR: INC R6     //interrupt service routine

DISPLAY: MOVC A,@A+DPTR // display sub routine
         CPL A
         MOV P0,A

DELAY: MOV R3,#255D  // 1mS delay
     DB 06H
     DB 5BH
     DB 4FH
     DB 66H
     DB 6DH
     DB 7DH
     DB 07H
     DB 7FH
     DB 6FH

About the program.

The program is written so that, it keeps displaying the current value in register R6 on the three digit seven segment display. When ever there is a valid negative going pulse (interrupt) at the INT0 pin, the program branches to the interrupt service routine (sub routine ISR). Subroutine ISR increments the value in register R6, then jumps back to the MAIN loop and the display gets updated by the new value.


Entire circuit can be powered from a 5V DC supply.
LDR must be placed in an enclosure so that the light from LED alone falls on it.

Electronics  lab   ,     Created by Muhammad Irfan 

Automatic Doorbell with Object Detection Circuit


Automatic Doorbell with Object Detection Circuit


The circuit operates using a pair of ultrasonic transmitter and receiver modules which are used to detect the person. When the person is detected (the person is in the front door), the doorbell is automatically turned ON.


Figure 1  Automatic Door Bell with Object Detection Circuit Diagram

The ultrasonic transmitter operates at a frequency of about 40 kHz, which means it continuously transmits the ultrasonic waves of about 40 kHz. The power supplied should be moderate such that the range of the transmitter is only about one or two meters. If the transmitting power is less than one meter, then there is a possibility that the person who is one meter away will not be detected. Likewise, if the range is set higher, then it may lead to false trigerring which means that objects from afar maybe considered as visitors triggering the circuit. So to avoid these problems, the transmitting power is kept to an optimum level.
The ultrasonic receiver module receives the power with the frequency the same as that of the transmitter so that the noise will be eliminated and minimized false triggering. The sensitivity of the receiver can be tuned by using a 500 kilo-ohm variable resistor arranged as a pot in the circuit. By tuning this properly, we can achieve the desired results. The buzzer circuit is the output load which acts a doorbell in the case. The receiver circuit uses the integrated circuit LM324 which has 4 operational amplifier internally. Out of the four, three operational amplifiers only are being utilized. The three op-amps are arranged in cascade to provide high gain as well as noise free output.
An optocoupler is used at the output to avoid any interaction between the circuit and the doorbell.
Assemble the circuit on a PCB as compactly as possible and then attach it to the main door. You may provide a power supply using a 9 VDC adapter with filtered and regulated output. If the 9 V adapter with regulated output is not available, then we recommend you to use a 12 V unregulated DC adapter with 7809 voltage regulator.

Electronics  lab   ,     Created by Muhammad Irfan Electronics  lab   ,     Created by Muhammad Irfan

Resistance Calculator From Band

No comments:

Calculate the resistance of a 4 band resistor


A resistor is a perhaps the most common building block used in circuits. Resistors come in many shapes and sizes this tool is used to decode information for color banded axial lead resistors.

4 Band Description

The number of bands is important because the decoding changes based upon the number of color bands. There are three common types: 4 band, 5 band, and 6 band resistors. For the 4 band resistor:
Band 1 – First significant digit.
Band 2 – Second significant digit
Band 3 – Multiplier
Band 4 – Tolerance

Resistance Value

The first 4 bands make up the resistance nominal value. The first 2 bands make up the significant digits where:
black – 0
brown – 1
red – 2
orange – 3
yellow – 4
green – 5
blue – 6
violet – 7
grey – 8
white – 9
The 3rd band or multiplier band is color coded as follows:
black – x1
brown – x10
red – x100
orange – x1K
yellow – x10K
green – x100K
blue – x1M
violet – x10M
grey – x100M
white – x1G
gold – .1
silver – .01
An example of a resistance value is:
band 1 = orange = 3,
band 2 = yellow = 4,
band 3 = blue = 1M
value = 34*1M = 34 Mohm

Resistance Tolerance

The fourth band is the tolerance and represents the worst case variation one might expect from the nominal value. The color code for tolerance is as follows:
brown – 1%
red – 2%
orange – 3%
yellow – 4%
green – .5%
blue – .25%
violet – .1%
gray – .05%
gold – 5%
silver – 10%
An example calculating the range of a resistor value is:
If the nominal value was 345 Ohm and the 4th band of the resistor was gold (5%) the value range would be nominal +/- 5% = 32.3 to 35.7

Also Over Here 

Electronics  lab   ,     Created by Muhammad Irfan 
Electronics  lab   ,     Created by Muhammad Irfan
 WEBENCH® Designer

    Enter your power supply requirements:
    DC  AC

    Ambient Temp°C
    Multiple Loads
    Single Output

    Sound Level Indicator

    No comments:
    Electronics  lab   ,     Created by Muhammad Irfan      Electronics  lab   ,     Created by Muhammad Irfan

    This project uses an LM3915 bar-graph IC driving two sets of ten LEDs for a 30dB range. The circuit is unique because it has an additional range of 20dB provided by an automatic gain control to allow it to be very sensitive to low sound levels but it increases its range 20dB for loud sounds.

    The LEDs are operating at 26mA each with the brightness control at maximum, which is very bright. The circuit has a switch to select the modes of operation: a moving dot of light, or a bar with a changing length.

    My prototype has a little 9V Ni-Cad rechargeable battery in it to be portable and the battery is trickle-charged when the project is powered by a 9V AC-DC adapter.

    Circuit Description
    1) The electret microphone is powered by and has a load of R1 from an LM2931 5V low-dropout regulator.

    2) The 1st opamp stage is an audio preamp with a gain of 101.

    3) The 2nd opamp stage is a single-supply opamp which works fine with its inputs and output at ground and is used as a rectifier driver with a gain of 1.8. It is biased at ground. Since it is inverting, when its input swings negative, its output swings positive.

    4) Three 2N3904 transistors are used as emitter-followers:
    a) Q1 is inside the negative feedback loop of the 2nd opamp as a voltage reference for the other two transistors. Hopefully the transistors match each other.
    b) Q2 emitter-follower transistor quickly charges C8 which discharges slower into R13 and is used as a peak detector.
    c) Q3 transistor is the automatic gain control. It is also a peak detector but has slower charge and discharge times. It drives the comparators’ resistor ladder in the LM3915 to determine how sensitive it is. R15 from +5V is in a voltage divider with the ladder’s total resistance of about 25k and provides the top of the ladder with about +0.51V when there is a very low sound level detected. Loud sounds cause Q3 to drive the top of the ladder to 5.1V for reduced sensitivity.

    5) The LM3915 regulates the current for the LEDs so they don’t need current-limiting resistors. In the bar mode with all LEDs lit then the LM3915 gets hot so the 10 ohm/1W resistor R16 shares the heat.

    1) You could use a switch to change the brightness instead of a pot, or leave it bright.
    2) You could use an LM358 dual opamp (I tried it) but its output drops above 4Khz. The MC33172 is flat to 20kHz with this high gain.
    3) You could add a 1uF to 2.2uF capacitor across R5 so the indicator responds only to bass or “the beat” of music. Then an LM358 dual opamp is fine.

    1) The stripboard layout was designed for a Hammond 1591B plastic box with space in the lower end for a rechargeable 9V battery. One bolt holds the circuit board and a second bolt was cut short as a guide.
    2) A second piece of stripboard was used on a diagonal to space the LEDs closely together. A few LEDs needed their rim to be filed slightly to fit.
    3) A third piece of stripboard was used as a separating wall for the battery and it interlocks with the LEDs stripboard to hold it in place.
    4) 11-wire flexible ribbon cable connects to the LEDs.
    5) Use shielded audio from the microphone and a rubber grommet holding it.

    Parts List 
    R2, R3, R5, R7, R8, R10--100k
    R12, R14--100
    R17, R19--390
    P1--10k audio-taper (log) pot

    C1, C4, C8--330nF
    C3, C9--100uF/10V
    5V reg--LM2931AZ5.0

    LEDs--MV8191 super-red diffused
    Electret microphone--two-wire type Box--Hammond 1591B
    Battery--9V Ni-Cad or Ni-MH
    SW1--SPST switch
    Adapter jack--switched

    Electronics  lab   ,     Created by Muhammad Irfan Electronics  lab   ,     Created by Muhammad Irfan Electronics  lab   ,     Created by Muhammad Irfan