Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Mr. GOPAKUMAR C
Asst. Prof., Electronics and Communication Engineering
College of Engineering, Chengannur
May 2011
COLL
ACKNOWLEDGEMENT
College of Engineering, Chengannur
Voice Controlled Robot For Remote Data Access
First of all we thank The Lord Almighty for His grace and mercy which has helped us
reach this far with our project.
We express our sincere gratitude to the Principal, Dr. V.P.Devassia, for providing us
with the lab facilities we require for the completion of the project.
We are greatly obliged to Prof. Jyothiraj, Asst. Professor and HOD, Electronics
Department, for the encouragement and support that he has provided.
We would like to thank our project guides, Mr. C Gopakumar and Sri. Sumeth K L
from the bottom of our hearts for all the help and advice they have bestowed upon us.
We on this occasion, remember the valuable suggestions and prayers offered by our
family members, classmates and friends which were inevitable for the successful
completion of the project.
ABSTRACT
The system has got a transmitter (ROBOT) section and a receiver section; i.e. operator
side built around controllers. ROBOT side is fitted with necessary sensors and a wireless
module for wireless data communication is provided on both sections. RF camera is used
at ROBOT side to give guidance and video information of the situation at the sight to
receiver section. PC interface makes communication with receiver section and displays the
calibrated data received from sensors and also provide controls for controlling ROBOT.
The control may be using voice commands or by using keypad provided on display
interface. The trolley on which the ROBOT runs have a built in receiver section and hence
is not a part of the project.
The system is now developed under cost constraints and hence the operational range as far
as ambient temperature, humidity, distance from receiver etc. is very limited. However
provision is present for future alterations.
CONTENTS
ACKNOWLEDGEMENT......................................................................I
ABSTRACT............................................................................................II
1 INTRODUCTION...................................................................................1
3 BLOCK DIAGRAM...............................................................................6
3.1 TRANSMITTER SECTION..........................................................................7
3.2 RECEIVER SECTION..................................................................................8
5 POWER SUPPLY.................................................................................11
5.1 DESIGN.........................................................................................................12
5.2 CIRCUIT.......................................................................................................13
7 CIRCUIT IMPLEMENTATION........................................................32
7.1 TRANSMITTER SECTION........................................................................33
7.1.1 Circuit Diagram................................................................................33
7.1.2 PCB Layout.......................................................................................34
7.2 RECEIVER SECTION..............................................................................35
7.1.1 Circuit Diagram................................................................................35
7.1.2 PCB Layout.......................................................................................36
8 SOFTWARE IMPLEMENTATION...................................................37
8.1 FLOW CHART (TRANSMITTER SECTION)........................................38
8.2 FLOW CHART (RECEIVER SECTION).................................................42
11 REFERENCES......................................................................................50
12 APPENDIXES.......................................................................................52
12.1 PROGRAM CODE (TRANSMITTER SECTION)..................................53
12.2 PROGRAM CODE (RECEIVER SECTION)...........................................60
12.3 PROGRAM CODE (VB PC INTERFACE)...............................................68
12.4 BILL OF MATERIALS...............................................................................79
12.5 GANTT CHART...........................................................................................80
13 DATA SHEETS.....................................................................................81
INTRODUCTION
This system developed to gather data of atmospheric condition in hazardous or remote areas
where human intervention is at risk is designed with microcontroller (PIC), LCD, ADC,
USART, Zigbee, sensors and visual basic 6.0. Values of atmospheric temperature, pressure,
humidity, light intensity and also wind direction are measured. Each of these readings has its
own importance under different situations, and hence the system to be developed here will
find diverse applications such as coal mines, wind turbines, power stations, and to some
extent for rescue operations.
The system has got two sections- TRANSMITTER (ROBOT) and RECEIVER (operator).
The transmitter section runs over a trolley with inbuilt RF receiver and hence is not a part of
system design. The trolley may use portions of unlicensed spectrum in the 27 MHz or 49
MHz bands (VHF) and is never expected to make any interference with other radio devices
included. An RF camera provided at ROBOT transmits video as well as audio information to
the operator side. Camera has its own transmitter operating at 0.9 GHz (UHF) and receiver
module at operator side with an A/V output which may be connected to a TV system. The
camera system is also never expected to make any interference with other RF. The sensor
data handled by the controller on ROBOT side is send to the operator side as serial data via
Xbee modules operating on both sides at 2.4 GHz in ISM band. Xbee is expected not to face
any interference from other RF modules operating in other frequency bands.
Sensors include: LM35 as temperature sensor capable of measurements within -50 to 150
°C; Wind direction sensor which has been designed on ring potentiometer with a wane on its
knob towards one side, that turns the knob under wind pressure; LDR circuitry used to
measure light intensity on linear scale; Sensor ICs are used for measuring atmospheric
pressure and humidity. On chip ADC is used to acquire sensor data in digital form with 8-
bit resolution. On chip USART module handles serial transmission and reception of data via
Xbee module within 1Km radius.
The entire system receives regulated power supply at 12V, 5V and 3.3V for each of the
modules and sensors. The supply may have a centre tap rectifier or battery as source.
The RS232 serial communication interface provides serial link between PC and transmitter
section, with MAX232 used as voltage level converter; i.e. the up conversion and down
conversion between 5V on receiver section PIC side and 12V on RS232 side. The Visual
Basic 6 operator interface running on PC provide operator, the interface for viewing the
sensor data received as well as to control the motion of trolley with voice commands or
onscreen keypad. This is possible by making use of relays in place of joystick of remote
control of trolley at receiver section, and being controlled by the controller at receiver
section based on commands from PC. The system runs at its maximum speed 9600bps being
limited by MAX232
LCD displays and RS232 interface are provided on both sides to perform test and
refinements under any stage of the project development as well as to ensure regular state of
working during operation.
The system shall be encased in a protective case that can withstand the atmospheric
conditions prevailing in the area of operation.
It is difficult to collect data at hazardous or remote areas where human intervention is at risk.
For such situations in coal mines, wind turbines, power stations, and to some extent for
rescue operations, the atmospheric conditions could not be measured. So this project aims at
making a system that employs various techniques to measure values of atmospheric
temperature, pressure, humidity, light intensity and also wind direction. Each of these
readings has its own importance/applications under different situations, and hence the
system to be developed here is expected to find diverse applications.
The system is planned to be built around a trolley which will carry the transmitter (ROBOT)
section consisting of sensors to remote places for data acquisition. It also contains the
wireless module for wireless data communication. The transmitted signal is to be received at
an operator section and displayed on PC. RF camera is used at ROBOT side to give
guidance and video information of the situation to receiver section. The control of trolley
may be made using voice commands or by using keypad both provided on display user
interface (PC).
BLOCK DIAGRAM
P
I
C
A
M
I
C
R
O
D C
O
N
3.1 TRANSMITTER SECTION T
R
O
C L
College of Engineering, Chengannur
AIR
WIND
TEMPERATURE
HUMIDITY
PRESSURE
LIGHT
DIRECTION L POWER
SENSOR E SOURCE
R
Voice Controlled Robot For Remote Data Access
USART XBEE
MODULE
8 16*2 LCD
DISPLAY
3.3 V
5V
CAMERA
TROLLEY
5V
5V USART
MAX232 XBEE
2 MODULE
P
I
12 V
C
RS232 8 16*2 LCD
M
DISPLAY
I
C
R 3.3 V
PC INTERFACE
VB FRONTEND O
C 5V POWER
O SOURCE
N
BUZZER T
R TROLLEY
O REMOTE
L
L 5
E 5
R ULN2003 12 V
& RELAY
The block diagram shows the data acquisition system with different sections built around the
Peripheral Interface Controller (PIC). The various sensors such as those used to acquire
temperature, humidity, pressure, wind direction and light are connected to ADC of the PIC.
The pin 25 the TX of USART is the serial data output to Xbee. An 8- bit PORT of PIC is
dedicated for 16*2 LCD, in which out of 8 only upper 4 lines will carry data and lower 4 is
for control functions. The camera is an independent module with its own RF transmission
system.
The program running in the controller will initialize every modules, perform scan of one
sensor, transmits calibrated data in ASCII format suitable for display at receiver section and
then displays the data in its own LCD. In a similar way data acquisition from each sensors is
performed one by one. The entire process repeats itself.The power supply has a 9V cell as its
source and provides regulated 5V supply for controller, sensors, LCD and also 3.3V for
Xbee module. Camera operates on its own dedicated 9V cell.
The receiver section is built around PIC and handles trolley motion control and data
reception from transmitter section on one side while command reception from and data out
to PC interface on other side. The major blocks consist of PC interface which is possible
through RS232 interface which uses a MAX232 chip to perform required voltage level
conversions for signals (5V on PIC side equivalent to 12V on RS232). The system runs at its
maximum speed of 9600bps being limited by MAX232, which also ensures error free data
acquisition from beginning to end. The PC interface has Visual Basic 6 program running on
it that provides the user interface with facilities to see the received sensor data as well as
give commands as voice or by onscreen keypad. The commands from PC as well as data
from Xbee are received on the same pin 26, the RX of USART. Here also a 16*2 LCD
module is used to display received commands. An LED indication while command reception
is ON. The activation of trolley remote with 5V supply and controlling by means of four
12V relays is based on signals commands and signals respectively from PC. A ULN2003
chip working at 12V actuates relays based on signals from PIC. Here the power supply has a
12V source consisting of a 230V-50Hz (60mA) transformer.
The program initializes every module and starts reception of data from transmitter section
and during the same time checks for any signal to initiate voice command reception on the
same pin. Upon reception of signal to initiate voice command reception program stops data
reception from Xbee, switches ON relays with a buzzer indication and waits for command
reception. Upon reception of commands the received command is displayed on LCD and
necessary signals are issued to control the trolley motion to the relay circuitry. Only on
reception of ‘exit’ command system returns for data reception. The entire process repeats.
POWER SUPPLY
5.1 DESIGN
Requirements:- 12 VDC/9 VDC; 5 VDC; 3.3 VDC for max. current< 600mA
College of Engineering, Chengannur
Voice Controlled Robot For Remote Data Access
R10 calculated as
Special Note
5.2 CIRCUIT
6.1 MICROCONTROLLER
368x8bytes Data RAM. Upto 190 GPRs. This memory organized as banks
Sink/Source Current: 25 mA
It operates on PORT A to which sensors are connected. We use only the most
significant 8 bits of data, though the ADC provides 10 bit resolution. ADC control
and status registers are under:-
For sensors all channels are configured for analog input [bit3:bit0= 0000]
USART
The USART is used for asynchronous serial data transfer between and PIC and Xbee
at transmitter section and for data transmissions between PIC and Xbee, PC both
sharing the same receive pin 26 (RX) of USART, at receiver section.
The baud rate is calculated for high speed asynchronous transmission as:-
The SPBRG register is loaded with the value of ‘X’ from above formula
TXIF flag in PIR1 register indicates (sets) end of transmission from TXREG
Timers
The system has got 3 timers: Timer 0 (8- bit), Timer 1 (16- bit), Timer 2 (8- bit).
Here we use Timer 0. The timer is used for providing delays.
The timer can provide a maximum delay of 65ms for a full run from 0 to 255;
i.e. full range of 8-bit values
Delay= (4/Fosc)*prescalar*(255-X)
The value of ‘X’ obtained from above formula is passed to TMR0 register to
start Timer 0 from that value
A ‘high’ on zero flag (Z) in status register indicates the end/overflow of timer
Significant Features:-
The Xbee module is used on either section of the system for providing point-to-point
data communication that helps receive sensor data from ROBOT side.
6.3 RF CAMERA/TROLLEY
Significant Features:-
Frequency : 0.9GHz
The RF Camera has its own transmitter and has dedicated receiver section that is
installed at receiver section of the system under development, where the output of receiver
of camera is given to the A/V input of a TV system for display. It draws a current of 200mA
from a 9 V cell working as its dedicated source. So for a single cycle of operation, it works
for approximately 2 hours.
A trolley platform is the base system on which the data acquisition transmitter
section runs. It has inbuilt receiver. It runs on six AA cells (1.5 V). The trolley remote is
controlled with relays from operator side.
MAX232 uses capacitor charge pumps to obtain 12V levels from 5V supply
The baud rate of the system is 9600bps; i.e 104us per bit
: Receiver (+/-30V)
The user interface on PC built with VB6 has controls to start voice command input,
stop and exit. It has also provision for displaying detected commands and received data from
each sensors, a keypad alternative for motion control and VU meter.
The switches of trolley remote control for the four motions: front, back, eft, right are
replaced with 12V relays, each to switch a 5V supply. A 12V relay is provided for switching
5V power supply for the trolley remote also. A ULN2003 relay driver IC operating at 12V
supply stands between PIC and relays. It operates based on outputs from PIC [RB7:RB4 and
RC2]
Significant Features:-
The LCD is operated in 4- bit mode with 8- bit data being send twice as 4- bit data in
order to get it displayed [Pins: 11:14]. The data MSB is the busy flag of LCD [Pin: 14]. It
has to be checked before any write operation. It is checked after setting LCD in its ‘read’
mode. LCD contrast control is done by adjusting a ‘pot’ through which supply is given to
Pin3. LCD has also following control Pins:-
Pin5 : RD/WR
6.7 SENSORS
All sensors except the wind direction sensor use readily available sensors in IC
packages. The calibration for sensors has been done in software based on field study.
The wind direction sensor has been constructed with a dynamic element that catches
air over a 10Kohm potentiometer, such that the wind turns the potentiometer due to the
presence of the dynamic element. The sensor is so designed that the wind will turn the pot to
that direction in which the dynamic element is along the direction of wind. This same
principle is used for commercial ones also. However since the trolley may move in any
direction, the directions are with reference to the forward direction of trolley.
Figure 6.7.1- The Wind direction sensor with its dynamic element attached to 10KOhm pot
The full range of output of potentiometer; i.e. the output of ADC for values of
resistance between 0 and 10Kohm that gives the full range of output of ADC between 0 and
255, is necessarily divided into 4 regions, for each of the wind directions. However, the
potentiometer we use do not have a full 360 degree range of rotation, so one of the
directions gets divided to either side of the extremities of the pot, which is one of the
greatest limitations of the system. We take this direction as ‘North’ with reference to trolley.
This gives direction ‘South’ as the direction of the sensor under normal conditions; i.e. when
the trolley is in motion. The exact south direction should stay at the 5Kohm point, i.e half
the full range of the pot. This should give a value nearly 128 (Decimal) as the ADC output.
The circuit consists of the pot that functions as sensor with its one terminal grounded
and other extreme terminal connected to 5V supply through a 10KOhm series resistor. This
limits maximum current to 0.5mA.
Significant Features:-
Accuracy : +/- 5%
Significant Features:-
Temperature : -50-150 °C
Sensitivity: 10mV/ °C
Due to its high output and sensitivity, the sensor can be placed up to 10 metres away
from the control circuitry that can provide satisfactory operation.
This sensor system consists of a readily available and cheap LDR (Light Detecting
Resistor). The light sensor circuitry hence has a linear operation.
Significant Features:-
Material : Selenium
The light sensor circuitry consist of a voltage divider in which LDR has one of its
terminals grounded and other leg connected to 5V supply through 10KOhm resistor. The
peak current is hence limited to 0.5mA.
The sensor calibration was based on field study with the use of a standard light
intensity meter (foot-candle meter) as reference. The field study considered cases where the
sensor circuitry under test as well as standard meter was introduced to light from the
following: a zero watt bulb, an ordinary room with a tube light lit and also without tubelight
but during day hours with medium level of sunlight and also direct sunlight. The values
were then compared and a correction factor was introduced, since the sensors showed linear
operation.
Vo= 5*R/(R+10)
Reworking the above equation gives equation for light intensity in unit of Lux.
The humidity sensor used in this project is capacitive humidity sensor based on
silicon technology on glass wafer from Smartec. It consists of three layers base and top layer
are conductive and the layer in between is humidity sensitive polyimide. The sensor is
highly independent to temperature effects. The top layer has grid like structure. The sensor
converts the humidity into a capacitance. Due to the construction the response to humidity is
very fast (<15 sec) and the hysteresis very low (<2% RH). Linearity is considered as the
maximum deviation from a straight line between 0% RH and 100% RH.
Significant Features:-
With : Cc= measured capacitance (pF); Cs= capacitance value at 55% RH (pF)
Figure 6.7.4- The capacitive humidity sensor based on silicon technology on glass wafer
The calibration of humidity sensors is not so easy. One can perform a lot of
measurements in the climate chamber but there is a much cheaper and low cost way to check
humidity sensors by means of salt solutions. Special saturated salt solutions have always the
same humidity in the area above. This humidity depends only on temperature. Find below an
overview of salt-solutions that can be used:-
The salt solution must be put into a glass container with a sealable top. With a couple
of cm. Salt solution on bottom the humidity above is constant and only depends on
temperature. Place the sensor into the air above the solution and close the access hole
carefully. Leave the sensor stabilizing for about half an hour and read afterwards the sensors
value. Be aware that the temperature of the container needs to be constant over the period.
Therefore it is recommended to use a well-isolated glass container. In case a two point
calibration is performed in general LiCl and NaCl solutions are used. In a three point
calibration LiCl, Mg(NO3) and K2SO4 solutions are recommended.
Figure 6.7.5.1- The internal schematic (left) and pressure sensor module (right)
The pressure sensor used in this project is ‘MPXHZ6115A6U’ model on-chip signal
conditioned, temperature compensated and calibrated sensor from Motorola. Note that the
sensor is internally calibrated for working at 5V supply and hence further calibrations are
never needed.
Significant Features:-
Vout= VS* (0.009* P - 0.095) ± (Pressure Error x Temp. Factor* 0.009* VS)
CIRCUIT IMPLEMENTATION
The following layout is that of the about circuit of receiver section. The layout
generation was done with OrCAD 9 where the line width was choosen ‘8mm’.
The following layout is that of the about circuit of receiver section. The layout
generation was done with OrCAD 9 where the line width was choosen ‘8mm’.
SOFTWARE IMPLEMENTATION
Set count=3
Configure USART,ADC,Timer
and Ports for sensors and LCD
Initialize LCD
Count=Count-1
If
Count
No =0
Yes
Display “ZIGBEE BASED
DATA ACQUISITION ROBOT”
Delay 1s
College of Engineering, Chengannur
Voice Controlled Robot For Remote Data Access
Caliberate
Convert to ASCII
Display TEMPERATURE
Delay 1s
Caliberate
Convert to ASCII
If
Value>6
No 3
Yes
If
Value>12
6 No
Yes
If
Value>18
No 9
Yes
Delay 1s Delay 1s Delay 1s
Delay 1s
Display
Display Display Display
“NORTH
“WEST” “EAST” “SOUTH”
”
Transmit
Transmit Transmit Transmit
“NORTH
“WEST” “EAST” “SOUTH”
”
Delay 1s
Convert to ASCII
Convert to ASCII
Display PRESSURE
Delay 1s
Caliberate
Convert to ASCII
Display HUMIDITY
START
College of Engineering, Chengannur
Voice Controlled Robot For Remote Data Access
Set count=3
Initialize LCD
Count=Count-1
If
Count
No =0
Yes E
Display “voice controlled x-bee robot”
Delay 1s
If data
College of Engineering, Chengannur
Receive
data= ‘*’
Voice Controlled Robot For Remote Data Access
No
Transfer data to PC
Yes
Trolley remote ON
Buzzer ON
Delay 0.5s
Buzzer OFF
Receive data
Yes
If
data= Display “left”
‘L’
Initiate trolley control 'left'
No
B D
B
If
If
College of Engineering, Chengannur
data=
data= ‘F’
‘S’ Yes
‘R’
‘B’
No Yes
Yes Display
InitiateDisplay
Display
Initiate trolley“straight”
trolley D“front”
“right”
“stop”
control
control'back'
'front'
'right'
'stop'
Voice Controlled Robot For Remote Data Access
Display “back”
If
data=
‘A’
C D
If No
data= D
‘E’
Yes
Display “VOICE MODE EXIT”
Delay 1s
This project which aimed at making a system that moves over a trolley and collect data from
remote areas, where the motion of the trolley being controlled by voice commands/keypad
from operator side was completed as expected and is therefore named- ‘VOICE
CONTROLLED ROBOT FOR REMOTE DATA ACCESS’.
The sensors, controllers, ‘xbee’ for data communication and trolley form the major parts of
the system. The sensors were installed and calibrated based on field study. However the
following challenges still exist:-
The wind direction sensor was not purchased, instead it was handmade by
coupling a wind catching element with a pot. The minimum detectable wind speed as
well as accuracy is therefore seriously limited when compared to sensors available in
market. However the cost could be brought down to a very low value.
The sensors were calibrated based on rough field study and this is not a
standard practice. Otherwise calibration should have been done against a standard
device (sensors).
A serious limitation is put over the working range (distance) of the entire
system by the limited range (30m) of the trolley, though the data communication is
possible up to 1Km successfully. However this could be overcome using a trolley
with a longer range of operation, but this will increase the cost.
The project failed to make an efficient braking system for the trolley on
which the system moves.
Sensors currently used may be replaced for higher range of operation (temperature, pressure
and humidity) while providing required mechanical support according to the requirement
and where cost doesn’t matter:-
High temperature (Range -70 °C -500 °C) Platinum RTD-Pt100 (Cost: INR 600)
Power plants where the transmitter section may be installed with components suited
to the conditions
With added sensors for distance measurement, the system may be used for rescue
operations
REFERENCES
APPENDIXES
BSF TRISA,2
BSF TRISA,3
MOVLW 0X00 //ADC result in ADRESH, all inputs analog
MOVWF ADCON1
BSF TRISC,7 //Pin 26 set for serial input from Xbee
BCF TRISC,6 //Pin 25 set for serial output to Xbee
MOVLW 0X24 //USART Trans. set for 8-bit,Async,high speed
MOVWF TXSTA
MOVLW 0X19 //USART set for 9600bps serial data transfer
MOVWF SPBRG
BCF STATUS,5 //Bank 0 selection
BCF STATUS,6
CLRF PORTD //PORT D full output set as ‘0’
MOVLW 0X85 //ADC started on channel 0
MOVWF ADCON0
MOVLW 0X90 //USART Rcvr. set for serial,8-bit,continuous
MOVWF RCSTA
MOVLW 0XC4 //A 15ms TIMER 0 delay
CALL TMRT
MOVLW 0XEB //A 5ms TIMER 0 delay
CALL TMRT
MOVLW D'50' //A 50us delay
MOVWF C2
DECFSZ C2,1
GOTO $-1
MOVLW 0X30 //LCD initialization command for 8-bit mode
MOVWF PORTD
CALL EN //Enable pulse
LCMD 0X21 //LCD command;4-bt mode
LCMD 0X0C //LCD command; Display ON (without cursor)
LCMD 0X06 //LCD command; Entry mode
LCMD 0X02 //LCD command; Cusor to home position
LCMD 0X01 //LCD command; Clear display
DECFSZ C1,1 //Count decrement by 1
GOTO L3
LCMD 0X01
LCMD 0X80 //LCD command; DDRAM home position
LCHAR 'Z' //Display ‘TITLE’
MOVWF C3
DECFSZ C3,1
GOTO $-1
NOP
NOP
BSF ADCON0,2 //ADC scanning channel 2
BTFSC ADCON0,2 //Waiting for ADC to finish
GOTO $-1
MOVF ADRESH,0 //ADC output moving to ‘M1’
MOVWF M1
// Character transmission ‘WIND DIRECTION’
//Note: Mnemonics here same as that for previous steps
//Display ‘WIND DIRECTION’
//Note: Mnemonics here same as that for previous steps
MOVLW D'63' //Move value ‘63’ to ‘W’
SUBWF M1,0 //[M1]-[W]->[W]
BTFSS STATUS,0 //Check for carry/borrow
GOTO WEST //Pass ‘WEST’ if [M1]<[W]; i.e no borrow/a carry
MOVLW D'126' // Move value ‘126’ to ‘W’
SUBWF M1,0
BTFSS STATUS,0
GOTO SOUTH //Pass ‘SOUTH’ if [M1]<[W]
MOVLW D'189' // Move value ‘189’ to ‘W’
SUBWF M1,0
BTFSC STATUS,0
GOTO EAST //Pass ‘NORTH’ if [M1]<[W]
GOTO NORTH //Pass ‘EAST’ if [M1]>[W]
WEST //Display ‘WEST’
//Note: Mnemonics here same as that for previous steps
CALL DELAY
//Character transmission ‘WEST’
//Note: Mnemonics here same as that for previous steps
GOTO LOP //Go for scanning next sensor data
SOUTH //Note: Mnemonics here same as that for previous steps
EAST //Note: Mnemonics here same as that for previous steps
NORTH //Note: Mnemonics here same as that for previous steps
LOP MOVLW B'10011001' //ADC halted with channel 3 selected
MOVWF ADCON0
GOTO $-2
DECFSZ C4,1
GOTO $-6
NOP
RETURN
SR1 MOVLW D'10' //10us delay for ADC data acquisition
MOVWF C3
DECFSZ C3,1
GOTO $-1
NOP
NOP
BSF ADCON0,2 //ADC scan/convertion starting
BTFSC ADCON0,2
GOTO $-1
MOVF ADRESH,0 //ADC output moving to ‘R6’ and ‘R2’
MOVWF R6
MOVWF R2
MOVLW 0XFF //Move binary value ‘11111111’ to ‘R3’
MOVWF R3
MOVLW D'100' //Getting value in 100s position of result
INCF R3,1 //‘R3’ will finally contain value in 100s position
SUBWF R2,1 //Division by repeated subtraction
BTFSC STATUS,0 //Wait unit a borrow/no carry generated
GOTO $-3
ADDWF R2,1 //‘R2’ will finally contain digits other than 100s
MOVLW 0XFF
MOVWF R4
MOVLW 0X0A //Getting value in 10s position of result
INCF R4,1 //‘R4’ will finally contain value in 10s position
SUBWF R2,1
BTFSC STATUS,0
GOTO $-3
ADDWF R2,0 //‘R2’ will finally contain digit in 1s position
MOVWF R5 //Move value in 1s position to ‘R5’
MOVLW 0X30
ADDWF R3,1 //Adding ‘0X30’ to convert sensor data to ASCII
ADDWF R4,1
ADDWF R5,1
RETURN
SR2 MOVWF TXREG //Move [W]->[TXREG] to start transmission
BCF PIR1,4 //Clear TXIF flag that indicates TXREG is empty
BTFSS PIR1,4
GOTO $-1 //Wait for TXREG to get emptied
BSF STATUS,5
BCF STATUS,6
MOVLW 0X87
MOVWF OPTION_REG
BCF STATUS,5
BCF STATUS,6
MOVLW D'235' //A 5ms delay
MOVWF TMR0
MOVF TMR0,0
BTFSS STATUS,2
GOTO $-2
NOP
RETURN
SR4 MOVF R3,0 //Subroutine to transmit sensor data
CALL SR2
MOVF R4,0
CALL SR2
MOVF R5,0
CALL SR2
RETURN
SUB BCF STATUS,6
BSF STATUS,5
MOVLW 0XF0 //Make upper 4 pins of PORT D as inputs
MOVWF TRISD
BCF STATUS,6
BCF STATUS,5
BSF PORTD,1 //PORT D bit 1 connected to LCD RD/WR is set
NOP
NOP
BSF PORTD,3 // PORT D bit 3 connected to LCD enable is set
NOP
NOP
BTFSC PORTD,7 //Checking pin 14 of LCD;i.e data MSB(busy flag)
MOVWF M1
BSF M2,0
CALL SUB
ENDM
LVALUE MACRO VALUE //VALUE DATA MACRO
MOVF VALUE,0
MOVWF M1
BSF M2,0
CALL SUB
ENDM
CLRF PORTC
CLRF PORTD
CLRF PORTE
MOVLW 0X03 //Set count for LCD initialization repetition
MOVWF R1
FIRST BSF STATUS,5 //LCD initialisation
BCF STATUS,6
CLRF TRISD
BCF STATUS,5
BCF STATUS,6
CALL DELAY1 //15ms delay
CALL DELAY1
CALL DELAY1
CALL FNSET
CALL DELAY1 //5ms delay
CALL FNSET
MOVLW D'254'
MOVWF TMR0
MOVF TMR0,0
BTFSS STATUS,2
GOTO $-2
CALL FNSET
LCOM 0X21
LCOM 0X0C
LCOM 0X06
LCOM 0X02
LCOM 0X01
DECFSZ R1,1
GOTO FIRST
DISP LCOM 0X01
LCOM 0X80
LDATA 'v' //Display ‘voice controlled x-bee robot’
//Note: Mnemonics here same as that for previous steps
CALL DEL1S
GOTO MSG
DELAY1 MOVLW D'235' //5ms delay
MOVWF TMR0
MOVF TMR0,0
BTFSS STATUS,2
GOTO $-2
RETURN
DELAY MOVLW .255 //0.25s delay
MOVWF Y2
AN MOVLW .255
MOVWF Y1
DECFSZ Y1,1
GOTO $-1
DECFSZ Y2,1
GOTO AN
RETURN
DEL1S MOVLW D'15' //1s delay
MOVWF CNT
MOVLW D'1'
MOVWF TMR0
MOVF TMR0,0
BTFSS STATUS,2
GOTO $-2
DECFSZ CNT,1
GOTO $-6
NOP //1us delay
RETURN
FNSET MOVLW 0X30 //LCD command; 8- bit mode initialization
MOVWF PORTD
BSF PORTD,3
NOP
NOP
NOP
BCF PORTD,3
RETURN
ENABLE BSF PORTD,3 //Enable pulse for LCD
NOP
NOP
NOP
BCF PORTD,3
RETURN
SUB BSF STATUS,5 //Subroutine to transfer data/command to LCD
BCF STATUS,6
MOVLW 0XF0
MOVWF TRISD
BCF STATUS,5
BCF STATUS,6
BSF PORTD,1
BSF PORTD,3
BTFSC PORTD,7
GOTO $-1
BSF STATUS,5
BCF STATUS,6
CLRF TRISD
BCF STATUS,5
BCF STATUS,6
CLRF PORTD
MOVLW 0XF0
ANDWF M1,0
MOVWF PORTD
BTFSC M2,0
BSF PORTD,2
CALL ENABLE
SWAPF M1,0
ANDLW 0XF0
MOVWF PORTD
BTFSC M2,0
BSF PORTD,2
CALL ENABLE
BCF PORTD,2
RETURN
MSG CALL REC //Go for data reception
MOVF R0,0
SUBLW '*' //Check if received data is ‘*’
BTFSC STATUS,2
GOTO VOICE //Prepare for VOICE COMMAND reception
CALL TRANS //Go for data transfer
GOTO MSG //SYSTEM RESTART (Program)
VOICE CLRF PORTB
BSF PORTE,0 //BUZZER ON
BCF PORTB,4
CALL DELAY
BSF PORTB,6
CALL DELAY
BCF PORTB,7
CALL DELAY
GOTO LOP
REC BSF RCSTA,CREN //Subroutine to receive data
BCF PIR1,RCIF
NOP
NOP
BTFSS PIR1,RCIF //Check if any data received
GOTO $-1
MOVF RCREG,0
MOVWF R0 //Move received data to ‘R0’
BCF RCSTA,CREN //Stop reception
RETURN
TRANS CLRF TXREG //Subroutine to Transmit data to PC
BTFSS PIR1,TXIF
GOTO $-1
MOVF R0,0
MOVWF TXREG //Move received data to start transmission
RETURN
END //Program end
MIDHU = 0
Label2.Caption = ""
' MSComm1.PortOpen = True
MSComm1.Output = "E"
' MSComm1.PortOpen = False
Frame1.Visible = False
' Frame2.Visible = True
End Sub
Text1.SelStart = 4
Text1.SelLength = 1
LIGHT = Text1.SelText
College of Engineering, Chengannur
Voice Controlled Robot For Remote Data Access
Text1.SelStart = 8
Text1.SelLength = 1
WIND = Text1.SelText
Text1.SelStart = 10
Text1.SelLength = 1
HUM = Text1.SelText
Text1.SelStart = 14
Text1.SelLength = 1
PRE = Text1.SelText
Text1.SelStart = 18
Text1.SelLength = 1
SPEED = Text1.SelText
End If
'Text1.Text = ""
End Sub
If MIDHU = 0 Then
MsgBox "click 'LISTEN' first"
Exit Sub
Else
Timer1.Enabled = False
' Display it.
Detect.Caption = Command
' Look for it in a list and execute the relavant commands
Select Case UCase(Command)
Case "EXIT"
Cmd_Exit_Click
Case "STOP"
Label2.BackColor = vbCyan
Label2.Caption = "STOP"
' MSComm1.PortOpen = True
MSComm1.Output = "S"
' MSComm1.PortOpen = False
Case "LEFT"
Label2.Caption = "LEFT DIRECTION"
Label2.BackColor = &H101FF
' MSComm1.PortOpen = True
MSComm1.Output = "L"
' MSComm1.PortOpen = False
Case "RIGHT"
' MSComm1.PortOpen = True
MSComm1.Output = "R"
' MSComm1.PortOpen = False
Label2.Caption = "RIGHT DIRECTION"
Label2.BackColor = &H1FF01
Case "FRONT"
Label2.Caption = "FORWARD"
Label2.BackColor = &HFF0101
' MSComm1.PortOpen = True
MSComm1.Output = "F"
' MSComm1.PortOpen = False
Case "BACK"
Label2.Caption = "REVERSE"
Label2.BackColor = vbMagenta
' MSComm1.PortOpen = True
MSComm1.Output = "B"
' MSComm1.PortOpen = False
Case "STRAIGHT"
Label2.Caption = "STRAIGHT"
Label2.BackColor = vbYellow
' MSComm1.PortOpen = True
MSComm1.Output = "A"
' MSComm1.PortOpen = False
End Select
DATASHEETS