motion detector
Post on 10-Mar-2015
308 Views
Preview:
TRANSCRIPT
CHAPTER 1 INTRODUCTION
1.) Introduction
A motion detector is a device that contains a physical mechanism or electronic sensor
that quantifies motion that can be either integrated with or connected to other devices that alert
the user of the presence of a moving object within the field of view.
1.1) Overview
An electronic motion detector contains a motion sensor that transforms the detection of motion
into an electric signal. This can be achieved by measuring optical or acoustical changes in the
field of view.
A motion detector may be connected to a burglar alarm that is used to alert the home owner or
security service after it detects motion. Such a detector may also trigger a red light camera.
An occupancy sensor is a motion detector that is integrated with a timing device. It senses when
motion has stopped for a specified time period in order to trigger a light extinguishing signal.
These devices prevent illumination of unoccupied spaces like public toilets.
1.2) Electronic devices
The principal methods by which motion can be electronically identified are optical detection and
acoustical detection. Infrared light or laser technology may be used for optical detection. Motion
detection devices, such as motion detectors, have sensors that detect movement and send a
signals to a sound device that produces an alarm or switch on an image recording device. There
are motion detectors which employ cameras connected to a computer which stores and manages
captured images to be viewed later or viewed over a computer network.
The chief applications for such detection are (a) detection of unauthorized entry, (b) detection of
cessation of occupancy of an area to extinguish lighting and (c) detection of a moving object
which triggers a camera to record subsequent events. The motion detector is thus a linchpin of
electronic security systems, but is also a valuable tool in preventing the illumination of
unoccupied spaces.
Chapter 2 Project Description
2.) Project Description
Security systems in present world had turned out to be a mandatory system for every
organization, Industries, workshops, factories, banks, offices, shops (especially -Jewellery shops)
and even at home these days we find various kind of security systems based on different
technologies. In other words Security Systems is 'The need of Hour '.
In this security system we employed Visual Basic Language .Specifically in this we focused
towards the 'IMAGE PROCESSING' modules of Visual Basic Programming. Now as we started
developing the code we found the need of Interfacing Computer System with Hardware. For that
we also learned Parallel Port Programming of Visual Basic.
This gave us an idea to correlate our developed code of Visual Basic with Embedded System
Technology.
Our developed system is a MULTI COMPUTER BASED SYSTEM which uses atleast two
computers connected via LAN/WAN/MAN. The whole system consists of only one system
named as SERVER while other Multiple Computers are named as CLIENTS. The server system
is always kept in ON condition. It is equipped with a Speaker and a Printer. Server is generally
kept at HOME (manager or owner of the shop)/CONTROL ROOM (Police Station).Now the
Client System is kept in area where security is to be provided. The Client System is equipped
with a Webcam and a Speaker. Both of these systems are connected to each other Via
LAN/WAN/MAN.
The utility of this system lies generally during Night hours or holidays when there is absence of
the staff members. To understand how this System works let us take an example of a jewellery
shop. The Client Systems are kept at different places of the shop where the security is to be
provided. And the Server System is kept at the home of the owner of the shop. Say at 3 a.m
(midnight hours) a thief enters the shop. Now here this Security System comes into action.The
Client System Detects change in Motion and starts capturing the Images of the thief at every
interval of 2 seconds. It switches On the Alarm of the shop so as to make the Gatekeeper of the
shop alert and simultaneously sends ALERT signals to the remote computer i.e. SERVER. Now
the Server System which is kept at home of Owner of the shop receives the alert signals from the
Client .Server switches on the audio file as Alarm by making the owner of the shop aware of
some mishap going on at his Shop. The Client System in the form of alert signal sends the exact
Date, Time and the exact location of Area of Theft in the shop(say floor no., room no. etc).After
receiving this information the Server System which is also equipped with a Printer takes out the
print out of all these valuable information. Now with the help of this Security System we can get
a series of Images of thief which are stored in Client Computer System. We also get the exact
information of the date ,time and area at the time of theft itself.
2.1) Background Task and Interrupt-Service-Routines (pseudo code)
1. Let the camera take a picture
2. Download a “thumbnail” version (40 × 31) of the image into the SDK.
3. Compare the thumbnail with a previously taken one
4. If the difference is greater than a threshold {
Execute an alarm function (to blink an LED i.e.)
5. Start, Pause or Stop the program based on Keypad inputs
6. Execute an alarm function, if the “watchdog countdown” reaches 0, (watchdog was not fed).
Figure 2: Keypad Encoder PINS (Source )
Figure 3: Schematic of keypad connection (Source )
2.2) Software Design
To support re-use and better maintainability of the software, the following modularization was
chosen:
• Main.c contains the main loop
• CamDriver.c contains the camera specific functions, allowing control of the camera.
• ImgProc.c contains the implementation of image comparison algorithms.
• Watchdog.c contains the implementation of the timer-based software watchdog.
• Serialin57.asm, Serialout57.asm, high-speed serial driver for the SDK’s internal serial port.
• Keypad.c contains keypad specific functions
CHAPTER 3 COMPONENTS
3.) Components used
S.NO. COMPONENTS NO OF COMPONENTS
1. ULN 2003 1
2. STEPPER MOTOR 1
3. D TYPE 25 PIN PARALLEL
PORT
1
4. WEB CAM 1
5. TRANSISTOR 4
6. D TYPE 25 PIN MALE TO
MALE CABLE
1
7. TRANSFORMER 1
8. DIODES AS PER REQUIRED
9. ZENER DIODES AS PER REQUIRED
10. RESISTANCES AS PER REQUIRED
11. CAPACITOR AS PER REQUIRED
12. LED AS PER REQUIRED
Table 1 component used
3.1 STEPPER MOTOR
In Theory, a Stepper motor is a marvel in simplicity. It has no brushes, or contacts. Basically
it's a synchronous motor with the magnetic field electronically switched to rotate the armature
magnet around.
3.1.1 Definition
A stepper motor is basically an electromechanical device which converts electrical
pulses into discrete mechanical movements. The shaft or spindle of a stepper motor rotates in
discrete step increments when electrical command pulses are applied to it in the proper sequence.
The motors rotation has several direct relationships to these applied input pulses. The sequence
of the applied pulses is directly related to the direction of motor shafts rotation. The speed of the
motor shafts rotation is directly related to the frequency of the input pulses and the length of
rotation is directly related to the number of input pulses applied.
3.1.2 Characteristics:
• Holding Torque - Steppers have very good low speed and holding torque. Steppers
are usually rated in terms of their holding force (oz/in) and can even hold a position (to a lesser
degree) without power applied, using magnetic 'detent' torque.
• Open loop positioning - Perhaps the most valuable and interesting feature of a
stepper is the ability to position the shaft in fine predictable increments, without need to query
the motor as to its position. Steppers can run 'open-loop' without the need for any kind of
encoder to determine the shaft position. Closed loop systems- systems that feed back position
information, are known as servo systems. Compared to servos, steppers are very easy to control;
the position of the shaft is guaranteed as long as the torque of the motor is sufficient for the load,
under all its operating conditions.
• Load Independent - The rotation speed of a stepper is independent of load, provided
it has sufficient torque to overcome slipping. The higher rpm a stepper motor is driven, the more
torque it needs, so all steppers eventually poop out at some rpm and start slipping. Slipping is
usually a disaster for steppers, because the position of the shaft becomes unknown. For this
reason, software usually keeps the stepping rate within a maximum top rate. In applications
where a known RPM is needed under a varying load, steppers can be very handy.
3.1.3 Working:
The stepper motor uses the theory of operation for magnets to make the motor
shaft turn a precise distance when a pulse of electricity is provided. You learned previously that
like poles of a magnet repel and unlike poles attract. Figure 1 shows a typical cross-sectional
view of the rotor and stator of a stepper motor. From this diagram you can see that the stator
(stationary winding) has four poles, and the rotor has six poles (three complete magnets). The
rotor will require 12 pulses of electricity to move the 12 steps to make one complete revolution.
Another way to say this is that the rotor will move precisely 30° for each pulse of electricity that
the motor receives. The number of degrees the rotor will turn when a pulse of electricity is
delivered to the motor can be calculated by dividing the number of degrees in one revolution of
the shaft (360°) by the number of poles (north and south) in the rotor. In this stepper motor 360°
is divided by 12 to get 30°.
Figure 4. Diagram that shows the position of the six-pole rotor and four-pole
stator of a typical stepper motor
When no power is applied to the motor, the residual magnetism in the rotor magnets will
cause the rotor to detent or align one set of its magnetic poles with the magnetic poles of one of
the stator magnets. This means that the rotor will have 12 possible detent positions. When the
rotor is in a detent position, it will have enough magnetic force to keep the shaft from moving to
the next position. This is what makes the rotor feel like it is clicking from one position to the next
as you rotate the rotor by hand with no power applied.
When power is applied, it is directed to only one of the stator pairs of windings, which will
cause that winding pair to become a magnet. One of the coils for the pair will become the north
pole, and the other will become the south pole. When this occurs, the stator coil that is the north
pole will attract the closest rotor tooth that has the opposite polarity, and the stator coil that is the
south pole will attract the closest rotor tooth that has the opposite polarity. When current is
flowing through these poles, the rotor will now have a much stronger attraction to the stator
winding, and the increased torque is called
holding torque.
By changing the current flow to the next stator winding, the magnetic field will be changed
90°. The rotor will only move 30° before its magnetic fields will again align with the change in
the stator field. The magnetic field in the stator is continually changed as the rotor moves
through the 12 steps to move a total of 360°. Figure 2 shows the position of the rotor changing as
the current supplied to the stator changes.
FIGURE 5 Movement of the stepper motor rotor as current is pulsed to the
stator. (a) Current is applied to the top and bottom windings, so the top winding is
north, (b) Current is applied to left and right windings, so the left winding is
north, (c) Current is applied to the top and bottom windings, so the bottom
winding is north, (d) Current is applied to the left and right windings so the right
winding is north.
In Fig. 5a you can see that when current is applied to the top and bottom stator windings,
they will become a magnet with the top part of the winding being the north pole, and the bottom
part of the winding being the south pole. You should notice that this will cause the rotor to move
a small amount so that one of its south poles is aligned with the north stator pole (at the top), and
the opposite end of the rotor pole, which is the north pole, will align with the south pole of the
stator (at the bottom). A line is placed on the south-pole piece that is located at the 12 o'clock
position in Fig. 5a so that you can follow its movement as current is moved from one stator
winding to the next. In Fig. 5b current has been turned off to the top and bottom windings, and
current is now applied to the stator windings shown at the right and left sides of the motor. When
this occurs, the stator winding at the 3 o'clock position will have the polarity for the south pole of
the stator magnet, and the winding at the 9 o'clock position will have the north-pole polarity. In
this condition, the next rotor pole that will be able to align with the stator magnets is the next
pole in the clockwise position to the previous pole. This means that the rotor will only need to
rotate 30° in the clockwise position for this set of poles to align itself so that it attracts the stator
poles.
In Fig. 5c you can see that the top and bottom stator windings are again energized, but this
time the top winding is the south pole of the magnetic field and the bottom winding is the north
pole. This change in magnetic field will cause the rotor to again move 30° in the clockwise
position until its poles will align with the top and bottom stator poles. You should notice that the
original rotor pole that was at the 12 o'clock position when the motor first started has now moved
three steps in the clockwise position.
In Fig. 5d you can see that the two side stator windings are again energized, but this time the
winding at the 3 o'clock position is the north pole. This change in polarity will cause the rotor to
move another 30° in the clockwise direction. You should notice that the rotor has moved four
steps of 30° each, which means the rotor has moved a total of 120° from its original position.
This can be verified by the position of the rotor pole that has the line on it, which is now pointing
at the stator winding that is located in the 3 o'clock position.
3.1.4 Types of Stepper Motors:
Stepper Motors come in a variety of sizes, and
strengths, from tiny floppy disk motors, to huge
machinery steppers rated over 1000 oz in. Three basic
types of stepper motors include the permanent magnet
motor, the variable re-luctance motor, and the hybrid
motor, which is a combination of the previous two
.
3.1.5 Stepping Modes
The following are the most common
drive modes.
• Wave Drive (1 phase on)
• Full Step Drive (2 phases on)
• Half Step Drive (1 & 2 phases on)
• Microstepping (Continuously varying
motor currents)
For the following discussions please refer to the figure 9.
In Wave Drive only one winding is energized at any given time. The stator is energized
according to the sequence A -> B -> A -> B and the rotor steps from position 8 -> 2 ->4 -> 6.
For unipolar and bipolar wound motors with the same winding parameters this excitation mode
would result in the same mechanical position. The disadvantage of this drive mode is that in the
unipolar wound motor you are only using 25% and in the bipolar motor only 50% of the total
motor winding at any given time. This means that you are not getting the maximum torque
output from the motor.
In Full Step Drive you are energizing two phases at any given time. The stator is energized
according to the sequence and the rotor steps from position 1 ->3 ->5-
> 7 . Full step mode results in the same angular movement as 1 phase on drive but the
mechanical position is offset by one half of a full step. The torque output of the unipolar wound
motor is lower than the bipolar motor (for motors with the same winding parameters) since the
unipolar motor uses only 50% of the available winding while the bipolar motor uses the entire
winding.
Half Step Drive combines both wave and full step (1&2 phases on) drive modes. Every
second step only one phase is energized and during the other steps one
phase on each stator. The stator is energized according to the sequence
And the rotor steps from position 1 ->2 -> 3-> 4 ->5 -> 6 -> 7 -
> 8. This results in angular movements that are half of those in 1- or 2-phases-on drive modes.
Half stepping can reduce a phenomena referred to as resonance which can be experienced in 1-
or 2- phases-on drive modes.
The excitation sequences for the above drive modes are summarized in Table 2.
Table 2 excitation sequence for different driving modes
In Microstepping Drive the currents in the windings are continuously varying to be able to
break up one full step into many smaller discrete steps.
Shortcut for finding the proper wiring sequence
Unipolar and bipolar wound stepper motors.
For 5 wires – 1 is common to be plugged at positive supply and rest four to the pulses. For 6
wires – 2 are common to be plugged at positive supply and rest four to the pulses.
Connect the center tap(s) to the power source (or current-Limiting resistor.) Connect the
remaining 4 wires in any pattern. If it doesn't work, you only need try these 2 swaps...
1 2 3 4 - (arbitrary first wiring order)
1 2 4 3 - switch end pair
1 4 2 3 - switch middle pair
You're finished when the motor turns smoothly in either direction. If the motor turns in the
opposite direction from desired, reverse the wires so that ABCD would become DCBA.
3.2 PARALLEL PORT
A parallel port is a type of interface found on computers (personal and otherwise) for connecting
various peripherals. It is also known as a printer port or Centronics port. The IEEE 1284 standard
defines the bi-directional version of the port.
A port contains a set of signal lines that the CPU sends or receives data with other
components. We use ports to communicate via modem, printer, keyboard, mouse etc. In
signaling, open signals are "1" and close signals are "0" so it is like binary system. A parallel
Fig7 parallel port
port sends 8 bits and receives 5 bits at a time. The serial port RS-232 sends only 1 bit at a
time but it is multidirectional so it can send 1 bit and receive 1 bit at a time...
FIGURE8 PARALLEL PORT
3.2.1 Parallel Port - Data Ports:
In sending the sequences, you will need the data ports which can be seen in the
picture from D0 to D7 .
3.2.2 Parallel Port - Status Ports:
These ports are made for reading signals. The range is like in data ports which
are S0-S7. But S0, S1, S2 are invisible in the connector. And S0 is different; this bit is for
timeout flag in EPP (Enhanced Parallel Port) compatible ports. The address of this status port is
0x379 . This will always be refer to "DATA+1" and it can send 5 numeric data from the 10 - 11 -
12 - 13 - 15 th pins. So how can we reach the data ports? It is simple: every parallel port has an
address. In Windows 2000, you can see yours by Settings > Control Panel > System > Hardware
> Device Manager > Ports (COM & LPT) > Printer Port(LPT1) > Properties = in Resources >
Resource Setting and you can see your address for your parallel port. For Ex: Generally it is
0378-037F. This is hexadecimal like in math (mod 16). 0x378 belongs to 888 in decimal form. In
this way you can look for your com port or game port addresses. Let's enlighten these bits with a
printer example:
S0: This bit becomes higher (1) if a timeout operation occurs in EPP mode.
S1: Not used (Maybe for decoration :))
S2: Mostly not used but sometime this bit shows the cut condition (PIRQ) of the port
S3: If the printer determines an error it becomes lower (0). Which is called nError or
nFault
S4: It is high (1) when the data inputs are active. Which is called Select
S5: It is high(1) when there is no paper in printer. Which is called PaperEnd, PaperEmpty
or PError
S6: It sends low impact signaling when the printer gets a one byte data. Which is called
nAck or nAcknowledge
S7: This is the only reversed pin on the connector (see my table in the article) . If the
printer is busy and it cannot get any additional data this pin becomes lower. Which is
called Busy
3.2.3 Parallel Port - Control Ports:
This port usually used for outputting but these can be used for inputting.
The range is like in data ports C0-C7 but C4, C5, C6, C7 are invisible in connector. And the
address for this is 0x37A
C0: This pin is reversed. It sends a command to read D0-D7 on the port. When the
computer starts it is high in the connector. Which is called nStrobe
C1: This pin is reversed. It sends a command to the printer to feed the next line. It is high
in the connector after the machine starts. Which is called Auto LF
C2: This pin is for reset the printer and clear the buffer. Which is called nInit, nInitialize
C3: This pin is reversed. Sends a high(1) for opening data inputs. It is low after the
machine starts. Which is called nSelectIn
C4: Opens the cut operation for the printer. Not visible in the connector...
C5: Sets the direction control in multidirectional ports. Not visible in the connector...
C6: Not used and also Not visible in the connector...
C7: Mostly not used but it is used as a C5 in some ports. Not visible in the connector...
3.2.4 Parallel Port -Ground Pins:
These are (G0 - G7) the pins from 18 to 25 . These are mostly used for
completing the circuit. Different pins are required when using all the pins including the inputs.
After these we will be using data ports in experiment because there are reversed pins in
control and status ports. Here is an explanation for reversed pins: While you are not sending any
signals to the data port it is in closed position like "00000000" so the 8 pins have no voltage on it
(0 Volt) .If you send decimal "255" (binary "11111111") every pin (D0-D7) has a +5 Volt... On
the other hand, if we use control ports, there are reversed pins which are C0, C1 and C3 so while
we send nothing to the control port its behaviour is "0100" in binary (decimal "11")...
Signal BIT PIN Direction
-Strobe ¬C0 1 Output
+Data Bit 0 D0 2 Output
+Data Bit 1 D1 3 Output
+Data Bit 2 D2 4 Output
+Data Bit 3 D3 5 Output
+Data Bit 4 D4 6 Output
+Data Bit 5 D5 7 Output
+Data Bit 6 D6 8 Output
+Data Bit 7 D7 9 Output
-Acknowledge S6 10 Input
+Busy ¬S7 11 Input
+Paper End S5 12 Input
+Select In S4 13 Input
-Auto Feed ¬C1 14 Output
-Error S3 15 Input
-Initialize C2 16 Output
-Select ¬C3 17 Output
Ground -18-
25Ground
Table 3 pins of parallel port
3.2.5 History
The Centronics Model 101 printer was introduced in 1970 and included the first
parallel interface for printers.[1] The interface was developed by Dr. An Wang, Robert Howard
and Prentice Robinson at Wang Laboratories. The now-familiar connector was selected because
Wang had a surplus stock of 20,000 Amphenol 36-pin micro ribbon connectors that were
originally used for one of their early calculators. The Centronics parallel interface quickly
became a de facto industry standard; manufacturers of the time tended to use various connectors
on the system side, so a variety of cables were required. For example, early VAX systems used a
DC-37 connector, NCR used the 36-pin micro ribbon connector, Texas Instruments used a 25-
pin card edge connector and Data General used a 50-pin micro ribbon connector.
Dataproducts introduced a very different implementation of the parallel interface for their
printers. It used a DC-37 connector on the host side and a 50 pin connector on the printer side—
either a DD-50 (sometimes incorrectly referred to as a "DB50") or the block shaped M-50
connector; the M-50 was also referred to as Winchester.[2][3] Dataproducts parallel was available
in a short-line for connections up to 50 feet (15 m) and a long-line version for connections from
50 feet (15 m) to 500 feet (150 m). The Dataproducts interface was found on many mainframe
systems up through the 1990s, and many printer manufacturers offered the Dataproducts
interface as an option.
IBM released the IBM Personal Computer in 1981 and included a variant of the Centronics
interface— only IBM logo printers (rebranded from Epson) could be used with the IBM PC.[4]
IBM standardized the parallel cable with a DB25F connector on the PC side and the Centronics
connector on the printer side. Vendors soon released printers compatible with both standard
Centronics and the IBM implementation.
IBM implemented an early form of bidirectional interface in 1987. HP introduced their version
of bidirectional, known as Bitronics, on the LaserJet 4 in 1992. The Bitronics and Centronics
interfaces were superseded by the IEEE 1284 standard in 1994.
3.2.6 Uses
Before the advent of USB, the parallel interface was adapted to access a
number of peripheral devices other than printers. Probably one of the earliest devices to use
parallel were dongles used as a hardware key form of software copy protection. Zip drives and
scanners were early implementations followed by external modems, sound cards, webcams,
gamepads, joysticks and external hard disk drives and CD-ROM drives. Adapters were available
to run SCSI devices via parallel. Other devices such as EPROM programmers and hardware
controllers could be connected parallel.
3.2.7 Current use
At the consumer level, the USB interface—and in some cases Ethernet—has
effectively replaced the parallel printer port. Many manufacturers of personal computers and
laptops consider parallel to be a legacy port and no longer include the parallel interface. USB to
parallel adapters are available to use parallel-only printers with USB-only systems. However,
due to the simplicity of its implementation, it is often used for interfacing with custom-made
peripherals.
3.3 ULN 2003
The ULN2001, ULN2002, ULN2003 and ULN 2004 are high voltage, high current
Darlington Arrays each are containing seven open collector Darlington pairs with common
emitters. Each Channel rated at 500 mA and can withstand peak currents of 600 mA.
Suppression diodes are Included for inductive load driving and the inputs are pinned opposite the
outputs to simplify board layout.
The versions interface to all common logic families:
– ULN2001 (general purpose, DTL, TTL,
PMOS, CMOS)
– ULN2002 (14-25V PMOS)
– ULN2003 (5V TTL, CMOS)
– ULN2004 (6-15V CMOS, PMOS)
These versatile devices are useful for driving a wide range of loads including solenoids,
relays DC motors; LED displays filament lamps, thermal print heads and high power buffers.
The ULN2001A/2002A/2003A and 2004A are supplied in 16 pin plastic DIP packages with a
Copper lead frame to reduce thermal resistance. They are available also in small outline
package SO-16) as ULN2001D1/2002D1/2003D1/ 2004D1.
3.3.1 Features
■ Seven darlingtons per package
■ Output current 500 mA per driver (600 Ma peak)
■ Output voltage 50 V■ Integrated suppression diodes for inductive
loads
■ Outputs can be paralleled for higher current ■ TTL/CMOS/PMOS/DTL Compatible inputs ■ Inputs pinned opposite outputs to simplify ayout
3.3.2 Pin configurations
Figure 9. Pin connections (top
view)
3.3.3 Maximum ratings
Symbo
l
VO
Output voltage
Parameter Value
50
Unit
V
V
I
I
C
I
B
T
A
T
S
T
G
T
J
Input voltage (for ULN2002A/D - 2003A/D - 2004A/D)
Continuous collector current
Continuous base current
Operating ambient temperature range
Storage temperature range
Junction temperature
30
500
25
- 20 to 85
- 55 to 150
150
V
mA
mA
°C
°C
°C
Table 4. ABSOLUTE MAXIMUM RATING
3.4 capacitor
A capacitor or condenser is a passive electronic component consisting of a pair of conductors
separated by a dielectric. When a voltage potential difference exists between the conductors, an
electric field is present in the dielectric. This field stores energy and produces a mechanical force
between the plates. The effect is greatest between wide, flat, parallel, narrowly separated
conductors.
An ideal capacitor is characterized by a single constant value, capacitance, which is measured in
farads. This is the ratio of the electric charge on each conductor to the potential difference
between them. In practice, the dielectric between the plates passes a small amount of leakage
current. The conductors and leads introduce an equivalent series resistance and the dielectric has
an electric field strength limit resulting in a breakdown voltage.
The properties of capacitors in a circuit may determine the resonant frequency and quality factor
of a resonant circuit, power dissipation and operating frequency in a digital logic circuit, energy
capacity in a high-power system, and many other important system characteristics.
3.4.1 Theory of operation
A capacitor consists of two conductors separated by a non-conductive region. The non-
conductive substance is called the dielectric medium, although this may also mean a vacuum or a
semiconductor depletion region chemically identical to the conductors. A capacitor is assumed to
be self-contained and isolated, with no net electric charge and no influence from an external
electric field. The conductors thus contain equal and opposite charges on their facing surfaces,
and the dielectric contains an electric field. The capacitor is a reasonably general model for
electric fields within electric circuits.
An ideal capacitor is wholly characterized by a constant capacitance C, defined as the ratio of
charge ±Q on each conductor to the voltage V between them:
Sometimes charge buildup affects the mechanics of the capacitor, causing the capacitance to
vary. In this case, capacitance is defined in terms of incremental changes:
In SI units, a capacitance of one farad means that one coulomb of charge on each conductor
causes a voltage of one volt across the device.
3.4.2 Energy storage
Work must be done by an external influence to move charge between the conductors in a
capacitor. When the external influence is removed, the charge separation persists and energy is
stored in the electric field. If charge is later allowed to return to its equilibrium position, the
energy is released. The work done in establishing the electric field, and hence the amount of
energy stored, is given by:
3.4.3 Current-voltage relation
The current i (t ) through a component in an electric circuit is defined as the rate of change of the
charge q (t ) that has passed through it. Physical charges cannot pass through the dielectric layer
of a capacitor, but rather build up in equal and opposite quantities on the electrodes: as each
electron accumulates on the negative plate, one leaves the positive plate. Thus the accumulated
charge on the electrodes is equal to the integral of the current, as well as being proportional to
the voltage (as discussed above). As with any antiderivative, a constant of integration is added to
represent the initial voltage v (t0). This is the integral form of the capacitor equation,
.
Taking the derivative of this, and multiplying by C, yields the derivative form,[9]
.
The dual of the capacitor is the inductor, which stores energy in the magnetic field rather than the
electric field. Its current-voltage relation is obtained by exchanging current and voltage in the
capacitor equations and replacing C with the inductance L.
3.4.4 DC circuits
A simple resistor-capacitor circuit demonstrates charging of a capacitor.
A series circuit containing only a resistor, a capacitor, a switch and a constant DC source of
voltage V0 is known as a charging circuit.[10] If the capacitor is initially uncharged while the
switch is open, and the switch is closed at t = 0, it follows from Kirchhoff's voltage law that
Taking the derivative and multiplying by C, gives a first-order differential equation,
At t = 0, the voltage across the capacitor is zero and the voltage across the resistor is V0. The
initial current is then i (0) =V0 /R. With this assumption, the differential equation yields
where τ0 = RC is the time constant of the system.
As the capacitor reaches equilibrium with the source voltage, the voltage across the resistor and
the current through the entire circuit decay exponentially. The case of discharging a charged
capacitor likewise demonstrates exponential decay, but with the initial capacitor voltage
replacing V0 and the final voltage being zero.
AC circuits
See also: reactance (electronics) and electrical impedance#Deriving the device specific
impedances
Impedance, the complex sum of reactance and resistance, describes the phase difference and the
ratio of amplitudes between sinusoidally varying voltage and sinusoidally varying current at a
given frequency. Fourier analysis allows any signal to be constructed from a spectrum of
frequencies, whence the circuit's reaction to the various frequencies may be found. The reactance
and impedance of a capacitor are respectively
where j is the imaginary unit and ω is the angular velocity of the sinusoidal signal. The - j phase
indicates that the AC voltage V = Z I lags the AC current by 90°: the positive current phase
corresponds to increasing voltage as the capacitor charges, zero current corresponds to
instantaneous constant voltage, etc.
Note that impedance decreases with increasing capacitance and increasing frequency. This
implies that a higher-frequency signal or a larger capacitor results in a lower voltage amplitude
per current amplitude—an AC "short circuit" or AC coupling. Conversely, for very low
frequencies, the reactance will be high, so that a capacitor is nearly an open circuit in AC
analysis—those frequencies have been "filtered out."
Capacitors are different from resistors and inductors in that the impedance is inversely
proportional to the defining characteristic, i.e. capacitance.
3.4.5 Parallel plate model
FIG10 PARALLEL PLATE CAPACIOTOR
Dielectric is placed between two conducting plates, each of area A and with a separation of d.
The simplest capacitor consists of two parallel conductive plates separated by a dielectric with
permittivity ε. The model may also be used to make qualitative predictions for other device
geometries. The plates are considered to extend uniformly over an area A and a charge density ±ρ
= ±Q/A exists on their surface. Assuming that the width of the plates is much greater than their
separation d, the electric field near the centre of the device will be uniform with the magnitude E
= ρ/ε. The voltage is defined as the line integral of the electric field between the plates
Solving this for C = Q/V reveals that capacitance increases with area and decreases with
separation
.
The capacitance is therefore greatest in devices made from materials with a high permittivity.
3.4.6 Networks
Several capacitors in parallel.
Main article: Series and parallel circuits
Capacitors in a parallel configuration each have the same applied voltage. Their capacitances add
up. Charge is apportioned among them by size. Using the schematic diagram to visualize parallel
plates, it is apparent that each capacitor contributes to the total surface area.
Several capacitors in series.
Connected in series, the schematic diagram reveals that the separation distance, not the plate
area, adds up. The capacitors each store instantaneous charge build-up equal to that of every
other capacitor in the series. The total voltage difference from end to end is apportioned to each
capacitor according to the inverse of its capacitance. The entire series acts as a capacitor smaller
than any of its components.
Capacitors are combined in series to achieve a higher working voltage, for example for
smoothing a high voltage power supply. The voltage ratings, which are based on plate
separation, add up. In such an application, several series connections may in turn be connected in
parallel, forming a matrix. The goal is to maximize the energy storage utility of each capacitor
without overloading it.
Series connection is also used to adapt electrolytic capacitors for AC use.
3.5 Resistor
A resistor is a two-terminal electronic component that produces a voltage across its terminals
that is proportional to the electric current through it in accordance with Ohm's law:
V = IR
Resistors are elements of electrical networks and electronic circuits and are ubiquitous in most
electronic equipment. Practical resistors can be made of various compounds and films, as well as
resistance wire (wire made of a high-resistivity alloy, such as nickel/chrome).
The primary characteristics of a resistor are the resistance, the tolerance and the power rating.
Other characteristics include temperature coefficient, noise, and inductance. Less well-known is
critical resistance, the value below which power dissipation limits the maximum permitted
current flow, and above which the limit is applied voltage. Critical resistance depends upon the
materials constituting the resistor as well as its physical dimensions; it's determined by design.
Resistors can be integrated into hybrid and printed circuits, as well as integrated circuits. Size,
and position of leads (or terminals) are relevant to equipment designers; resistors must be
physically large enough not to overheat when dissipating their power.
3.5.1 Theory of operation
Ohm's law
The behavior of an ideal resistor is dictated by the relationship specified in Ohm's law:
V = IR
Ohm's law states that the voltage (V) across a resistor is proportional to the current (I) through it
where the constant of proportionality is the resistance (R).
Series and parallel resistors
Resistors in a parallel configuration each have the same potential difference (voltage). To find
their total equivalent resistance (Req):
The parallel property can be represented in equations by two vertical lines "||" (as in geometry) to
simplify equations. For two resistors,
The current through resistors in series stays the same, but the voltage across each resistor can be
different. The sum of the potential differences (voltage) is equal to the total voltage. To find their
total resistance:
A resistor network that is a combination of parallel and series can sometimes be broken up into
smaller parts that are either one or the other. For instance,
However, many resistor networks cannot be split up in this way. Consider a cube, each edge of
which has been replaced by a resistor. For example, determining the resistance between two
opposite vertices requires matrix methods for the general case. However, if all twelve resistors
are equal, the corner-to-corner resistance is 5⁄6 of any one of them.
The practical application to resistors is that a resistance of any non-standard value can be
obtained by connecting standard values in series or in parallel.
3.5.2 Power dissipation
The power dissipated by a resistor is the voltage across the resistor multiplied by the current
through the resistor:
All three equations are equivalent. The first is derived from Joule's law, and Ohm’s Law derives
the other two from that.
The total amount of heat energy released is the integral of the power over time:
If the average power dissipated is more than the resistor can safely dissipate, the resistor may
depart from its nominal resistance, and may be damaged by overheating. Excessive power
dissipation may raise the temperature of the resistor to a point where it burns out, which could
cause a fire in adjacent components and materials. There are flameproof resistors that fail (open
circuit) before they overheat dangerously.
Note that the nominal power rating of a resistor is not the same as the power that it can safely
dissipate in practical use. Air circulation and proximity to a circuit board, ambient temperature,
and other factors can reduce acceptable dissipation significantly. Rated power dissipation may be
given for an ambient temperature of 25°C in free air. Inside an equipment case at 60°C, rated
dissipation will be significantly less; if we are dissipating a bit less than the maximum figure
given by the manufacturer we may still be outside the safe operating area, and courting
premature failure.
3.5.3 Construction
Lead arrangements
Through-hole components typically have leads leaving the body axially. Others have leads
coming off their body radially instead of parallel to the resistor axis. Other components may be
SMT (surface mount technology) while high power resistors may have one of their leads
designed into the heatsink.
Carbon composition
Carbon composition resistors consist of a solid cylindrical resistive element with embedded wire
leads or metal end caps to which the lead wires are attached. The body of the resistor is protected
with paint or plastic. Early 20th-century carbon composition resistors had uninsulated bodies; the
lead wires were wrapped around the ends of the resistance element rod and soldered. The
completed resistor was painted for color coding of its value.
The resistive element is made from a mixture of finely ground (powdered) carbon and an
insulating material (usually ceramic). A resin holds the mixture together. The resistance is
determined by the ratio of the fill material (the powdered ceramic) to the carbon. Higher
concentrations of carbon, a weak conductor, result in lower resistance. Carbon composition
resistors were commonly used in the 1960s and earlier, but are not so popular for general use
now as other types have better specifications, such as tolerance, voltage dependence, and stress
(carbon composition resistors will change value when stressed with over-voltages). Moreover, if
internal moisture content (from exposure for some length of time to a humid environment) is
significant, soldering heat will create a non-reversible change in resistance value. These resistors,
however, if never subjected to overvoltage nor overheating were remarkably reliable.
They are still available, but comparatively quite costly. Values ranged from fractions of an ohm
to 22 megohms.
Carbon film
A carbon film is deposited on an insulating substrate, and a helix cut in it to create a long, narrow
resistive path. Varying shapes, coupled with the resistivity of carbon, (ranging from 9 to 40 µΩ-
cm) can provide a variety of resistances.[1] Carbon film resistors feature a power rating range of
1/6 W to 5 W at 70°C. Resistances available range from 1 ohm to 10 megohm. The carbon film
resistor can operate between temperatures of -55°C to 155°C. It has 200 to 600 volts maximum
working voltage range.
Thick and thin film
Thick film resistors became popular during the 1970s, and most SMD (surface mount device)
resistors today are of this type. The principal difference between thin film and thick film resistors
is not the actual thickness of the film, but rather how the film is applied to the cylinder (axial
resistors) or the surface (SMD resistors).
Thin film resistors are made by sputtering (a method of vacuum deposition) the resistive material
onto an insulating substrate. The film is then etched in a similar manner to the old (subtractive)
process for making printed circuit boards; that is, the surface is coated with a photo-sensitive
material, then covered by a pattern film, irradiated with ultraviolet light, and then the exposed
photo-sensitive coating is developed, and underlying thin film is etched away.
Because the time during which the sputtering is performed can be controlled, the thickness of the
thin film can be accurately controlled. The type of material is also usually different consisting of
one or more ceramic (cermet) conductors such as tantalum nitride (TaN), ruthenium dioxide
(RuO2), lead oxide (PbO), bismuth ruthenate (Bi2Ru2O7), nickel chromium (NiCr), and/or
bismuth iridate (Bi2Ir2O7).
The resistance of both thin and thick film resistors after manufacture is not highly accurate; they
are usually trimmed to an accurate value by abrasive or laser trimming. Thin film resistors are
usually specified with tolerances of 0.1, 0.2, 0.5, or 1%, and with temperature coefficients of 5 to
25 ppm/K.
Thick film resistors may use the same conductive ceramics, but they are mixed with sintered
(powdered) glass and some kind of liquid so that the composite can be screen-printed. This
composite of glass and conductive ceramic (cermet) material is then fused (baked) in an oven at
about 850 °C.
Thick film resistors, when first manufactured, had tolerances of 5%, but standard tolerances have
improved to 2% or 1% in the last few decades. Temperature coefficients of thick film resistors
are high, typically ±200 or ±250 ppm/K; a 40 kelvin (70°F) temperature change can change the
resistance by 1%.
Thin film resistors are usually far more expensive than thick film resistors, although, for
example, SMD thin film resistors, with 0.5% tolerances, and with 25 ppm/K temperature
coefficients, when bought in full size reel quantities, are about twice the cost of 1%, 250 ppm/K
thick film resistors.
Metal film
A common type of axial resistor today is referred to as a metal-film resistor. MELF (Metal
Electrode Leadless Face) resistors often use the same technology, but are a cylindrically shaped
resistor designed for surface mounting. [Note that other types of resistors, e.g. carbon
composition, are also available in "MELF" packages].
Metal film resistors are usually coated with nickel chromium (NiCr), but might be coated with
any of the cermet materials listed above for thin film resistors. Unlike thin film resistors, the
material may be applied using different techniques than sputtering (though that is one such
technique). Also, unlike thin-film resistors, the resistance value is determined by cutting a helix
through the coating rather than by etching. [This is similar to the way carbon resistors are made.]
The result is a reasonable tolerance (0.5, 1, or 2%) and a temperature coefficient of (usually) 25
or 50 ppm/K.
Resistance standards
Resistors of extremely high precision are manufactured as substandards of resistance for
calibration and laboratory use. They may have 4 terminals, using one pair to carry an operating
current, and the other pair to measure the voltage drop; this minimizes temperature coefficients
and thermal EMFs.
3.5.4 Resistor marking
Most axial resistors use a pattern of colored stripes to indicate resistance. Surface-mount resistors
are marked numerically, if they are big enough to permit marking; more-recent small sizes are
impractical to mark. Cases are usually tan, brown, blue, or green, though other colors are
occasionally found such as dark red or dark gray.
Early 20th century resistors, essentially uninsulated, were dipped in paint to cover their entire
body for color coding. A second color of paint was applied to one end of the element, and a color
dot (or band) in the middle provided the third digit. The rule was "body, tip, dot", providing two
significant digits for value and the decimal multiplier, in that sequence. Default tolerance was
±20%. Closer-tolerance resistors had silver (±10%) or gold-colored (±5%) paint on the other end.
Four-band resistors
Four-band identification is the most commonly used color-coding scheme on all resistors. It
consists of four colored bands that are painted around the body of the resistor. The first two
bands encode the first two significant digits of the resistance value, the third is a power-of-ten
multiplier or number-of-zeroes, and the fourth is the tolerance accuracy, or acceptable error, of
the value. Sometimes a fifth band identifies the thermal coefficient, but this must be
distinguished from the true 5-color system, with 3 significant digits.
For example, green-blue-yellow-red is 56×104 Ω = 560 kΩ ± 2%. An easier description can be as
followed: the first band, green, has a value of 5 and the second band, blue, has a value of 6, and
is counted as 56. The third band, yellow, has a value of 104, which adds four 0's to the end,
creating 560,000Ω at ±2% tolerance accuracy. 560,000Ω changes to 560 kΩ ±2% (as a kilo- is
103).
Each color corresponds to a certain digit, progressing from darker to lighter colors, as shown in
the chart below.
Color 1st band 2nd band 3rd band (multiplier) 4th band (tolerance) Temp. Coefficient
Black 0 0 ×100
Brown 1 1 ×101 ±1% (F) 100 ppm
Red 2 2 ×102 ±2% (G) 50 ppm
Orange 3 3 ×103 15 ppm
Yellow 4 4 ×104 25 ppm
Green 5 5 ×105 ±0.5% (D)
Blue 6 6 ×106 ±0.25% (C)
Violet 7 7 ×107 ±0.1% (B)
Gray 8 8 ×108 ±0.05% (A)
White 9 9 ×109
Gold ×10-1 ±5% (J)
Silver ×10-2 ±10% (K)
TABL
E
5
Diffren
t
Color of resistor
Preferred values
Early resistors were made in more or less arbitrary round numbers; a series might have 100, 125,
150, 200, 300, etc. Resistors as manufactured are subject to a certain percentage tolerance, and it
makes sense to manufacture values that correlate with the tolerance, so that the actual value of a
resistor overlaps slightly with its neighbors. Wider spacing leaves gaps; narrower spacing
increases manufacturing and inventory costs to provide resistors that are more or less
interchangeable.
A logical scheme is to produce resistors in a range of values which increase in a geometrical
progression, so that each value is greater than its predecessor by a fixed multiplier or percentage,
chosen to match the tolerance of the range. For example, for a tolerance of ±20% it makes sense
to have each resistor about 1.5 times its predecessor, covering a decade in 6 values. In practice
the factor used is 1.4678, giving values of 1.47, 2.15, 3.16, 4.64, 6.81, 10 for the 1-10 decade (a
decade is a range increasing by a factor of 10; 0.1-1 and 10-100 are other examples); these are
rounded in practice to 1.5, 2.2, 3.3, 4.7, 6.8, 10; followed, of course by 15, 22, 33, … and
preceded by … 0.47, 0.68, 1. This scheme has been adopted as the E6 range of the IEC 60063
preferred number series. There are also E12, E24, E48, E96 and E192 ranges for components of
ever tighter tolerance, with 12, 24, 96, and 192 different values within each decade. The actual
values used are in the IEC 60063 lists of preferred numbers.
A resistor of 100 ohms ±20% would be expected to have a value between 80 and 120 ohms; its
E6 neighbors are 68 (54-82) and 150 (120-180) ohms. A sensible spacing, E6 is used for ±20%
components; E12 for ±10%; E24 for ±5%; E48 for ±2%, E96 for ±1%; E192 for ±0.5% or better.
Resistors are manufactured in values from a few milliohms to about a gigaohm in IEC60063
ranges appropriate for their tolerance.
Earlier power wirewound resistors, such as brown vitreous-enameled types, however, were made
with a different system of preferred values, such as some of those mentioned in the first sentence
of this section.
5-band axial resistors
5-band identification is used for higher precision (lower tolerance) resistors (1%, 0.5%, 0.25%,
0.1%), to specify a third significant digit. The first three bands represent the significant digits,
the fourth is the multiplier, and the fifth is the tolerance. Five-band resistors with a gold or silver
4th band are sometimes encountered, generally on older or specialized resistors. The 4th band is
the tolerance and the 5th the temperature coefficient.
3.6 Diode
In electronics, a diode is a two-terminal device (thermionic diodes may also have one or two
ancillary terminals for a heater).
Diodes have two active electrodes between which the signal of interest may flow, and most are
used for their unidirectional electric current property. The varicap diode is used as an electrically
adjustable capacitor.
The unidirectionality most diodes exhibit is sometimes generically called the rectifying property.
The most common function of a diode is to allow an electric current in one direction (called the
forward biased condition) and to block the current in the opposite direction (the reverse biased
condition). Thus, the diode can be thought of as an electronic version of a check valve.
Real diodes do not display such a perfect on-off directionality but have a more complex non-
linear electrical characteristic, which depends on the particular type of diode technology. Diodes
also have many other functions in which they are not designed to operate in this on-off manner.
Early diodes included “cat’s whisker” crystals and vacuum tube devices (also called thermionic
valves). Today the most common diodes are made from semiconductor materials such as silicon
or germanium.
3.6.1 Semiconductor diodes
Most diodes today are based on semiconductor p-n junctions. In a p-n diode, conventional
current is from the p-type side (the anode) to the n-type side (the cathode), but not in the opposite
direction. Another type of semiconductor diode, the Schottky diode, is formed from the contact
between a metal and a semiconductor rather than by a p-n junction.
3.6.2 Current–voltage characteristic
A semiconductor diode's current–voltage characteristic, or I–V curve, is related to the transport
of carriers through the so-called depletion layer or depletion region that exists at the p-n junction
between differing semiconductors. When a p-n junction is first created, conduction band
(mobile) electrons from the N-doped region diffuse into the P-doped region where there is a
large population of holes (places for electrons in which no electron is present) with which the
electrons "recombine". When a mobile electron recombines with a hole, both hole and electron
vanish, leaving behind an immobile positively charged donor (the dopant) on the N-side and
negatively charged acceptor (the dopant) on the P-side. The region around the p-n junction
becomes depleted of charge carriers and thus behaves as an insulator.
However, the width of the depletion region (called the depletion width) cannot grow without
limit. For each electron-hole pair that recombines, a positively-charged dopant ion is left behind
in the N-doped region, and a negatively charged dopant ion is left behind in the P-doped region.
As recombination proceeds and more ions are created, an increasing electric field develops
through the depletion zone which acts to slow and then finally stop recombination. At this point,
there is a "built-in" potential across the depletion zone.
If an external voltage is placed across the diode with the same polarity as the built-in potential,
the depletion zone continues to act as an insulator, preventing any significant electric current
flow (unless electron/hole pairs are actively being created in the junction by, for instance, light.
see photodiode). This is the reverse bias phenomenon. However, if the polarity of the external
voltage opposes the built-in potential, recombination can once again proceed, resulting in
substantial electric current through the p-n junction (i.e. substantial numbers of electrons and
holes recombine at the junction).. For silicon diodes, the built-in potential is approximately 0.6
V. Thus, if an external current is passed through the diode, about 0.6 V will be developed across
the diode such that the P-doped region is positive with respect to the N-doped region and the
diode is said to be "turned on" as it has a forward bias.
Figure 11: I–V characteristics of a P-N junction diode (not to scale).
A diode’s I–V characteristic can be approximated by four regions of operation (see the figure at
right).
At very large reverse bias, beyond the peak inverse voltage or PIV, a process called reverse
breakdown occurs which causes a large increase in current (i.e. a large number of electrons and
holes are created at, and move away from the pn junction) that usually damages the device
permanently. The avalanche diode is deliberately designed for use in the avalanche region. In the
zener diode, the concept of PIV is not applicable. A zener diode contains a heavily doped p-n
junction allowing electrons to tunnel from the valence band of the p-type material to the
conduction band of the n-type material, such that the reverse voltage is "clamped" to a known
value (called the zener voltage), and avalanche does not occur. Both devices, however, do have a
limit to the maximum current and power in the clamped reverse voltage region. Also, following
the end of forward conduction in any diode, there is reverse current for a short time. The device
does not attain its full blocking capability until the reverse current ceases.
The second region, at reverse biases more positive than the PIV, has only a very small reverse
saturation current. In the reverse bias region for a normal P-N rectifier diode, the current through
the device is very low (in the µA range).
The third region is forward but small bias, where only a small forward current is conducted.
As the potential difference is increased above an arbitrarily defined "cut-in voltage" or "on-
voltage" or "diode forward voltage drop (Vd)", the diode current becomes appreciable (the level
of current considered "appreciable" and the value of cut-in voltage depends on the application),
and the diode presents a very low resistance.
The current–voltage curve is exponential. In a normal silicon diode at rated currents, the arbitrary
"cut-in" voltage is defined as 0.6 to 0.7 volts. The value is different for other diode types —
Schottky diodes can be as low as 0.2 V and red light-emitting diodes (LEDs) can be 1.4 V or
more and blue LEDs can be up to 4.0 V.
At higher currents the forward voltage drop of the diode increases. A drop of 1 V to 1.5 V is
typical at full rated current for power diodes.
3.6.3 Shockley diode equation
The Shockley ideal diode equation or the diode law (named after transistor co-inventor William
Bradford Shockley, not to be confused with tetrode inventor Walter H. Schottky) is the I–V
characteristic of an ideal diode in either forward or reverse bias (or no bias). The equation is:
where
I is the diode current,
IS is the reverse bias saturation current,
VD is the voltage across the diode,
VT is the thermal voltage,
and n is the emission coefficient, also known as the ideality factor. The emission
coefficient n varies from about 1 to 2 depending on the fabrication process and
semiconductor material and in many cases is assumed to be approximately equal to 1
(thus the notation n is omitted).
The thermal voltage VT is approximately 25.85 mV at 300 K, a temperature close to “room
temperature” commonly used in device simulation software. At any temperature it is a known
constant defined by:
where
q is the magnitude of charge on an electron (the elementary charge),
k is Boltzmann’s constant,
T is the absolute temperature of the p-n junction in kelvins
The Shockley ideal diode equation or the diode law is derived with the assumption that the only
processes giving rise to current in the diode are drift (due to electrical field), diffusion, and
thermal recombination-generation. It also assumes that the recombination-generation (R-G)
current in the depletion region is insignificant. This means that the Shockley equation doesn’t
account for the processes involved in reverse breakdown and photon-assisted R-G. Additionally,
it doesn’t describe the “leveling off” of the I–V curve at high forward bias due to internal
resistance.
Under reverse bias voltages (see Figure 5) the exponential in the diode equation is negligible,
and the current is a constant (negative) reverse current value of -IS. The reverse breakdown
region is not modeled by the Shockley diode equation.
For even rather small forward bias voltages (see Figure 5) the exponential is very large because
the thermal voltage is very small, so the subtracted ‘1’ in the diode equation is negligible and the
forward diode current is often approximated as
The use of the diode equation in circuit problems is illustrated in the article on diode modeling.
3.7Transistor
n electronics, a transistor is a semiconductor device commonly used to amplify or switch
electronic signals. A transistor is made of a solid piece of a semiconductor material, with at least
three terminals for connection to an external circuit. A voltage or current applied to one pair of
the transistor's terminals changes the current flowing through another pair of terminals. Because
the controlled (output) power can be much larger than the controlling (input) power, the
transistor provides amplification of a signal. The transistor is the fundamental building block of
modern electronic devices, and is used in radio, telephone, computer and other electronic
systems. Some transistors are packaged individually but most are found in integrated circuits.
3.7.1 Usage
The bipolar junction transistor, or BJT, was the first transistor invented, and through the 1970s,
was the most commonly used transistor. Even after MOSFETs became available, the BJT
remained the transistor of choice for many analog circuits such as simple amplifiers because of
their greater linearity and ease of manufacture. Desirable properties of MOSFETs, such as their
utility in low-power devices, usually in the CMOS configuration, allowed them to capture nearly
all market share for digital circuits; more recently MOSFETs have captured most analog and
power applications as well, including modern clocked analog circuits, voltage regulators,
amplifiers, power transmitters, motor drivers, etc.
Fig 12 BJT used as an electronic switch, in grounded-emitter configuration.
3.7.2 Simplified operation
Fig 13 Amplifier circuit, standard common-emitter configuration.
Fig 14 Simple circuit using a transistor.
Fig 15 Operation graph of a transistor
The essential usefulness of a transistor comes from its ability to use a small signal applied
between one pair of its terminals to control a much larger signal at another pair of terminals. This
property is called gain. A transistor can control its output in proportion to the input signal, that is,
can act as an amplifier. Or, the transistor can be used to turn current on or off in a circuit like an
electrically controlled switch, where the amount of current is determined by other circuit
elements.
The two types of transistors have slight differences in how they are used in a circuit. A bipolar
transistor has terminals labelled base, collector and emitter. A small current at base terminal (that
is, flowing from the base to the emitter) can control or switch a much larger current between
collector and emitter terminals. For a field-effect transistor, the terminals are labelled gate,
source, and drain, and a voltage at the gate can control a current between source and drain.
The image to the right represents a typical bipolar transistor in a circuit. Charge will flow
between emitter and collector terminals depending on the current in the base. Since internally the
base and emitter connections behave like a semiconductor diode, a voltage drop develops
between base and emitter while the base current exists. The size of this voltage depends on the
material the transistor is made from, and is referred to as VBE.
3.7.3 Transistor as a switch
Transistors are commonly used as electronic switches, for both high power applications
including switched-mode power supplies and low power applications such as logic gates.
It can be seen from the graph that once the base voltage reaches a certain level, shown at point B,
the current will no longer increase with increasing VBE and the output will be held at a fixed
voltage.[dubious – discuss] The transistor is then said to be saturated. Hence, values of input voltage can
be chosen such that the output is either completely off, [9] or completely on. The transistor is
acting as a switch, and this type of operation is common in digital circuits where only "on" and
"off" values are relevant.
3.7.4 Transistor as an amplifier
The above common emitter amplifier is designed so that a small change in voltage in (Vin)
changes the small current through the base of the transistor and the transistor's current
amplification combined with the properties of the circuit mean that small swings in Vin produce
large changes in Vout.
It is important that the operating parameters of the transistor are chosen and the circuit designed
such that as far as possible the transistor operates within a linear portion of the graph, such as
that shown between A and B, otherwise the output signal will suffer distortion.
Various configurations of single transistor amplifier are possible, with some providing current
gain, some voltage gain, and some both.
From mobile phones to televisions, vast numbers of products include amplifiers for sound
reproduction, radio transmission, and signal processing. The first discrete transistor audio
amplifiers barely supplied a few hundred milliwatts, but power and audio fidelity gradually
increased as better transistors became available and amplifier architecture evolved.
Modern transistor audio amplifiers of up to a few hundred watts are common and relatively
inexpensive.
Some musical instrument amplifier manufacturers mix transistors and vacuum tubes in the same
circuit, as some believe tubes have a distinctive sound.
3.7.5 Construction
Semiconductor material
The first BJTs were made from germanium (Ge). Silicon (Si) types currently predominate but
certain advanced microwave and high performance versions now employ the compound
semiconductor material gallium arsenide (GaAs) and the semiconductor alloy silicon
germanium (SiGe). Single element semiconductor material (Ge and Si) is described as
elemental.
Rough parameters for the most common semiconductor materials used to make transistors are
given in the table below; it must be noted that these parameters will vary with increase in
temperature, electric field, impurity level, strain and various other factors:
Semiconductor
material
Junction forward
voltage
V @ 25 °C
Electron mobility
m²/(V·s) @ 25 °C
Hole mobility
m²/(V·s) @ 25 °C
Max. junction temp.
°C
Ge 0.27 0.39 0.19 70 to 100
Si 0.71 0.14 0.05 150 to 200
GaAs 1.03 0.85 0.05 150 to 200
Al-Si junction 0.3 — — 150 to 200
Table 6 Semiconductor material characteristics
The junction forward voltage is the voltage applied to the emitter-base junction of a BJT in order
to make the base conduct a specified current. The current increases exponentially as the junction
forward voltage is increased. The values given in the table are typical for a current of 1 mA (the
same values apply to semiconductor diodes). The lower the junction forward voltage the better,
as this means that less power is required to "drive" the transistor. The junction forward voltage
for a given current decreases with increase in temperature. For a typical silicon junction the
change is approximately −2.1 mV/°C.[14]
The density of mobile carriers in the channel of a MOSFET is a function of the electric field
forming the channel and of various other phenomena such as the impurity level in the channel.
Some impurities, called dopants, are introduced deliberately in making a MOSFET, to control
the MOSFET electrical behavior.
The electron mobility and hole mobility columns show the average speed that electrons and holes
diffuse through the semiconductor material with an electric field of 1 volt per meter applied
across the material. In general, the higher the electron mobility the faster the transistor. The table
indicates that Ge is a better material than Si in this respect. However, Ge has four major
shortcomings compared to silicon and gallium arsenide:
its maximum temperature is limited
it has relatively high leakage current
it cannot withstand high voltages
it is less suitable for fabricating integrated circuits
Because the electron mobility is higher than the hole mobility for all semiconductor materials, a
given bipolar NPN transistor tends to be faster than an equivalent PNP transistor type. GaAs has
the highest electron mobility of the three semiconductors. It is for this reason that GaAs is used
in high frequency applications. A relatively recent FET development, the high electron mobility
transistor (HEMT), has a heterostructure (junction between different semiconductor materials)
of aluminium gallium arsenide (AlGaAs)-gallium arsenide (GaAs) which has double the electron
mobility of a GaAs-metal barrier junction. Because of their high speed and low noise, HEMTs
are used in satellite receivers working at frequencies around 12 GHz.
Max. junction temperature values represent a cross section taken from various manufacturers'
data sheets. This temperature should not be exceeded or the transistor may be damaged.
Al-Si junction refers to the high-speed (aluminum-silicon) semiconductor-metal barrier diode,
commonly known as a Schottky diode. This is included in the table because some silicon power
IGFETs have a parasitic reverse Schottky diode formed between the source and drain as part of
the fabrication process. This diode can be a nuisance, but sometimes it is used in the circuit.
3.7.6 packaging
Fig 16 Through-hole transistors (tape measure marked in centimetres)
Transistors come in many different packages (chip carriers) (see images). The two main
categories are through-hole (or leaded), and surface-mount, also known as surface mount
device (SMD). The ball grid array (BGA) is the latest surface mount package (currently only
for large transistor arrays). It has solder "balls" on the underside in place of leads. Because they
are smaller and have shorter interconnections, SMDs have better high frequency characteristics
but lower power rating.
Transistor packages are made of glass, metal, ceramic or plastic. The package often dictates the
power rating and frequency characteristics. Power transistors have large packages that can be
clamped to heat sinks for enhanced cooling. Additionally, most power transistors have the
collector or drain physically connected to the metal can/metal plate. At the other extreme, some
surface-mount microwave transistors are as small as grains of sand.
Often a given transistor type is available in different packages. Transistor packages are mainly
standardized, but the assignment of a transistor's functions to the terminals is not: different
transistor types can assign different functions to the package's terminals. Even for the same
transistor type the terminal assignment can vary (normally indicated by a suffix letter to the part
number- i.e. BC212L and BC212K).
CHAPTER4 – VISUAL BASIC
Table 7 characteristics of visual basic
VISUAL BASIC is a high level programming language which was evolved from the earlier
DOS version called BASIC. BASIC means Beginners' All-purpose Symbolic Instruction Code.
It is a very easy programming language to learn. The codes look a lot like English Language.
Different software companies produced different version of BASIC, such as Microsoft QBASIC,
QUICKBASIC, GWBASIC ,IBM BASICA and so on. However, it seems people only use
Microsoft Visual Basic today, as it is a well developed programming language and supporting
resources are available everywhere. Now, there are many versions of VB exist in the market, the
most popular one and still widely used by many VB programmers is none other than Visual
Basic 6. We also have VB.net, VB2005 and the latest VB2008, which is a fully object oriented
programming (OOP) language. It is more powerful than VB6 but looks more complicated to
master.
Paradigm Object-oriented and Event-driven
Developer Microsoft
Latest release VB6/ 1998
Typing discipline Static, strong
Influenced by QuickBASIC
Influenced Visual Basic .NET, Gambas
OS Microsoft Windows, MS-DOS
VISUAL BASIC is a VISUAL and events driven Programming Language. These are the main
divergence from the old BASIC. In BASIC, programming is done in a text-only environment and
the program is executed sequentially. In VB, programming is done in a graphical environment.
In the old BASIC, you have to write program codes for each graphical object you wish to display
it on screen, including its position and its color. However, In VB , you just need to drag and drop
any graphical object anywhere on the form, and you can change its color any time using the
properties windows.
On the other hand, because users may click on a certain object randomly, so each object has to
be programmed independently to be able to response to those actions (events). Therefore, a VB
Program is made up of many subprograms, each has its own program codes, and each can be
executed independently and at the same time each can be linked together in one way or another.
it is the third-generation event-driven programming language and integrated development
environment (IDE) from Microsoft for its COM programming model. VB is also considered a
relatively easy to learn and use programming language, because of its graphical development
features and BASIC heritage.
Visual Basic was derived from BASIC and enables the rapid application development (RAD) of
graphical user interface (GUI) applications, access to databases using Data Access Objects,
Remote Data Objects, or ActiveX Data Objects, and creation of ActiveX controls and objects.
Scripting languages such as VBA and VBScript are syntactically similar to Visual Basic, but
perform differently.
A programmer can put together an application using the components provided with Visual Basic
itself. Programs written in Visual Basic can also use the Windows API, but doing so requires
external function declarations.
The final release was version 6 in 1998. Microsoft's extended support ended in March 2008 and
the designated successor was Visual Basic .NET (now known simply as Visual Basic).
Figure 17 form of vb
4.1Language features
Full set of objects - you 'draw' the application Lots of icons and pictures for your use Response to mouse and keyboard actions Clipboard and printer access Full array of mathematical, string handling, and graphics functions Can handle fixed and dynamic variable and control arrays Sequential and random access file support Useful debugger and error-handling facilities Powerful database access tools ActiveX support Package & Deployment Wizard makes distributing your applications simple
Like the BASIC programming language, Visual Basic was designed to be easy to learn and use.
The language not only allows programmers to create simple GUI applications, but can also
develop complex applications. Programming in VB is a combination of visually arranging
components or controls on a form, specifying attributes and actions of those components, and
writing additional lines of code for more functionality. Since default attributes and actions are
defined for the components, a simple program can be created without the programmer having to
write many lines of code. Performance problems were experienced by earlier versions, but with
faster computers and native code compilation this has become less of an issue.
Although programs can be compiled into native code executables from version 5 onwards, they
still require the presence of runtime libraries of approximately 1 MB in size. This runtime is
included by default in Windows 2000 and later, but for earlier versions of Windows like
95/98/NT it must be distributed together with the executable.
Forms are created using drag-and-drop techniques. A tool is used to place controls (e.g., text
boxes, buttons, etc.) on the form (window). Controls have attributes and event handlers
associated with them. Default values are provided when the control is created, but may be
changed by the programmer. Many attribute values can be modified during run time based on
user actions or changes in the environment, providing a dynamic application. For example, code
can be inserted into the form resize event handler to reposition a control so that it remains
centered on the form, expands to fill up the form, etc. By inserting code into the event handler
for a key press in a text box, the program can automatically translate the case of the text being
entered, or even prevent certain characters from being inserted.
Visual Basic can create executables (EXE files), ActiveX controls, or DLL files, but is primarily
used to develop Windows applications and to interface database systems. Dialog boxes with less
functionality can be used to provide pop-up capabilities. Controls provide the basic functionality
of the application, while programmers can insert additional logic within the appropriate event
handlers. For example, a drop-down combination box will automatically display its list and allow
the user to select any element. An event handler is called when an item is selected, which can
then execute additional code created by the programmer to perform some action based on which
element was selected, such as populating a related list.
Alternatively, a Visual Basic component can have no user interface, and instead provide ActiveX
objects to other programs via Component Object Model (COM). This allows for server-side
processing or an add-in module.
The language is garbage collected using reference counting, has a large library of utility objects,
and has basic object oriented support. Since the more common components are included in the
default project template, the programmer seldom needs to specify additional libraries. Unlike
many other programming languages, Visual Basic is generally not case sensitive, although it will
transform keywords into a standard case configuration and force the case of variable names to
conform to the case of the entry within the symbol table entry. String comparisons are case
sensitive by default, but can be made case insensitive if so desired.
The Visual Basic compiler is shared with other Visual Studio languages (C, C++), but
restrictions in the IDE do not allow the creation of some targets (Windows model DLL's) and
threading models.
4.2 Characteristics present in Visual Basic
Visual Basic has the following traits which differ from C-derived languages:
Multiple assignment available in C language is not possible. A = B = C does not imply
that the values of A, B and C are equalled. The boolean result of "Is B = C?" is stored in
A. The result stored in A could therefore be false(0) or true(-1)
Boolean constant True has numeric value −1.[3] This is because the Boolean data type is
stored as a 16-bit signed integer. In this construct −1 evaluates to 16 binary 1s (the
Boolean value True), and 0 as 16 0s (the Boolean value False). This is apparent when
performing a Not operation on a 16 bit signed integer value 0 which will return the
integer value −1, in other words True = Not False. This inherent functionality becomes
especially useful when performing logical operations on the individual bits of an integer
such as And, Or, Xor and Not.[4] This definition of True is also consistent with BASIC
since the early 1970s Microsoft BASIC implementation and is also related to the
characteristics of CPU instructions at the time.
Logical and bitwise operators are unified. This is unlike some C-derived languages (such
as Perl), which have separate logical and bitwise operators. This again is a traditional
feature of BASIC.
Variable array base. Arrays are declared by specifying the upper and lower bounds in a
way similar to Pascal and Fortran. It is also possible to use the Option Base statement to
set the default lower bound. Use of the Option Base statement can lead to confusion when
reading Visual Basic code and is best avoided by always explicitly specifying the lower
bound of the array. This lower bound is not limited to 0 or 1, because it can also be set by
declaration. In this way, both the lower and upper bounds are programmable. In more
subscript-limited languages, the lower bound of the array is not variable. This uncommon
trait does exist in Visual Basic .NET but not in VBScript.
OPTION BASE was introduced by ANSI, with the standard for ANSI Minimal BASIC in
the late 1970s.
Relatively strong integration with the Windows operating system and the Component
Object Model.
Banker's rounding as the default behavior when converting real numbers to integers with
the Round function.
Integers are automatically promoted to reals in expressions involving the normal division
operator (/) so that division of an odd integer by an even integer produces the intuitively
correct result. There is a specific integer divide operator (\) which does truncate.
By default, if a variable has not been declared or if no type declaration character is
specified, the variable is of type Variant. However this can be changed with Deftype
statements such as DefInt, DefBool, DefVar, DefObj, DefStr. There are 12 Deftype
statements in total offered by Visual Basic 6.0. The default type may be overridden for a
specific declaration by using a special suffix character on the variable name (# for
Double, ! for Single, & for Long, % for Integer, $ for String, and @ for Currency) or using
the key phrase As (type). VB can also be set in a mode that only explicitly declared
variables can be used with the command Option Explicit.
4.3Toolbox Tools
Contols are the building blocks with which you assemble your Visual Basic 6.0 program. The
Visual Basic 6.0 Toolbox is a palette of controls, and you build your user interface by selecting
controls from the Visual Basic 6.0 Toolbox and placing them on your forms.
Figure18 tool box
4.4 Control Categories
There are three broad categories of controls in Visual Basic:
Intrinsic controls, such as the command button and frame controls. These controls are
contained inside the Visual Basic .exe file. Intrinsic controls are always included in the
toolbox, unlike ActiveX controls and insertable objects, which can be removed from or
added to the toolbox.
ActiveX controls, which exist as separate files with a .ocx file name extension. These
include controls that are available in all editions of Visual Basic (DataCombo, DataList
controls, and so on) and those that are available only in the Professional and Enterprise
editions (such as Listview, Toolbar, Animation, and Tabbed Dialog). Many third-party
ActiveX controls are also available.
Note Controls with the .vbx file name extension use older technology and are found in
applications written in earlier versions of Visual Basic. When Visual Basic opens a
project containing a .vbx control, the default behavior is to replace the .vbx control with
an .ocx control, but only if an .ocx version of the control is available. See "Updating
Older Versions of Visual Basic Controls" later in this chapter for information on updating
controls to the .ocx format.
Insertable Objects, such as a Microsoft Excel Worksheet object containing a list of all
your company's employees, or a Microsoft Project Calendar object containing the
scheduling information for a project. Since these can be added to the toolbox, they can be
considered controls. Some of these objects also support Automation (formerly called
OLE Automation), which allows you to program another application's objects from
within a Visual Basic application. See "Programming with Objects," for more
information on Automation.
4.5 Evolution of Visual Basic
VB 1.0 was introduced in 1991. The drag and drop design for creating the user interface is
derived from a prototype form generator developed by Alan Cooper and his company called
Tripod. Microsoft contracted with Cooper and his associates to develop Tripod into a
programmable form system for Windows 3.0, under the code name Ruby (no relation to the Ruby
programming language).
Tripod did not include a programming language at all. Microsoft decided to combine Ruby with
the Basic language to create Visual Basic.
The Ruby interface generator provided the "visual" part of Visual Basic and this was combined
with the "EB" Embedded BASIC engine designed for Microsoft's abandoned "Omega" database
system. Ruby also provided the ability to load dynamic link libraries containing additional
controls (then called "gizmos"), which later became the VBX interface[5].
4.6 Timeline of Visual Basic (VB1 to VB6)
Project 'Thunder' was initiated
Visual Basic 1.0 (May 1991) was released for Windows at the Comdex/Windows World
trade show in Atlanta, Georgia.
Fig19 Visual Basic for MS-DOS
Visual Basic 1.0 for DOS was released in September 1992. The language itself was not
quite compatible with Visual Basic for Windows, as it was actually the next version of
Microsoft's DOS-based BASIC compilers, QuickBASIC and BASIC Professional
Development System. The interface used the "COW" (Character Oriented Windows)
interface, using extended ASCII characters to simulate the appearance of a GUI.
Visual Basic 2.0 was released in November 1992. The programming environment was
easier to use, and its speed was improved. Notably, forms became instantiable objects,
thus laying the foundational concepts of class modules as were later offered in VB4.
Visual Basic 3.0 was released in the summer of 1993 and came in Standard and
Professional versions. VB3 included version 1.1 of the Microsoft Jet Database Engine
that could read and write Jet (or Access) 1.x databases.
Visual Basic 4.0 (August 1995) was the first version that could create 32-bit as well as
16-bit Windows programs. It also introduced the ability to write non-GUI classes in
Visual Basic. Incompatibilities between different releases of VB4 caused installation and
operation problems. While previous versions of Visual Basic had used VBX controls,
Visual Basic now used OLE controls (with files names ending in .OCX) instead. These
were later to be named ActiveX controls.
With version 5.0 (February 1997), Microsoft released Visual Basic exclusively for 32-bit
versions of Windows. Programmers who preferred to write 16-bit programs were able to
import programs written in Visual Basic 4.0 to Visual Basic 5.0, and Visual Basic 5.0
programs can easily be converted with Visual Basic 4.0. Visual Basic 5.0 also introduced
the ability to create custom user controls, as well as the ability to compile to native
Windows executable code, speeding up calculation-intensive code execution. A free,
downloadable Control Creation Edition was also released for creation of ActiveX
controls. It was also used as an introductory form of Visual Basic: a regular .exe project
could be created and run in the IDE, but not compiled.
Visual Basic 6.0 (Mid 1998) improved in a number of areas [6] including the ability to
create web-based applications. VB6 has entered Microsoft's "non-supported phase" as of
March 2008. Although the Visual Basic 6.0 development environment is no longer
supported, the runtime is supported on Windows Vista, Windows Server 2008 and
Windows 7.
Mainstream Support for Microsoft Visual Basic 6.0 ended on March 31, 2005. Extended
support ended in March 2008.[8] In response, the Visual Basic user community expressed
its grave concern and lobbied users to sign a petition to keep the product alive.[9]
Microsoft has so far refused to change their position on the matter. (but see) Ironically,
around this time (2005), it was exposed that Microsoft's new anti-spyware offering,
Microsoft AntiSpyware (part of the GIANT Company Software purchase), was coded in
Visual Basic 6.0.[11]Its replacement, Windows Defender, was rewritten as C++ code.
4.7 Derivative languages
Microsoft has developed derivatives of Visual Basic for use in scripting. Visual Basic itself is
derived heavily from BASIC, and subsequently has been replaced with a .NET platform version.
Some of the derived languages are:
Visual Basic for Applications (VBA) is included in many Microsoft applications
(Microsoft Office), and also in many third-party products like SolidWorks, AutoCAD,
WordPerfect Office 2002, ArcGIS and Sage Accpac ERP. There are small
inconsistencies in the way VBA is implemented in different applications, but it is largely
the same language as VB6 and uses the same runtime library.
VBScript is the default language for Active Server Pages. It can be used in Windows
scripting and client-side web page scripting. Although it resembles VB in syntax, it is a
separate language and it is executed by vbscript.dll as opposed to the VB runtime. ASP
and VBScript should not be confused with ASP.NET which uses the .NET Framework
for compiled web pages.
Visual Basic .NET is Microsoft's designated successor to Visual Basic 6.0, and is part of
Microsoft's .NET platform. Visual Basic.Net compiles and runs using the .NET
Framework. It is not backwards compatible with VB6. An automated conversion tool
exists, but fully automated conversion for most projects is impossible.[13]
Star Basic is a Visual Basic compatible interpreter included in StarOffice suite,
developed by Sun Microsystems.
Gambas is a Visual Basic inspired free software programming language for GNU/Linux.
It is not a clone of Visual Basic, but it does have the ability to convert Visual Basic
programs to Gambas.
KBasic is a Visual Basic inspired free software programming language for Linux, Mac
and Windows. It is not a clone of Visual Basic, but it does have the ability to convert
Visual Basic programs to KBasic.
4.8 Performance and other issues
Earlier counterparts of Visual Basic (prior to version 5) compiled the code to P-Code or Pseudo
code only. Visual Basic 5 and 6 are able to compile the code to either native or P-Code as the
programmer chooses. The P-Code is interpreted by the language runtime, also known as virtual
machine, implemented for benefits such as portability and small code. However, it usually slows
down the execution by adding an additional layer of interpretation of code by the runtime
although small amounts of code and algorithms can be constructed to run faster than the
compiled native code. Visual Basic applications require Microsoft Visual Basic runtime
MSVBVMxx.DLL, where xx is the relevant version number, either 50 or 60. MSVBVM60.dll
comes as standard with Windows in all editions after Windows 98 while MSVBVM50.dll comes
with all editions after Windows 95. A Windows 95 machine would however require inclusion
with the installer of whichever dll was needed by the program.
Other criticisms levelled at Visual Basic editions prior to VB.NET include:
Versioning problems associated with various runtime DLL's (see DLL hell)
Poor support for object-oriented programming[15]
Inability to create multi-threaded applications, without resorting to Windows API calls
Lack of unicode support
Inability to create Windows services
Inability to create console applications
Variant types have a greater performance and storage overhead than strongly typed
programming languages
4.9 Legacy development and support
All versions of Visual Basic from 1.0 to 6.0 have been retired and are now unsupported by
Microsoft. Visual Basic 6 programs can still run on Windows versions up to and including Vista,
Windows Server 2008 and Windows 7, and the runtime is supported by Microsoft on these
versions.[16]. Development and maintenance development for Visual Basic 6 is possible on
Windows XP, Windows Vista and Windows 2003 using Visual Studio 6.0. Documentation for
Visual Basic 6.0, its application programming interface and tools is best covered in the last
MSDN release before Visual Studio.NET 2002. Later releases of MSDN focused on .NET
development and had significant parts of the Visual Basic 6.0 programming documentation
removed. Development for this type of legacy system can be done using a virtual machine with
Windows 2003 or Windows XP, Visual Studio 6.0 and MSDN documentation. The Visual Basic
IDE can be installed and used on Windows Vista, where it exhibits some minor incompatibilities
which do not hinder normal software development and maintenance. As of August 2008, both
Visual Studio 6.0 and the MSDN documentation mentioned above are available for download by
MSDN subscribers.
4.10 Example code
Here is an example of the language: Code snippet that display a message box "Hello, World!" as
the window Form loads:
Private Sub Form_Load()
MsgBox "Hello, World!"
End Sub
CHAPTER 5 APPLICATION
5.)Applications
5.1) The motion detector is primirally desigend for secuirity system basially in night time
5.2) It would be easy to incorporate the camera into automatic doors.
Doors are ideal to take a picture of people entering a building, as one
always enters face-front. Normal doors can be used as well, provided you
add a reed switch for the trigger signal.
5.3) Another interesting product could be an automated barrier capable to
register number plate and driver of each car entering a parking lot. Or
maybe you just like to have a look at what people is ringing your bell
when you’re not at home.
5.4) Perhaps the most natural alternative use of the Witnesscam is as in-
vehicle camera (this photo with the lorry was taken on a test drive). The
trigger facility can start recording automatically as the engine ignites - or
a tilt switch detects an excessive bump. The SD-card can collect precious
evidence and survive an accident – something you may want to tell to
your insurance in order to get a rebate. Young drivers may hate it, but an
electronic eye can help making them drive more responsibly.
5.5) Managers must prevent fraudulent use of corporate cars, and need a
means to verify that a vehicle – and consequently employees – was where
they were intended to be. Delivery trucks, patrol squads, and even taxi
can profitably adopt a cheap recording system.
5.6) Other times a vehicle or a machinery can cause injury or damage a
property. It is the case of bulldozers, cranes, road rollers, mining and
engineering vehicles, excavators… After an accident, Witnesscam
evidence helps discovering how and why an accident occurred,
pinpointing responsibilities, and making clear how to prevent it from
happening again.
CHAPTER 6 COST EVALUATION
S.NO COMPONENTS NO OF COMPONENTS
RATE TOTAL
1. ULN 2003 1 50 50
2. STEPPER MOTOR 1 250 250
3. WEBCAM 1 800 800
4. D TYPE 25 PIN
PARALLEL PORT
1 25 25
5. REGULATOR IC 1 10 10
6. TRANSISTOR 4 10 40
7. D TYPE 25 PIN
MALE TO MALE
CABLE
1 80 80
8. TRANSFORMER 1 50 50
9. DIODES AS REOUIRED - -
10. ZENER DIODES AS REOUIRED - -
11. RESISTANCES AS REOUIRED - -
12. CAPACITOR AS REOUIRED - -
13. LED AS REOUIRED - -
Table 8 cost evaluation
The cost of individual component is shown above in table. This cost is estimation of the electronic circuitry. There are some additional material used in this project these increase the cost of project. It also include the labour . So the total cost of project approximates 2000 Rs only
CHAPTER 7 COADING
7.1) SEREVR
Private Sub cmdsend_Click()Winsock1.SendData "server:" & txtmsg.Texttxtchat.Text = txtchat.Text & "server:" & txtmsg.Text & vbNewLinetxtmsg.Text = ""
End Sub
Private Sub Form_Load()Winsock1.Listen
End Sub
Private Sub txtmsg_Change()'If txtmsg.Text = "on" Then'MsgBox " good"'Shape1.BackColor = &HFF00&'End If
End Sub
Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)Winsock1.CloseWinsock1.Accept requestIDEnd Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)Winsock1.GetData dataarrived, vbStringtxtchat.Text = txtchat.Text & dataarrived & vbNewLineIf dataarrived = "client:" Then'MsgBox " good"Shape1.BackColor = &HFF00&Form2.ShowForm1.ShowEnd IfIf dataarrived = "client:off" Then'MsgBox " good"
Shape1.BackColor = &HFF
End If
End Sub
Dim x As BooleanDim n As VariantDim i As Integer, Y As Integer, l As Integer, r As Boolean, ls As BooleanDim value As IntegerDim ll As String
Private Sub Command1_Click()Dim i As Integeri = Val(Text1.Text)If i = 0 Then End If If i = 1 Then
End If If i = 2 Then Call anticlkwise End If If i = 3 Then Call clkwise End If
End Sub
Private Sub Form_Load() Dim k As IntegerDim m As Integer'Timer1.Enabled = TrueTimer2.Enabled = True'wmp1.URL = VB.App.Path & "\u.wav"'wmp1.Controls.play'i = 3'frmMain.Show'Me.HideEnd Sub'Private Sub clkwise()
'Call PortOut(&H378, 2)'''End Sub'Private Sub anticlkwise()''Call PortOut(&H378, 2)''End Sub
Private Sub Text1_Change()If Text1.Text = "END" ThenEndEnd IfEnd Sub
'Private Sub Timer1_Timer()'' Call clkwise'Sleep (1000)'Call PortOut(&H378, 0)''Sleep (1000)' Timer1.Enabled = False''End Sub
Private Sub Timer2_Timer() wmp1.URL = VB.App.Path & "\u.wav"wmp1.Controls.playEnd Sub
Private Sub Form_Load()Timer1.Enabled = TrueMe.Hide
End Sub
Private Sub Timer1_Timer()With PrinterPrinter.Print "alert!!!!!!!!!!!!!!! "'.FontBold = True
Printer.Print "thief detected in area - poornima college of engineering,2nd floor, sitapura ,jaipur,rajasthan "'.FontItalic = TruePrinter.Print "help!!!!!!!!!!! "'.FontBold = False'.FontItalic = FalsePrinter.Print "help"Printer.Print "time -" & Time & " date - " & Date.EndDocEnd WithTimer1.Enabled = FalseEnd Sub
7.2) CLIENT
Private Sub cmdconnect_Click()'Winsock1.Connect txtip.Text, txtport.Text
End Sub
Private Sub cmdsend_Click()'Winsock1.SendData "client:" & txtmsg.Text'txtchat.Text = txtchat.Text & "client:" & txtmsg.Text & vbNewLine'txtmsg.Text = ""
'txtmsg.Text = ""
End Sub
Private Sub Form_Load()'txtip.Text = Winsock1.LocalIP this is written when lan is absent otherwise make this line as comment n type in textip the address of server
txtip.Text = Winsock1.LocalIPWinsock1.Connect txtip.Text, txtport.TextEnd Sub
Private Sub Timer1_Timer()Winsock1.SendData "client:" & txtmsg.Texttxtchat.Text = txtchat.Text & "client:" & txtmsg.Text & vbNewLinetxtmsg.Text = ""End Sub
Private Sub txtchat_Change()If dataarrived = "client:" ThenForm2.ShowEnd IfEnd Sub
Private Sub txtmsg_Change()'If txtmsg.Text = "on" Then'MsgBox " good"'Shape1.BackColor = &HFF00&
'End If
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)Winsock1.GetData dataarrived, vbStringtxtchat.Text = txtchat.Text & dataarrived & vbNewLine'If dataarrived = "server: on" Then'MsgBox " good"'Shape1.BackColor = &HFF00&'End If'If dataarrived = "server: off" Then'MsgBox " good"'Shape1.BackColor = &HFF
'End If
End Sub
Dim x As BooleanDim n As VariantDim i As Integer, y As Integer, l As Integer, r As Boolean, ls As BooleanDim value As IntegerDim ll As String
Private Sub Command1_Click()Dim i As Integeri = Val(Text1.Text)If i = 0 Then End If If i = 1 Then
End If If i = 2 Then Call anticlkwise End If If i = 3 Then Call clkwise End If End Sub
Private Sub Form_Load()Call PortOut(&H378, 0)Dim k As IntegerDim m As IntegerTimer1.Enabled = TrueTimer2.Enabled = True'wmp1.URL = VB.App.Path & "\u.wav"'wmp1.Controls.playi = 3frmMain.ShowMe.HideEnd Sub'Private Sub clkwise()''Call PortOut(&H378, 2)'For i = 1 To 26'Call PortOut(&H378, 1)'Sleep (59)'Call PortOut(&H378, 2)'Sleep (59)'Call PortOut(&H378, 4)'Sleep (59)'Call PortOut(&H378, 8)'Sleep (59)''Next i''End Sub'Private Sub anticlkwise()'For i = 1 To 26'Call PortOut(&H378, 8)'Sleep (59)'Call PortOut(&H378, 4)'Sleep (59)'Call PortOut(&H378, 2)'Sleep (59)
'Call PortOut(&H378, 1)'Sleep (59)''Next i''Call PortOut(&H378, 2)''End Sub
Private Sub Timer1_Timer()For i = 1 To 13Call PortOut(&H378, 1)Sleep (59)Call PortOut(&H378, 2)Sleep (59)Call PortOut(&H378, 4)Sleep (59)Call PortOut(&H378, 8)Sleep (59)
Next i ' Call clkwise'Sleep (1000)'Call PortOut(&H378, 0)'Sleep (1000) Timer1.Enabled = False
End Sub
Private Sub Timer2_Timer() wmp1.URL = VB.App.Path & "\ub.wav"wmp1.Controls.play
End Sub
'Option Explicit '---------------------------- Dim StdVar As Double Dim Promedio As Double Dim Suma As Double Dim CuentaIMG As Integer Dim CuentaCiclo(10) As Integer Dim SumaCuadr As Double Dim Matriz_Prom(10, 10) As Double Dim Matriz_Desvest(10, 10) As Double
Dim Prom_Cadena(10) As Double Dim Prom_Cadena_Anterior(10) As Double Dim Desvest_Cadena(10) As Double Dim Umbral_Prom As Double Dim Umbral_Desvest As Double Dim SeHallenadoCadena(10) As Boolean Dim SeIncorporaNuePixel(10) As Boolean '---------------------------- '---------------------------- Dim lPicLeft As Single 'Long Dim lPicTop As Single 'Long Dim lMoveX As Long Dim lMoveY As Long Dim bForwardMove As Boolean Dim bDownMove As Boolean Dim bMoving As Boolean Dim lTransColor As Long '----------------------------Const Ancho = 164Const Alto = 124Const Delta = 1000000Dim Sheet1 As Object Dim ColorPunto As LongDim MatrizPunto(1000) As LongDim SumaPunto(10000) As Long
Dim Locked As Boolean
Dim i As IntegerDim j As Integer
Dim UmbralTrFalse As DoublePrivate c As ColorComponent
Private Sub Command1_Click()Call PortOut(&H378, 3)Sleep (1000)Call PortOut(&H378, 0)Unload Form2End Sub
Private Sub Form_Load()
Locked = False
Picture1.AutoSize = True Dim lpszName As String * 100 Dim lpszVer As String * 100 Dim Caps As CAPDRIVERCAPS '----------------------------- Timer1.Interval = BuscaValor(3) 'In the file "InfoPlanilla.txt" 'change the third value to 'increase or decrease surveillance ' cycles in frequency. '----------------------------- Umbral_Prom = BuscaValor(1) Umbral_Desvest = BuscaValor(2) UmbralTrFalse = BuscaValor(4) 'In the file "InfoPlanilla.txt" 'change the fourth value to 'increase or decrease sensibility to ' motion elements. '----------------------------- '----------------------------- '//Create Capture Window capGetDriverDescriptionA 0, lpszName, 100, lpszVer, 100 '// Retrieves driver info lwndC = capCreateCaptureWindowA(lpszName, WS_CAPTION Or WS_THICKFRAME Or WS_VISIBLE Or WS_CHILD, 0, 0, 160, 120, Me.hwnd, 0)
'// Set title of window to name of driver SetWindowText lwndC, lpszName '// Set the video stream callback function capSetCallbackOnStatus lwndC, AddressOf MyStatusCallback capSetCallbackOnError lwndC, AddressOf MyErrorCallback '// Connect the capture window to the driver If capDriverConnect(lwndC, 0) Then
capDriverGetCaps lwndC, VarPtr(Caps), Len(Caps)
If Caps.fHasDlgVideoSource = 0 Then mnuSource.Enabled = False If Caps.fHasDlgVideoFormat = 0 Then mnuFormat.Enabled = False If Caps.fHasDlgVideoDisplay = 0 Then mnuDisplay.Enabled = False
capPreviewScale lwndC, True '// preview rate in ms
capPreviewRate lwndC, 66 '// previewing image from Webcam capPreview lwndC, True ResizeCaptureWindow lwndC
End If
Picture1.ScaleMode = vbPixels Picture1.AutoRedraw = True lPicLeft = 1 lPicTop = 1MakeTopMost (hwnd)
End Sub
Private Sub Form_Unload(Cancel As Integer)Form2.wmp1.Controls.stopUnload Form2 '// Disable all callbacks capSetCallbackOnVideoStream lwndC, vbNull capSetCallbackOnWaveStream lwndC, vbNull capSetCallbackOnCapControl lwndC, vbNull capSetCallbackOnError lwndC, vbNull capSetCallbackOnStatus lwndC, vbNull capSetCallbackOnYield lwndC, vbNull capSetCallbackOnFrame lwndC, vbNull
End Sub
Private Sub mnuAllocate_Click()
Dim sFile As String * 250 Dim lSize As Long '// Setup swap file for capture lSize = 1000000 sFile = "C:\TEMP.AVI" capFileSetCaptureFile lwndC, sFile capFileAlloc lwndC, lSize End Sub
Private Sub mnuAlwaysVisible_Click() mnuAlwaysVisible.Checked = Not (mnuAlwaysVisible.Checked) If mnuAlwaysVisible.Checked Then SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE Else SetWindowPos Me.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE End If
End Sub
Private Sub mnuCompression_Click()
capDlgVideoCompression lwndC
End Sub
Private Sub mnuCopy_Click()
capEditCopy lwndC End Sub
Private Sub mnuDisplay_Click()
capDlgVideoDisplay lwndC End Sub
Private Sub mnuExit_Click()
Unload Me End Sub
Private Sub mnuFormat_Click() capDlgVideoFormat lwndC ResizeCaptureWindow lwndC
End Sub
Private Sub mnuPreview_Click()
frmMain.StatusBar.SimpleText = vbNullString mnuPreview.Checked = Not (mnuPreview.Checked) capPreview lwndC, mnuPreview.Checked End Sub
Private Sub mnuScale_Click() mnuScale.Checked = Not (mnuScale.Checked) capPreviewScale lwndC, mnuScale.Checked If mnuScale.Checked Then SetWindowLong lwndC, GWL_STYLE, WS_THICKFRAME Or WS_CAPTION Or WS_VISIBLE Or WS_CHILD Else SetWindowLong lwndC, GWL_STYLE, WS_BORDER Or WS_CAPTION Or WS_VISIBLE Or WS_CHILD End If
ResizeCaptureWindow lwndC End Sub
Private Sub mnuSelect_Click() frmSelect.Show vbModal, Me
End Sub
Private Sub mnuSource_Click() capDlgVideoSource lwndC
End Sub
Private Sub mnuStart_Click()
Dim sFileName As String Dim CAP_PARAMS As CAPTUREPARMS capCaptureGetSetup lwndC, VarPtr(CAP_PARAMS), Len(CAP_PARAMS) CAP_PARAMS.dwRequestMicroSecPerFrame = (1 * (10 ^ 6)) / 30 ' 30 Frames per second CAP_PARAMS.fMakeUserHitOKToCapture = True CAP_PARAMS.fCaptureAudio = False
capCaptureSetSetup lwndC, VarPtr(CAP_PARAMS), Len(CAP_PARAMS) sFileName = "C:\myvideo.avi" capCaptureSequence lwndC capFileSaveAs lwndC, sFileName
End SubPrivate Sub StatusBar1_PanelClick(ByVal Panel As ComctlLib.Panel)
End SubPrivate Sub CargadePantalla() Picture1.Picture = Clipboard.GetData(vbCFDIB)End SubPrivate Function ValoresLinea(Xa As Integer, Ya As Integer, Xb As Integer, Yb As Integer) As ParPromDest'Yields Avg and StdVar for the specified lineDim i As Single, j As Single, ve As Double, Suma As Double, SumaCuadr As DoubleIniPunto = 1
If Yb - Ya > Xb - Xa Then 'Analysis through Y axis ve = (Xb - Xa) / (Yb - Ya) For j = Ya To Yb i = Int((j - Ya) * ve) + Xa GetColores Picture1, i, j, c Suma = Suma + c.SumaColInt SumaCuadr = SumaCuadr + (c.SumaColInt ^ 2) Next j ValoresLinea.Promedio = Int(Suma / (Yb - Ya + 1)) ValoresLinea.StdVar = Int(Sqr(((Yb - Ya + 1) * SumaCuadr - (Suma ^ 2)) / (Yb - Ya + 1) / (Yb - Ya))) Else 'Analysis through X axis ve = (Yb - Ya) / (Xb - Xa) For i = Xa To Xb j = Int((i - Xa) * ve) + Ya GetColores Picture1, i, j, c Suma = Suma + c.SumaColInt
SumaCuadr = SumaCuadr + (c.SumaColInt ^ 2) Next i
ValoresLinea.Promedio = Int(Suma / (Xb - Xa + 1)) ValoresLinea.StdVar = Int(Sqr(((Xb - Xa + 1) * SumaCuadr - (Suma ^ 2)) / (Xb - Xa + 1) / (Xb - Xa)))End IfEnd Function
Private Sub Picture1_Click()
End Sub
Private Sub Timer1_Timer()Dim DiagoPrinc As ParPromDestDim Signal1 As Boolean'-----*-*-*-*-*-*-*-*-*Static DiagoPromAnte As DoubleStatic Diferencia As DoubleStatic DiferenciaAnte As DoubleStatic SegDerivada As DoubleStatic Contador As Integer'-----*-*-*-*-*-*-*-*-*If Locked = False Then Pausa (10) Locked = TrueEnd If Signal1 = False capEditCopy lwndC: CargadePantalla
'---*-*-*-*-*-*'Routine that counts each "Chain" CycleDiagoPrinc = CicleaLinea(1, 58, 159, 60, 1)'---*-*-*-*-*-*
If DiagoPromAnte <> 0 Then Diferencia = Abs(DiagoPromAnte - DiagoPrinc.Promedio) If Diferencia > UmbralTrFalse Then DiagoPromAnte = DiagoPrinc.Promedio Signal1 = True Else DiagoPromAnte = DiagoPrinc.Promedio End IfElse DiagoPromAnte = DiagoPrinc.Promedio
End If' the second derivative allows to make the difference' between an out-of Avg. image and the normal lightning persitence' the Avg. value has to overcome when restoring to usual image' conditionsSegDerivada = Diferencia - DiferenciaAnte If SegDerivada > 0 Then DiferenciaAnte = Diferencia If Signal1 = True Then Contador = Contador + 1 Debug.Print "Saving", Contador SavePicture Picture1.Image, App.Path & "\image\ImageNo." & Contador & ".jpg" If Contador = 1 Then Form1.Hide Form2.Show End If End If Else DiferenciaAnte = Diferencia End If
End SubPrivate Function CicleaLinea(Xa As Integer, Ya As Integer, Xb As Integer, Yb As Integer, NL As Integer) As ParPromDestDim Resultado As ParPromDestResultado = ValoresLinea(Xa, Ya, Xb, Yb)
If CuentaCiclo(NL) = 9 Then ' Cycle n°9 already executed ' CuentaCiclo(NL) = 0 SeHallenadoCadena(NL) = TrueEnd If
CuentaCiclo(NL) = CuentaCiclo(NL) + 1
'---*-*-*-*-*-* '---*-*-*-*-*-* '---*-*-*-*-*-*If CuentaCiclo(NL) = 1 Then 'First Value added to "Chain" If SeHallenadoCadena(NL) = False Then Matriz_Desvest(1, NL) = Resultado.StdVar Matriz_Prom(1, NL) = Resultado.Promedio SeIncorporaNuePixel(NL) = True Else SeIncorporaNuePixel(NL) = False '---*-*-*-*-*-* ' Condition for adding latest Value to "Chain"
If Abs(Matriz_Desvest(9, NL) - Resultado.StdVar) < Umbral_Desvest And Abs(Matriz_Prom(9, NL) - Resultado.Promedio) < Umbral_Prom Then Matriz_Desvest(CuentaCiclo(NL), NL) = Resultado.StdVar Matriz_Prom(CuentaCiclo(NL), NL) = Resultado.Promedio SeIncorporaNuePixel(NL) = True End If '---*-*-*-*-*-*-*-*-*-*-*-* PROMEDIAR_CADENA (NL) '---*-*-*-*-*-*-* ' Condition for handling Image saving If Abs(Desvest_Cadena(NL) - Resultado.StdVar) > Umbral_Desvest And Abs(Prom_Cadena(NL) - Resultado.Promedio) > Umbral_Prom Then CuentaIMG = CuentaIMG + 1 End If End If
Else ' CuentaCiclo(NL) >= 2 Then '---*-*-*-*-*-* SeIncorporaNuePixel(NL) = False
If Abs(Matriz_Desvest(CuentaCiclo(NL) - 1, NL) - Resultado.StdVar) < Umbral_Desvest And Abs(Matriz_Prom(CuentaCiclo(NL) - 1, NL) - Resultado.Promedio) < Umbral_Prom Then Matriz_Desvest(CuentaCiclo(NL), NL) = Resultado.StdVar Matriz_Prom(CuentaCiclo(NL), NL) = Resultado.Promedio SeIncorporaNuePixel(NL) = True End If
PROMEDIAR_CADENA (NL)
If Abs(Desvest_Cadena(NL) - Resultado.StdVar) > Umbral_Desvest And Abs(Prom_Cadena(NL) - Resultado.Promedio) > Umbral_Prom Then
CuentaIMG = CuentaIMG + 1 End If End If
If SeIncorporaNuePixel(NL) = False Then CuentaCiclo(NL) = CuentaCiclo(NL) - 1 End If
CicleaLinea.Promedio = Prom_Cadena(NL)CicleaLinea.StdVar = Desvest_Cadena(NL)
End Function
Private Sub PROMEDIAR_CADENA(NL As Integer)Dim j As IntegerIf SeIncorporaNuePixel(NL) = True Then
If SeHallenadoCadena(NL) = True Then Prom_Cadena(NL) = (Prom_Cadena(NL) * 8 + Matriz_Prom(CuentaCiclo(NL), NL)) / 9 Desvest_Cadena(NL) = (Desvest_Cadena(NL) * 8 + Matriz_Desvest(CuentaCiclo(NL), NL)) / 9 Else Prom_Cadena(NL) = 0: Desvest_Cadena(NL) = 0 For j = 1 To 9 If Matriz_Prom(j, NL) = 0 And Matriz_Desvest(j, NL) = 0 Then Exit For Prom_Cadena(NL) = Prom_Cadena(NL) + Matriz_Prom(j, NL) Desvest_Cadena(NL) = Desvest_Cadena(NL) + Matriz_Desvest(j, NL) Next j If j <> 1 Then Prom_Cadena(NL) = Prom_Cadena(NL) / (j - 1) Desvest_Cadena(NL) = Desvest_Cadena(NL) / (j - 1) End If End If
End If ' No new pixel added so there is' No need for calculating new avg.End Sub
Private Sub Pausa(TimePause As Variant)Dim Inicio ''---------------------------------------------- Inicio = Timer ' Sets starting time for pause (in sec.) Do While Timer < Inicio + TimePause DoEvents 'Shifts to other process LoopEnd Sub
Private Function BuscaValor(i As Integer) As String Dim LeeString, cuenta Open App.Path & "\InfoPlanilla.txt" For Input As #1 For cuenta = 1 To i Input #1, LeeString Next cuenta Close #1
BuscaValor = LeeString End Function
Option ExplicitPrivate Sub cmdCancel_Click() Unload MeEnd Sub
Private Sub cmdSelect_Click() Dim sTitle As String Dim Caps As CAPDRIVERCAPS If cmboSource.ListIndex <> -1 Then '// Connect the capture window to the driver If capDriverConnect(lwndC, cmboSource.ListIndex) Then '// Get the capabilities of the capture driver capDriverGetCaps lwndC, VarPtr(Caps), Len(Caps) '// If the capture driver does not support a dialog, grey it out '// in the menu bar. frmMain.mnuSource.Enabled = Caps.fHasDlgVideoSource frmMain.mnuFormat.Enabled = Caps.fHasDlgVideoFormat frmMain.mnuDisplay.Enabled = Caps.fHasDlgVideoDisplay sTitle = cmboSource.Text SetWindowText lwndC, sTitle ResizeCaptureWindow lwndC End If End If Unload Me End Sub
Private Sub Form_Load() Dim lpszName As String * 100
Dim lpszVer As String * 100 Dim x As Integer Dim lResult As Long Dim Caps As CAPDRIVERCAPS '// Get a list of all the installed drivers x = 0 Do lResult = capGetDriverDescriptionA(x, lpszName, 100, lpszVer, 100) '// Retrieves driver info If lResult Then cmboSource.AddItem lpszName x = x + 1 End If Loop Until lResult = False
'// Get the capabilities of the current capture driver lResult = capDriverGetCaps(lwndC, VarPtr(Caps), Len(Caps)) '// Select the driver that is currently being used If lResult Then cmboSource.ListIndex = Caps.wDeviceIndex
End Sub
CHAPTER 8 CONCLUSION
Security systems in present world had turned out to be a mandatory system for every
organization. Industries, workshops, factories, banks, offices, shops (especially -Jewellery shops)
and even at home these days we find various kind of security systems based on different
technologies. In other words Security Systems is 'The need of Hour '.
Keeping in mind every ones need we Final year students of Poornima college of engineering,
Electronics and Communication Branch planned to develop such a system which is capable to
meet requirements of every organization from small residential areas to largely scaled Hytech
Bank.
In this security system we employed Visual Basic Language .Specifically in this we focused
towards the 'IMAGE PROCESSING' modules of Visual Basic Programming. Now as we started
developing the code we found the need of Interfacing Computer System with Hardware. For that
we also learned Parallel Port Programming of Visual Basic.
This gave us an idea to correlate our developed code of Visual Basic with Embedded System
Technology.
Our developed system is a MULTI COMPUTER BASED SYSTEM which uses at least two
computers connected via LAN/WAN/MAN. The whole system consists of only one system
named as SERVER while other Multiple Computers are named as CLIENTS. The server system
is always kept in ON condition. It is equipped with a Speaker and a Printer. Server is generally
kept at HOME (manager or owner of the shop)/CONTROL ROOM (Police Station).Now the
Client System is kept in area where security is to be provided. The Client System is equipped
with a Webcam and a Speaker. Both of these systems are connected to each other Via
LAN/WAN/MAN.
The utility of this system lies generally during Night hours or holidays when there is absence of
the staff members. To understand how this System works let us take an example of a jewellery
shop. The Client Systems are kept at different places of the shop where the security is to be
provided. And the Server System is kept at the home of the owner of the shop. Say at 3 a.m
(midnight hours) a thief enters the shop. Now here this Security System comes into action. The
Client System Detects change in Motion and starts capturing the Images of the thief at every
interval of 2 seconds. It switches On the Alarm of the shop so as to make the Gatekeeper of the
shop alert and simultaneously sends ALERT signals to the remote computer i.e. SERVER. Now
the Server System which is kept at home of Owner of the shop receives the alert signals from the
Client .Server switches on the audio file as Alarm by making the owner of the shop aware of
some mishap going on at his Shop. The Client System in the form of alert signal sends the exact
Date, Time and the exact location of Area of Theft in the shop(say floor no., room no. etc).After
receiving this information the Server System which is also equipped with a Printer takes out the
print out of all these valuable information. Now with the help of this Security System we can get
a series of Images of thief which are stored in Client Computer System. We also get the exact
information of the date, time and area at the time of theft itself.
We have designed this system with a notion in mind to reduce the crime rate (Theft cases) in our
city. Hope this System successfully meets every organization’s requirements.
top related