wireless control of powered wheelchair using tongue report,tongue drive system report,tds...
DESCRIPTION
This WIRELESS CONTROL OF POWERED WHEELCHAIR USING TONGUE project report uploaded by http://engineeringprojecthelp.blogspot.in/TRANSCRIPT
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 1
CHAPTER 1
INTRODUCTION
Tongue Drive system (TDS) is a tongue-operated unobtrusive assistive technology, which can
potentially provide people with severe disabilities with effective access and environment
control. It translates user’s intentions in to control commands by detecting and classifying their
voluntary tongue motion utilizing a small permanent magnet, secured on the tongue, and an
array of magnetic sensors mounted on a headset outside the mouth or an orthodontic brace
inside. Customized interface circuitry had been developed and four control strategies to drive
a powered wheel chair (PWC) using an external TDS prototype is implemented.
Persons with severe disabilities as a result of causes ranging from traumatic brain and spinal
cord injuries (TBI/SCI) to amyotrophic lateral sclerosis (ALS) and stroke generally find it
extremely difficult to carry out daily tasks without receiving continuous help. These individuals
are completely dependent on wheeled mobility for transportation inside and out of their homes.
Many of them use electrically powered wheelchairs (PWC) that are the most helpful tools
allowing individuals to complete daily tasks with greater independence, and to access school,
work, and community environments. Unfortunately, the default method for controlling PWCs
is by operating a joystick, which requires a certain level of physical movement ability, which
may not exist in people with severe disabilities.
The magnetic sensors are nothing but hall-effect sensors. A Hall Effect sensor is a transducer
that varies its output voltage in response to changes in magnetic field. In its simplest form, the
sensor operates as an analogue transducer, directly returning a voltage. This Project consists of
a Microcontroller Units, Wheel chair and Hall Effect sensor. Wheel chair is made up of High
torque Geared DC Motors, the Motors Directions can be changed through the set of instructions
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 2
given from the Hall Effect sensor and the action of these Instructions is already loaded into the
Microcontroller using Embedded C programming.
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 3
CHAPTER 2
LITERATURE SURVEY
2.1 EXISTING ASSISTIVE TECHNOLOGIES
2.1.1 SIP – AND – PUFF WHEELCHAIR
The Sip-and-Puff system is a method of sending signals to a device using air pressure. The
signals are conveyed by "sipping", or inhaling, and “puffing", or exhaling, into a wand as
demonstrated in Figure 2.1. The system is used for a variety of purposes, ranging from basic
wheelchair commands to sports, like hunting.
When used for controlling an electric wheelchair there are typically four different inputs from
the user used in various patterns described as follows. An initial hard puff will enable the chair
to move forward, while a hard sip will stop the wheelchair. Conversely, an initial hard sip will
enable the wheelchair to move backward, while a hard puff will stop the wheelchair. A
continuous soft sip or soft puff will enable the wheelchair to move left or right, respectively,
depending on how long the user blows into the wand.
The main problem with this mode of control is the range in breathing capability across the
spectrum of consumers. The system is calibrated to respond to hard and soft puffs and sips, and
for individuals that have problems controlling their breathing, achieving the hard puffs or sips
with consistency can be difficult
Fig 2.1 Sip – and – Puff System
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 4
2.1.2 HUMMING AND SPEECH RECOGNITION
Another alternative is powering the chair through speech or humming. A version for this option
is being constructed at George Mason University in Virginia (prototype miniature shown in
Figure 2.2). The configuration on this prototype is two digital signal processors mounted on a
custom printed circuit board to perform humming and speech recognition.
The main problem with this method is that many people have difficulty with speech recognition
software in general, because speech recognition varies due to many documented reasons
including: accent, pronunciation, articulation, roughness, nasality, pitch, volume, and speed.
Furthermore, speech is distorted by a background noise, echoes, and electrical characteristics
that cannot always be recognized and filtered out by the system. The humming recognition
attempts to compensate for the lack of accuracy in the speech recognition but limits the quantity
of commands the system can be programmed for.
Fig 2.2 Small Scale Prototype of George Mason University’s Humming and Speech
Recognition Wheelchair System
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 5
2.1.3 HEAD/CHIN CONTROLLED SYSTEM
The Head or chin controls are very invasive alternatives to a joystick. The system requires
constant pressure to be applied to the sensor. The sensor is either a ball placed near the chin or
a pad placed at the lower back of the head (Figure 2.3).
In head control devices, switches are mounted in the headrest and activated by head
movements. Ideally the system has six commands: mode, power (on-off/emergency stop), and
the four directional controls. By being in proximity to the switch in the centre pad, the patient
moves the wheelchair forward. Activating the side pads moves the chair in the corresponding
direction. A reset switch toggles between the forward and reverse functions. Some new head
controllers can detect the position and movement of the head using ultrasonic transducers or
RF, and translate those movements into proportional control of the wheelchair.
Chin control is usually considered in a separate category from head control, but a chip-mounted
joystick requires head movement (Figure 2.4). The chin sits in a cup-shaped joystick handle
and is usually controlled by neck flexion, extension and rotation. This system is designed for a
user with good head control.
A major problem with this mode of control is the need for constant pressure. For users that lack
trunk control, or abdominal control, common compensation is to lean to one side, using the
limits of their neck rotation to the left or right to stabilize their head. The strain this puts on a
person’s neck can be hazardous to their health over time, so this method is not recommended
for people with decreased trunk function. Another problem with this system is the lack of
stability. When the wheelchair rides on uneven roads, a person with any difficulty holding their
head in a constant position will inevitably hit the joystick in unintentional directions as their
head sways to the movement of the uneven ride. The only way to stop the cycle of unintentional
movement is to completely stop the wheelchair by letting go of the joystick and waiting for the
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 6
rocking to stop. Therefore, this system is not meant for people with decreased control of the
neck or abdomen.
Fig 2.3 Head Controlled System Fig 2.4 Chin Controlled System
2.1.4 BRAIN WAVE POWERED SYSTEM
Another alternative is powering the chair through brainwaves. A version for this option is being
constructed at California State University Northridge.
The technology used in the referenced project is an Emotive EPOC EEG
(electroencephalography) headset to decipher user’s brainwave inputs as commands for the
wheelchair (image of headset in Figure 2.5). The EPOC headset monitors three separate inputs:
facial expressions, head positions and brain sensing. The main use for the referenced project
was the brain sensing aspect. The headset with a set of EEG electrodes needs to be tuned to
optimize its functionality. Signatures of the waveforms will be identified and analysed, and
then used to create a movement command in steering an intelligent wheelchair. The project
requires a non-invasive brain-computer interface (BCI), which learns by repetition.
The main problems with this method are the sensor headset shown in Figure 2.5, the cost, and
the BCI interface. Consumer reviews claim that the Emotiv headset’s fragile, hard-to-handle
nature is disappointing for its high price of $299. To make the entire system work, the user
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 7
must purchase the software separately, which brings the cost up by another $500. In addition,
the reviews found the thought-sensing functionality of the “sensor-stuffed EPOC headgear” to
be a bit too random and inaccurate to actually be useful. Furthermore, the sensor pads must be
wet separately and then placed in the headset slots each time the headset is used. Because of
the clunky hardware issues and the cost of the headset being almost as expensive as the
wheelchair itself, consumers are already looking for alternatives. The most important drawback
is that the BCI learning interface is difficult to control. The user may become distracted and
not think “stop” or might think “go” when they do not mean to, causing the wheelchair to react
unexpectedly. This could lead to many embarrassing and even dangerous situations for a
consumer.
Fig 2.5 Emotiv EPOC EEG Sensor (EMOTIV)
2.2 OUR PROPOSED SOLUTION
We proposed a simpler solution than the common joystick to solve this problem. Our focus is
purely on extreme cases, for example on quadriplegic individuals or individuals that cannot use
joysticks. Our goal in this project was to create a design that can easily adapt to a common
electric, joystick controlled wheelchair.
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 8
In our system, we are controlling the wheelchair using our tongue. Controlling a wheelchair
using our tongue has several advantages.
Muscle fibers in tongue are similar to heart muscle fibers.
Low rate of perceived exertions
Directly connected to brain
Hidden inside mouth will give a certain degree of privacy
REQUIREMENTS:
There were three types of requirements: first the constraint requirements, which were limits set
on the project due to resource or time constraints; second were user or consumer requirements,
which are set by asking those currently in a wheelchair what they would want or need in an
alternative control system design; the final requirement set was the engineering requirements,
which set goals or limits on the project design based on the previous requirement sets and what
is physically possible with current tools and budget at our disposal. The requirements listed
below were known requirements when we began constructing our project.
Constraint Requirements:
The new alternative control system shall cost a maximum of $100 to prototype and
build.
All major components shall be easily assessable (may be ordered on the internet.)
Consumer Requirements:
The system shall be non-invasive.
The system shall be made for persons with quadriplegia.
The system shall to be easy to operate.
The system shall to be safe. (Incorporate emergency stops.)
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 9
Engineering Requirements:
The portion of the system mounted on the wheelchair shall run off a common
wheelchair battery (12V VDC, 50 Amp-hours).
Wireless shall not have interference with other devices.
Table 2.1 shows the advantages of our proposed solution over existing solutions.
Table 2.1 Proposed solution compared to existing solutions
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 10
CHAPTER 3
THE BASIC PRINCIPLE
Our proposed Tongue Drive System consists of 4 Hall Sensors that can be placed outside the
mouth. A small permanent magnet is placed on the tongue. The Hall Sensors are interfaced to
a microcontroller. When the magnet placed on the tongue moves towards a particular Hall
Sensor, the microcontroller takes a decision to move the wheel chair in a particular direction
which is sent wirelessly to another microcontroller to which motors are interfaced. For
example, when the magnet placed on tongue is moved towards sensor S1as shown in the figure,
the wheelchair moves in the forward direction. Similarly when it is moved towards the sensors
S2, S3 and S4 the wheelchair moves back, left and right respectively.
Fig 3.1 Basic principle of TDS
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 11
CHAPTER 4
SYSTEM DESIGN
4.1 BLOCK DIAGRAM
4.1.1 TRANSMITTER BLOCK DIAGRAM
Fig 4.1 Transmitter Block Diagram
Figure 4.1 shows the block diagram of the transmitter. There are four Hall Effect Sensors which
are interfaced to the microcontroller. Hall Effect Sensors are transducers whose output voltage
varies in response to the change in magnetic field. We are using four Hall Effect Sensors to
control the direction of the powered wheelchair. When a magnet is brought near a particular
Hall Effect Sensor, the sensor gets activated. When the magnetic field is removed, the Hall
Effect Sensor gets deactivated. Based on which Hall Effect Sensor is activated, the
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 12
microcontroller takes a particular decision regarding which direction the wheelchair should go.
The RF transmitter sends that particular decision to the receiver circuitry.
4.1.2 RECEIVER BLOCK DIAGRAM
Fig 4.2 Receiver Block Diagram
Figure 4.2 shows the block diagram of the receiver part of our project. The decision transmitted
by the transmitter circuitry is received through the RF receiver which is interfaced to the
microcontroller as shown in the figure. The motors are connected to the microcontroller using
an H – Bridge motor driver. The motor driver is used to control the directions of both the motors
used. Based on the decision transmitted, the wheelchair is moved in a specific direction by
controlling the motor’s direction. To prevent the wheelchair from ramming into obstacles such
as walls, we have connected a proximity sensor to the microcontroller to detect the obstacles.
Based on the proximity sensor output, the microcontroller takes decision whether or not to
emergency stop the wheelchair.
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 13
4.2 CIRCUIT DIAGRAM
4.2.1 TRANSMITTER CIRCUIT DIAGRAM
Fig 4.3 Transmitter Circuit Diagram
Figure 4.3 shows the circuit diagram of the transmitter of our project. We are using 4 Hall
Effect Sensors in our project and they are connected to pins P1.0, P1.1, P1.2 and P1.3 of
ATMEL AT89S52 microcontroller. We have therefore configured Port 1 as the input port. The
output of Hall Effect sensor is very less to be detected by the microcontroller (which required
5V at its pins). To alleviate this problem, we have used pull – up resistors with each Hall Effect
Sensors to pull up the output voltage of each sensor to 5V. The pull – up resistors used in our
project are of 1kΩ value and they are connected between the output and VCC terminals of the
Hall Effect Sensors. Without any magnetic field, the output of all Hall Effect Sensors are pulled
up to VCC (5V). When a magnet is brought near a particular Hall Effect Sensor, the Hall
Sensors gets activated and the output gets pulled down to ground (0V). Pins P0.1, P0.2, P0.3,
and P0.4 are connected to the RF Transmitter (which transmits bit patterns) for transmitting
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 14
the controlling decisions of the wheelchair. We have therefore configured Port 0 as the output
port.
4.2.2 RECEIVER CIRCUIT DIAGRAM
Fig 4.4 Receiver Circuit Diagram
Figure 4.4 shows the circuit diagram of the receiver of our project. The RF receiver is connected
to pins P2.0, P2.1, P2.2 and P2.3 of the ATMEL AT89S52 microcontroller. The RF receiver
receives the decisions for controlling the wheelchair which were transmitted by the RF
transmitter using bit patterns. Therefore, we configure Port 2 as input port. Pins P1.0, P1.1,
P1.2 and P1.2 of the microcontroller are connected to pins A1, A2, B1 and B2 of the H – bridge
driver which is used to control the direction of the motors of the powered wheelchairs. Since
we are using two motors, we need two H – bridge drivers. Hence, we are using L293d where
A1 and A2 is the control pins of motor A whereas B1 and B2 are controls pins of motor B.
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 15
Since we are using both the H – bridge drivers in L293d IC, we connect both enable pins of the
IC to VCC (5V). The output pins of the H – bridge drivers are connected to the motors. Another
feature which we have incorporated into our project is the ability of the wheelchair to stop in
case the wheelchair rams into obstacles. For this, we have connected a proximity sensor to pin
P2.4 of the microcontroller. The proximity sensor gives an output voltage of 5V in case it
comes near any obstacles. Thus, we have programmed the microcontroller in such a way that
the wheelchair stops if it encounters any obstacles. Also, once the proximity sensor is activated
(the wheelchair stops), the forward, left and right motion of the wheelchair is inhibited and the
only movement allowed then is the backward motion so that the user can come out the situation.
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 16
CHAPTER 5
HARDWARE
5.1 MICROCONTROLLER (ATMEL AT89S52)
The AT89S52 is a low-power, high-performance CMOS 8-bit microcontroller with 8K bytes
of in-system programmable Flash memory. The device is manufactured using Atmel’s high-
density non – volatile memory technology and is compatible with the industry-standard 80C51
instruction set and pinout. The on-chip Flash allows the program memory to be reprogrammed
in-system or by a conventional non – volatile memory programmer. By combining a versatile
8-bit CPU with in-system programmable Flash on a monolithic chip, the Atmel AT89S52 is a
powerful microcontroller which provides a highly flexible and cost-effective solution to many
embedded control applications. The AT89S52 provides the following standard features: 8K
bytes of Flash, 256 bytes of RAM, 32 I/O lines, Watchdog timer, two data pointers, three 16-
bit timer/counters, a six-vector two-level interrupt architecture, a full duplex serial port, on-
chip oscillator, and clock circuitry. In addition, the AT89S52 is designed with static logic for
operation down to zero frequency and supports two software selectable power saving modes.
5.1.1 FEATURES OF AT89S52
• 8K Bytes of In-System Reprogrammable Flash Memory
• Endurance: 100,000 cycles per byte
• Fully Static Operation: 0 Hz to 33 MHz
• Three-level Program Memory Lock
• 256 x 8-bit Internal RAM
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 17
• 32 Programmable I/O Lines
• Three 16-bit Timer/Counters
• Eight Interrupt Sources
• Watchdog Timer
• Low-power Idle and Power-down Modes
5.1.2 PIN DESCRIPTION
Fig 5.1 Pin Diagram of AT89S52
Port 0:
Port 0 is an 8-bit open-drain bi-directional I/O port. As an output port, each pin can sink eight
TTL inputs. When 1s are written to port 0 pins, the pins can be used as high impedance inputs.
Port 0 may also be configured to be the multiplexed low order address/data bus during accesses
to external program and data memory. In this mode P0 has internal pull-ups.
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 18
Port 0 also receives the code bytes during Flash programming, and outputs the code bytes
during program verification. External pull-ups are required during program verification.
Port 1:
Port 1 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 1 output buffers can
sink/source four TTL inputs. When 1s are written to Port 1 pins they are pulled high by the
internal pull-ups and can be used as inputs. As inputs, Port 1 pins that are externally being
pulled low will source current (IIL) because of the internal pull-ups. Port 1 also receives the
low-order address bytes during Flash programming and verification.
Port 2:
Port 2 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 2 output buffers can
sink/source four TTL inputs.
Port 3
Table 5.1 Port 3 pin details
Port 3 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 3 output buffers can
sink/source four TTL inputs. When 1s are written to Port 3 pins they are pulled high by the
internal pull-ups and can be used as inputs. As inputs, Port 3 pins that are externally being
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 19
pulled low will source current (IIL) because of the pull-ups. Port 3 also serves the functions of
various special features of the AT89S52 as listed in Table 5.1.
XTAL1: Input to the inverting oscillator amplifier and input to the internal clock operating
circuit.
XTAL2: Output from the inverting oscillator amplifier.
5.1.3 CIRCUIT DIAGRAM
Fig 5.2 Circuit Diagram of AT89S52
As shown in Figure 5.2 the mother board of AT89S52 has following sections: Power Supply,
AT89S52 IC, Oscillator, Reset Switch and I/O ports. Let us see these sections in detail.
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 20
1) POWER SUPPLY
This section provides the clean and harmonic free power to IC to function properly. The output
of the full wave rectifier section, which is built using two rectifier diodes, is given to filter
capacitor. The electrolytic capacitor C1 filters the pulsating dc into pure dc and given to Vin
pin-1 of regulator IC 7805.This three terminal IC regulates the rectified pulsating dc to constant
+5 volts. C2 & C3 provides ground path to harmonic signals present in the inputted voltage.
The Vout pin-3 gives constant, regulated and spikes free +5 volts to the mother board.
The allocation of the pins of the AT89S52 follows a U-shape distribution. The top left hand
corner is Pin 1 and down to bottom left hand corner is Pin 20. And the bottom right hand corner
is Pin 21 and up to the top right hand corner is Pin 40. The Supply Voltage pin VCC is 40 and
ground pin VSS is 20.
2) OSCILLATOR
If the CPU is the brain of the system then the oscillator, or clock, is the heartbeat. It provides
the critical timing functions for the rest of the chip. The greatest timing accuracy is achieved
with a crystal or ceramic resonator. For crystals of 2.0 to 12.0 MHz, the recommended
capacitor values should be in the range of 15 to 33pF.
Across the oscillator input pins 18 & 19 a crystal x1 of 4.7 MHz to 20 MHz value can be
connected. The two ceramic disc type capacitors of value 30pF are connected across crystal
and ground, stabilizes the oscillation frequency generated by crystal.
3) I/O PORTS
There are a total of 32 I/O pins available on this chip. The amazing part about these ports is
that they can be programmed to be either input or output ports, even "on the fly" during
operation! Each pin can source 20 mA (max) so it can directly drive an LED. They can also
sink a maximum of 25 mA current.
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 21
Some pins for these I/O ports are multiplexed with an alternate function for the peripheral
features on the device. In general, when a peripheral is enabled, that pin may not be used as a
general purpose I/O pin. The alternate function of each pin is not discussed here, as port
accessing circuit takes care of that.
This 89C51 IC has four I/O ports and is discussed in detail:
P0.0 TO P0.7
PORT0 is an 8-bit [pins 32 to 39] open drain bi-directional I/O port. As an output port, each
pin can sink eight TTL inputs and configured to be multiplexed low order address/data bus then
has internal pull ups. External pull ups are required during program verification.
P1.0 TO P1.7
PORT1 is an 8-bit wide [pins 1 to 8], bi-directional port with internal pull ups. P1.0 and P1.1
can be configured to be the timer/counter 2 external count input and the timer/counter 2 trigger
input respectively.
P2.0 TO P2.7
PORT2 is an 8-bit wide [pins 21 to 28], bi-directional port with internal pull ups. The PORT2
output buffers can sink/source four TTL inputs. It receives the high-order address bits and some
control signals during Flash programming and verification.
P3.0 TO P3.7
PORT3 is an 8-bit wide [pins 10 to 17], bi-directional port with internal pull ups. The Port3
output buffers can sink/source four TTL inputs. It also receives some control signals for Flash
programming and verification.
4) PSEN
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 22
Program Store Enable [Pin 29] is the read strobe to external program memory.
5) ALE
Address Latch Enable [Pin 30] is an output pulse for latching the low byte of the address during
accesses to external memory.
6) EA
External Access Enable [Pin 31] must be strapped to GND in order to enable the device to fetch
code from external program memory locations starting at 0000H upto FFFFH.
7) RST
Reset input [Pin 9] must be made high for two machine cycles to resets the device’s oscillator.
The potential difference is created using 10MFD/63V electrolytic capacitor and 20KOhm
resistor with a reset switch.
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 23
5.2 RF MODULE
The circuit of this project utilises the RF module (Tx/Rx) for making a wireless remote, which
could be used to drive an output from a distant place. RF module, as the name suggests, uses
radio frequency to send signals. These signals are transmitted at a particular frequency and a
baud rate. A receiver can receive these signals only if it is configured for that frequency.
A four channel encoder/decoder pair has also been used in this system. The input signals, at
the transmitter side, are taken through four switches while the outputs are monitored on a set
of four LEDs corresponding to each input switch.
The circuit can be used for designing Remote Appliance Control system. The outputs from the
receiver can drive corresponding relays connected to any household appliance.
This radio frequency (RF) transmission project employs Amplitude Shift Keying (ASK) with
transmitter/receiver (Tx/Rx) pair operating at 434 MHz. The transmitter module takes serial
input and transmits these signals through RF. The transmitted signals are received by the
receiver module placed away from the source of transmission.
The system allows one way communication between two nodes, namely, transmission and
reception. The RF module has been used in conjunction with a set of four channel
encoder/decoder ICs. Here HT12E & HT12D have been used as encoder and decoder
respectively. The encoder converts the parallel inputs (from the remote switches) into serial set
of signals. These signals are serially transferred through RF to the reception point. The decoder
is used after the RF receiver to decode the serial format and retrieve the original signals as
outputs. These outputs can be observed on corresponding LEDs.
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 24
Fig 5.3 Transmission of data from transmitter to receiver using RF module
Encoder IC (HT12E) receives parallel data in the form of address bits and control bits. The
control signals from remote switches along with 8 address bits constitute a set of 12 parallel
signals. The encoder HT12E encodes these parallel signals into serial bits. Transmission is
enabled by providing ground to pin14 which is active low. The control signals are given at pins
10-13 of HT12E. The serial data is fed to the RF transmitter through pin17 of HT12E.
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 25
Fig 5.4 RF Transmitter
Transmitter, upon receiving serial data from encoder IC (HT12E), transmits it wirelessly to the
RF receiver. The receiver, upon receiving these signals, sends them to the decoder IC (HT12D)
through pin2. The serial data is received at the data pin (DIN, pin14) of HT12D. The decoder
then retrieves the original parallel format from the received serial data.
Fig 5.5 RF Receiver
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 26
When no signal is received at data pin of HT12D, it remains in standby mode and consumes
very less current (less than 1µA) for a voltage of 5V. When signal is received by receiver, it is
given to DIN pin (pin14) of HT12D. On reception of signal, oscillator of HT12D gets activated.
IC HT12D then decodes the serial data and checks the address bits three times. If these bits
match with the local address pins (pins 1-8) of HT12D, then it puts the data bits on its data pins
(pins 10-13) and makes the VT pin high. An LED is connected to VT pin (pin17) of the decoder.
This LED works as an indicator to indicate a valid transmission. The corresponding output is
thus generated at the data pins of decoder IC.
A signal is sent by lowering any or all the pins 10-13 of HT12E and corresponding signal is
received at receiver’s end (at HT12D). Address bits are configured by using the by using the
first 8 pins of both encoder and decoder ICs. To send a particular signal, address bits must be
same at encoder and decoder ICs. By configuring the address bits properly, a single RF
transmitter can also be used to control different RF receivers of same frequency.
To summarize, on each transmission, 12 bits of data is transmitted consisting of 8 address bits
and 4 data bits. The signal is received at receiver’s end which is then fed into decoder IC. If
address bits get matched, decoder converts it into parallel data and the corresponding data bits
get lowered which could be then used to drive the LEDs. The outputs from this system can
either be used in negative logic or NOT gates (like 74LS04) can be incorporated at data pins.
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 27
5.3 HALL EFFECT SENSOR
5.3.1 HALL EFFECT
The Hall Effect is the production of a voltage difference (the Hall voltage) across an electrical
conductor, transverse to an electric current in the conductor and a magnetic field perpendicular
to the current. It was discovered by Edwin Hall in 1879.
The Hall coefficient is defined as the ratio of the induced electric field to the product of the
current density and the applied magnetic field. It is a characteristic of the material from which
the conductor is made, since its value depends on the type, number, and properties of the charge
carriers that constitute the current.
5.3.2 THEORY
The Hall Effect is due to the nature of the current in a conductor. Current consists of the
movement of many small charge carriers, typically electrons, holes, ions or all three. When a
magnetic field is present that is not parallel to the direction of motion of moving charges, these
charges experience a force, called the Lorentz force. When such a magnetic field is absent, the
charges follow approximately straight, 'line of sight' paths between collisions with impurities,
phonons, etc. However, when a magnetic field with a perpendicular component is applied, their
paths between collisions are curved so that moving charges accumulate on one face of the
material.
This leaves equal and opposite charges exposed on the other face, where there is a scarcity of
mobile charges. The result is an asymmetric distribution of charge density across the Hall
element that is perpendicular to both the 'line of sight' path and the applied magnetic field. The
separation of charge establishes an electric field that opposes the migration of further charge,
so a steady electrical potential is established for as long as the charge is flowing.
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 28
In the classical view, there are only electrons moving in the same average direction both in the
case of electron or hole conductivity. This cannot explain the opposite sign of the Hall Effect
observed. The difference is that electrons in the upper bound of the valence band have opposite
group velocity and wave vector direction when moving, which can be effectively treated as if
positively charged particles (holes) moved in the opposite direction to that of the electrons.
For simple metal where there is only one type of charge carrier (electrons) the Hall Voltage VH
is given by
𝑉𝐻 = −𝐼𝐵
𝑛𝑡𝑒
where I is the current across the plate length, B is the magnetic field, t is the thickness of the
plate, e is the elementary charge, and n is the charge carrier density of the carrier electrons.
The Hall Effect coefficient is defined as
𝑅𝐻 = 𝐸𝑦
𝑗𝑥𝐵
where j is the current density of the carrier electrons and Ey is the induced electric field. In SI
unit, this becomes
𝑅𝐻 = 𝐸𝑦
𝑗𝑥𝐵=
𝑉𝐻𝑡
𝐼𝐵= −
1
𝑛𝑒
As a result, the Hall Effect is very useful as a means to measure either the carrier density or the
magnetic field.
When a current-carrying semiconductor is kept in a magnetic field, the charge carriers of the
semiconductor experience a force in a direction perpendicular to both the magnetic field and
the current. At equilibrium, a voltage appears at the semiconductor edges.
The simple formula for the Hall coefficient given above becomes more complex in
semiconductors where the carriers are generally both electrons and holes which may be present
in different concentrations and have different mobilities. For moderate magnetic fields the Hall
coefficient is
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 29
𝑅𝐻 = 𝑝𝜇ℎ
2 − 𝑛𝜇𝑒2
𝑒(𝑝𝜇ℎ + 𝑛𝜇𝑒)2
Here n is the electron concentration, p the hole concentration, µe the electron mobility, µh the
hole mobility and e the absolute value of electronic charge. For larger applied fields the simpler
expression analogous to that for a single carrier type holds.
Fig 5.6 Hall Effect in Semiconductors
5.3.3 HALL EFFECT SENSOR HISTORY
The invention of the Hall phenomenon took place in the year 1879 in the Johns Hopkins
University in Baltimore. An American scientist named Edwin Herbert Hall, while working for
his doctoral degree, he discovered that, if current is flowing through an electrical conductor,
and this conductor is placed perpendicular to a magnetic field, then a voltage is developed on
this conductor on a right angle to the currents' path. This effect is called the "Hall effect", and
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 30
the voltage developed is called "Hall voltage". The Hall voltage is measured in micro-volts.
This invention was firstly used for making sensor to measure the DC current, or the intensity
of static magnetic fields in laboratories, as the amplifiers to measure this voltage were big and
expensive. The Hall Effect sensors was widely used after the silicon semiconductors became
popular, and an implementation of a sensor along with an amplifier in a closed package was
possible.
5.3.4 INSIDE THE HALL EFFECT SENSOR SWITCH
The simplest Hall sensor, has inside the Hall element and a differential amplifier. This amplifier
must have some special characteristics. The Hall element may produce Hall voltages down to
20 microvolts. Therefore, the amplifier must have very low noise, high input impedance and
high gain in order to detect and amplify this micro voltage. The output of the amplifier is
usually driven through a Schmitt trigger and the sensor acts as a switch sensitive to magnetism.
The Hall voltage (VH) is proportional to the current across the Hall element (I) and the density
of the magnetic flux (B). To make the Hall voltage proportional to the density of the magnetic
flux, the current must be kept constant. Therefore, usually Hall sensors have also a built in
current regulator. The chip integrates also temperature compensation. A typical Hall sensor
diagram is shown in Figure 5.7.
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 31
Fig 5.7 Inside the Hall Effect Sensor Switch
5.3.5 ADVANTAGES
It can be operated as a switch.
It can be operated up to 100 kHz.
Cost is less than other mechanical switches.
It does not suffer from contact bounce because a sequence of contacts are used
rather than a single contact.
It will not be affected by environmental contaminants. Therefore it can be used
under severe conditions.
It can be used as position, displacement and proximity sensors.
5.3.6 APPLICATIONS
The Hall Effect has been applied to numerous applications. Using hall sensors, contactless
current flow meters have been made. The current flow within a wire generates a magnetic field
around it. The hall sensor is wrapped onto the cable and measures the magnetism. The intensity
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 32
of the field is proportional to the current flow, while the Hall voltage is proportional to the
intensity of the field. The great advantage is that the cable does not even need to be stripped.
Also, it can be used to measure the intensity of magnetic fields for measuring applications.
Furthermore, the Hall sensors can distinguish the polarity of the magnetic field.
Hall sensors are also used extensively in the car industry. The solid construction and the lack
of moving parts makes the hall sensor ideal to work in harsh environments and under heavy
vibrations. The Hall sensors are used to find the position of the crankshaft, just like it used to
be done with the distributor. The electronic fuel ignition systems needs to know when the
crankshaft is in this very position, so that they calculate and ignite the spark plugs accordingly.
Another application is found on the anti-block system of the cars. The sensor will sense if the
magnetic field from the wheel is stopped and it will send a pulse to the controller to release
part of the pressure on the break piston. Also it is used for measuring a vehicle's (usually
bicycle) speed. A permanent magnet is attached to the perimeter of the wheel. Opposite this
position, on the fork, the Hall sensor is positioned. It will sense a pulse every time the magnet
passes in front of the sensor, once per wheel revolution. The controller will calculate the speed
of the vehicle by knowing the wheel diameter.
The Hall sensors are also used for synchronization in brushless motors. Their capability to
switch on and off many times a second, makes them possible to be used for high speed BLDCs.
The Hall sensor are used to distinguish which pole of the rotor permanent magnet is in which
position, and turn on or off the appropriate coils accordingly. They are also used to measure
the speed of these motors.
Many applications in automation uses also Hall sensors. Pneumatic systems use them to find
if a cylinder is extended or retracted. The piston of the cylinder carries a permanent magnet. A
Hall sensor is positioned outside the cylinder. When the magnet is in front of the Hall sensor,
it transmits a signal to the controller.
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 33
5.4 THE H – BRIGGE DRIVER
5.4.1 H – BRIDGE DRIVER WORKING PRINCIPLE
Generally, even the simplest robot requires a motor to rotate a wheel or performs particular
action. Since motors require more current then the microcontroller pin can typically generate,
you need some type of a switch (Transistors, MOSFET, Relay etc.,) which can accept a small
current, amplify it and generate a larger current, which further drives a motor. This entire
process is done by what is known as a motor driver.
Fig 5.8 Amplification of current generated by microcontroller pin for running a motor
Motor driver is basically a current amplifier which takes a low-current signal from the
microcontroller and gives out a proportionally higher current signal which can control and drive
a motor. In most cases, a transistor can act as a switch and perform this task which drives the
motor in a single direction.
Turning a motor ON and OFF requires only one switch to control a single motor in a single
direction. What if you want your motor to reverse its direction? The simple answer is to reverse
its polarity. This can be achieved by using four switches that are arranged in an intelligent
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 34
manner such that the circuit not only drives the motor, but also controls its direction. Out of
many, one of the most common and clever design is an H – Bridge circuit where transistors are
arranged in a shape that resembles the English alphabet "H".
Fig 5.9 An H – Bridge Circuit
As we can see in the Figure 5.9, the circuit has four switches A, B, C and D. Turning these
switches ON and OFF can drive a motor in different ways.
1. Turning on Switches A and D makes the motor rotate clockwise.
2. Turning on Switches B and C makes the motor rotate anti-clockwise.
3. Turning on Switches A and B will stop the motor (Brakes).
4. Turning off all the switches gives the motor a free wheel drive.
5. Lastly turning on A & C at the same time or B & D at the same time shorts your entire
circuit.
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 35
5.4.2 L293D IC OVERVIEW
L293D IC generally comes as a standard 16-pin DIP (dual-in line package) as shown in Figure
5.10. This motor driver IC can simultaneously control two small motors in either direction;
forward and reverse with just 4 microcontroller pins (if we do not use enable pins). Some of
the features (and drawbacks) of this IC are:
1. Output current capability is limited to 600mA per channel with peak output current
limited to 1.2A (non-repetitive). This means we cannot drive bigger motors with this
IC. However, most small motors used in hobby robotics should work. If we are unsure
whether the IC can handle a particular motor, connect the IC to its circuit and run the
motor with your finger on the IC. If it gets really hot, then beware... Also note the words
"non-repetitive"; if the current output repeatedly reaches 1.2A, it might destroy the
drive transistors.
2. Supply voltage can be as large as 36 Volts. This means we do not have to worry much
about voltage regulation.
3. L293D has an enable facility which helps you enable the IC output pins. If an enable
pin is set to logic high, then state of the inputs match the state of the outputs. If we pull
this low, then the outputs will be turned off regardless of the input states
4. The datasheet also mentions an "over temperature protection" built into the IC. This
means an internal sensor senses its internal temperature and stops driving the motors if
the temperature crosses a set point
5. Another major feature of L293D is its internal clamp diodes. This flyback diode helps
protect the driver IC from voltage spikes that occur when the motor coil is turned on
and off (mostly when turned off)
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 36
6. The logical low in the IC is set to 1.5V. This means the pin is set high only if the voltage
across the pin crosses 1.5V which makes it suitable for use in high frequency
applications like switching applications (upto 5KHz)
7. Lastly, this integrated circuit not only drives DC motors, but can also be used to drive
relay solenoids, stepper motors etc.
Fig 5.10 Pin Diagram of L293D
5.4.3 L293D CONNECTIONS
The circuit shown in Figure 5.11 is the most basic implementation of L293D IC. There are 16
pins sticking out of this IC and we have to understand the functionality of each pin before
implementing this in a circuit
1. Pin1 and Pin9 are "Enable" pins. They should be connected to +12V for the drivers to
function. If they pulled low (GND), then the outputs will be turned off regardless of the
input states, stopping the motors.
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 37
2. Pin4, Pin5, Pin12 and Pin13 are ground pins which should ideally be connected to
microcontroller's ground.
3. Pin2, Pin7, Pin10 and Pin15 are logic input pins. These are control pins which should
be connected to microcontroller pins. Pin2 and Pin7 control the first motor (left); Pin10
and Pin15 control the second motor (right).
4. Pin3, Pin6, Pin11, and Pin14 are output pins. Tie Pin3 and Pin6 to the first motor, Pin11
and Pin14 to second motor
5. Pin16 powers the IC and it should be connected to regulated +12Volts.
6. Pin8 powers the two motors and should be connected to positive lead of a secondary
battery. As per the datasheet, supply voltage can be as high as 36 Volts.
Fig 5.11 L293D Connections
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 38
5.4.4 TRUTH TABLE
Table 5.2 shows the truth table representing the functionality of L293D motor driver.
Pin 1 Pin 2 Pin 7 Function
High High Low Turn Anti-clockwise (Reverse)
High Low High Turn clockwise (Forward)
High High High Stop
High Low Low Stop
Low X X Stop
High ~ +12V, Low ~0V, X = either high or low (don't care)
Table 5.2 Truth Table of L293D Motor Driver
In the truth table shown in Table 5.2 we can observe that if Pin1 (E1) is low then the motor
stops, irrespective of the states on Pin2 and Pin7. Hence it is essential to hold E1 high for the
driver to function, or simply connect enable pins to positive 12 volts.
With Pin1 high, if Pin2 is set high and Pin7 is pulled low, then current flows from Pin2 to Pin7
driving the motor in anti-clockwise direction. If the states of Pin2 and Pin7 are flipped, then
current flows from Pin7 to Pin2 driving the motor in clockwise direction.
The above concept holds true for other side of the IC too. Connect your motor to Pin11 and
Pin14; Pin10 and Pin15 are input pins, and Pin9 (E2) enables the driver.
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 39
5.5 THE POWER SUPPLY
The LM317 is a popular adjustable linear voltage regulator. It was invented by Robert C.
Dobkin and Robert J. Widlar in 1970 while they worked at National Semiconductor. The
LM317 Voltage Regulator is a 3-terminal adjustable voltage regulator which can supply an
output voltage adjustable from 1.2V to 37V. It can supply more than 1.5A of load current to a
load.
5.5.1 LM317 PINOUT
The LM317 Voltage Regulator has 3 pins. Figure 5.12 shows the pinout.
Fig 5.12 LM317 Pinout
Looking from the front of the voltage regulator, the first pin (on the left) is the Adjustable Pin,
the middle is Vout, and the last pin (on the right) is VIN.
VIN – VIN is the pin which receives the incoming voltage which is to be regulated down to a
specified voltage. For example, the input voltage pin can be fed 12V, which the regulator will
regulate down to 10V. The input pin receives the incoming, unregulated voltage.
Adjustable – The Adjustable pin (Adj) is the pin which allows for adjustable voltage output.
To adjust output, we swap out resistor R2 value for a different resistance. This creates
adjustable voltages.
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 40
VOUT – VOUT is the pin which outputs the regulated voltage. For example, the LM317 may
receive 12V as the input and output a constant 10V as output.
5.5.2 LM317 SCHEMATIC
To modify the voltage to the level we want as output, we change the value of the resistor
connected to the Adj pin of the voltage regulator.
Fig 5.13 Schematic of LM317 voltage regulator
As shown in Figure 5.13 we connect two resistors to the voltage regulator. These resistors
determine the voltage that the voltage regulator adjusts to and outputs.
The voltage that the adjustable regulator outputs is determined by the equation:
𝑉𝑂𝑈𝑇 = 1.25 (1 + 𝑅2
𝑅1) 𝑣𝑜𝑙𝑡𝑠
Therefore, you can see based on this formula, that the more the value of resistor R2 increases,
the greater the voltage output.
In our setup now, these are the values we're going to use. We're going to put 12 volts into the
voltage regulator and regulate it down to 5V. Based on the formula above, in order for the
LM317 to output 5 volts, the value of R2 must be 720Ω. We can this above circuit up and then
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 41
use a multimeter to check the output voltage by placing it across the 1μF capacitor or across
the resistors. We find that it is very close to 5 volts. Now if swap out the R2 resistor and place
a 1.5KΩ resistor in its place we find the voltage output to be 10V.
This is the advantage of adjustable voltage regulators. You can adjust it to any voltage within
the range that the voltage regulator supports.
Note that the capacitors C1 and C2 are used to clean up the power line. C1 is optional and it's
used to clean up transient response. C2 is needed if the device is far from any filter capacitors.
This capacitors helps smooth out the power supply line in case of abrupt current spikes.
5.5.3 LM317 CIRCUIT
Figure 5.14 shows how LM317 regulator would look when connected to a circuit so that it
supplies a constant DC voltage output.
Fig 5.14 LM317 Circuit
In this circuit, we add a DC voltage supply to the VIN pin of the regulator. This is the pin
which, again, receives incoming voltage which the chip will then regulate down. The voltage
which enters this pin must be larger than the voltage it is feeding out. Remember, voltage
regulators are just devices that regulate voltage down to a certain level. They do not and cannot
create voltage on their own. Therefore, in order to a get a voltage, VOUT, VIN must be greater
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 42
than VOUT. In this circuit, we want a regulated 5VDC as output. Therefore, VIN must be
greater than 5 volts. Generally, with regulators, unless they are low drop out regulators, you
want the input voltage to be about 2 volts higher. So therefore, since we want 5 volts as output,
we will feed into this regulator 7 volts.
Now that we've dealt with the input pin, we must now deal with the adjustable pin (Adj). This
is the pin which allows us to adjust the voltage to the level we want. Since we want 5 volts to
be output, we must calculate which value of R2 will yield an output of 5 volts. Using the
formula for the output voltage, VOUT= 1.25V (1 + R2/R1).
Being that R1=240Ω, our equation is now 5V= 1.25V (1 + R2/240Ω), so R2=720Ω. So with
R2 being a value of 720Ω, the LM317 will output 5V if fed an input voltage greater than 5
volts.
The last pin of the LM317 is the output pin. This is where the regulated voltage (in this case, 5
volts) will come out. To feed a circuit the regulated 5 volts, we just connect it to the output pin.
5.6 PROXIMITY SENSOR
A proximity sensor is a sensor able to detect the presence of nearby objects without any
physical contact. Since there is no contact between the sensors and sensed object and lack of
mechanical parts, these sensors have long functional life and high reliability. The different
types of proximity sensors are Inductive Proximity sensors, Capacitive Proximity sensors,
Ultrasonic proximity sensors, photoelectric sensors, Hall-effect sensors, etc.
5.6.1 WORKING PRINCIPLE
A proximity sensor often emits an electromagnetic field or a beam of electromagnetic radiation
(infrared, for instance), and looks for changes in the field or return signal. The object being
sensed is often referred to as the proximity sensor's target. Different proximity sensor targets
demand different sensors. For example Inductive Proximity sensors have an oscillator as input
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 43
to change the loss resistance by the proximity of an electrically conductive medium. These
sensors are preferred for metal targets. Capacitive Proximity sensors convert the electrostatic
capacitance variation flanked by the detecting electrode and the ground electrode. This occurs
by approaching the nearby object with a variation in an oscillation frequency. To detect the
nearby object, the oscillation frequency is transformed into a direct current voltage which is
compared with a predetermined threshold value. These sensors are preferred for plastic targets.
The maximum distance that this sensor can detect is defined "nominal range". Some sensors
have adjustments of the nominal range or means to report a graduated detection distance.
Proximity sensors can have a high reliability and long functional life because of the absence of
mechanical parts and lack of physical contact between sensor and the sensed object.
5.6.2 ADVANTAGES OF PROXIMITY SENSORS
No physical contact required with the target to be detected, therefore, no moving parts,
so no friction and wear out.
Fast switching characteristics
Unlimited number of switching cycles since there is no mechanical contact
Can work in harsh conditions
Any type of target material can be detected.
5.6.3 APPLICATIONS OF PROXIMITY SENSORS
Parking sensors, systems mounted on car bumpers that sense distance to nearby cars for
parking
Ground proximity warning system for aviation safety
Vibration measurements of rotating shafts in machinery
Top dead centre (TDC)/camshaft sensor in reciprocating engines.
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 44
Sheet break sensing in paper machine.
Anti-aircraft warfare
Roller coasters
Conveyor systems
Beverage and food can making lines
Mobile devices
Touch screens that come in close proximity to the face
Attenuating radio power in close proximity to the body, in order to reduce
radiation exposure
5.7 DC MOTOR
In our project, we have used two 12V geared DC motors as shown in figure 5.15 for running
the wheelchair. We have used 2 motors one for left and one for right so that turning might be
made easy. Right motor at rest and left motor in forward motion moves the wheelchair right.
Left motor at rest and right motor in forward motion moves the wheelchair left. For moving
forward, both the motors move in forward motion at same speed. For moving backward, both
the motors move in reverse motion at same speed.
Fig 5.15 12 V DC Motor
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 45
CHAPTER 6
SOFTWARE
6.1 EMBEDDED C
6.1.1 OVERVIEW
Embedded C is a set of language extensions for the C Programming language by the C
Standards committee to address commonality issues that exist between C extensions for
different embedded systems. Historically, embedded C programming requires nonstandard
extensions to the C language in order to support exotic features such as fixed-point arithmetic,
multiple distinct memory banks and I/O operations.
In 2008, the C Standards Committee extended the C language to address these issues by
providing a common standard for all implementations to adhere to. It includes a number of
features not available in normal C, such as, fixed- point arithmetic, named address spaces, and
basic I/O hardware addressing.
Embedded C use most of the syntax and semantics of standard C, e.g. main () function, variable
definition, data type declaration, conditional statements (if, switch, case), loops (while, for),
functions, arrays and strings, structures and union, bit operations, macros, unions, etc.
In short, Embedded C deals with Microcontrollers, I/O Ports (RAM, ROM).whereas C deals
with only memory, operating systems. C is a desktop programming language used for
embedding a piece of software code into the hardware for its functioning.
6.1.2 COMPONENTS OF AN EMBEDDED C PROGRAM
Embedded C use most of the syntax and semantics of standard C, e.g. main () function, variable
definition, data type declaration, conditional statements (if, switch, case), loops (while, for),
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 46
functions, arrays and strings, structures and union, bit operations, macros, etc. In addition, there
are some specifics to embedded C which are mentioned below:
1. Low Level Codes
Embedded programming requires access to underlying hardware, i.e., timers, memory, ports,
etc. In addition, it is often needed to handle interrupts, manage job queues, etc. As C offers
pointers and bit manipulation features, they are extensively used for direct hardware access.
2. In-line Assembly Code
For a particular embedded device, there may be instructions for which no equivalent C code is
available. In such cases, inline assembly code, i.e., assembly code embedded within C
programs is used; the syntax depends upon the compiler. Writing inline assembly code is much
easier than writing full-fledged assembly code.
3. Features like Heap, recursion
Embedded devices have no or limited heap area (where dynamic memory allocation takes
place). Hence, embedded programs do not use standard C functions like malloc. Structures like
linked lists/trees are implemented using static allocation only.
Similarly, recursion is not supported by most embedded devices because of its inefficiency in
terms of space and execution time. Such other costly features of standard C which consume
space and execution time are either not available or not recommended
4. I/O Registers
Microcontrollers typically have I/O, ADCs, serial interfaces and other peripherals in-built into
the chips. These are accessed as I/O Registers, i.e., to perform any operation on these
peripherals, bits in these registers are read / written.
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 47
Special function registers (SFRs) are accessed as shown below:
SFR portb=0x0B;
It is used to declare portB at location 0x0B.
Some embedded processors have separate I/O space for such registers. Since there are no such
concepts in C, compilers provide special mechanisms to access them.
Unsigned char portB @portB 0x08;
In this example, ‘@portB<address>’ declares portB at location 0x8B by the variable portB.
Such extensions are not a part of standard C, syntax and semantics differ in various embedded
C compilers.
5. Memory Pointers
Some CPU architectures allow us to access I/O registers as memory addresses. This allows
treating them just like any other memory pointers.
6. Bit Access
Embedded controllers frequently need bit operations as individual bits of I/O registers
correspond to the output pin of an I/O port. Standard C has quite powerful tools to do bitwise
operations. However, care must be taken while using them in structures because C standard
doesn’t define the bit field allocation order and C compilers may allocate bit fields either from
left to right or from right to left.
7. Use of Variable data type
In C, data types can be simply declared, and compiler takes care of the storage allocation as
well as that of code generation. But, data type’s usage should be carefully done to generate
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 48
optimized code. For most 8-bit C compilers, ‘char’ is 8-bits, ‘short’ and ‘int’ are 16-bits, ‘long’
is 32-bits.
Some embedded processors favour use of 69unsigned type. Use of ‘long’ and floating variable
should be avoided unless it is very necessary. Using long data types increase code size and
execution time. Use of floating point variables is not advised due to intrinsic imprecise nature
of floating point operations, alongside speed and code penalty.
8. Use of Const and Volatile
Volatile is quite useful for embedded programming. It means that the value can change without
the program touching it. Consequently, the compiler cannot make any assumptions about its
value. The optimizer must reload the variable every time it is used instead of holding a copy in
a register.
Const is useful where something is not going to change, for e.g., function declarations, etc.
6.1.3 ADVANTAGES OF USING EMBEDDED C
1. Direct access to low level hardware API’s
2. You can find a C compiler for the vast majority of these devices. This is not true for any
high level language.
3. C (the runtime and your generated executable) is “small”. You don’t have to load a bunch
of stuff into the system to get the code running.
4. The hardware API/drivers will likely be written in C or C++.
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 49
6.2 KEIL C CROSS COMPILER
Keil Software provides the software development tools for the 8051 family of microcontrollers.
With these tools embedded applications for the multitude of 8051 derivatives is generated. Keil
provides following tools for 8051 development
1. C51 Optimizing C Cross Compiler.
2. A51 Macro Assembler.
3. 8051 Utilities (linker, object file converter, library manager).
4. Source-level Debugger/Simulator.
5. µVision for Windows Integrated Development Environment.
The Keil 8051 tool kit includes three main tools, assembler, compiler and linker.
An assembler is used to assemble 8051 assembly program.
A compiler is used to compile C source code into an object file.
A linker is used to create an absolute object module suitable for your in-circuit emulator.
8051 project development cycle: These are the steps to develop 8051 project using Keil
1. Create source files in C or assembly.
2. Compile or assemble source files.
3. Correct errors in source files.
4. Link object files from compiler and assembler.
5. Test linked application.
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 50
6.2.1 CONFIGURING THE SIMULATOR
1 .Open Keil µVision 4.
2. Create a new project.
Fig 6.1 Step 2 of Keil Configuration
3. Select the required microcontroller and click ok.
Fig 6.2 Step 3 of Keil Configuration
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 51
4. Creating new file
Fig 6.3 Step 4 of Keil Configuration
5. Type the code and save it as filename.c
Fig 6.4 Step 5 of Keil Configuration
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 52
6. Go to Project – Manage – Select components, environments and books and add the C file to
source group.
Fig 6.5 Step 6 of Keil Configuration
7. Save the project
Fig 6.6 Step 7 of Keil Configuration
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 53
8. Compile (Translate) the C file
Fig 6.7 Step 8 of Keil Configuration
9. Build target files
Fig 6.8 Step 9 of Keil Configuration
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 54
10. Rebuild Target Files
Fig 6.9 Step 10 of Keil Configuration
11. Go to Project and select Options for Target “Target 1”..
Fig 6.10 Step 11 of Keil Configuration
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 55
12 Make sure that the oscillator crystal frequency is 11.0592 MHz.
Fig 6.11 Step 12 of Keil Configuration
13. Go to output tab under Options for Target “Target 1” and select “Create HEX File”.
Fig 6.12 Step 13 of Keil Configuration
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 56
6.3 WILLAR PROGRAMMER
We are using WILLAR Programmer to burn the hex files generated by Keil µVision to the
ATMEL AT89S52 microcontroller. The steps to do the same are shown below,
1. Open WILLAR Programmer
2. Select the target device as AT89S52
Fig 6.13 Step 2 of Willar Programmer Configuration
3. Load the hex file generated by Keil µVision.
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 57
Fig 6.14 Step 3 of Willar Programmer Configuration
4. Click Auto to blank check, program, verify and protect the hex code into AT89S52.
Fig 6.15 Step 4 of Willar Programmer Configuration
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 58
CHAPTER 7
ADVANTAGES AND DISADVANTAGES OF TDS
7.1 ADVANTAGES
Simple to implement, low cost and easy to operate.
Unobtrusive.
Offers better privacy to users.
7.2 DISADVANTAGES
User should avoid inserting ferromagnetic objects in their mouth.
Magnetic tracer should be removed if user is undergoing MRI scan.
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 59
CHAPTER 8
CHALLENGES FACED
We have faced a number of challenges in this project and also learned a number of new terms
and microcontroller terminology.
Hall sensor output not enough to drive microcontroller.
Back emf produced by motors (took a long time for rectification, had burned 2 IC’s
and one ATMEL AT89S52 microcontroller PCB)
Exact positioning of sensors
Turning the vehicle left and right
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 60
CHAPTER 9
CONCLUSION
This project “Tongue Drive Assistive Technology for paralysed persons” is mainly intended to
design a wheelchair which can be controlled by movement of tongue, which is very useful for
handicapped and paralysed persons. This system consists of Hall Effect sensors and a
Wheelchair interfaced to microcontrollers. This device could revolutionize the field of assistive
technologies by helping individuals with severe disabilities such as those with severe high level
spinal cord injuries return to rich, active, independent and productive lives. Also this Hall
Effect sensor can be used to control different devices basing on the movement of the tongue.
For example, home appliances like fan, TV can be controlled by paralysed person on his own.
Thus this model helps severely paralysed person in reducing his/her dependency on others.
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 61
CHAPTER 10
REFERENCES
BOOKS
The 8051 Microcontroller and Embedded System using assembly and C by Muhammad
Ali Mazzidi (Author), Janice Gillespie Mazzidi (Author) and Rollin D Mckinlay
(Author); Pearson
Hall Effect Sensors : Theory and Applications by Edward Ramsden (Author); Elsevier
The 8051 Microcontroller by Kenneth Ayala (Author); Thomson Delmar Learning, 3rd
Edition, 2005
WEBSITES
Datasheets, http://www.DatasheetCatalog.com
Keil C Evaluator edition, http://www.keil.com
Assistive Technology Devices, http://www.wheelchairnet.org
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 62
APPENDIXES
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 63
APPENDIX A
SOURCE CODE
TRANSMITTER SOURCE CODE
#include<reg51.h>
#define SW P1
void main()
unsigned char input;
SW=0xff;
SW=SW&0x0f;
input=0x00;
while(1)
input=SW;
if (input==0x0f)
P0=0x05;
else if(input==0x0E)
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 64
P0=0x02;
else if(input==0x0D)
P0=0x08;
else if(input==0x0B)
P0=0x04;
else if(input==0x07)
P0=0x06;
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 65
RECEIVER SOURCE CODE
#include<reg51.h>
#define MOVE_FORWARD 0x0A
#define TURN_RIGHT 0x02
#define TURN_LEFT 0x08
#define STOP 0x00
#define REVERSE 0x05
#define MOTOR P1
#define INPUT_PORT P2
sbit r = P2^4;
void main()
unsigned char input;
INPUT_PORT = 0xff;
input = 0x00;
while(1)
input = INPUT_PORT;
input = input & 0x0f;
if(input == 0x08)
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 66
MOTOR = REVERSE;
else if(input == 0x05)
MOTOR = STOP;
if(r == 0)
if(input == 0x02)
MOTOR = MOVE_FORWARD;
else if(input == 0x04)
MOTOR = TURN_RIGHT;
else if(input == 0x06)
MOTOR = TURN_LEFT;
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 67
else if(r == 1 && input != 0x08)
MOTOR = STOP;
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 68
APPENDIX B
DATA SHEETS
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 69
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 70
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 71
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 72
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 73
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 74
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 75
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 76
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 77
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 78
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 79
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 80
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 81
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 82
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 83
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 84
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 85
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 86
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 87
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 88
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 89
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 90
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 91
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 92
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 93
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 94
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 95
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 96
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 97
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 98
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 99
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 100
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 101
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 102
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 103
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 104
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 105
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 106
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 107
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 108
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 109
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 110
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 111
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 112
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 113
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 114
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 115
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 116
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 117
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 118
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 119
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 120
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 121
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 122
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 123
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 124
TDS 2013 – 2014
Department of Electronics and Communication, Sir MVIT Page 125