Sunteți pe pagina 1din 96

CHAPTER 1

INTRODUCTION

1.1 Motivation
Assistive Technology (AT) that refers to hardware and software solutions for persons with
physical, cognitive or sensory disabilities can help people to have more productive and
pleasant lives. Several physical disabilities/conditions require the use of wheelchair including
brain injury, stroke, fractures, amputation, pulmonary disease, neurological disorders,
musculoskeletal diseases/injuries and spinal cord injuries. In such cases the use of a
wheelchair can bring an enhanced independence that will increase the user’s quality of life.
However some of the impairments cause severe difficulties on the use of wheelchair manual
or electronic.
This study concluded that 9 to 10 % of patients who use power chairs and who
received appropriate training “find it extremely difficult or impossible to use the wheelchair
for activities of daily living”. Some of the pointed reasons are difficult on controlling the
wheelchair with a joystick, uncomfortable and inappropriate interface for the disability
(because users with severe motor impairments are unable to operate the joystick smoothly).
For elderly patients arthritis is one of the major reasons for wheelchair use. The
repeated usage of joysticks and continuous wrist movements can be very painful for an
arthritic patient, and may result in reinforced difficulties. For the referred groups of users a
voice based interface is highly encouraging because it represents a natural and simple way of
controlling the device. For other types of disabilities different types of interfacing devices can
be used.
To achieve this, a wheelchair-based assistive device is developed, allowing the user to
select arbitrary local destinations through a voice recognition module and a mems module.

1.2 Challenges and contribution


1.2.1 Challenges
 The increase in the weight of the user results in increase of load to the motor and its
drivers. These results in the increase of the torque force required to move the
wheelchair.

1
 Since we use a voice recognition chip, it recognizes only user’s voice, additional noise
causes disturbances in input signal.
 While using voice recognition module the sensitivity of MEMS causes overwriting of
voice input signal.

1.2.2 Contribution
 High torque motors are used whenever high loads are given as input. In order to avoid
the clumsiness that occurs while recognition of several voices, a single user voice can
be used to give instructions.
 MEMS module can be fixed rigidly such that, while operating with voice module, the
high sensitivity nature of MEMS shows no effect on the movement of wheel chair.

1.3 Organization of thesis report

Chapter 1 Deals with the introduction of the project which includes motivation,
challenges and contributions, brief description of embedded system
organization of thesis and conclusion.
Chapter 2 Deals with the relevant work study on the wheel chair theoretical overview
and conclusion.

Chapter 3 Deals with hardware description of the project i.e schematic diagram and its
description.

Chapter 4 Deals with the software used to implement the project that is keil software,
Embedded C programming for communication of the data and ISIS
Professional Proteus 8.1

Chapter 5 Deals with the result and analysis of the project

Chapter 6 Deals with conclusion of the project

1.4 Conclusion

2
This chapter discussed the motivation of the project, challenges that are faced while doing
project and its contribution. Also discussed organization of thesis; given a brief description
about chapters. The next chapter will discuss the relevant work study.

3
Chapter 2

Relevant Work Study

2.1. Introduction

This project mainly consists of micro controller LPC2103, MEMS, Voice recognition module
V2 and for the function of all the components power supply is needed. The power supply
module converts 230V A.C into 5V D.C supply, for this we preferred the book "Electronic
devices and circuits" by "Srinivasan" and "Shalivahana". For sensors we preferred the book
"Hand book of Modern Sensors" by "Jacob Fraden". For keil software, sensors and its
specifications we preferred the website www.google.com.
To work out this project we had studied different real time and working models of
automatic wheel chair as follows

2.2. Relevant Study

A smart wheelchair equipped with sensors and driven by Head movement control that allows
the rider to interact with and command the system at various levels of abstraction as in [1]. A
novel hands-free control system for Intelligent Wheelchairs is proposed in [2]. A robust Hand
Gesture Interface is designed for vision based head gesture recognition of the Robot Chair
user. The recognized gestures are used to generate motion control commands so that the
Robot Chair can be controlled according to the user’s intention. An integrated approach to
real time detection, tracking and direction recognition of hands, which is intended to be used
as a human-robot interaction interface for the intelligent wheel chair is presented in [3]. The
author here demonstrates that accelerometers can be used to effectively translate finger and
hand gestures into computer interpreted signals. A different gesture recognition methods that
are employed in wheelchair used for navigation and that is affordable by the people in
developing nations is given in [4]. In this technique a GCUI (Gesture Controlled User
Interface) prototype application, called Open Gesture, to help users carry out everyday
activities such as making phone calls, controlling their television and performing
mathematical calculations is proposed as in [5]. Open Gesture uses simple hand gestures to
perform a diverse range of tasks via a television interface. This technique proposes a reactive
navigation algorithm that guarantees the safety of automated intelligent wheelchairs for
people with mobility impairments in dynamic uncertain environments as in [6]. The proposed

4
navigation algorithm restricts neither the natures nor the motions of the obstacles; the shapes
of the obstacles can be time-varying (deforming obstacles) and does not require prior
information about the positions and velocities of the obstacles to accomplish obstacle
avoidance.

In this method the development of a novel architecture of an intelligent wheelchair


working on wireless hand gesture control is shown as in [7] .This Wheelchair also has a
distress call system (GSM) to alert the concerned people or family in times of necessity for
the person, or when there is any sudden detection of edge or staircase during backward
motion, thus saving the chair from accidents. A voice and gesture based system to control a
wheelchair using voice commands and moment of hand (MEMS sensor is connected to hand)
is proposed as in [8]. In the speech recognition module, hidden Markov models are used as
the main method in recognizing voice commands. The MEMS sensor senses the angle of the
hand, i.e. according to the tilt of hand it gives voltages to microcontroller. The wheelchair
control unit is developed using ARM controller. This method proposes a device in which by
pressing the keypad (buttons), people with disabilities can move the wheelchair as in [9].

The NavChair Assistive Wheelchair Navigation System, The NavChair has


application to the development and testing of shared control systems where a human and
machine share control of a system and the machine can automatically adapt to human
behaviors[10].

The NavChair shares vehicle control decisions with the wheelchair operator regarding
obstacle avoidance, safe object approach, maintenance of a straight path, and other
navigational issues, to reduce the motor and cognitive requirements for operating a power
wheelchair[10].

[11]Touch Screen Based Direction and Speed Control of Wheel Chair for Physically
Challenged, This paper describes an intelligent motorized wheel chair for handicapped person
using touch screen technology. It enables a disabled person to move around independently
using a touch screen application which is interfaced with motors through micro-controller.
When we want to change the direction, the touch screen sensor is modelled to direct the user
to required destination using direction keys on the screen and that values are given to micro-
controller. Depending on the direction selected on the touch screen, micro-controller controls
the wheel chair directions. The speed controller works by varying the average voltage sent to

5
the motor. This is done by switching the motors supply on and off very quickly using PWM
technique.

[12]In this project the author has worked on the automatic wheelchair which is
controlled by both voice and MEMS sensor. This differs our project by usage of voice
module HM2007 instead of voice module v2.

[13] In the paper along with working on automatic wheelchair movement the authors
have also implemented home automation system using zigbee module and emergency call
system using GSM modules.

2.3 Conclusion

In this chapter we had discussed about the relevant work study done by us to refer projects
that relates to automatic movement of wheel chair using different technologies.

6
Chapter 3

Hardware Description

Considering the intensity levels of the technology support to the physically challenged
personalities the developed working model is tested with voice and MEMS based
accelerometer sensor

3.1 Block Diagram

TTT Voice RESET


input

Display

VOICE Central BATTERY


RECOGNITION Control unit Power
Motor Driver
IC

MEMS MOTOR
SENSOR Assembly

Figure 3.1: Block diagram of the proposed wheel Chair

3.2 Power Supply

All the digital circuits require regulated power supply. The power supply is designed to
convert high voltage AC mains electricity to a suitable low voltage supply for electronic
circuits and other devices. A power supply can be broken down into a series of blocks, each
of which performs a particular function. A DC power supply which maintains the output
voltage constant irrespective of AC mains fluctuations or load variations is known as
Regulated D.C Power Supply. But here voltage rectification is enough for the application.

7
Figure 3.2: Block Diagram of Power Supply

Battery power supply


A battery is a type of linear power supply that offers benefits that traditional line-operated
power supplies lack: mobility, portability and reliability. A battery consists of multiple
electrochemical cells connected to provide the voltage desired.

Figure 3.3: Battery

8
The lead-acid storage battery may be used. This battery is rechargeable; it consists of
lead and lead/dioxide electrodes which are immersed in sulfuric acid. When fully charged,
this type of battery has a 2.06-2.14 V potential (A 12 volt car battery uses 6 cells in series).
During discharge, the lead is converted to lead sulfate and the sulfuric acid is converted to
water. When the battery is charging, the lead sulfate is converted back to lead and lead
dioxide A nickel-cadmium battery has become more popular in recent years.
This battery cell is completely sealed and rechargeable. The electrolyte is not involved
in the electrode reaction, making the voltage constant over the span of the batteries long
service life. During the charging process, nickel oxide is oxidized to its higher oxidation state
and cadmium oxide is reduced. The nickel-cadmium batteries have many benefits.

Transformer

Figure3.4: Transformer circuit diagram

A transformer is a device which transforms high voltage AC into low voltage AC or vice
versa. Our goal is to convert high voltage AC into low voltage DC. So there is absolutely no
reason to use step-up transformer. The transformer that is used in power supply is step-down
transformer, which steps down the input AC voltage. The magnitude by which transformer
steps down the voltage depends on the turns ratio of primary and secondary winding. Observe
the magnitude of sinusoidal signal before the transformer block. Its magnitude is quite high
as compared to that of the signal after the transformer block diagram. This indicates that that
the signal was stepped down by the transformer. There arises an obvious question as to why
transformer is used in this system. The main reason why we use transformer in the system are
as follows.
9
1. We want to reduce the voltage level which we get from the AC mains. Transformer
can do the job of reducing the voltage level in a simple and efficient manner.

2. The diodes used in the rectifier block cannot handle such a high level of voltage from
the AC mains. So the voltage is first stepped down by the transformer and the reduced
voltage is applied to the rectifier section.

Rectifier

Rectifier is an electronic circuit consisting of diodes which carries out the rectification
process. Rectification is the process of converting an alternating voltage or current into
corresponding direct (dc) quantity. The input to a rectifier is ac whereas its output is
unidirectional pulsating dc. Usually a full wave rectifier or a bridge rectifier is used to rectify
both the half cycles of the ac supply (full wave rectification).

Rectifiers are basically of two types

1. Half wave rectifiers

2. Full wave rectifiers

Filter capacitor

Figure 3.5: Rectifier


The rectified voltage from the rectifier is a pulsating dc voltage having very high ripple
content. But this is not we want, we want a pure ripple free dc waveform. This can be done
by using a capacitor at the output of the rectifier this capacitor is also called as Filter
Capacitor or Smoothing Capacitor or Reservoir Capacitor.
In this reservoir capacitor as the instantaneous voltage starts increasing the capacitor
charges, it charges till the waveform reaches its peak value. When the instantaneous value
starts reducing the capacitor starts discharging exponentially and slowly through the load

10
(input of the regulator in this case). Hence, an almost constant dc value having very less
ripple content is obtained.
Voltage Regulator

Input

GND

Output

Figure 3.6: Regulator

A voltage regulator is necessary to maintain a constant output dc voltage. The voltage


regulator receives the signal from the filter and delivers a constant voltage regardless of the
variations on the load or the voltage supply. Voltage regulator ICs are available with fixed
(typically 5, 12 and 15V) or variable output voltages. Each regulator has its own data sheet
and pin configuration.

3.3MEMS Accelerometer

MEMS (Micro-Electro Mechanical System)-based accelerometers are devices that measure


the proper acceleration. In relativity theory, proper acceleration is the physical acceleration
experienced by an object. The psychical acceleration is measurable by sensors. These sensors
are part of the sensing cluster of ubiquitous technologies. Sensing technologies make use of
physical parameters from the environment, such as temperature, pressure, force and light. An
accelerometer measures weight per unit of mass, a quantity also known as specific force, or
g-force. Measuring g-forces allows users to for instance interact with products by means of
gesture recognition. MEMS-based accelerometers are available in 1-, 2- and 3-axis
configurations, with analog or digital output, in low-g or high-g sensing ranges.

3.3.1Principles of Operation

11
Most accelerometers are Micro-Electro-Mechanical Sensors (MEMS). The basic principle of
operation behind the MEMS accelerometer is the displacement of a small proof mass etched
into the silicon surface of the integrated circuit and suspended by small beams. Consistent
with Newton's second law of motion (F = ma), as an acceleration is applied to the device, a
force develops which displaces the mass. The support beams act as a spring, and the fluid
(usually air) trapped inside the IC acts as a damper, resulting in a second order lumped
physical system. This is the source of the limited operational bandwidth and non-uniform
frequency response of accelerometers.

3.3.2 The working principle

MEMS-based accelerometers are available with different technologies. The most common are
based on capacitors and gas chambers.

3.3.2.1 Capacitor

MEMS-based accelerometer with capacitors is typically a structure that uses two capacitors
formed by a moveable plate held between two fixed plates. Under zero net force the two
capacitors are equal but a change in force will cause the moveable plate to shift closer to one
of the fixed plates, increasing the capacitance, and further away from the other fixed reducing
that capacitance. This difference in capacitance is detected and amplified to produce a voltage
proportional to the acceleration. The dimensions of the structure are of the order of microns.

Figure 3.7: Operation of MEMS

3.3.2.2 Gas Chambers

12
Another design is based on the distribution of hot gas in a chamber and is typically used to
measure static tilt. The accelerometer has a chamber of gas with a heating element in the
center and four temperature sensors around its edge. Just as hot air rises and cooler air sinks,
the same applies to hot and cool gasses. The figure below on the left illustrates the situation
when the accelerometer is held level. The hot gas rises to the top-center of the accelerometer's
chamber, and all four temperature sensors measure the same temperature. The hot gas rises to
the top-center of the accelerometer’s chamber, and all four temperature sensors measure the
same temperature. When tilted, as is shown in the figure below on the right, the hot gas will
now collect closer to one, or possibly two, of the temperature sensors and the difference in
the four temperatures being measured will give a measure of the tilt.

Figure 3.8:
Gas
chamber
MEMS

3.3.2.3
Inputs,
outputs and performance characteristics

The main component of MEMS accelerometers with a capacitor is a cantilever beam with a
proof mass (also known as seismic mass). Damping results from the residual gas sealed in the
device. As long as the Q-factor is not too low, damping does not reduce sensitivity. External
accelerations make the proof mass deflect from its neutral position. This deflection is
measured in an analogue or digital manner. Most commonly, the capacitance between a set of
fixed beams and a set of beams attached to the proof mass is measured. This method is
simple, reliable, and inexpensive

3.4 ADXL335

The ADXL335 is a small, thin, low power, complete 3-axis accelerometer with signal
conditioned voltage outputs. The product measures acceleration with a minimum full-scale
13
range of ±3 g. It can measure the static acceleration of gravity in tilt-sensing applications, as
well as dynamic acceleration resulting from motion, shock, or vibration. The user selects the
bandwidth of the accelerometer using the Cx ,Cy, and Cz capacitors at the Xout , Yout and Zout pins.
Bandwidths can be selected to suit the application, with a range of 0.5 Hz to 1600 Hz for the X
and Y axes, and a range of 0.5 Hz to 550 Hz for the Z axis.

The ADXL335 is available in a small, low profile, 4 mm × 4 mm × 1.45 mm, 16-lead,


plastic lead frame chip scale package.

Figure3.9 : Axis MEMS Accelerometer (ADXL335)

Features

1.3-axis sensing

2. Wide power range DC3V to 5V

3. Breakout module

4. Small, low profile package 4 mm × 4 mm × 1.45 mm LFCSP

5. Low power: 350 μA at 3V (typical)

6. Single-supply operation: 1.8 V to 3.6 V

7.10,000 g shock survival

8. BW adjustment with a single capacitor per axis

9. High sensitive

10. Excellent temperature stability

3.4.1 Applications

14
1. Cost sensitive, low power, motion- and tilt-sensing applications

2. Mobile devices

3. Gaming systems

4. Disk drive protection

5. Image stabilization

6. Sports and health devices

Figure 3.10: Axes of Acceleration Sensitivity

3.4.2 Pin configuration and Function descriptions

ADXl335 is a16 pin IC

Figure 3.1: Pin Diagram

3.4.3 Theory of Operation

15
Table 3.1: Orientation of axis

The ADXL335 is a complete 3-axis acceleration measurement system. The ADXL335 has a
measurement range of ±3 g mini-mum. It contains a poly silicon surface-micro machined
sensor and signal conditioning circuitry to implement open-loop acceleration measurement
architecture. The output signals are analog voltages that are proportional to acceleration. The
accelerometer can measure the static acceleration of gravity in tilt-sensing applications as
well as dynamic acceleration resulting from motion, shock, or vibration.

The basic block diagram of ADXL335 as mentioned in the data sheet. The chip has
in-built coupling capacitor between supply voltage and ground; thus reducing the noise at the
power supply line. It contains micro machined three axis sensor along with signal
conditioning circuitry. The output shows ratio metric characteristics thus, output voltage
changes depending on the change in supply voltage. Nominally, at zero g, output voltage is
half of the supply voltage. Each axis has a separate bandwidth adjustments. The capacitor in
series with output decides the bandwidth of each axis. Bandwidth range of 200 Hz to 1 KHz
is used.

16
Figure 3.12: ADXL Internal Structure

The accelerometer sensor used here is a poly silicon surface-micro machined structure
built on top of a silicon wafer. Deflection of the structure is measured using a differential
capacitor. The differential capacitor involves the inter digitations of moving fingers attached
to the proof mass with fixed fingers attached to the frame. The differential capacitance is
proportional to the overlapping area and the distance between the moving and fixed fingers.
Acceleration deflects the moving mass and unbalances the differential capacitor resulting in a
sensor output whose amplitude is proportional to acceleration. Acceleration deflects the
moving mass and unbalances the differential capacitor resulting in a sensor output whose
amplitude is proportional to acceleration. Phase sensitive demodulation techniques are then
used to determine the magnitude and direction of the acceleration.

The demodulator output is amplified and brought off-chip through a 32 kΩ resistor.


The user then sets the signal bandwidth of the device by adding a capacitor. This filtering
improves measurement resolution and helps prevent aliasing. The ADXL335 accelerometer
outputs a voltage between 0 and Vcc volts for each axis, and zero acceleration for the axis
occurs at approximately ½ Vcc. Therefore, each voltage output contains an offset that must
be specifically calibrated for each axis. To convert a measured voltage reading to
acceleration, Axis Sensitivity is also required a conversion constant that must also be
measured specifically for each axis. The approximate sensitivity of each axis depends on the
type of accelerometer. The ADXL335 Accelerometer has an approximate Axis Sensitivity of
330mV/g, where g is the acceleration due to gravity equal to 9.81m/s2.

17
3.5 Voice Recognition Module V2

Figure 3.13: Voice module V2

The module could recognize your voice. It receives configuration commands or responds
through serial port interface. With this module, we can control the car or other electrical
devices by voice.

This module can store up to 15 pieces of voice instruction. Those 15 pieces are
divided into 3 groups, with 5 in each group. First we should train the module with voice
instructions group by group. After that, we should import one group before it could recognize
the 5 voice instructions within that group. If we need to implement instructions in other
groups, we should import the group first. This module is speaker dependent. If you trained
the module, your friend might not be able to make it work.

3.5.1 Parameters

1. Voltage: 4.5-5.5V
2. Current: <40mA
3. Digital Interface: 5V TTL level UART interface and GPIO
4. Analog Interface: 3.5mm mono-channel microphone connector + microphone pin
interface
5. Size: 30mm x 47.5mm
6. Recognition accuracy: 99% (under ideal environment)

3.5.2 Serial Command

This module can be configured by sending commands via serial port. Configuration
will be not erased after powered off.

Its interface is 5V TTL. The serial data format: 8 data bits, no parity, 1 stop bit. The
default baud rate is 9600 and baud rate can be changed.

18
Command format is "Head + Key". "Head" is a 0xaa, and "Key" is as follows:

Key Description Respond in Common Respond in Compact


(HEX format) Mode Mode
0x00 Enter into “Waiting” "Waiting! \ n" : 0xcc : successful
state successful 0xe0 : Instruction
"ERROR! \ n" : error
Instruction error
0x01 Delete the "Group1 Deleted ! \ 0xcc : successful
instructions of group n" : successful 0xe0 : Instruction
1 "ERROR! \ n" : error
Instruction error
0x02 Delete the "Group2 Deleted ! \ 0xcc : successful
instructions of group n" : successful 0xe0 : Instruction
2 "ERROR! \ n" : error
Instruction error
0x03 Delete the "Group3 Deleted ! \ 0xcc : successful
instructions of group n" : successful 0xe0 : Instruction
3 "ERROR! \ n" : error
Instruction error
0x04 Delete the " All Groups 0xcc : successful
instructions of all the Deleted !\n " : 0xe0 : Instruction
3 groups successful error
"ERROR! \ n" :
Instruction error
0x11 "ERROR! \ n" : Instruction error can speak now

Begin to "START \ n" : Ready for recording, you 0x41 : no voice detected
record can speak 0x42 : Speak the voice

instructions of now instruction again. Do not

group 1 "No voice \ n" : no voice detected speak until getting the START
"Again \ n" : Speak the voice message
instruction again. Do not speak until 0x43 : Too loud to record
getting the START message 0x44 : voice instruction
"Too loud \ n" : Too loud to record confirming failed. Voice for
"Different \ n" : voice instruction the second chance is different
confirming failed. Voice for the second with the first one.

19
chance is different with the first one. 0x45 : recording one voice
"Finish one \ n" : recording one voice instruction successfully
instruction successfully 0x46 : finish recording group
"Group1 finished! \ n" : finish 1
recording group 1
0x12 Begin to "ERROR! \ n" : Instruction error 0xe0 : Instruction error 0x40 :
record "START \ n" : Ready for recording, you Ready for recording, you can
instructions of can speak now "No voice \ n" : no speak now 0x41 : no voice
group 2 voice detected "Again \ n" : Speak the detected 0x42 : Speak the
voice instruction again. Do not speak voice instruction again. Do not
until getting the START message "Too speak until getting the START
loud \ n" : Too loud to record "Different message 0x43 : Too loud to
\ n" : voice instruction confirming record 0x44 : voice instruction
failed. Voice for the second chance is confirming failed. Voice for
different with the first one. "Finish the second chance is different
one \ n" : recording one voice with the first one. 0x45 :
instruction successfully "Group2 recording one voice
finished! \ n" : finish recording group 2 instruction successfully 0x47 :
finish recording group 2
0x13 Begin to "ERROR! \ n" : Instruction error 0xe0 : Instruction error
record "START \ n" : Ready for recording, you 0x40 : Ready for recording,
instructions of can speak now you can speak now
group 3 "No voice \ n" : no voice detected 0x41 : no voice detected
"Again \ n" : Speak the voice 0x42 : Speak the voice
instruction again. Do not speak until instruction again. Do not
getting the START message speak until getting the START
"Too loud \ n" : Too loud to record message
"Different \ n" : voice instruction 0x43 : Too loud to record
confirming failed. Voice for the second 0x44 : voice instruction
chance is different with the first one. confirming failed. Voice for
"Finish one \ n" : recording one voice the second chance is different
instruction successfully with the first one.
"Group3 finished! \ n" : finish 0x45 : recording one voice
recording group 3 instruction successfully

20
0x48 : finish recording group3
0x21 Import group 1 "Group1 Imported !\n" : Successful 0xcc : Successful 0xe0 :
and be ready "ERROR! \ n" : Instruction error Instruction error 0xe1 :
for voice "Import failed !\n" : Importing voice Importing voice group failed
instruction group failed
0x22 Import group 2 "Group2 Imported !\n" : Successful 0xcc : Successful
and be ready "ERROR! \ n" : Instruction error 0xe0 : Instruction error
for voice "Import failed !\n" : Importing voice 0xe1 : Importing voice group
instruction group failed failed
0x23 Import group 3 "Group3 Imported !\n" : Successful 0xcc : Successful 0xe0 :
and be ready "ERROR! \ n" : Instruction error Instruction error 0xe1 :
for voice "Import failed !\n" : Importing voice Importing voice group failed
instruction group failed
0x24 Query the "Used group:0\n" : No group is 0x00 : No group is recorded
recorded group recorded 0x01 : Group 1 is recorded
"Used group:1\n" : Group 1 is recorded 0x02 : Group 2 is recorded
"Used group:2\n" : Group 2 is recorded 0x04 : Group 3 is recorded
"Used group:3\n" : Group 3 is recorded 0x03 : Group 1 and Group 2
"Used group:12\n" : Group 1 and are recorded
Group 2 are recorded 0x05 : Group 1 and Group 3
"Used group:13\n" : Group 1 and are recorded
Group 3 are recorded 0x06 : Group 2 and Group 3
"Used group:23\n" : Group 2 and are recorded
Group 3 are recorded 0x07 : All the 3 groups are
"Used group:123\n" : All the 3 groups recorded
are recorded 0xe0 : Instruction error
"ERROR! \ n" : Instruction error
0x31 Change the "Baud: 2400\n" : Successful
baud rate to "ERROR! \ n" : Instruction error
2400bps
0x32 Change the "Baud: 4800\n" : Successful
baud rate to "ERROR! \ n" : Instruction error
4800bps
0x33 Change the "Baud: 9600\n" : Successful
baud rate to "ERROR! \ n" : Instruction error
9600bps

21
0x34 Change the "Baud: 19200\n" : Successful
baud rate to "ERROR! \ n" : Instruction error 0xcc : successful 0xe0 :
19200bps Instruction error
0x35 Change the "Baud: 38400\n" : Successful
baud rate to "ERROR! \ n" : Instruction error
38400bps
0x36 Switch to "Common Mode\n" : Successful
Common "ERROR! \ n" : Instruction error
Mode

0x37 Switch to "Compact Mode\n" : Successful


Compact "ERROR! \ n" : Instruction error
Mode
0x41 Reset output of
O1
0x42 Reset output of
O2
0x43 Reset output of
O3
0x44 Reset output of "Ok\n" : Successful 0xcc : successful
O4 "ERROR! \ n" : Instruction error 0xe0 : Instruction error
0x45 Reset output of
O5
0x46 Reset output of
O1~O5
0x50 Set O1~O5 to
Pulse Mode
(negative
pulse)
0x51 Set O1~O5 to
"Ok\n" : Successful 0xcc : successful
Flip Mode
"ERROR! \ n" : Instruction error 0xe0 : Instruction error
0x52 Set O1~O5 to
Down Mode
0x53 Set O1~O5 to
Up Mode
0x60 Set the output
0x61 duty of O1~O5
0x62

22
0x63 in Pulse Mode
0x64 0x60 -- 10ms
0x65
0x61 -- 15ms
0x66
0x62 -- 20ms
0x67
0x68 0x63 -- 25ms
0x69 0x64 -- 30ms
0x6 0x65 -- 50ms "Ok\n" : Successful 0xcc : successful
A 0x66 -- 60ms "ERROR! \ n" : Instruction error 0xe0 : Instruction error
0x6B
0x67 -- 70ms
0x6C
0x68 -- 80ms
0x6
0x69 -- 90ms
D
0x6E 0x6A -- 100ms
0x6F 0x6B -- 200ms

0x6C -- 300ms
0x6D -- 400ms
0x6E -- 500ms
0x6F -- 1s
0x70 Reset Serial
Port to:
9600 baud "Ok\n" : Successful 0xcc : successful
rate, 8 data "ERROR! \ n" : Instruction error 0xe0 : Instruction error
bits, no parity,
1 stop bit
0xbb Query version Version information No respond
information
Table3.2: Commands of voice module V2

The main difference between Compact Mode and Common Mode is the returning
message. Common Mode response is long string but Compact Mode response is a byte. For
example, after sending 0xaa04 to delete all the contents of the 3 groups, in Common Mode it
will return "All Groups Deleted! \ n", but in Compact Mode it will return a concise bytes such
as 0xcc which means a successful operation.

Pulse Mode: Output is negative pulse. The pulse duration time (pulse duty) could be set by
command 0x60 ~ 0x6F

23
Flip Mode: each time while the module recognizes voice command, it will change the state
of the output pin.

Down Mode: The output will become LOW from HIGH once it detects voice command. It
will never come back to HIGH again until the module receives output reset command 0x41 ~
0x46

Up Mode: The output will become HIGH from LOW once it detects voice command. It
will never come back to LOW again until the module receives output reset command 0x41 ~
0x46

For the first-time use, we need to do some configuration:

1. Select the serial baud rate (default 9600)

2. Select the communication mode: Common Mode or Compact Mode

3. Recording five instructions of the first group( or 2nd or 3rd as required)

4. Import the group you need to use (only recognize 5 instructions within one group at the
same time)

After all the setting above, you can speak or send voice instruction to it. If identified
successfully, result will be returned via serial port in the format: group number + command
number. For example, return Result: 11 (Compact mode returns 0x11) means identified the
first command of group 1.

If voice instruction is recorded, each time after you power it on, you need to import
the group before letting it identify voice instructions

3.5.3 LED

3.5.3.1 Recording stage:

1. Record indication: D1 (RED) flashes 3 times within the 600ms, then off for400ms,
and then flashes quickly for 4 times within 600ms. Now the recording indication is
over.

24
2. Begin to speak: D1 (RED) is off for 400ms, and then is on. Voice during the time
while D1 (RED) is on will be recorded by this module.

3. Recording a voice instruction successfully for the first time: D1 (RED) off, D2
(ORANGE) on for 300ms.

4. Recording a voice instruction successfully for the first time: D1 (RED) off, D2
(ORANGE) on for 700ms.

5. Recording failure: D2 (ORANGE) flashes 4 times within the 600ms. In cases that
voice instructions detected twice don’t match, or the sound is too large, or there is no
sound, recording will fail. You need to start over the recording process for that
instruction.

3.5.3.2 Waiting mode:

In waiting mode, D2 (ORANGE) is off, and D1 (RED) is on for 80ms every other 200ms,
fast flashing. In this mode, it doesn’t recognize voice command, only waiting for serial
commands.

3.5.3.3 Recognition stage

In identification stage, D2 (ORANGE) is off, and D1 (RED) is on for 100ms every other
1500ms, slow flashing. In this stage, this module is processing received voice signal, and if
matching, it will send the result immediately via serial port.

3.5.3.4 Recording

Before using it, we have train it by recording voice instructions. Each voice instruction has
the maximum length of 1300ms, which ensures that most words can be recorded. Once you
start recording, you can’t stop the recording process until you finish all the 5 voice
instructions recording of one group. Also, once you start recording, the previous voice
instructions in that group will be erased. In training state, this module doesn’t reply to any
other serial commands.

LED will flash to indicate state. First, you need a serial tool. Here we use AccessPort

Recording Steps are:

25
1. Serial port setting:

 Baud rate: 9600


 Parity bit: None
 Data bit: 8
 Stop bit: 1
 Send format: Hex
 Receive format: Char

2. Send commands

Send: 0xaa11
Receive (in Common Mode):

START
No voice // I did not make any sound. So it replied such message
START
Speak now
Again
START
Speak again now
Different // I spoke another words for the second time. So it replied such message
START
Speak now
Again
START
Speak again now
Finish one // recording one instruction successfully
START
Again
START
Finish one
START
Again
START

26
Finish one
START
Again
START
Finish one
START
Again
START

Finish one

Group1 finished! // recording group 1 successfully

By now, you’ve finished instruction recording for group 1.

3.5.3.5 Recognition

We added another way to import the voice instruction group on V2. For V1, the only way is to
send command to it through serial port, for example:

 Send command 0xAA21 to import group 1.

 Send command 0xAA22 to import group 2.

 Send command 0xAA23 to import group 3.

On V2, we added an easy way to import the group:


Look at the following picture, you could control GCH and GCL pins. Those two pins are all
5V TTL.

GCH GCL Working State


Table3.3: Control of LOW LOW No Change GCH GCL pins
LOW HIGH Import Group 2
Once the group is
HIGH LOW Import Group 1
important, it will output message
HIGH HIGH Import Group 3
through serial port. It could have 15 voice
instructions in 3 groups. Each time you need to import the group before it could recognize
instructions in that group. That means, this module could recognize 5 voice instructions at the
same time. In recognition stage, this module could receive other serial commands. It will not

27
exit the recognition stage until you send 0xAA00, or delete that group, or begin recording
instructions.

3.6 Arm 7 Microcontroller

3.6.1 Introduction:

The ARM was originally developed at Acorn Computers Limited of Cambridge, England,
between 1983 and 1985. It was the first RISC microprocessor developed for commercial use
and has some significant differences from subsequent RISC architectures. In 1990 ARM
Limited was established as a separate company specifically to widen the exploitation of ARM
technology and it is established as a market-leader for low-power and cost-sensitive
embedded applications. The 16-bit CISC microprocessors that were available in 1983 were
slower than standard memory parts. They also had instructions that took many clock cycles to
complete (in some cases, many hundreds of clock cycles), giving them very long interrupt
latencies. As a result of these frustrations with the commercial microprocessor offerings, the
design of a proprietary microprocessor was considered and ARM chip was designed.

3.6.2 ARM 7TDMI-S Processor:

The ARM7TDMI-S processor is a member of the ARM family of general-purpose 32-bit


microprocessors. The ARM family offers high performance for very low-power consumption
and gate count. The ARM7TDMI-S processor has Von Neumann architecture, with a single
32-bit data bus carrying both instructions and data. Only load, store, and swap instructions
can access data from memory. The ARM7TDMI-S processor uses a three stage pipeline to
increase the speed of the flow of instructions to the processor. This enables several operations
to take place simultaneously, and the processing, and memory systems to operate
continuously. In the three-stage pipeline the instructions are executed in three stages.

Figure3.14 Pipelining in ARM7

28
The three stage pipelined architecture of the ARM7 processor is shown in the above figure.

The ARM7TDMI-S processor also employs a unique architectural strategy known as


THUMB, which makes it ideally suited to high-volume applications with memory
restrictions, or applications where code density is an issue.

The key idea behind THUMB is that of a super-reduced instruction set. Essentially, the

ARM7TDMI-S processor has two instruction sets:

• The standard 32-bit ARM instruction set.

• A 16-bit THUMB instruction set.

The THUMB set’s 16-bit instruction length allows it to approach twice the density of
standard ARM code while retaining most of the ARM’s performance advantage over a
traditional 16-bit processor using 16-bit registers. This is possible because THUMB code
operates on the same 32-bit register set as ARM code.

3.6.3 ARM identification

29
Figure3.15: ARM7 identification

3.6.4 Features of Arm Processors

The ARM processors are based on RISC architectures and this architecture has provided
small implementations, and very low power consumption. Implementation size, performance,
and very low power consumption remain the key features in the development of the ARM
devices.

The typical RISC architectural features of ARM are:

30
 A large uniform register file
 A load/store architecture, where data-processing operations only operate on register
contents, not directly on memory contents
 Simple addressing modes, with all load/store addresses being determined from
register contents and instruction fields only uniform and fixed-length instruction
fields, to simplify instruction decode.
 Control over both the Arithmetic Logic Unit (ALU) and shifter in most data-
processing instructions to maximize the use of an ALU and a shifter
 Auto-increment and auto-decrement addressing modes to optimize program loops
 Load and Store Multiple instructions to maximize data throughput
 Conditional execution of almost all instructions to maximize execution throughput.

3.7 LPC 2103


In this project we are using LPC2103. The LPC2103 microcontrollers are based on a 16-
bit/32-bit ARM7TDMI-S CPU with real-time emulation that combines the microcontroller
with 8 kB, 16 kB or 32 kB of embedded high-speed flash memory. A 128-bit wide memory
interface and unique accelerator architecture enable 32-bit code execution at the maximum
clock rate. For critical performance in interrupt service routines and DSP algorithms, this
increases performance up to 30 % over Thumb mode. For critical code size applications, the
alternative 16-bit Thumb mode reduces code by more than 30 % with minimal performance
penalty. Due to their tiny size and low power consumption, the LPC2103 is ideal for
applications where miniaturization is a key requirement

31
3.7.1 Block Diagram

Figure3.16:Block Diagram of LPC2103

32
3.7.2 Pin Diagram

Figure3.17: PIN Diagram of 2103

3.7.3 ARM Registers:

ARM has a total of 37 registers .In which - 31 are general-purpose registers of 32-bits, and
six status registers .But all these registers are not seen at once. The processor state and
operating mode decide which registers are available to the programmer. At any time, among
the 31 general purpose registers only 16 registers are available to the user. The remaining 15
registers are used to speed up exception processing. There are two program status registers:
CPSR and SPSR (the current and saved program status registers, respectively). In ARM state
the registers r0 to r13 are orthogonal—any instruction that you can apply to r0 you can
equally well apply to any of the other registers.

33
The main bank of 16 registers is used by all unprivileged code. These are the User
mode registers. User mode is different from all other modes as it is unprivileged. In addition
to this register bank, there is also one 32-bit Current Program status Register (CPSR)

Figure3.18: Register Bank.

In the 15 registers, the r13 acts as a stack pointer register and r14 acts as a link
register and r15 acts as a program counter register.

Register r13 is the sp register, and it is used to store the address of the stack top. R13
is used by the PUSH and POP instructions in T variants, and by the SRS and RFE
instructions from ARMv6.

Register 14 is the Link Register (LR). This register holds the address of the next
instruction after a Branch and Link (BL or BLX) instruction, which is the instruction used to
make a subroutine call. It is also used for return address information on entry to exception
modes. At all other times, R14 can be used as a general-purpose register.

Registe r 15 is the Program Counter (PC). It can be used in most instructions as


a pointer to the instruction which is two instructions after the instruction being executed.

The remaining 13 registers have no special hardware purpose.

CPSR:

The ARM core uses the CPSR register to monitor and control internal operations. The CPSR
is a dedicated 32-bit register and resides in the register file. The CPSR is divided into four
fields, each of 8 bits wide: flags, status, extension, and control. The extension and status
fields are reserved for future use. The control field contains the processor mode, state, and
interrupts mask bits. The flags field contains the condition flags. The 32-bit CPSR register is
shown below.

34
Figure3.19: Current Program Status Register

3.7.4 Processor Modes:

There are seven processor modes. Six privileged modes abort, fast interrupt request, interrupt
request, supervisor, system, and undefined and one non-privileged mode called user mode.

The processor enters abort mode when there is a failed attempt to access memory.
Fast interrupt request and interrupt request modes correspond to the two interrupt levels
available on the ARM processor. Supervisor mode is the mode that the processor is in after
reset and is generally the mode that an operating system kernel operates in. System mode is a
special version of user mode that allows full read-write access to the CPSR. Undefined mode
is used when the processor encounters an instruction that is undefined or not supported by the
implementation. User mode is used for programs and applications.

3.7.5 PIPELINE:

Pipeline is the mechanism used by the RISC processor to execute instructions at an increased
speed. This pipeline speeds up execution by fetching the next instruction while other
instructions are being decoded and executed.The ARM7 processor has a three stage
pipelining architecture namely Fetch, Decode and Execute. The three stage pipelining is
explained as below.

35
Figure3.20 Pipe line in ARM7

As the pipeline length increases, the amount of work done at each stage is reduced,
which allows the processor to attain a higher operating frequency. This in turn increases the
performance.

3.8 Motor Driver

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 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.

Turning a motor ON and OFF requires only one switch to control a single motor in a
single direction. What if we want to reverse its direction is to reverse its polarity. This can be
achieved by using four switches that are arranged in an intelligent 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 a H-bridge circuit where transistors are arranged in a shape that
resembles the English alphabet "H"

As you can see in the image, 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. So, do not attempt this.

36
Figure3.21 H Bridge of l293d

3.8.1 Introduction to L293D

Figure3.22 PIN Diagram of L293D

3.8.2 Features

 Wide Supply-Voltage Range: 4.5 V to 36 V


 Separate Input-Logic Supply
 Internal ESD Protection
 Thermal Shutdown
 High-Noise-Immunity Inputs
 Functionally Similar to SGS L293 and SGS L293D
 Output Current 1 A Per Channel (600 mA for L293D)
 Peak Output Current 2 A Per Channel (1.2 A for L293D)
 Output Clamp Diodes for Inductive Transient Suppression (L293D)

37
 Output current capability is limited to 600mA per channel with peak output current
limited to 1.2A

3.8.3 Working of L293D

There are 4 input pins for l293d, pin 2,7 on the left and pin 15 ,10 on the right as shown on
the pin diagram. Left input pins will regulate the rotation of motor connected across left side
and right input for motor on the right hand side. The motors are rotated on the basis of the
inputs provided across the input pins as LOGIC 0 or LOGIC 1.

DIRECTION RIGHT MOTOR LEFT MOTOR

FORWARD ON(C) ON(C)


BACKWARD ON(AC) ON(AC)
RIGHT OFF ON(C)

LEFT ON(C) OFF

Figure3.23 : Function table of L239D

3.9Relays

Relays are electromechanical switches, used to control the several circuits by using low-
power signal or one signal. These are found in all sorts of devices. Relays allow one circuit to
switch a second circuit which can be completely separate from the first. There is no electrical
connection inside the relay between the two circuits; the link is magnetic and mechanical
only.

38
Figure3.24: Pin Diagram of Relay

Basically a Relay consists of an electromagnet, an armature, a spring and a series of


electrical contacts. The electromagnet coil gets power through a switch or a relay driver and
causes the armature to get connected such that the load gets the power supply. The armature
movement is done using a spring. Thus the relay consists of two separate electrical circuits
which are connected to each other only through magnetic connection and the relay is
controlled by controlling the switching of the electromagnet

3.9.1 Working of the Relay System

The relay driver can drive up to 7 relays with each relay connected to each of the 7 outputs.
The input pins of the relay are connected to the I/O pins of the Microcontroller. Here only one
relay is shown for demonstration purpose. The relay as well as the relay driver requires a
power supply of 12 V at pin 9. The operation is similar to an inverter where a logic low input
results in a logic high output. The load is connected to the normally open contact. When a
logic zero is applied to one of the input pin of the relay driver, a logic high output is
developed across the corresponding output pin. Since the relay is connected to almost same
voltage at both of the end points, no current flows and the relay is not energized. Incase of a
high logic at the input pin, the output pin

39
Figure3.25: Working Diagram of relay

gets a low logic signal and due to a potential difference, a current flows and the relay coil gets
energized such that it causes the armature to move from the normally closed position to the
normally open position , thus completing the circuit and causing the lamp to glow.

3.10 Motors

Gear motors are complete motive force systems consisting of an electric motor and a
reduction gear train integrated into one easy-to-mount and -configure package. This greatly
reduces the complexity and cost of designing and constructing power tools, machines and
appliances calling for high torque at relatively low shaft speed or RPM. Gear motors allow
the use of economical low-horsepower motors to provide great motive force at low speed
such as in lifts, winches, medical tables, jacks and robotics. They can be large enough to lift a
building or small enough to drive a tiny clock

Figure3.26: Dc Gear Motor 12V High Torque

Operating Principle of Gear motor


Most synchronous AC electric motors have output ranges of from 1,200 to 3,600 revolutions
per minute. They also have both normal speed and stall-speed torque specifications. The
reduction gear trains used in gear motors are designed to reduce the output speed while

40
increasing the torque. The increase in torque is inversely proportional to the reduction in
speed. Reduction gearing allows small electric motors to move large driven loads, although
more slowly than larger electric motors. Reduction gears consist of a small gear driving a
larger gear. There may be several sets of these reduction gear sets in a reduction gear box.

Figure3.27:Gear Motor Working


Toothed wheel that transmits the turning movement of one shaft to another shaft. Gear
wheels may be used in pairs or in threes if both shafts are to turn in the same direction. The
gear ratio – the ratio of the number of teeth on the two wheels – determines the torque ratio,
the turning force on the output shaft compared with the turning force on the input shaft. The
ratio of the angular velocities of the shafts is the inverse of the gear ratio.
The common type of gear for parallel shafts is the spur gear, with straight teeth parallel to the
shaft axis. The helical gear has teeth cut along sections of a helix or corkscrew shape; the
double form of the helix gear is the most efficient for energy transfer. Bevel gears, with
tapering teeth set on the base of a cone, are used to connect intersecting shafts.

Figure3.28: Operation of Gear motor

41
The toothed and interlocking wheels which make up a typical gear movement. Gear
ratio is calculated by dividing the number of teeth on the driver gear by the number of teeth
on the driven gear (gear ratio = driver/driven); the idler gears are ignored. Idler gears change
the direction of rotation but do not affect speed. A high driven to driver ratio (middle) is a
speed-reducing ratio.Different gears are used to perform different engineering functions
depending on the change in direction of motion that is needed. Rack and pinion gears are the
commonest gears and are used in car steering mechanics.

Speed Reduction

Sometimes the goal of using a gear motor is to reduce the rotating shaft speed of a motor in
the device being driven, such as in a small electric clock where the tiny synchronous motor
may be spinning at 1,200 rpm but is reduced to one rpm to drive the second hand, and further
reduced in the clock mechanism to drive the minute and hours hand. Here the amount of
driving force is irrelevant as long as it is sufficient to overcome the frictional effects of the
clock mechanism.

Torque Multiplication

Another goal achievable with a gear motor is to use a small motor to generate a very large
force albeit at a low speed. These applications include the lifting mechanisms on hospital
beds, power recliners, and heavy machine lifts where the great force at low speed is the goal.

3.11 Wheelchair

Wheelchair used in this project is galvanized steel chair. It consists of two major wheels
made-up of with steel and two supporting wheels made up of with hard plastic. In this set up
the two major wheels support the motion of chair and bear the weight of the person who is
using it. The two plastic wheels are for direction changing purpose.

Figure 3.29: Operation of Gear motor

42
In this wheel chair setup gear motors are connected to wheels through gears. These gears are
made with iron and differ in diameter. Larger gear consists of 86 teeth and smaller one
consists of 8 teeth.

3.12 Schematic diagram

The schematic diagram for the MEMS and voice controlled wheel chair is as follows

Figure 3.30: Schematic diagram

43
3.13 Conclusion

In this chapter we had discussed the hardware components and interconnection of all the
components present in circuitry

44
Chapter 4
Code Implementation

4.1 Introduction

The software used to implement this project is KEIL SOFTWARE. Keil Software provides us
with software development tools for PIC16F877A based microcontrollers. With the Keil
tools, we can generate embedded applications for virtually every PIC16F877A derivative.

The software used to implement this project is KEIL SOFTWARE. Keil Software provides us
with software development tools for PIC16F877A based microcontrollers. With the Keil
tools, we can generate embedded applications for virtually every PIC16F877A derivative.

4.2 Kiel Software

It is possible to create the source files in a text editor such as Notepad, run the Compiler on
each C source file, specifying a list of controls, run the Assembler on each Assembler source
file, specifying another list of controls, run either the Library Manager or Linker (again
specifying a list of controls) and finally running the Object-HEX Converter to convert the
Linker output file to an Intel Hex File. Once that has been completed the Hex File can be
downloaded to the target hardware and debugged. Alternatively KEIL can be used to create
source files; automatically compile, link and covert using options set with an easy to use user
interface and finally simulate or perform debugging on the hardware with access to C
variables and memory. Unless you have to use the tolls on the command line, the choice is
clear. KEIL Greatly simplifies the process of creating and testing an embedded application.

4.3 Use of Keil in Projects

The user of KEIL centers on projects. A project is a list of all the source files required to build
a single application, all the tool options which specify exactly how to build the application,
and – if required – how the application should be simulated. A project contains enough
information to take a set of source files and generate exactly the binary code required for the
application. Because of the high degree of flexibility required from the tools, there are many
options that can be set to conFigure the tools to operate in a specific manner. It would be
tedious to have to set these options up every time the application is being built; therefore they
are stored in a project file. Loading the project file into KEIL informs KEIL which source

45
files are required, where they are, and how to conFigure the tools in the correct way. KEIL
can then execute each tool with the correct options. It is also possible to create new projects
in KEIL. Source files are added to the project and the tool options are set as required. The
project can then be saved to preserve the settings. The project is reloaded and the simulator or
debugger started, all the desired windows are opened. KEIL project files have the extension.

4.4 Simulation

The simulator/ debugger in KEIL can perform a very detailed simulation of a processor along
with external signals. It is possible to view the precise execution time of a single assembly
instruction, or a single line of C code, all the way up to the entire application, simply by
entering the crystal frequency. A window can be opened for each peripheral on the device,
showing the state of the peripheral. This enables quick trouble shooting of mis-conFigured
peripherals. Breakpoints may be set on either assembly instructions or lines of C code, and
execution may be stepped through one instruction or C line at a time. The contents of all the
memory areas may be viewed along with ability to find specific variables. In addition the
registers may be viewed allowing a detailed view of what the microcontroller is doing at any
point in time.

4.5Working with Kiel software


1. Click on the Keil u Vision4 Icon on Desktop
2. Click on the Project menu from the title bar
3. Then Click on New Project

46
Figure 4.1: Selection of new project

4. Save the Project by typing suitable project name with no extension in your own folder sited
in either C:\ or D:\

6. Then Click on save button above.

7. Select the component for your project. i.e.NXP……

8.Click on the + Symbol beside of NXP

47
Figure 4.2: Selection of Vendor of controller

9. Select LM2310

10. Then Click on OK

11. Now your project is ready to USE

12. Now double click on the Target1, you would get another option Source group 1

13. Click on the file option from menu bar and select new

Figure 4.3: Selection of new work space

14. The next screen will be as shown in next page, and just maximize it by double clicking on
its blue boarder.

48
15.Now start writing program in either in C or ASM

Figure 4.4: Work Space

14. For a program written in Assembly, then save it with extension (. Asm) and for C based program

Figure 4.5: Save as popup window

15. Now right click on Source group 1 and click on “Add files to Group Source”

49
Figure 4.6: Adding files to target

16. Now you will get another window, on which by default C files will appear

Figure 4.7: Selecting created file

17. Now select as per your file extension given while saving the file

18. Click only one time on option ADD

19. Now Press function key F7 to compile. Any error will appear if so happen.

50
Figure 4.8: Compilation

20. If the file contains no error, then press Control+F5 simultaneously.

21. The new window is as follows

Figure 4.9: Running code size

22. Then Click OK

51
23. Now click on the Peripherals from menu bar, and check your required port as shown in
fig below

Figure 4.10: Selecting resultant ports

24. Drag the port a side and click in the program file.

Figure 4.11: Checking Program with ports

25. Now keep Pressing function key F11 slowly and observe.

52
26. You are running your program successfully.

4.6 Proteus

ISIS provides the development environment for PROTEUS VSM, our revolutionary
interactive system level simulator. This software combines mixed mode circuit simulation,
micro-processor models and interactive component models to allow the simulation of
complete micro-controller based designs. ISIS provides the means to enter the design in the
first place, the architecture for real time interactive simulation and a system for managing the
source and object code associated with each project. In addition, a number of graph objects
can be placed on the schematic to enable conventional time, frequency and swept variable
simulation to be performed.

Major features of PROTEUS VSM include:

1. CPU Models available for popular microcontrollers such as the PIC.

2. Interactive peripheral models include LED and LCD displays, a universal matrix keypad,
an RS232 terminal and a whole library of switches, pots, lamps, LEDs etc.

4.5.1 Procedure
Creating the circuit diagram using Proteus.

1. Open Proteus by clicking

Start > All Program > Proteus 8Professional > ISIS 8 Professional.

Figure 4.12: Opening Proteus

2. Proteus work area will appear and Select button “P”as shown below

53
Figure 4.13: Component Selection

3. A window in Figure 3 will appear.

Figure 4.14: Choosing required component

4. Type the component name at keyword list box. Click OK button at the bottom right.
Repeat this step to select the components needed.

At the keyword list type the components name such as below:

1. LM2310

54
2. RES (R1=330Ω, R2=4.7k Ω and R3=4.7k)
3. LED-RED
4. BUTTON (SW1, SW RESET)
5. CRYSTAL (X1=20MHz)
6. CAP (C1= 22pF, C2= 22pF)
5. Select instruction bellows and double click your left mouse to input components inside
category window

6. Drag and drop components by clicking at “DEVICES” window to working window

7. Double click at components to change the value

8. Right click mouse and select properties for rotate the components to your suitable positions

9. Connect and wiring all components

10. Click “Terminals Mode” button to input ‘POWER’ and ‘GROUND’ to your working space

Figure 4.15: Selecting Power source

11. Arrange your components to suitable position and completed your work with the correct
connections

12. Save your project in your own folder by select FILE>SAVE DESIGN AS

13. Extractthe Hex file by double clicking the IC

55
Figure 4.16: Loading HEX file

14. Click DEBUG>EXECUTE to simulate your program and click


DEBUG>STOPANIMATIONto stop the program. From your window project, you
cananimate your program by clicking suitable button

4.17: Simulation buttons

4.7 Algorithm

Step 1: Reset the Controller

Step2: initialize the sensor and driver ports

Step3: Determine the Mode of operation

If the source is MEMS then go to Step 9

Else

Go to Step 4

Step 4: Fix The audio Signal Threshold value

Apply the Global Threshold value.

Release the voice command

If the Command is Front

then Go to Step 5

56
Step 5: compare the threshold value of the audio input

If

the Audio Signal level is above the threshold value

Then

Enable the L293d driver to move the wheel chair until further command is received .

Step6: If the Command is back

then Go to Step5

Step 7: If The Command is right

then go to step5

Step 8: Go to Step 3

Step 9: read the signal from the MEMS Sensor

If

the X,Y,Z Axis positions are forward

Then enable the motor drivers to move until further commands received.

else

Go to next Step.

Step10: Read the Signal from the Mems Sensor

If

the X,Y,Z Axis positions are backward

Then enable the motor drivers to move until further commands received.

else

Go to next Step.

Step11: read the Mems sensor

57
If

the X,Y,Z Axis positions are stop

Then enable the motor drivers to move until further commands received.

else

Go to next Step.

Step12: Read the MEMS sensor

If

the X,Y,Z Axis positions are clockwise

Then enable the motor drivers to move until further commands received.

else

Go to next Step.

Step13: read the MEMS Sensor

If

the X,Y,Z Axis positions are anti clockwise

Then enable the motor drivers to move until further commands received.

else

Go to step3.

4.8. Conclusion.

In this chapter we are discussing about the software used to implement the project that is keil
Software, Embedded C programming for communication of the data, Proteus 8.1 features and
Algorithm of the report.

58
Chapter 5

5.1 Results and Discussion

The working model is developed for physically challenged personalities. The experiments
were conducted with MEMS accelerometer sensor to drive the wheel chair in all directions.
In order to move the wheel chair, MEMS module and Voice recognition module must be
initiated first. Fig 5.1 and Fig 5.2 represents the initialization of the MEMS and VOICE
modules. The wheel chair is able to drive forward, backward, right and left directions by
tilting the axis of the MEMS sensor. While driving the wheel chair with MEMS the voice
module is to be kept in standby mode even though it is enabled. Fig 5.3 and Fig 5.4
represents the forward and backward direction movements of the wheel chair. Fig 5.5 and
Fig 5.6 represents the left and right directions of the wheel chair movements. By keeping the
voice module in standby mode the wheel chair motion control is tested with varying load
conditions. With no load the acceleration and response of the device is significantly good.
100 rpm D.C motors are used to drive the wheel chair. With increasing the load the motion of
the wheel chair is significantly reduced. By considering the geared motor with high torque,
the proto type model wheelchair can be implemented for real time applications.

The Voice operated wheel chair is tested by keeping the MEMS Sensor position
Constant. Any tilt in the MEMS accelerometer sensor cause to enable the wheel chair
movements. Since the device is powered with both MEMS and Voice based devices the
MEMS Sensor should be positioned in a fixed surface with Zero Tilt angle. Then based on
the voice commands the developed wheel chair will respond to move in respective positions.
Fig 5.7, Fig.5.8, Fig 5.9, fig 5.10 represents the received command status of the wheel chair
for forward, backward, Left and right direction movements of the wheel Chair. The
command 1 is equated for forward direction. Command 2 is equated for back ward direction,
Command 3 is equated for left direction and command ‘4’ is equated for right direction.
Command ‘5’ is used for Stop the wheel chair motion.

The experiments were conducted repeatedly to meet the challenges and desired
positional directions. It has been observed that the proposed model response is favorably

59
good with both MEMS and Voice devices. The Base of the Voice input signal is
comparatively synchronized with the pre loaded voice base. It has been observed that Voice
Module ‘V2 ‘ is an optimum choice for voice operated Wheel chair for Physically challenged
Personalities. The Directional Control logic levels applied for the wheel chair with four D.C
motors represented in table 5.1.

FIGURE 5.1 MEMS initializing FIGURE 5.2 Voice module initializing

The proposed wheel chair moves in the respective direction based upon the direction of tilting
the MEMS sensor.

FIGURE 5.3 MEMS tilted forward FIGURE 5.4 MEMS tilted backward

60
FIGURE 5.5: MEMS tilted left FIGURE 5.6: MEMS tilted right

While moving the wheel chair with voice recognition module, it moves in the direction
respective to the voice commands.

Figure 5.7 Voice command for FRONT


Figure 5.8 Voice command for BACK

61
Figure 5.9 Voice command for LEFT
Figure 5.10 Voice command for RIGHT

The movement of the hand is sensed by the MEMS sensor and the corresponding
signal based on the angle of elevation is sent to the micro controller. The signal is
processed in the micro controller and corresponding directions are given to the motors.

Specifications/Directions Forward Backward Right Turn Left Turn

Common 1(IN-1)
Left motor +Ve(Blue 1 0 1 0
Wire) –Yellow LED (High) (Low) (High) (Low)

Common 2(IN-2)
Left motor -Ve(Violet 0 1 0 1
Wire) –Green LED (Low) (High) (Low) (High)

Common 3(IN-3)
Right motor +Ve(Blue 1 0 0 1
Wire) –Yellow LED (High) (Low) (Low) (High)

Common 4(IN-4)
Right motor -Ve(Violet 0 1 1 0
Wire) –Yellow LED (Low) (High) (High) (Low)

Table 5.1: Relay Board Input-Output Combinations

62
If the angle of elevation is towards forward direction then the wheel chair moves in
forward direction. Similarly if the angle of elevation is towards left, right then the wheel chair
moves in the left, right directions respectively. The movement of wheelchair wheels, are as
follows

COMMAND DIRECTION RIGHTMOTOR LEFTMOTOR

FRONT FORWARD CLOCKWISE CLOCKWISE

BACK BACKWARD ANTICLOCKWISE ANTICLOCKWISE

RIGHT RIGHT OFF CLOCKWISE

LEFT LEFT CLOCKWISE OFF

TABLE 5.2 Movement of wheels using voice module

5.2 Conclusion

In this chapter we had discuss the result and the directional outcome of the automatic wheel
chair. This study also analyzed how the wheel chair moves in the respective positions based
on the sensed outputs of MEMS Accelerometer sensor and Voce recognition module. The
next chapter will discuss the conclusions of the thesis report.

Chapter 6

Conclusion

Considering the intensity levels of the technology support to the physically challenged
personalities the developed working model is tested with voice and MEMS based

63
accelerometer sensor. This study is focused to develop a user friendly device for both visually
imperative and physically dumb persons. The results harvested with the proposed model are
favorably impressive to meet the challenges identified in the chapter 1. The loading capacity
of the 100 rpm D.C motors is not supportive drive the heavy load torques.

This project is a user friendly device which is also a powerful tool to the physically
challenged people. It enables to carry out their own actions by themselves. This model the
replaced the human assistance accordingly. The result harvested clearly exhibits that the
proposed system is easy to operate by the patients. This chair can move forward, backward,
right and left directions by tilting the angle of the MEMS sensor which is attached to the hand
or head and mostly with voice recognition module.

In future the developed model is implemented for real time applications by selecting
the high torque geared motors to reach the demands of the society. The position and the state
wheel chair is to be monitored by imparting the internet of things. And also this model can be
further enhanced with Global system for Mobile Communication (GSM) module, housed
with the wheel chair for transmitting the state to the supervising locations.

64
References
References
[1] Rakhi A. Kalantri., D.K. Chitre., “ Automatic Wheelchair using Gesture Recognition”,
International Journal of Engineering and Innovative Technology (IJEIT), Vol 2,No.
9,pp.216218, March 2013.

[2] Pei Jia., Huosheng H. Hu., Tao Lu., Kui Yuan., “ Head gesture recognition for hands-free
control of an intelligent wheelchair” , An International Journal on Industrial Robot, Vol 34,
No.1, pp.60-68, 2007 .

[3] Javajji Veeraiah., P.V.N Aravind Syam,. N. Naga Durga., K. Ravi Kanth., G. Vasudha,
“Accelerometer Based Gesture Recognisation for Wheel Chair Direction Control Using
ZIGBEE Protocol”, International Journal of Technological Exploration and Learning (IJTEL),
Vol. 2, No. 2,pp.104-108, April 2013.

[4] Rajesh Kannan Megalingam., Athul Asokan Thulasi., Rithun Raj Krishna., “Methods of
Wheelchair Navigation: Novel Gesture Recognition Method”, International Journal of Applied
Engineering Research, Vol.7 No.11,pp.1-5, 2012.

[5] Moniruzzaman Bhuiyan., Rich Picking., “A Gesture Controlled User Interface For Inclusive
Design And Evaluation Study Of Its Usability”, Journal Of Software Engineering And
Applications,Vol.4,No.9,pp.513-521,September 2011.

[6] Chao Wang., Alexey S., Matveev., Andrey V. Savkin., Tuan Nghia Nguyen., Hung T.
Nguyen., “A Collision Avoidance Strategy for Safe Autonomous Navigation of an Intelligent
ElectricPowered Wheelchair in Dynamic Uncertain Environments with Moving Obstacles” ,
2013 European Control Conference (ECC) , Zürich, Switzerland,pp.4382-4387,17-19 July
2013.

[7]Shreedeep Gangopadhyay., Somsubra Mukherjee., Soumya Chatterjee., “Intelligent


Gesture Controlled Wireless Wheelchair For The Physically Handicapped”, Proceedings of
Fifth IRAJ International Conference, Pune, India,Vol.1,No.7,pp.47-52, 15 September 2013.

[8] K. Sudheer., T.V. Janardhan Rao., CH. Srivedi., M.S. Madhan Mohan., “ Voice and
Gesture Based Electric-Powered Wheelchair Using ARM”, International Journal of Research

65
in Computer and Communication technology, IJRCCT, Vol 1, No. 6,pp.278-283, November
2012.

[9] S.Shaheen., A.Umakeswari., “ Intelligent Wheelchair For People With Disabilities”,


International Journal of Engineering and Technology (IJET),Vol.5,No.1,pp.391-397,Feb-Mar
2013.

[10] Lincoln A. Jaros Richard C. Simpson Yoram Koren Senior Member IEEE Simon P. Levine,
David A. Bell and IEEEi Johann Borenstein, Member, “The navchair assistive wheelchair
navigation system,” IEEE TRANSACTIONS ON REHABILITATION ENGINEERING, 1999.

[11] Mahaboob Ali Shaik M.Prathyusha, K. S. Roy, “Voice and touch screen based direction
and speed control of wheel chair for physically challenged using arduino,”.

[12] K. Sudheer ,et al, International Journal of Research in Computer and Communication
technology, IJRCCT, ISSN 2278-5841, Vol 1, Issue 6, November 2012 , “Voice and Gesture
Based Electric-Powered Wheelchair Using ARM”.

[13] Automatic Wheelchair using Gesture Recognition Along with Room Automation

66
Appendix

The program code which is dumped in the microcontroller of our project is shown below.

SOURCE CODE:

#include<LPC2103.H>

#include<string.h>

#define GPIO_Port0s_IODIR IODIR

#define Set_Port0s IOSET

#define Clear_Port0s IOCLR

#define Port0_Set IOPIN

#define Restg 0

#define Restd 1

#define BMotor_left_frwd (1<<24)

#define BMotor_left_bkwd (1<<25) // (0xFFFFFFFF)<<31

#define BMotor_right_frwd (1<<26)

#define BMotor_right_bkwd (1<<27)

67
#define Robot_Motors (BMotor_left_frwd|BMotor_left_bkwd |BMotor_right_frwd|
BMotor_right_bkwd)

#define RF_bit1 (1<<16)

#define RF_bit2 (1<<17) //port0

#define RF_bit4 (1<<18)

#define RF_bit8 (1<<19)

#define RF_Data (RF_bit1|RF_bit2|RF_bit4|RF_bit8)

/************ Mode Leds P0-21,22,23*****************/

#define M1_Led (1<<21)

#define M2_Led (1<<22)

#define M3_Led (1<<23)

#define Mode_Leds (M1_Led|M2_Led|M3_Led)

/**************************************************/

68
/* Mode Pin- P0.15 Int 0*/

#include "external_int.c"

#include "I2C.c"

#include "robo.c"

//#include "rtc.c"

int PinStatus_Port(unsigned char ,unsigned int);

void Robo_Movements(void);

void LCD_Lable_display(void);

void Motor_Init(void);

unsigned char x;

//unsigned char LCD_CLEAR=0X01;

69
main()

//GPIO_Port1s_IODIR =(Robot_Motors); //output=1 // input=0

GPIO_Port0s_IODIR =(RF_Data|Mode_Leds|Robot_Motors);

Set_Port0s=M1_Led;

Set_Port0s=M2_Led;

Set_Port0s=M3_Led;

Motor_Init();

//ADC0_Init();

//Init_ExInt2_Interrupt_P0_15();

I2C_Init();

MEMS_Init();

while(1)

//if(Mode_select==1)

70
//{

Wheel_Chair_M1();

//}

/*

if(Mode_select==2)

{ */

//RF_Device_M2();

/*

if(Mode_select==3)

Voice_M3();

*/

71
PinStatus_Port(unsigned char port,unsigned int pin)

if(port==0)

x=(Port0_Set& (1<<pin))?1:0;

return x;

int PinStatus_Port(unsigned char ,unsigned int);

void RF_Device_M2(void);

void Voice_M3(void);

void Wheel_Chair_M1(void);

void Robot_Values(void);

void Mems_X_Y_Getdata(void);

unsigned int r,X_value,Y_value;

float ADC_VALUE;

void Motor_Init(void)

72
Set_Port0s=BMotor_left_frwd;

Clear_Port0s=BMotor_left_bkwd;

Set_Port0s=BMotor_right_frwd;

Clear_Port0s=BMotor_right_bkwd;

Delay(400);

Clear_Port0s=BMotor_left_frwd;

Clear_Port0s=BMotor_left_bkwd;

Clear_Port0s=BMotor_right_frwd;

Clear_Port0s=BMotor_right_bkwd;

void Wheel_Chair_M1(void)

Reading_X_Y_Z_MEMS();

73
//"ROBO Moving Forward \r\n");

// //x y

//void XY_Directions(unsigned char f_b,unsigned char l_r)

//{

if((x>15&&x<25))

Set_Port0s=BMotor_left_frwd;

Clear_Port0s=BMotor_left_bkwd;

Set_Port0s=BMotor_right_frwd;

Clear_Port0s=BMotor_right_bkwd;

Delay(200);

Clear_Port0s=BMotor_left_frwd;

Clear_Port0s=BMotor_left_bkwd;

Clear_Port0s=BMotor_right_frwd;

Clear_Port0s=BMotor_right_bkwd;

74
//Set_Port0s=RF_bit1;

//Clear_Port0s=RF_bit2;

//Clear_Port0s=RF_bit4;

//Clear_Port0s=RF_bit8;

//Delay(100);

//Clear_Port0s=RF_bit1;

//Clear_Port0s=RF_bit2;

//Clear_Port0s=RF_bit4;

//Clear_Port0s=RF_bit8;

if(x<55&&x>45)

//Set_Port0s=RF_bit1;

//Clear_Port0s=RF_bit2;

//Clear_Port0s=RF_bit4;

//Clear_Port0s=RF_bit8;

//Delay(100);

//Clear_Port0s=RF_bit1;

//Clear_Port0s=RF_bit2;

//Clear_Port0s=RF_bit4;

75
//Clear_Port0s=RF_bit8;

Clear_Port0s=BMotor_left_frwd;

Set_Port0s=BMotor_left_bkwd;

//BACKWARD

Clear_Port0s=BMotor_right_frwd;

Set_Port0s=BMotor_right_bkwd;

Delay(200);

Clear_Port0s=BMotor_left_frwd;

Clear_Port0s=BMotor_left_bkwd;

Clear_Port0s=BMotor_right_frwd;

Clear_Port0s=BMotor_right_bkwd;

if(y>15&&y<25)

//Set_Port0s=RF_bit1;

//Clear_Port0s=RF_bit2;

76
//Clear_Port0s=RF_bit4;

//Clear_Port0s=RF_bit8;

//Delay(100);

//Clear_Port0s=RF_bit1;

//Clear_Port0s=RF_bit2;

//Clear_Port0s=RF_bit4;

//Clear_Port0s=RF_bit8;

Clear_Port0s=BMotor_left_frwd;

Set_Port0s=BMotor_left_bkwd;

Set_Port0s=BMotor_right_frwd;

Clear_Port0s=BMotor_right_bkwd;

Delay(200);

Clear_Port0s=BMotor_left_frwd;

Clear_Port0s=BMotor_left_bkwd;

Clear_Port0s=BMotor_right_frwd;

Clear_Port0s=BMotor_right_bkwd; //LEFT

77
}

if(y<55&&y>45)

Set_Port0s=BMotor_left_frwd;

Clear_Port0s=BMotor_left_bkwd;

Clear_Port0s=BMotor_right_frwd;

Set_Port0s=BMotor_right_bkwd;

Delay(200);

Clear_Port0s=BMotor_left_frwd;

Clear_Port0s=BMotor_left_bkwd;

Clear_Port0s=BMotor_right_frwd;

Clear_Port0s=BMotor_right_bkwd;

//Set_Port0s=RF_bit1;

//Clear_Port0s=RF_bit2;

//Clear_Port0s=RF_bit4;

//Clear_Port0s=RF_bit8;

//Delay(100);

//Clear_Port0s=RF_bit1;

78
//Clear_Port0s=RF_bit2;

//Clear_Port0s=RF_bit4;

//Clear_Port0s=RF_bit8;

void RF_Device_M2(void)

Reading_X_Y_Z_MEMS();

//"ROBO Moving Forward \r\n");

//

if((x>15&&x<25))

Set_Port0s=RF_bit1;

Clear_Port0s=RF_bit2;

79
Clear_Port0s=RF_bit4;

Clear_Port0s=RF_bit8;

Delay(100);

Clear_Port0s=RF_bit1;

Clear_Port0s=RF_bit2;

Clear_Port0s=RF_bit4;

Clear_Port0s=RF_bit8;

if(x<55&&x>45)

Clear_Port0s=RF_bit1;

Set_Port0s=RF_bit2;

Clear_Port0s=RF_bit4;

Clear_Port0s=RF_bit8;

Delay(100);

Clear_Port0s=RF_bit1;

Clear_Port0s=RF_bit2;

Clear_Port0s=RF_bit4;

Clear_Port0s=RF_bit8;

80
}

if(y>15&&y<25)

Set_Port0s=RF_bit1;

Set_Port0s=RF_bit2;

Clear_Port0s=RF_bit4;

Clear_Port0s=RF_bit8;

Delay(100);

Clear_Port0s=RF_bit1;

Clear_Port0s=RF_bit2;

Clear_Port0s=RF_bit4;

Clear_Port0s=RF_bit8; //LEFT

if(y<55&&y>45)

Clear_Port0s=RF_bit1;

Clear_Port0s=RF_bit2;

81
Set_Port0s=RF_bit4;

Clear_Port0s=RF_bit8;

Delay(100);

Clear_Port0s=RF_bit1;

Clear_Port0s=RF_bit2;

Clear_Port0s=RF_bit4;

Clear_Port0s=RF_bit8;

void Voice_M3(void)

Reading_X_Y_Z_MEMS();

//"ROBO Moving Forward \r\n");

//

if((x>15&&x<25))

Set_Port0s=RF_bit1;

82
Clear_Port0s=RF_bit2;

Set_Port0s=RF_bit4;

Clear_Port0s=RF_bit8;

Delay(100);

Clear_Port0s=RF_bit1;

Clear_Port0s=RF_bit2;

Clear_Port0s=RF_bit4;

Clear_Port0s=RF_bit8;

if(x<55&&x>45)

Clear_Port0s=RF_bit1;

Set_Port0s=RF_bit2;

Set_Port0s=RF_bit4;

Clear_Port0s=RF_bit8;

Delay(100);

Clear_Port0s=RF_bit1;

Clear_Port0s=RF_bit2;

Clear_Port0s=RF_bit4;

Clear_Port0s=RF_bit8;

83
if(y>15&&y<25)

Set_Port0s=RF_bit1;

Set_Port0s=RF_bit2;

Set_Port0s=RF_bit4;

Clear_Port0s=RF_bit8;

Delay(100);

Clear_Port0s=RF_bit1;

Clear_Port0s=RF_bit2;

Clear_Port0s=RF_bit4;

Clear_Port0s=RF_bit8; //LEFT

#define SlaAdd_RD 0X99 // 0X4C+1

#define SlaAdd_WR 0X98 // 0X4C+0

#define X_add 0X00

#define Y_add 0X01

#define Z_add 0X02

#define TILT 0x03

#define SRST 0x04

#define SPCNT 0x05

#define INTSU 0x06

84
#define MODE 0x07

#define SR 0x08

#define PDET 0x09

#define PD 0x0A

#define All_Flags_Clr 0x6c

#define ENB_I2C 6

#define Start_I2C 5

#define Stop_I2C 4

#define INTR_I2C 3

#define ACK 2

//#define BMotor_left_frwd (1<<28)

//#define BMotor_left_bkwd (1<<29)

//#define BMotor_right_frwd (1<<26)

//#define BMotor_right_bkwd (1<<27)

85
void I2C_Init(void);

void I2C_Write(unsigned char wr_Data[]);

void I2C_Read(void);

void MEMS_Init(void);

void WrByte_MEMS(unsigned char,unsigned char);

void WrData_MEMS(unsigned char);

char RrByte_MEMS(unsigned char);

char RdData_MEMS(void);

void Reading_X_Y_Z_MEMS(void);

void XY_Directions(unsigned char,unsigned char);

//-------------------------------------------------------------------------

//-------------------------------------------------------------------------

unsigned char Data,x,y,z;

/******************************************************/

86
void I2C_Init(void)

PINSEL0 = 0x00000050;

I2C0SCLH=62;

I2C0SCLL=62;

I2C0CONCLR=All_Flags_Clr;

void Start(void)

I2C0CONCLR=All_Flags_Clr;

I2C0CONSET=(1<<ENB_I2C);

I2C0CONSET=(1<<Start_I2C);

void Stop(void)

I2C0CONCLR=(1<<INTR_I2C);

I2C0CONSET=(1<<Stop_I2C);

void MEMS_Init(void)

87
//Lcd_Data_Str(1,1,"Mem initing ");

Clear_Port0s=M1_Led;

Clear_Port0s=M2_Led;

Clear_Port0s=M3_Led;

WrByte_MEMS(MODE,0x00);

WrByte_MEMS(SPCNT,0x00);

//Lcd_Data_Str(1,12,".");

WrByte_MEMS(INTSU,0x03);

WrByte_MEMS(PDET,0x00);

//Lcd_Data_Str(1,13,".");

WrByte_MEMS(SR,0x00);

//Lcd_Data_Str(1,14,".");

WrByte_MEMS(PD,0x00);

//Lcd_Data_Str(1,15,".");

WrByte_MEMS(MODE,0x41);

//Lcd_Data_Str(1,16,".");

Delay(150);

Set_Port0s=M1_Led;

Set_Port0s=M2_Led;

Set_Port0s=M3_Led;

88
//Lcd_Data_Str(1,1," Mems Inited ");

Delay(250);

void WrByte_MEMS(unsigned char wr_ptr,unsigned char wr_value)

Start();

while(I2C0STAT!=0X08);

I2C0CONCLR=(1<<Start_I2C);

I2C0CONCLR=(1<<INTR_I2C);

I2C0ADR=SlaAdd_WR ;

I2C0DAT=SlaAdd_WR ;

I2C0CONCLR=(1<<INTR_I2C);

while(I2C0STAT!=0X18);

I2C0CONCLR=(1<<INTR_I2C);

WrData_MEMS(wr_ptr);

89
while(I2C0STAT!=0X28);

I2C0CONCLR=(1<<INTR_I2C);

WrData_MEMS(wr_value);

while(I2C0STAT!=0X28);

Stop();

Delay(100);

void WrData_MEMS(unsigned char value)

I2C0DAT=value;

char RrByte_MEMS(unsigned char rd_add)

/*******************Start Condition****************/

90
Start();

while(I2C0STAT!=0X08);

I2C0CONCLR=(1<<Start_I2C);

I2C0CONCLR=(1<<INTR_I2C);

/*****************Writing Slave Add+WR**************/

I2C0ADR=SlaAdd_WR ;

I2C0DAT=SlaAdd_WR ;

I2C0CONCLR=(1<<INTR_I2C);

while(I2C0STAT!=0X18);

/*****************Sending Read_Mem Loc**************/

WrData_MEMS(rd_add);

I2C0CONCLR=(1<<INTR_I2C);

while(I2C0STAT!=0X28);

/*********************Sending Start****************/

I2C0CONSET=(1<<Start_I2C)|(1<<ACK);

I2C0CONCLR=(1<<INTR_I2C);

while(I2C0STAT!=0X10);

/****************Sending SlaveAdd+RD*************/

I2C0ADR=SlaAdd_RD ;

I2C0DAT=SlaAdd_RD ;

I2C0CONCLR=(1<<Start_I2C);

I2C0CONCLR=(1<<INTR_I2C);

91
while(I2C0STAT!=0X40);

I2C0CONCLR=(1<<INTR_I2C);

while(I2C0STAT!=0X50);

Data=I2C0DAT;

I2C0CONCLR=(1<<INTR_I2C);

I2C0CONCLR=(1<<ACK);

Delay(25);

Stop();

I2C0DAT=0x00;

return(Data);

void Reading_X_Y_Z_MEMS(void)

x=RrByte_MEMS(0x00);

//Delay(5);

//Lcd_Data_Chr(1,2,2,((x/10)+48));

//Delay(25);

//Lcd_Data_Chr(1,2,3,((x%10)+48));

92
Delay(25);

y=RrByte_MEMS(0x01);

/*

Delay(5);

Lcd_Data_Chr(1,2,8,((y/10)+48));

Delay(25);

Lcd_Data_Chr(1,2,9,((y%10)+48));

*/

//Delay(25);

void XY_Directions(unsigned char f_b,unsigned char l_r)

if((f_b>15&&f_b<25))

Set_Port0s=BMotor_left_frwd;

Clear_Port0s=BMotor_left_bkwd;

Set_Port0s=BMotor_right_frwd;

Clear_Port0s=BMotor_right_bkwd;

Delay(700);

93
Clear_Port0s=BMotor_left_frwd;

Clear_Port0s=BMotor_left_bkwd;

Clear_Port0s=BMotor_right_frwd;

Clear_Port0s=BMotor_right_bkwd;

if(f_b<55&&f_b>45)

Clear_Port0s=BMotor_left_frwd;

Set_Port0s=BMotor_left_bkwd;

//BACKWARD

Clear_Port0s=BMotor_right_frwd;

Set_Port0s=BMotor_right_bkwd;

Delay(700);

Clear_Port0s=BMotor_left_frwd;

Clear_Port0s=BMotor_left_bkwd;

Clear_Port0s=BMotor_right_frwd;

Clear_Port0s=BMotor_right_bkwd;

94
}

if(l_r>15&&l_r<25)

Clear_Port0s=BMotor_left_frwd;

Set_Port0s=BMotor_left_bkwd;

Set_Port0s=BMotor_right_frwd;

Clear_Port0s=BMotor_right_bkwd;

Delay(700);

Clear_Port0s=BMotor_left_frwd;

Clear_Port0s=BMotor_left_bkwd;

Clear_Port0s=BMotor_right_frwd;

Clear_Port0s=BMotor_right_bkwd; //LEFT

if(l_r<55&&l_r>45)

95
Set_Port0s=BMotor_left_frwd;

Clear_Port0s=BMotor_left_bkwd;

Clear_Port0s=BMotor_right_frwd;

Set_Port0s=BMotor_right_bkwd;

Delay(700);

Clear_Port0s=BMotor_left_frwd;

Clear_Port0s=BMotor_left_bkwd;

ear_Port0s=BMotor_right_frwd;

Clear_Port0s=BMotor_right_bkwd;

*/

96

S-ar putea să vă placă și