Professional Documents
Culture Documents
SPCC Assignment Documentation
SPCC Assignment Documentation
1
Marking Grid
Contents
1.0 Acknowledgement...........................................................................................................................4
2
2.0 Abstract...........................................................................................................................................5
3.0 Introduction.....................................................................................................................................6
3.1 Project Summary.........................................................................................................................6
3.2 Lab View.....................................................................................................................................6
4.0 Project Requirement........................................................................................................................7
4.1 Project requirements fulfilled by LabVIEW....................................................................................7
4.2 How Does LabVIEW work?........................................................................................................8
4.3 Hardware devices that can be used in LabVIEW.......................................................................12
5.0 System Design...............................................................................................................................13
5.0.1 Client Side Flowchart.............................................................................................................13
5.1.1 Server side Flowchart.............................................................................................................14
6.0 Protocol Design.............................................................................................................................15
6.1 Client-server model using TCP/IP with LabVIEW....................................................................15
6.2 Smart Home Protocol design.....................................................................................................18
6.3 Control Interface-Client Side.....................................................................................................18
6.4 Indicator Interface-Server..........................................................................................................24
7.0 Limitation......................................................................................................................................25
8.0 Future Enhancement......................................................................................................................25
9.0 Conclusion.....................................................................................................................................25
10.0 Reference :...................................................................................................................................26
11.0 Appendix.....................................................................................................................................27
11.1 User Manual............................................................................................................................27
11.2 Gantt Chart..............................................................................................................................29
1.0 Acknowledgement
3
Firstly, I would like to express my deepest thanks to, Mr. SHOUNAK GHOSH, our lecturer
at Asia Pacific University of Technology & Innovation (APU) for his guidance of using
LabVIEW software on this module project. LabVIEW focus on graphical programming
approach for the user to put programming into practise by visualizing its aspects. I would
thank our lecturer for this project as the guidance through lab practises truly help in
constructing the smart home project. I also would like to thank Asia Pacific University of
Technology & Innovation (APU) for updated education system in Malaysia.
2.0 Abstract
4
This project is a simulation of Smart Home System by using the programming concept of
socket programming provided by LabVIEW software. Socket is the interface between
application layer and transport layer of OSI layer model. In reality, multiple clients can
access the system. By simulating the Smart Home System, only one client can is
implemented to create a prototype. The project is based on the smart home concept,
illustrating the features of the smart home control system that could work and developed in
reality. The prototype simulates the control feature by using Client/Server methodology with
different sensors and controls. Client and Server is the main part of this project which are
implemented separately. Client side is the control pad consists of controls to control the
software sensors (Lights, Doors, Curtains, etc.) remotely at the Server side which is the home
in this case. Hence, the sensors at the Server side will be control by the Client’s controls, such
as switching the lights on by at the Server Side from the Client Side. The control pad is
password protected and the user will be authenticated before any access. A master pin is
required for the user to access the control system. Communications between Client and
Server handled by TCP/IP connections using a custom protocol.
1. Server.vi: It is the server part that contains indicators and floor plans.
2. Client.vi: It is the client part of system and it provides register page, login page and
all control buttons to be used in the Smart Home.
3.0 Introduction
3.1 Project Summary
Smart Home System is a collection of sensors and controllers that works together and being
automated by every aspects of home according to a configured settings. The authorised user
can control every part of this system remotely.
5
The Smart Home System controls different aspect of house such as the light, curtain,
door, tv, fan and air conditioner. The user can control individual software sensors at once, or
control all software sensors of the same type by controlling the master button. In case of TV,
it simulates the TV remote control that have 9 channels and some functional buttons such as
play, pause, fast forward, fast rewind, and so on. Additionally, the TV has the sound control
to adjust the volume or mute it.
All part of the system has been created by using only the functionalities of Lab View
without implementations of external programming language.
6
LabVIEW is preferred over other programming software because LabVIEW is more efficient
on constructing prototypes compare to other software such as NetBeans and Java, especially
for this project. There are some factors that need to be considered:
Graphical Programming
LabVIEW is a graphic user interface based programming software which is different
compared to text-based software such as Java, Python, and C#. The user can perform Drag
and Drop techniques to design the graphic user interface from the function palette easily.
LabVIEW has built-in functions and IP including I/O and analysis.
Efficiency
Constructing a prototype in the shortest time possible is advisable to test out the functions
and developing it into the final product. Compare to conventional programming languages,
LabVIEW had the advantage to construct the prototype in shorter time by constructing the
prototype graphically which is easier to visualise and modify compare to text-based
programming such as Netbeans and Java.
Multi platforms
LabVIEW is compatible on many platforms such as Windows, Linux and Apple. Thus,
LabVIEW is portable across these platforms that is used by majority.
LabVIEW is flexible to perform changes on the project without affecting other components,
resulting efficiency for programmers to perform changes.
Simulation
LabVIEW able to bring the project into reality by using real hardware devices. It is indeed a
powerful advantage for programmers to design a system that will work in reality rather than
leaving it as a logic concept alone without hardware to perform it.
7
LabVIEW program consists of virtual instruments (Vis) that can be either one or more than
one. Virtual instruments resemble the actual physical instruments due to their appearance and
behaviour. A VI has front panel, block diagram and an icon as the 3 main parts.
Front Panel
Front Panel act as the user interface which consist of the controls and indicators. The concept
is the controls will affect the indicators.
8
Block Diagram
Block diagram is the template to design the mechanism of the user interface (front panel)
which consist of wires to connect the entities of controls and indicators in the form on icons.
Control Palette
9
Control palette can be access in the user panel by right clicking at the empty areas. Control
palette provides every built in features of LabVIEW to design and implement the project. For
user that is not familiar of the category of the icons, a search button at the top right can be
used.
Function Palette
10
Similar to control palette, function palette can be access in the block diagram by right
clicking at the empty areas. Function palette provides every built in features of LabVIEW to
design and implement the project. For user that is not familiar of the category of the icons, a
search button at the top right can be used.
11
4.3 Hardware devices that can be used in LabVIEW
LabVIEW is able to transform the prototype into real product by using real-world hardwares.
From Ni.com, There is a list of compatible hardware devices which can be called NI
Hardware:
Digital Multimeters
High-Speed Digitizers (Oscilloscopes)
RF Signal Analysers
RF Signal Generators
Signal Generators
High-Speed Digital I/O
Switches
Programmable Power Supplies
Reconfigurable FPGA I/O
Motion Controllers
Vision Systems
12
5.0 System Design
Smart home system is design to allow users to connect to their houses remotely using TCP/IP
protocol. Before users can control the house , they need to login to the system to gain access.
In this project, user details are stored at client side as only owner of the house can connect to
the house. It is not necessary for us to save user credentials in server side(house).
13
5.1.1 Server side Flowchart
14
6.0 Protocol Design
6.1 Client-server model using TCP/IP with LabVIEW
TCP/IP in LabVIEW
Server side of smart home need to be available most of the time to be connect by the client.
TCP Listen
TCP Listen is located at the server. “localhost” is the service name or address of the server.
The port number is 51000. Timeout is set to -1 to set this server runs endlessly.
15
TCP Open Connection
TCP open connection is placed in client side. The address and port of the TCP needs to be the
same as the server in order for the connection to be established. Timeout is set to 60000ms or
60s, which means the connection will last for only 60s.
TCP Write
TCP write is located at the client side. After the connection is established, TCP write will
send commands to the server. Two TCP Write are used here as TCP requires the length of the
string in order to read the whole string on server side. The first TCP write will write the
length of the string. The second TCP will write the full string.
16
TCP Read
TCP Read is located in server side. Two TCP Read allows the server to obtain the exact
string that the client wants to send. The first TCP Read’s “bytes to read” is set to 4 as the
value brought from TCP Write from client will be “number+number+boolean” in this project.
The number is 1 byte, whereas the boolean is 2 bytes. The first TCP read will read the String
length and transfer it to the “byte to read” of the second TCP read. The second TCP will read
the whole String. An interesting part is even though the “number+number+boolen” is 4 bytes.
When the string length(int) is converted to String , the number of byte becomes 3 . So the
actual length that second TCP Read will read is 3.
After the command is written or read by TCP, the connnection needs to be closed. Any errors
that appeared during the whole TCP process can be cleared by using Clear error.vi.
17
6.2 Smart Home Protocol design
The Smart Home System prototype used a custom protocol which is TCP connection
that defines formats of all communications between client and server. TCP is a connection
based protocol that delivers data in sequence which is a reliable transmission across the
networks. TCP has the functionality to permit multiple and simultaneous connections
between computers and other hardware. The clients and servers of TCP must firstly form a
connection before transferring the data, which can be done by placing the ‘listening’ at the
server side and open a connection on the client side at the port where the server is receiving
commands through ‘listening’. Then, client of Smart Home can send commands to the server
and the server can send the response to the client.
18
The username and password are stored in txt files.
The username is located at the left whereas the password is located at the right.
If the username can be found in the textfile , password will be compared. This is done by
using comparison icon. After login is successful , the login page will be changed to main
control page.
The comparison icon functions as a match-checker to enable only the matching credentials of
the input and the textfile condition will be directed to the controls.
19
Control Page
After the user has been directed to the control page, the use can access the controls
categorized by different sub-pages such as door, light, curtain, air conditional, fan, master
button, TV, burglar alarm, as shown in the Figure 6.3.3. Basically every button controls the
relative sensors located at the server side, and the master button can control all buttons lies
under the same category at once.
Figure 6.3.4 Block Diagram for sending command to the server side
20
TV page
This page simulates the TV remote control in reality, having 9 channels to watch can able to
perform various functions using controls such as play, pause, stop, fast forward, fast rewind,
adjusting the volume and mute the sound.
In this page , users can choose the either channel 1 or channel 2. They can play, pause,stop,
fastforward,fastbackward , change volumn and mute the tv.
21
Figure 6.3.6 Block diagram for sending channel 1 command to server
22
User Registration
The user registration page able to overwrite the textfile to provide login access to the users.
23
6.4 Indicator Interface-Server
24
7.0 Limitation
This smart home system has a limitation that the master button cannot disable other controls
falls under the same category. For instance, turning on the light master button will not disable
a single light button afterwards, which a kitchen light can be switched off right after master
button. Another limitation is all the controls can only be remotely control by the user instead
of functioning automatically.
9.0 Conclusion
The outcome of doing this project is a better understanding towards socket programming
found in the client-server model. This is useful in implementing TCP/IP connection in other
projects.
25
10.0 Reference :
26
11.0 Appendix
11.1 User Manual
27
Figure 11.1.1
4. Insert the master Pin Number to access to controls, which is 1234 by default.
Figure 11.1.2
5. You will be directed to Control Panel in Client side.
Below is the control panel for smart home system. The software sensors can be control by
the relative buttons on the control pad, categorized by pages of the tab control. The
system will be shut down after the close button is pressed.
Figure11.1.3
28
6. New users can register at the register table.
Figure 11.1.4
11.2 Gantt Chart
29
30