Академический Документы
Профессиональный Документы
Культура Документы
1/071
Date of birth
24-04-1988
Title
2010/2011
RESTRICTED
OPEN ACCESS
SIGNATURE
880424-08-5609
(NEW 1C NO. /PASSPORT NO.)
NOTES :
SIGNATURE OF SUPERVISOR
If the thesis is CONFIDENTIAL or RESTRICTED, please attach with the letter from
the organisation with period and reasons for confidentiality or restriction.
"I declare that I have read this thesis and in my opinion this thesis is
sufficient in terms of scope and quality for award a Degree of
Bachelor of Engineering (Electrical - Electronics)."
Signature
Name of Supervisor : DR. MUHAMMAD NASIR IBRAHIM
Date
: 16 MAY 2011
APRIL 2011
I declare that this thesis entitled "PC Based Home Automation Using Speech
Recognition and Network" is the results of my own research except as cited
in the references.
The thesis has not been accepted for any degree and
Signature
W.-Jf^
Name
: Choo Chian'Choong
Date
: 16 MAY 2011
iii
iv
ACKNOWLEDGEMENT
During the process of this final year project, I had faced lot of problems
especially come to troubleshooting and idea on how the project can be implemented.
Thanks to my friends, Koay Jian Cong, Lam Kong Shen, Voon Zheng Loong, Pui
Hing Ngain and Voon Wee Sun for the advices and idea on my project, finally I was
able to finish my final year project smoothly.
ABSTRACT
vi
ABSTRAK
vii
TABLE OF CONTENT
CHAPTER
TITLE
PAGE
TITLE
DECLARATION
ii
DEDICATION
iii
ACKNOWLEDGEMENT
iv
ABSTRACT
ABSTRAK
vi
TABLE OF CONTENT
vii
LIST OF CODES
xi
LIST OF FIGURES
xii
LIST OF ABBREVIATIONS
xiv
LIST OF APPENDICES
xv
INTRODUCTION
1.1 Introduction
viii
LITERATURE REVIEW
2.1 Introduction
Devices
2.5 USB CDC Class on an Embedded Device
10
11
2.7.1
Zero-Crossing Detector
12
2.7.2
13
2.7.3
13
2.7.4
14
2.7.5
Load switch
15
16
2.9 Bootlaoder
17
2.10
18
2.11
19
2.12
MPLAB 7.62
20
2.13
Related Journal
20
2.14
Related Thesis
23
RESEARCH METHODOLOGY
3.1 Introduction
25
26
3.2.1
26
part)
3.2.2
27
3.2.3
27
3.2.4
27
ix
3.2.5
28
3.2.6
29
30
3.3.2
30
3.3.3
31
29
32
FUNCTIONAL DESCRIPTION
33
33
34
41
DESIGN ARCHITECTURE
42
42
44
5.3.1
45
5.3.2
Firmware
58
61
63
CONCLUSION
7.1 Conclusion
72
7.2 Recommendation
73
REFERENCES
74
APPENDICES
76
xi
LIST OF CODE
CODE NO.
TITLE
PAGE
5.1
45
5.2
46
5.3
Frmhome_load code
47
5.4
47
5.5
48
5.6
49
5.7
Buttons Coding
51
5.8
52
5.9
53
xii
LIST OF FIGURES
No.
TITLE
PAGE
2.1
10
2.2
11
2.3
Zero-crossing detector
12
2.4
13
2.5
14
2.6
15
2.7
Load switch
16
2.8
17
PIC16F877A
2.9
Bootloader schematic
18
3.1
25
3.2
28
3.3
31
3.4
32
4.1
35
4.2
35
4.3
Log in form
36
4.4
36
4.5
37
4.6
37
4.7
38
4.8
39
4.9
39
xiii
4.10
40
5.1
42
5.2
42
5.3
43
5.4
44
5.5
45
5.6
54
6.1
56
6.2
57
6.3
Hardware verification
57
6.4
System Verification
58
6.5
58
6.6
59
6.7
59
6.8
60
6.9
60
6.10
61
6.11
61
6.12
62
6.13
62
6.14
63
6.15
63
6.16
64
6.17
64
xiv
LIST OF ABBREVIATIONS
LAN
SMS
RF
Radio Frequency
PIC
USB
USB CDC
GUI
LED
xv
LIST OF APPENDICES
APPENDIX
TITLE
PAGE
76
System
B
81
CHAPTER 1
INTRODUCTION
1.1
Project Overview
In recent years, home automation is becoming more and more popular due to
the technologies that are available nowadays. Automation had transferred from
industrial sector to home. Home automation allow user to control, monitor various
electric appliances through a single system. Currently there are many technologies
and standard available for home automation, including X10, CEBus, LonWorks,
EIB/KNX [1]. These systems give advantage for the consumers have a more
convenience way of living style, and make the home a safer place to live, save
energy while taking control all the home appliances.
By applying home automation, users are able to perform their daily task
schedule automatically, such as lighting in the home will switch on or off following
the daily schedule. Some use this advantage to make the house looks like occupied
when owner of the house is out for a long vacation. Home automation system for
monitoring and controlling various home appliances can be achieved using variety of
methods, such as LAN technologies, SMS, GSM, and so on. By all these method,
consumers are able to monitor or control their home appliances even they are away
from home [2]. For example, when you are on the way back from the office and the
weather is unbearable, you can remote you air-conditional in your home from the
office to switch on before you get in the house. It brings a lot of convenient for the
consumer.
1.2
Project Objective
This system enable user to control their home appliances using a computer or
a graphic user interface (GUI).
Internet connection is used to enable client computer remote control the home
computer, which enables users to remote control their home electric appliance
though internet
Since the installation of the wire for the home automation is hardly to be done,
hence RF wireless communication protocol is used in the system, where there
is no extra rewiring work is required to implement this system.
1.3
Problem Statement
Home automation system is very expensive and yet not popular in Malaysia.
In order to make it affordable for consumer, RF is able to give a cheap solution and
yet affective way to implement home automation.
Home automation usually comes only with limited control method. Hence, to
make the home automation system more convenient, few control method is
implement in the project, including speech recognition. User just has to give
command to the system to control their home appliances, without walking near to the
switch. This brings a lot of benefit to disabled or handicap people to take control
their home appliances.
Most of the people are unable to monitor or control when outside the home.
Many house break-in cases happen in Malaysia, and most of this cases happened
when the owner is not available. The system is able to schedule the on and off time
of the lighting, or control though internet to on the lighting to make it look like the
house is occupied. Camera can be installed to monitor the house.
1.4
Scope of Project
This project can be divided into two parts, hardware and software approach
implementation. The following are the scopes of the project, including:
1. The system is only able to control to switch on or off for lamp and fan.
Dimmer function or speed control are excluded in the project.
2. Speech recognition from the Microsoft SDK 5.3 is used in the GUI.
Only English can be recognized by the system.
3. LED is used to implement the status of the home appliance.
1.5
CHAPTER 2
LITERATURE REVIEW
2.1
Introduction
2.2
Home Automation
Home automation is a very promising area. Its main benefits range from
increased comfort and greater safety and security, to a more rational use of energy
and other resources, allowing for significant savings. It also offers powerful means
for helping and supporting the special needs of people with disabilities and, in
particular, the elderly. This application domain is very important and will steadily
increase in the future [3].
According to Khusvinder Gill, Shuang-Hua Yang, Fang Yao, and Xin Lu, in
recent years the introduction of network enabled devices into the home environment
has proceeded at an unprecedented rate [4]. Moreover, with the rapid expansion of
the Internet, there is the potential for the remote control and monitoring of such
network enabled devices. However, the new and exciting opportunities to increase
the connectivity of devices within the home for the purpose of home automation
remain largely unexploited.
The totally automated and super-sophisticated home of the future is inching
closer to reality [5]. By the technology development nowadays, the full automated
home automation can be realized and it will be the trend of the future home.
2.3
For this project, both kinds of microcontrollers are used in the project.
PIC18F4550 is used for the main system which communicates with the computer
through USB and X10 transmitter, and PIC16F877A is used in the X10 receiver to
taking control on the home appliances.
For PIC18F4550, this family of devices offers the advantages of all PIC18
microcontrollers namely, high computational performance at an economical price
with the addition of high-endurance, Enhanced Flash program memory. In addition
to these features, the PIC18F2455/2550/4455/4550 family introduces design
enhancements that make these microcontrollers a logical choice for many highperformances, power sensitive applications. [6]
2.4
Small firmware code size (less than 450 instruction words on most devices)
Baud rate flexibility, from 1,200 bps to 3 Mbps for extremely fast
programming
A 16-bit CRC packet and Flash memory verification for quick verification of
successful programming, even at low baud rates
Support for a wide variety of PIC16 and PIC18 devices through an essential
device characteristics database
2.5
The Universal Serial Bus (USB) has made it very simple for end users to
attach peripheral devices to a personal computer, all but eliminating the myriad of
different interconnects that used to be necessary. One such interconnect that is
becoming increasingly more rare is the RS-232 serial COM port. In fact, many
modern laptop computers no longer have one. This can pose a challenge, for the
developer needs a serial communication channel from a peripheral to a host PC. [9]
Fortunately, a device can use the USB Communication Device Class (CDC)
and allow the user to take advantage of the simplicity of the USB while providing the
functionality of a COM port. The CDC is how communication devices interface to
the USB. Intended for devices such as MODEMS and network interfaces, a subset of
the CDC features can be used to emulate a serial port providing a virtual UART.
The overall flexibility and power of the USB requires managing protocols for
device identification, configuration, control and data transfer. The Microchip PIC32
CDC serial driver handles the USB so the developer designing a device doesnt have
to.
The CDC serial driver provides a simple UART-like firmware interface for
transmitting and receiving data to and from the host, hiding most of the USB details
10
away from the application. The sample code provided is easily customizable,
reducing the amount of effort and learning that might otherwise be necessary when
adding a USB interface to a device. [10][11]
2.6
The RF transmitter and receiver modules are very small in dimension. The
low cost RF Transmitter can be used to transmit signal up to 100 meters (the antenna
design, working environment and supply voltage will seriously impact the effective
distance). It is good for short distance, battery power device development. Cytron
Technologies provides 2 types of RF Transmitter and Receiver Modules at either
315MHz or 433MHz for user. The following figure showed the Cytron transmitter
and receiver. [12][13]
11
2.7
Microchip had provided a full guideline to build the X-10 system using
PIC16F877A. The PIC16F877A was selected for this application because of its
versatility as a general purpose microcontroller, its FLASH program memory (for
ease of development), data EEPROM, and ample I/O. The application note AN236 is
attached in the appendix for reference.
12
Zero-crossing detector
User interface functions are accomplished with an LCD display and five push
buttons. A real-time clock is created using Timer1 and an external 32 kHz oscillator.
Users modified control data, such as unit on and off times are stored in the PIC
MCUs built-in EEPROM. Load switch is used in this application. The schematic of
the whole system can be referring from the appendix.
2.7.1
Zero-Crossing Detector
13
To receive X-10 signals, it is necessary to detect the presence of the 120 kHz
signal on the AC power line. This is accomplished with a decoupling capacitor, a
high-pass filter, a tuned amplifier, and an envelope detector. The components of the
carrier detector are illustrated in Figure 2.4.
2.7.3
14
input and the 120 kHz signal is not presented to the pin. When the TRISC bit is clear,
the pin becomes an output and the 120 kHz signal is coupled to the AC power line
through a transistor amplifier and capacitor, as depicted in Figure 2.5.
15
A load switch is included on the home controller so that it may act as a lamp
module, with its own house and unit address. A Triac was selected as the load switch,
because its medium power switching capacity and rapid switching capability make it
well-suited for lamp control and dimming.
A Triac is an inexpensive, three-terminal device that basically acts as a highspeed, bidirectional AC switch. Two terminals, MT1 and MT2, are wired in series
with the load. A small trigger current between the gate and MT1 allow conduction to
occur between MT1 and MT2. Current continues to flow after the gate current is
removed, as long as the load current exceeds the latching value. Because of this, the
Triac will automatically switch off near each zero-crossing as the AC voltage falls
below the latching voltage.
A Teccor L4008L6 Triac was selected because it has a sensitive gate that
can be directly controlled from the logic level output of the PIC MCU I/O pin. The
sensitive gate Triac can control AC current in both directions through the device,
even though the PIC MCU can provide only positive voltages to the gate.
16
2.8
17
on a PC is -10V for logic zero, and +10V for logic one. Since the signal level on the
microcontroller is +5V for logic one and 0V for logic zero, we need an intermediary
stage that will convert the levels. One chip specially designed for this task is
MAX232. This chip receives signals from -10 to +10V and converts them into 0 and
5V. The circuit for this interface is shown in the Figure 3.7
Figure 2.8: Connection between D9 Female serial port, MAX232 and PIC16F877A
2.9
Bootlaoder
18
2.10
19
2.11
To implement the speech recognition into the system, Microsoft Speech SDK
5.3 is used. Microsoft Speech SDK 5.3 is also known as SAPI 5.3. The Speech
Application Programming Interface or SAPI is an API developed by Microsoft to
allow the use of speech recognition and speech synthesis within Windows
applications. To date, a number of versions of the API have been released, which
have shipped either as part of a Speech SDK, or as part of the Windows OS itself.
Applications that use SAPI include Microsoft Office, Microsoft Agent and Microsoft
Speech Server.
In general all versions of the API have been designed such that a software
developer can write an application to perform speech recognition and synthesis by
using a standard set of interfaces, accessible from a variety of programming
languages. In addition, it is possible for a 3rd-party company to produce their own
Speech Recognition and Text-To-Speech engines or adapt existing engines to work
with SAPI. In principle, as long as these engines conform to the defined interfaces
they can be used instead of the Microsoft-supplied engines.
20
2.12
MPLAB 7.62
2.13
Related Journal
There are many home automation projects had been done successfully
nowadays. Related journal included:
i.
21
system. This system offers a complete, low cost, powerful and user friendly
way of real-time monitoring and remote control of a house.
ii.
iii.
The interaction with the home control system is done through specific
hardware or PC standard interfaces such as the serial port or USB, or by LAN.
The application offers a powerful way of controlling and programming the
behavior of the home, using scripts. For the common user, a simpler version
of a script - a scenario may be used. A scenario consists of a set of devices
in a particular state and can be activated directly by the user, by a time
stimulus or by any event in the home.
22
iv.
v.
This paper identifies the reasons for this slow adoption and evaluates
the potential of ZigBee for addressing these problems through the design and
implementation of a flexible home automation architecture. A ZigBee based
home automation system and Wi-Fi network are integrated through a
common
home
gateway.
The
home
gateway
provides
network
interoperability, a simple and flexible user interface, and remote access to the
system. A dedicated virtual home is implemented to cater for the systems
security and safety needs. To demonstrate the feasibility and effectiveness of
the proposed system, four devices, a light switch, radiator valve, safety sensor
and ZigBee remote control have been developed and evaluated with the home
automation system
23
2.14
Related Thesis
The following are some of the related thesis by previous UTM student.
i.
This project involve a simple switching system that used the transistor
along with relay to do all the connecting of the power to the devices, a voice
recognition system that consists of voice recognition chip HM2007, and the
PIC18F8722 microcontroller to build up the system. The HM2007 serves as
the ear that will listen and interpret the command by the given while the
PIC18F8722 serve as the brain of the system that will coordinate the correct
output with the input command given. This project able to recognition the
command trained by the user and successfully to execute the correct output.
This project is a small scale design which consists of 8 commands that will
used to control three different switches. The command is able to individually
switch on and switch off each of the switch. Besides that, the command
able to switch on all and off all switches at the same time.
ii.
Home Automation Control Using Voice Recognition And Phone Sms [18]
iii.
24
iv.
25
CHAPTER 3
METHODOLOGY
3.1
Introduction
26
Two microcontrollers is used for the system, one is for transmitter of the radio
frequency wireless communication, and one is for the receiver on the port of the
home appliances switch.
The system is divides into two parts that are software and hardware
implementation.
3.2
Hardware Implementation
This section will discuss about components that had been used in the system,
included RF system, USB CDC communication of microcontroller and computer.
3.2.1
27
3.2.2
3.2.3
3.2.4
28
3.2.5
Computer that had a minimum requirement of window vista, LAN card and
RS-232 serial port available is used in the system. The intel platform is used for the
computer that used in the system. This platform provides a cheap solution to
implement the system. The platform fit the minimum requirement of the system and
it is able to handle the network control and the speech recognition control of the
system.
29
3.2.6
Switched Ethernet is now the most common data link layer protocol and IP as
a network layer protocol, but many options have been used and continue popular in
niche areas. LANs may have connections with other LANs via leased lines, leased
services, or by 'tunneling' across the Internet using VPN technologies. They may
become a Metropolitan Area Network (MAN), a Wide Area Network (WAN), or a
part of the internet which depend on how the connections are made, secured, and the
distance involved.
3.3
Software Implementation
The software implementation including the software used to design the GUI
of the system in the computer, the speech recognition software, and the
microcontroller compiler and programmer.
30
3.3.1
In order for the user to control the home appliance by using computer, a
graphic user interface had been design for the user easier to control their home
appliance.
The graphic user interface of the system was build using Visual Basic 2008.
The program code used in this project is visual basic .net. It had provided a lot of
useful API for the user to code their program, including COM port interface, speech
recognize (SAPI) and so on. The code is more simplify compare to C++ and C#.
3.3.2
Instead of using MPlab for the PIC compiler, this project use PICBASIC
PRO compiler for the programming in PIC.
The PICBASIC PRO Compiler (or PBP) makes it even quicker and easier
for you to program Microchip Technologys powerful PIC microcontrollers (MCUs).
The English-like BASIC language is much easier to read and write than assembly
language. The PICBASIC PRO Compiler is BASIC Stamp II like and has most of
the libraries and functions of both the BASIC Stamp I and II. Being a true compiler,
programs execute much faster and may be longer than their Stamp equivalents.
31
3.3.3
Live
FolderShare) is
free-to-use
Internet-based
file
32
3.4
Flow of project
This project is summarized to the flow chart below. The project is done step
by step and Figure 3.3 shown the flow chart of the project work.
hardware
testing
bootloader
Software
Network
Testing
Design the bootloader to make connection between computer and the system.
Test the functionality of the bootloader with MPLAB.
Establish a remote connection with the window remote desktop connection function.
The computer of the system (host) can be taking control by the other's computer (client).
33
CHAPTER 4
FUNCTIONAL DESCRIPTION
4.1
This home automation system purpose is to use the computer to control the
electric home appliance. The features that come with the system included:
1. Speech recognition using SAPI 5.3
2. Network controlling using Windows Live Mesh
3. Wireless RF home appliance controlling
This system is directed to residential user, where the maximum ampere the
system can handle is 7A. This is not suitable to use in the industrial field.
4.2
Operating Environment
The system software has to be work under a computer that has the following
minimum requirements:
1. Operating system window vista or window 7
2. Minimum one LAN and USB port
34
3. Sound card
4. Internet connection
5. Install the window live mesh program
For the hardware part, this system is suitable for residential user, where the
maximum ampere the system can handle is 7A for 240VAC power line. For the
home appliances, make sure the power of home appliance used is not more than
1680watt.
4.3
Functional Requirements
There are three methods for a user to control the home appliance, shown as
following:
1. By clicking the desired output on the GUI
2. By speech recognition function
3. By using network control using window mesh
Before the user can control the home appliances, the transmitter have to
connect to the computer via USB and the receiver have to connect to the power
supply.
35
In order for the user to control the home appliance by using computer, a
graphic user interface had been design for the user easier to control their home
appliance.
36
First, the user has to log in before they can control to the home appliance. A
login form shown as below had been designed to provide authorize to the user.
User can either choose log in to the home automation or update username and
password after they key in their password. For the update option, a form will be
shown, figure 4.4, in order for the user to update his detail.
37
In the home automation form (figure 4.5), the user is able to control which
switch to be ON/OFF, by clicking the desire button. For the ALL ON and ALL OFF
button, it will on or off all the switches. The user has to choose the right comport in
comport list box before he can interface to the device.
38
For the speech recognition function, user can activate it by clicking the listen
button. A window speech recognition dialog will be pop out and user can start give
command. To start the speech recognition, user is required to speak start listening
to wake it up.
To on the certain switch, user has to say computer first, follow by the
switch you want to on or off, example: if you want to on switch 1, you may say
computer, on one.
The computer will respond back to you which switch is off or on after you
give the command. This will beneficial to blind people to control their home switch
by just speaking. The picture also will update the status of the switch, shown in
figure 4.7.
39
The next section we will discussed about the network controlling using
window live mesh. First, the system has to sign in with window live mesh.
40
After sign in for your system, then you can leave it alone and you can control
it by sign in the window live mesh in other computer and click for the remote tab.
This allow user to control their system online.
41
4.4
Performance requirements
The system has to work in a few conditions in order to working get the desire
output, these included:
42
CHAPTER 5
DESIGN ARCHITECTURE
5.1
This chapter will be discussed about the design architecture of the system;
there are two sections, hardware design and software design. Hardware design
included the transmitter part, receiver part and the electric appliance port part.
Software design included the programming coding for GUI, window live mesh,
speech recognition and hardware firmware.
5.2
Hardware Design
43
For the receiver part of the system, it required to receive the signal from the
transmitter and activate the certain relay to ON/OFF the switch. For the actual look
of the circuit, you can refer to Figure 4.2.
44
5.3
Software Design
This can divide into two parts, one is the GUI programming code, and
another one is the firmware of the PIC microcontroller. For the GUI programming
code, the author had used Microsoft Visual Basic to code my program, using
BASIC .net coding. For the firmware, PICBASIC is used as the assembler of the
program.
45
5.3.1
In order for the user to control the home appliance by using computer, a
graphic user interface had been design for the user easier to control their home
appliance.
To start coding the GUI, you have to follow the following step:
46
First, the user has to log in before they can control to the home appliance. A
login form shown as Figure 4.3 had been designed to provide authorize to the user.
47
There are two options after user have key in the username and password,
either the user want to login or update his username and password. The username
and password are saved in the user.txt and password.txt file. It will compare the
username and password that user type in the text box, with the username and
password in the txt file, to make decision that the username and password type by the
user is right or not. If the user want to login to the home automation system,
frmhome will show up and hide the login form. If the user wants to update his
username and password, form2 will show up and hide the login form.
Form2 (figure 4.4) is the update username and password form, as shown in
figure. It require user to key in the new username and password, and it will update
the user.txt and password.txt using the following code.
My.Computer.FileSystem.WriteAllText(user.txt, CStr(txtnewusername.Text),
False)
My.Computer.FileSystem.WriteAllText(pass.txt, CStr(txtnewpassword1.Text),
False)
Code 5.2: Write text coding
The home automation form is the control form for the whole system. Figure
4.5 had shown the design of the home automation form. To implement this project, 4
light is use in the form, and two buttons beside the light is to control the light
ON/OFF. The four lights will update when user open or close the light, these picture
will show the status of the light. The listen button is to start the speech recognition
function and the stop listen is the stop the function.
Before we start control the light, we have to load the com port initialization
and the speech recognition initialization first. The following is the load code for the
frmhome.
48
SetState(False)
initialize voice object
Voice = New SpeechLib.SpVoice
computer speak welcome to home automation
Voice.Speak(welcome
to
home
SpeechLib.SpeechVoiceSpeakFlags.SVSFlagsAsync)
End Sub
Code 5.3: frmhome_load code
Sub InitializeForm()
Dim nameArray() As String
' Find the COM ports on the system.
nameArray = SerialPort.GetPortNames
Array.Sort(nameArray)
' Fill a combo box with the port names.
automation,
49
cmbPorts.DataSource = nameArray
cmbPorts.DropDownStyle = ComboBoxStyle.DropDownList
' Select a default port.
End Sub
Code 5.4: Initialize the com port
Sub OpenComPort()
Try
' Get the selected COM port's name from the combo box.
If Not mycomport.IsOpen Then
mycomport.PortName = cmbPorts.SelectedItem.ToString
' Set other port parameters.
mycomport.Parity = Parity.None
mycomport.DataBits = 8
mycomport.StopBits = StopBits.One
mycomport.Handshake = Handshake.None
mycomport.ReadTimeout = 3000
mycomport.WriteTimeout = 5000
' Open the port.
mycomport.Open()
End If
Catch ex As InvalidOperationException
MessageBox.Show(ex.Message)
Catch ex As UnauthorizedAccessException
MessageBox.Show(ex.Message)
Catch ex As System.IO.IOException
MessageBox.Show(ex.Message)
End Try
End Sub
Code 5.5: Open Com Port Coding
50
Most of the coding is explained in the comment; refer to the code for further
understanding.
In order to sent a string and receive response string through COM port, a
sendcommand function is used, shown in code 3.6.
Case "0"
Picoff1.Show()
Picon1.Hide()
Case "1"
Picon1.Show()
Picoff1.Hide()
Case "2"
Picoff2.Show()
Picon2.Hide()
Case "3"
Picon2.Show()
Picoff2.Hide()
Case "4"
51
Picoff3.Show()
Picon3.Hide()
Case "5"
Picon3.Show()
Picoff3.Hide()
Case "6"
Picoff4.Show()
Picon4.Hide()
Case "7"
Picon4.Show()
Picoff4.Hide()
Case Else
End Select
Catch ex As TimeoutException
MessageBox.Show(ex.Message)
Catch ex As InvalidOperationException
MessageBox.Show(ex.Message)
Catch ex As UnauthorizedAccessException
MessageBox.Show(ex.Message)
End Try
End Sub
Code 5.6: SendCommand subroutine function
For each button click, a string will sent to the device through COM port using
the sendcommand subroutine function. To on switch 1, 2, 3 and 4, it should sent
52
component
had
on",
SpeechLib.SpeechVoiceSpeakFlags.SVSFlagsAsync)
End Sub
component
had
off",
SpeechLib.SpeechVoiceSpeakFlags.SVSFlagsAsync)
End Sub
had
on",
SpeechLib.SpeechVoiceSpeakFlags.SVSFlagsAsync)
End Sub
53
Voice.Speak("Light
had
on",
SpeechLib.SpeechVoiceSpeakFlags.SVSFlagsAsync)
End Sub
had
on",
SpeechLib.SpeechVoiceSpeakFlags.SVSFlagsAsync)
End Sub
had
on",
SpeechLib.SpeechVoiceSpeakFlags.SVSFlagsAsync)
End Sub
had
off",
SpeechLib.SpeechVoiceSpeakFlags.SVSFlagsAsync)
End Sub
had
off",
SpeechLib.SpeechVoiceSpeakFlags.SVSFlagsAsync)
End Sub
54
SendCommand("4")
Voice.Speak("Light
had
off",
SpeechLib.SpeechVoiceSpeakFlags.SVSFlagsAsync)
End Sub
had
off",
SpeechLib.SpeechVoiceSpeakFlags.SVSFlagsAsync)
End Sub
Friend WithEvents btnexit As System.Windows.Forms.Button
The following section is the speech recognition function for the GUI. When
the listen button is click, the following code will be run. The following code is to
initialize the speech recognition and add in the SAPI into the program. The
initialization included the specific grammar we will used (the initial state and the
transition state).
55
Voice.Speak("what
can
help
you?",
SpeechLib.SpeechVoiceSpeakFlags.SVSFlagsAsync)
' Initialize recognition context object and grammar object, then
' start dictation
If (RecoContext Is Nothing) Then
Debug.Print("Initializing SAPI reco context object...")
RecoContext = New SpeechLib.SpSharedRecoContext
' Add two rules. The top level rule will reference the items rule.
TopRule
Grammar.Rules.Add("TopLevelRule",
SpeechLib.SpeechRuleAttributes.SRATopLevel
Or
SpeechLib.SpeechRuleAttributes.SRADynamic, 1)
ListItemsRule
Grammar.Rules.Add("ListItemsRule",
SpeechLib.SpeechRuleAttributes.SRADynamic, 2)
AfterCmdState = TopRule.AddState
56
Grammar.Rules.Commit()
Grammar.CmdSetRuleState("TopLevelRule",
SpeechLib.SpeechRuleState.SGDSActive)
End If
SetState(True)
End Sub
As
Object,
ByVal
RecognitionType
As
57
oItem = Result.PhraseInfo.Properties.Item(1).Children.Item(0)
index = oItem.Id
58
End If
End Sub
Code 5.9: Speech Recognition Function
5.3.2
Firmware
59
For the transmitter part, the PIC has to handle USB CDC protocol and the RF
transmits. The code for the transmitter part PIC18F4550 is shown in the appendix 1.
Before coding for the PIC18F4550, it should include two libraries, one is HID
descriptors for the USB CDC stack (cdc_desc.bas) and one is the serial modes
(modedefs.bas) for the serial communication for transmitter. The firmware will
continuously check the data in from the USB and give the corresponding respond to
the command, by using USBIN function.
When it receives the command (0 to 7), it will show respond on the led and
then sent the command through RF transmitter 10 times to the terminal port, using
SEROUT function. This is to make sure the string is successfully sent out. The
command sent format is set to be, AABB, _., where it sent (0-7) string after
sending AABB string. This is to make sure the receiver can react accurately after
receive the command. After that, it will send a response ending back to the computer
using USBOUT function. To make sure the USB connection does not drop,
USBSERVICE should be done regularly.
For the receiver part, the PIC has to handle the RF receiver and give the
output to the relay to on/off the relay. The code for the receiver part PIC16F877A is
shown in the appendix 2. Serial mode library should be included in the firmware. To
receive the RF signal, SERIN function is used. It responds only after it detects string
60
AABB, and it will save the string in B0. By using SELECT CASE B0 function, it
will give respond on the corresponding result, and switch ON/OFF the switch.
61
CHAPTER 6
6.1
Hardware Verification
62
After that, you can send string by typing on the TeraTerm window. The
device will give back echo response via USB. TeraTerm will shown the response
after receive the response from PIC18F4550, shown in figure 6.2.
It can show the result in the fastest way before the software developed. When
7 is sent to the PIC18F4550, it will show the respond by ON the fourth led, then it
will sent the rf signal to the terminal part and ON the switch in the receiver part,
figure 6.3
63
6.2
System Verification
To start the speech recognition, say start listening to wake up the computer.
Then you may give the command by saying computer follow with the command.
the author started saying with computer, all on and the system responded by ON all
the switch, shown in figure 6.5.
64
Lastly the author tried to test on the specific switch by using, computer, on 1
command. As the result, it had ON the switch 1, as shown in figure 6.7.
65
For the next test, the author tried on the reliability of the RF transmits. The
author placed the receiver part around 7m apart from the transmitter part. As a result,
it still working perfectly without any error occurred.
66
7m
The last section is to test the network controlling using the window live mesh
program. First we connect the system to the window live mesh online, please refer to
figure 4.8 for the log in part.
67
After log in the Window Live Mesh on the system, then you may connect the
client computer to Window Live Mesh as well using the same account. On the client
computer, clicked connect to the computer to connect to the system.
Click to connect
to the system
As a result, it pop out the window below, which is the process connecting
with your system, as shown in Figure 6.11. You may require waiting until the
connection is established.
68
After connected successfully, a window will pop out, showing the screen of
the system computer. You have to key in the password before you can take control to
the system computer, as shown in figure below.
After log in, you may start you home automation program by clicking the
home automation shortcut. Log in to it and start control the system through internet,
which shown in figure 6.13 to figure 6.16.
69
70
71
For the network connection through Window Live Mesh, the result is
satisfied, but slow respond may occur if the internet service is not good enough.
72
CHAPTER 7
CONCLUSION
7.1
Conclusion
The speech recognition made the convenient to the motion disabled. It can
easily control the switch by just using speech. With SAPI 5.3, the result of the
recognition is reliable with lowest error recognition occurred.
The networking controlling through Window Live Mesh can enable the user
to control the system through online. The whole system is secured through a login
password and username based authentication.
The design is wireless with RF communication, which makes the system easy
to install, instead of using wired communication. It provided a low-cost, robust and
easily operable system. You can connect any electric appliance to the system, as long
as it does not existing 7A current usage.
73
7.2
Recommendation
74
REFERENCES
75
76
APPENDIX A
Include"cdc_desc.bas"
Include "modedefs.bas"
SO
VAR PORTC.6
led1
var PORTD.3
led2
var PORTD.2
led3
var PORTD.0
led4
var PORTD.1
buffer Var
cnt
i
Byte[16]
Var Byte
var byte
Define
OSC
'led blinking
for i=1 to 2
high led1
pause 50
high led2
pause 50
high led3
pause 50
high led4
pause 50
low led1
low led2
48
'Define variable
77
low led3
low led4
high led4
pause 50
high led3
pause 50
high led2
pause 50
high led1
pause 50
low led1
low led2
low led3
low led4
next i
USBInit
USBService
idleloop:
USBService
cnt = 16
buffer[0]=0
buffer[1]=0
USBIn 3, buffer, cnt, idleloop
'sent rf signal
FOR I=1 To 10
Serout SO,N2400,["AABB","7"]
78
next i
USBService
USBOut 3, buffer, 2, outloop
case "6"
low led4
'sent rf signal
FOR I=1 To 10
Serout SO,N2400,["AABB","6"]
next i
USBService
USBOut 3, buffer, 2, outloop
case "5"
high led3
'sent rf signal
FOR I=1 To 10
Serout SO,N2400,["AABB","5"]
next i
USBService
USBOut 3, buffer, 2, outloop
case "4"
low led3
'sent rf signal
FOR I=1 To 10
Serout SO,N2400,["AABB","4"]
next i
USBService
USBOut 3, buffer, 2, outloop
case "3"
high led2
'sent rf signal
79
FOR I=1 To 10
Serout SO,N2400,["AABB","3"]
next i
USBService
USBOut 3, buffer, 2, outloop
case "2"
low led2
'sent rf signal
FOR I=1 To 10
Serout SO,N2400,["AABB","2"]
next i
USBService
USBOut 3, buffer, 2, outloop
case "1"
high led1
'sent rf signal
FOR I=1 To 10
Serout SO,N2400,["AABB","1"]
next i
USBService
USBOut 3, buffer, 2, outloop
case "0"
low led1
'sent rf signal
FOR I=1 To 10
Serout SO,N2400,["AABB","0"]
next i
USBService
USBOut 3, buffer, 2, outloop
case else
GOTO outloop
80
end select
outloop:
' Must service USB regularly
USBService
Goto idleloop
81
APPENDIX B
Include "modedefs.bas"
SI
VAR
PORTC.7
B0
Var Byte
LED1
VAR PORTD.0
LED2
VAR PORTD.1
LED3
VAR PORTD.2
LED4
var PORTD.3
var byte
Define OSC
'led blinning
for i=1 to 2
high led1
pause 50
high led2
pause 50
high led3
pause 50
high led4
pause 50
low led1
low led2
low led3
20
82
low led4
high led4
pause 50
high led3
pause 50
high led2
pause 50
high led1
pause 50
low led1
low led2
low led3
low led4
next i
START:
B0=0
Serin SI,N2400,["AABB"],B0
select case B0
CASE "7"
HIGH LED4
CASE "6"
LOW LED4
CASE "5"
HIGH LED3
CASE "4"
LOW LED3
CASE "3"
HIGH LED2
CASE "2"
LOW LED2
CASE "1"
83
HIGH LED1
CASE "0"
LOW LED1
END SELECT
GOTO START