IR Counter Report

Download as pdf
Download as pdf
You are on page 1of 13

Table of Contents

Infrared Counter.............................................................................................................................2
Introduction...........................................................................................................................2
Applications of Counters.......................................................................................................2
Applications of Infrared Counters........................................................................................2
People counter ...............................................................................................................2
Vehicle Counter..............................................................................................................3
Assembly Line Counters................................................................................................3
Merits and Demerits..............................................................................................................4
Abstract...........................................................................................................................................5
Operation........................................................................................................................................6
IR module...............................................................................................................................6
IR Engine.................................................................................................................................6
Display unit.............................................................................................................................6
VHDL code..............................................................................................................................8
Simulation Result............................................................................................................................9
Conclusions...................................................................................................................................10
Bibliography..................................................................................................................................11
Infrared Counter

Introduction
In digital logic and computing, a counter is a device which stores (and sometimes
displays) the number of times a particular event or process has occurred, often in
relationship to a clock signal.
In computability theory, a counter is considered a type of memory. A counter stores a
single natural number (initially zero) and can be arbitrarily many digits long. A
counter is usually considered in conjunction with a finite-state machine (FSM), which
can perform the following operations on the counter:
• Check whether the counter is zero
• Increment the counter by one
• Decrement the counter by one (if it's already zero, this leaves it unchanged).

Applications of Counters
Counters are used in nearly all but the most trivial electronic instrumentation. The
fundamental need of most electronic and mechanical measurement is to be able to
count the number of excitations that occur in a given time duration, and retain that
display for evaluation.
Counter find a wide gamut of applications in the world around us. Industrially,
counters are used intermediate to nearly every process to keep a check on production
volumes and efficiency. From odometers for bicycles and cars, fuel dispensers to taxi
meters. Counter are used everywhere.
The most basic counters may consist of a system of disks and cables and more
sophisticated ones may have statistic generating and analyzing logic implemented on
powerful computers.

Applications of Infrared Counters.

People counter
A people counter is a device used to measure the number and direction of people
traversing a certain passage or entrance per unit time. The resolution of the
measurement is entirely dependent on the sophistication of the technology employed.
The device is often used at the entrance of a building so that the total number of
visitors can be recorded. Many different technologies are used in people counter
devices, such as infrared beams, computer vision, thermal imaging and pressure-
sensitive mats.
There are various reasons for counting people. In retail stores, counting is done as a
form of intelligence-gathering. The use of people counting systems in the retail
environment is necessary to calculate the Conversion Rate, i.e. the percentage of a
store's visitors that makes purchases. This is the key performance indicator of a store's
performance and is far superior to traditional methods, which only take into account
sales data. Traffic counts and conversion rates together tell you how you got to your
sales. i.e. if year-over-year sales are down: did fewer people visit my store, or did fewer
people buy?

The simplest form of counter is a single, horizontal infrared beam across an entrance
which is typically linked to a small display unit. Such a beam counts a 'tick' when the
beam is broken, therefore it is normal to divide the 'ticks' by two to get visitor
numbers. Dual beam units are also available from some suppliers and can provide low
cost directional flow 'in' and 'out' data. Accuracy depends highly on the width of the
entrance monitored and the volume of traffic.
Horizontal Beam Counters usually require a receiver or a reflector mounted opposite
the unit with a typical range up to 6 meters, although range finding beam counters
which do not require a reflector or receiver usually have a shorter range of around 2.5
meters.
Vertical beams are somewhat more accurate than horizontal, with accuracies of over
90% possible if the beams are very carefully placed. Typically they do not give 'in and
out' information, although some directional beams do exist.

Vehicle Counter
Vehicle Counters are designed to count general traffic on trails and paths ― hikers,
joggers, horseback riders, snowmobiles, cyclists, etc. Unlike most infrared trail
counters, it does not require a receiving unit or reflector to operate. This results in a
very compact, easy-to-hide design, that reduces risk of vandalism. Using a small, high-
quality infrared scope mounted on a tree and pointed towards the trail, the counter
detects and counts the infrared signature associated with warm, moving objects.

Illustration 1: Vehicle
Counter

Assembly Line Counters


These are used for keeping track of the number of articles manufactured on an
assembly line. These may also provide feedback to other machines which monitor the
process.

Illustration 2:
Assembly Line
Counter

Merits and Demerits


The merits and demerits of the IR counter are as follows:
Advantages:
• Inexpensive
• Simple to fit
Disadvantages:
• Most basic beam sensors are limited to non-directional counts
• Can't discern people walking side-by-side
• Cannot count high volume, uninterrupted traffic
• High potential to become blocked by people standing in an entrance or by
merchandise or displays
• Infra-red beam counters may be negatively affected when subject to direct
sunlight
Abstract
The main objective of the project was to develop the VHDL code for the drive logic and
engine of a IR based counter. The intention is to receive an electrical pulse from an
external IR module, which converts IR radiation to a digital clock signal. This clock
signal will be processed and based on the mode set the count will either be
incremented or decremented.
The outputs from the engine will drive directly a seven segment display without need
for separate decoder circuits. The mode of the counter may be set to either UP Count
mode or DOWN count mode, depending on the input to the UP/DOWN pin.
A Reset input may be used to clear the counter and bring the count to zero.
The project has been designed with the 38kHz Infrared (IR) Receiver Module from Radi
Shack in mind.
It is a small IR receiver module with built in lens, preamp, internal filter and
demodulator. Standard application IC for use with the most popular 38kHz IR carrier
frequency for commercial infrared detection and transmission.

Illustration 3: IR rx Module

How ever any infrared module capable of generating a clock pulse from IR excitation
will suffice as input to the Infra-Red clock.
Operation
The block diagram of the circuit is shown:

Illustration 4: Block Diagram of Project

The main components of the system are:


1. IR module
2. IR engine
3. Display Unit

IR module
This is an Infra-red sensing module. It consists of a IR detector, preamplifier and signal
conditioning circuits. It is available in cylindrical and 3 terminal IC packs and is used
in a wide variety of microprocessor and CPLD/FPGA circuits.
It detects IR excitation and generates a clock pulse.

IR Engine
This module will receive the clock pulse and will advance or decrease the state of the
clock. It is programmed to be controllable. It can be set to count up, down or clear its
memory.

Display unit
This consists of a seven segment display. It receives a 7 signal input from the engine
and depending on the signal, it turns on or off, a lamp. These lamps are arranges so as
to form the glyphs of numbers. This project is designed for common cathode type
display.
The truth table of the display unit is as follows:
Illustration 5: Truth Table of Seven Segment display
VHDL code
ENTITY IR_COUNTER IS
PORT ( IR_CLK:IN BIT; -- Clock Signal from IR module
UP_DOWN:IN BIT; -- UP Count = 1, DOWN Count = 0
RST: IN BIT;
COUNT_TENS:OUT INTEGER RANGE 0 TO 9;
COUNT_UNITS:OUT INTEGER RANGE 0 TO 9;
DECODED_TENS:OUT BIT_VECTOR (6 DOWNTO 0);
DECODED_UNITS:OUT BIT_VECTOR (6 DOWNTO 0));
END IR_COUNTER; -- End of Entity
ARCHITECTURE ENGINE OF IR_COUNTER IS
BEGIN
PROCESS (IR_CLK, UP_DOWN)
VARIABLE UNIT:INTEGER:=0;
VARIABLE TEN:INTEGER:=0;
VARIABLE MODE:INTEGER;
VARIABLE COUNT10:BIT;
BEGIN
-- RISING EDGE EVENTS --
IF (IR_CLK='0' AND IR_CLK 'EVENT) THEN
IF(RST='1') THEN
UNIT:=0;
TEN:=0;
END IF;
IF(UP_DOWN='1') THEN
MODE:=1;
ELSIF(UP_DOWN='0') THEN
MODE:=-1;
END IF;
-- COUNT THE UNITS COUNTER --
IF(RST='0') THEN
UNIT:=UNIT+MODE;
END IF;
-- COUNT THE TENS COUNTER --
IF(RST='0' AND COUNT10='1') THEN
TEN:=TEN+MODE;
COUNT10:='0';
END IF;
-- SAFEGAURD TO KEEP OUTPUTS INSIDE RANGE
--IF(UNIT<0) THEN
UNIT:=9;
END IF;
-- SAFEGAURD TO KEEP OUTPUTS INSIDE RANGE
--IF(TEN<0) THEN
TEN:=9;
END IF;
-- SAFEGAURD TO KEEP OUTPUTS INSIDE RANGE
--IF(UNIT>9) THEN
UNIT:=0;
END IF;
-- SAFEGAURD TO KEEP OUTPUTS INSIDE RANGE
--IF(TEN>9) THEN
TEN:=0;
END IF;
END IF;
-- FALLING EDGE EVENTS --
IF (IR_CLK='1' AND IR_CLK 'EVENT) THEN
-- SET COUNT10 --
IF(UNIT=9 AND MODE=1) THEN
COUNT10:='1';
ELSIF(UNIT=0 AND MODE=-1) THEN
COUNT10:='1';
END IF;
END IF;
-- OUTPUTS --
COUNT_TENS<=TEN;
COUNT_UNITS<=UNIT;
IF (TEN=0) THEN DECODED_TENS <= "1111110"; END IF; --0
IF (TEN=1) THEN DECODED_TENS <= "0110000"; END IF; --1
IF (TEN=2) THEN DECODED_TENS <= "1101101"; END IF; --2
IF (TEN=3) THEN DECODED_TENS <= "1111001"; END IF; --3
IF (TEN=4) THEN DECODED_TENS <= "0110011"; END IF; --4
IF (TEN=5) THEN DECODED_TENS <= "1011011"; END IF; --5
IF (TEN=6) THEN DECODED_TENS <= "0011111"; END IF; --6
IF (TEN=7) THEN DECODED_TENS <= "1110000"; END IF; --7
IF (TEN=8) THEN DECODED_TENS <= "1111111"; END IF; --8
IF (TEN=9) THEN DECODED_TENS <= "1110011"; END IF; --9
IF (UNIT=0) THEN DECODED_UNITS <= "1111110"; END IF; --0
IF (UNIT=1) THEN DECODED_UNITS <= "0110000"; END IF; --1
IF (UNIT=2) THEN DECODED_UNITS <= "1101101"; END IF; --2
IF (UNIT=3) THEN DECODED_UNITS <= "1111001"; END IF; --3
IF (UNIT=4) THEN DECODED_UNITS <= "0110011"; END IF; --4
IF (UNIT=5) THEN DECODED_UNITS <= "1011011"; END IF; --5
IF (UNIT=6) THEN DECODED_UNITS <= "0011111"; END IF; --6
IF (UNIT=7) THEN DECODED_UNITS <= "1110000"; END IF; --7
IF (UNIT=8) THEN DECODED_UNITS <= "1111111"; END IF; --8
IF (UNIT=9) THEN DECODED_UNITS <= "1110011"; END IF; --9
END PROCESS;
END ENGINE; -- End of Architecture
Simulation Result
VHDL code attached above was compiled and simulated in ModelSim XE III (Started
Edition).
Simulation was run for 10100 picoseconds, with a 100 picoseconds clock. This length
gave use all the states of operation for up counting.
The results of the simulation are attached ahead.

Illustration 6: Simulation being run on ModelSim XE


Conclusions
The counting engine for the IR counter was successfully implemented in VHDL and
simulated using ModelSim III XE (starter edition).
The code behaves as required for the purpose of counting and displaying, and has been
tested to remove any bugs.
Through the project we have enlisted the following CAD tools:
• ModelSim III XE: Simulation and VHDL compiler
• Ghostscript: Printing of simulation results to PDF.
• GIMP: Image and graph editing.

The project can be synthesized for transfer on a CPLD/FPGA solution, or manufacture.


Bibliography
Books:
• VHDL Primer – Third Edition – J. Bhasker
• Digital Design, 3E – M. Morris Mano,
• Circuit Design with VHDL - Volnei A. Pedroni

Websites:
• NJIT UG course:
http://architecture.njit.edu/academics/undergraduate/artanddesign/dd-
brochure.pdf
• ModelSim basics:
http://www.tkt.cs.tut.fi/tools/public/tutorials/mentor/modelsim/getting_started/gs
ms.html
• Doctronics 7 segment display: http://www.doctronics.co.uk/4511.htm
• ModelSim Environment Setup: www.ece.msstate.edu/~reese/EE8993/setup.html
• EDNC VHDL 101:
www.ednc.com/bbs/data/file/pds/6734cd03_IntroModelSim60GUI.pdf
• VHDL primer: www.seas.upenn.edu/~ese201/vhdl/vhdl_primer.html
• VHDL resources: http://esd.cs.ucr.edu/labs/tutorial/VHDL_Page.html

You might also like