You are on page 1of 30

Name : Yeo Khang Hsien TP051413

Intake Code : UC2F1905IS


Lecturer : Mr. Shounak Ghosh
Module Title : CT047-3-2-SPCC
Project Title : Individual Assignment
Hand-out date : 1 July 2019
Hand-in date : 16 August 2019

1
Marking Grid

Sections Max Marks


Marks
Obtained
1. Meet Criteria Requirement. 15
2. User interface 15
3. Software running without error. (ie. No runtime errors, 10
syntax errors etc.)
4. Codes are consistent, clean, modular and follows 10
programming logic.
5. Algorithm and Documentation 10
6. Practical class work 20
7. Presentation 20
Total 100

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.

Smart Home project consists of two *.vi files:

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.

3.2 Lab View

LabVIEW is short for Laboratory Instrument Engineering Workbench which provides a


programming environment to create programs visually by using Drag and Drop technique on
graphical icons to construct the relationship between them by drawing wires to connect the
nodes. LabVIEW is different from text-based programming language such as C, C++, Python
and Java, it is an interactive program development and execution system designed for
specialists such as scientist and engineers to design and implement specific projects.
Additionally, LabVIEW do create programs that supports many platforms such as Windows,
Linux, and Apple.

4.0 Project Requirement

4.1 Project requirements fulfilled by LabVIEW

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.

Flexibility and scalability

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.

4.2 How Does LabVIEW work?

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.

Figure 4.2.1 Front panel

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.

Figure 4.2.2 Block diagram

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.

Figure 4.2.3 Control Palette

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.

Figure 4.2.4 Function Palette

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

5.0.1 Client Side Flowchart

Figure 5.0.1 Client side flowchart

13
5.1.1 Server side Flowchart

Figure 5.1.1 Server side flowchart

14
6.0 Protocol Design
6.1 Client-server model using TCP/IP with LabVIEW

TCP/IP is short of Transmission Control Protocol/Internet Protocol. It is used to connect


network devices for data transfer on computer networks. TCP is responsible for creating
channel of communication across the network whereas IP is responsible for determining the
correct path for the packets to travel. The main 4 layers of the TCP/IP are application,
transport, network and physical layers which is the hardware.

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

Figure 6.1.1 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

Figure 6.1.2 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

Figure 6.1.3 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

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

TCP Close Connection

Figure 6.1.5 TCP close connection

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.

6.3 Control Interface-Client Side


Login Form
Whenever the user starts the program, the login page will appear and prompt users for their
credentials before they are able to access the other control. The user can only access the
controls if they provide the correct match of username and password. Additionally, there will
have a pop up message that require the user to key in the master pin number in order to
access the controls.

Figure 6.3.1 Login Form

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.

Figure 6.3.2 Block diagram of login

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

Figure 6.3.3 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

Figure 6.3.5 TV control

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

Figure 6.3.7 User Registration page

The user registration page able to overwrite the textfile to provide login access to the users.

Figure 6.3.8 Block diagram of User Registration page

23
6.4 Indicator Interface-Server

Figure 6.4.1 Server


In the picture above , these are the lights , windows , doors , curtain, air conditioner and tv
that can be controlled by users.
The Figure above shows the indicators of lights, curtains, doors, air conditional, TV, fan and
burglar alarm which can be controlled from the client side by the user.

Figure 6.4.2 Block diagram of the server


The server will receive the command and execute the command based on the case in the case
structure by getting the string input from the client. The string input will be convert into the
correct data type by connecting it with Typecast with its top part connected to the respective
datatype.

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.

8.0 Future Enhancement


Nothing is the best, there is always a space for improvements. For example, the air
conditional can have heat sensor to detect heat changes and automatically adjust to the
optimum temperature. Also the Burglar Alarm can be designed to be trigger automatically
whenever an intruder enters the house.

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 :

Chamestudio Private Limited (2019). Fan Icon. [image] Available at:


https://iconscout.com/icon/fan-182 [Accessed 15 Aug. 2019].
Zone.ni.com. (2019). Configuring Options for Tab Controls - LabVIEW 2018 Help -
National Instruments. [online] Available at: https://zone.ni.com/reference/en-
XX/help/371361R-01/lvhowto/additionalconfigfortabcntr/ [Accessed 16 Aug. 2019].
ACADEMIA. (2019). Design & Implementation of Smart House Control Using LabVIEW.
[online] Available at:
https://www.academia.edu/30079722/Design_and_Implementation_of_Smart_House_Contro
l_Using_LabVIEW [Accessed 16 Aug. 2019].
Edrawsoft (2019). Free Printable Floor Plan Templates Download. [image] Available at:
https://www.edrawsoft.com/free-floorplan-templates.php [Accessed 15 Aug. 2019].
Forums.ni.com. (2019). How do I Control the Windows "Close" Button (Little Red "X").
[online] Available at: https://forums.ni.com/t5/LabVIEW/How-do-I-Control-the-Windows-
quot-Close-quot-Button-Little-Red/td-p/1264032?profile.language=en [Accessed 16 Aug.
2019].
IconBunny (2017). Air Conditioner Line Icon. [image] Available at:
https://www.iconbunny.com/icons/home-electronics-air-conditioner-line-icon [Accessed 15
Aug. 2019].
LabVIEW (2019). How to Close or Exit VI Programmatically - LabVIEW. [image] Available
at: https://www.youtube.com/watch?v=yTDJSWAVGvE [Accessed 16 Aug. 2019].
Knowledge.ni.com. (2019). Programmatically Accessing Tab Controls Properties - National
Instruments. [online] Available at: https://knowledge.ni.com/KnowledgeArticleDetails?
id=kA00Z0000019O8LSAU&l=en-MY [Accessed 16 Aug. 2019].
Ni.com. (2019). Connect Sensors and Signals to a DAQ Device - National Instruments.
[online] Available at: http://www.ni.com/getting-started/set-up-hardware/data-
acquisition/sensors [Accessed 16 Aug. 2019].
Ni.com. (2019). Hardware Integration with NI LabVIEW - National Instruments. [online]
Available at: https://www.ni.com/en-my/innovations/white-papers/13/hardware-integration-
with-ni-labview.html [Accessed 16 Aug. 2019].

26
11.0 Appendix
11.1 User Manual

1. Start server first by running Server.vi file


2. Then only, start client by running Client.vi file
3. Login to client by using default password of:
Username: abc
Password: 123

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

You might also like