Upload
others
View
4
Download
0
Embed Size (px)
Citation preview
Wireless to Infrared
Converter for iPad
European Project Semester Ingeniørhøjskolen i København By: Maxim Gladines, José Ignacio Busca, Vicente Ruiz Spring 2011
2
Abstract
This project manages an improvement in the world of universal remote
controllers taking benefit of the advantages of a Wireless LAN and being capable
of control any multimedia device with an iPad.
A local database stores the information about the infrared codes and it is placed
inside the application. The converter consists of a Wireless board, which receives
the data through the WLAN, converts this data into an infrared signal and to send
it to the IR device.
fig 1. Abstract view of the project
3
1. Introduction __________________________________________________ 8
1.1 Project briefing ......................................................................................... 8
1.2 Problem statement ................................................................................... 8
1.3 Statement of challenges ........................................................................... 8
1.4 Approach of the problem ......................................................................... 8
1.5 Summary of results ................................................................................... 8
2. Structure and management of the project __________________________ 9
2.1 Feasibility study ........................................................................................ 9
2.2 Goals and objectives ............................................................................... 11
2.3 Requirements .......................................................................................... 11
2.4 Scope management ................................................................................ 12
2.5 Resource pool ........................................................................................ 13
2.6 Time management .................................................................................. 14
3. Project components ___________________________________________ 15
3.1 Hardware ............................................................................................... 15
3.1.1 Hardware comparison table ........................................................... 16
3.1.2 Arduino Uno ................................................................................... 17
3.1.3 Wifly shield ..................................................................................... 18
3.1.4 IR Led .............................................................................................. 19
3.1.5 Wireless Router .............................................................................. 21
3.2 Software .................................................................................................. 22
3.2.1 Arduino ........................................................................................... 22
3.2.2 Adobe CS5 suite .............................................................................. 22
3.2.3 TeraTerm ........................................................................................ 23
3.2.4 Lita .................................................................................................. 23
4
4. The converter ________________________________________________ 24
4.1 Introduction ............................................................................................ 24
4.2 Infrared Protocols ................................................................................... 25
4.2.1 NEC Protocol ................................................................................... 26
4.2.2 SONY SIRC protocol ........................................................................ 27
4.2.3 PHILIPS RC5 protocol ...................................................................... 28
4.2.4 PHILIPS RC6 protocol ...................................................................... 29
4.2.5 SAMSUNG protocol ........................................................................ 30
4.3 Wifly shield ............................................................................................. 31
4.3.1 Connecting to the Arduino ............................................................. 31
4.3.2 Connecting to a network ................................................................ 32
4.4 Initializing Arduino and Wifly ................................................................. 34
4.5 Incoming data to the Arduino ................................................................. 35
4.6 Processing data ....................................................................................... 35
4.7 Selecting IR protocol ............................................................................... 35
4.8 Arduino libraries ..................................................................................... 35
4.9 Signal output ........................................................................................... 36
4.10 Flowchart ................................................................................................ 37
4.11 Different ideas applicable to this project ............................................... 38
4.11.1 Recording IR LED ............................................................................ 38
4.11.2 Chip with codes inside .................................................................... 39
4.11.3 More range with the IR LED ........................................................... 39
4.12 Tests and results of the IR signals ........................................................... 40
4.12.1 NEC protocol ................................................................................... 41
4.12.2 SONY protocol ................................................................................ 42
4.12.3 PHILIPS RC5 protocol ...................................................................... 43
5
4.12.4 PHILIPS RC6 protocol ...................................................................... 44
4.12.5 SAMSUNG protocol ........................................................................ 45
4.12.6 Consumption values ....................................................................... 46
4.13 Design of the converter .......................................................................... 47
4.14 Difficulties ............................................................................................... 50
5. Network _____________________________________________________ 51
6. The application _______________________________________________ 53
6.1 Software design process ......................................................................... 53
6.1.1 Introduction .................................................................................... 53
6.1.2 Portable Network Graphic ............................................................. 54
6.1.3 Vectors............................................................................................ 54
6.2 Development process ............................................................................. 57
6.2.1 Introduction .................................................................................... 57
6.2.2 Sockets............................................................................................ 58
6.2.3 TCP Protocol ................................................................................... 59
6.2.4 Sending data ................................................................................... 61
6.3 Database ................................................................................................. 63
6.4 Information architecture ........................................................................ 66
7. Proof of concept ______________________________________________ 67
8. Conclusion ___________________________________________________ 69
9. References ___________________________________________________ 70
6
Table of figures
1. Abstract picture of the Project ............................................................. 2
2. Economic feasibility of the project ....................................................... 9
3. Work Breakdown Structure ................................................................ 12
4. Resource pool ..................................................................................... 13
5. Gantt Chart .......................................................................................... 14
6. Responsibility Matrix .......................................................................... 14
7. Hardware comparison table ............................................................... 16
8. Arduino blueprint ................................................................................ 17
9. WiFly Shield ......................................................................................... 19
10. Infrared LED blueprint ......................................................................... 20
11. 3Com Wireless Router ........................................................................ 21
12. The converter ...................................................................................... 24
13. Standard NEC message ....................................................................... 26
14. Standard Sony message ...................................................................... 27
15. Standard Philips RC5 message ............................................................ 28
16. Standard Philips RC6 message ............................................................ 29
17. Standard Samsung message ............................................................... 30
18. Arduino Uno and WiFly shield ............................................................ 34
19. Converter flowchart ............................................................................ 37
20. IR learning method .............................................................................. 38
21. Chip with protocols stored inside ....................................................... 39
22. IR range increasing circuit ................................................................... 39
23. NEC IR wave shape .............................................................................. 41
24. Sony IR wave shape ............................................................................. 42
25. Philips RC5 IR wave shape ................................................................... 43
26. Philips RC6 IR wave shape ................................................................... 44
27. Samsung IR wave shape ...................................................................... 45
28. Consumption table .............................................................................. 46
29. Converter shape comparison .............................................................. 47
30. Ball shaped converter ......................................................................... 48
31. Platonic shaped converter .................................................................. 48
7
32. Cylindrical shaped converter .............................................................. 49
33. Cube shaped converter ....................................................................... 49
34. Wireless technology comparison chart .............................................. 51
35. Button states ....................................................................................... 53
36. User‐Interface design 1 ....................................................................... 55
37. User‐Interface design 2 ....................................................................... 56
38. Socket connection ............................................................................... 58
39. TCP data segment ............................................................................... 60
40. Protocol symbols ................................................................................. 61
41. String code example ............................................................................ 61
42. Database design .................................................................................. 63
43. Flowchart application.......................................................................... 66
44. User‐interface design 2 ....................................................................... 67
45. Project scheme .................................................................................... 68
8
1. Introduction
1.1 Project briefing
The briefing stated: Research the theory behind wireless and infrared
communication, create a working wireless to infrared converter prototype and
use an iPad / iPhone or laptop as a wireless Media Center.
1.2 Problem statement
The last couple of years we have been struggling with an overload of remote
controls. In this project we want to come up with a solution to this problem so we
can control all (infrared) remote‐controlled devices from the iPad and get rid of all
the remote controls. We are aware of the availability of universal remotes but we
found an even better solution.
1.3 Statement of challenges
Our main challenge is to control infrared devices by first sending wireless data,
converting it, and then emitting it as infrared data.
1.4 Approach of the problem
We have solved this problem by creating a physical converter, which receives
data from an application on the iPad, converts it, and emits it as an infrared signal
1.5 Summary of results
During our semester we booked the following results
We found a solution to convert wireless data to infrared data
Created a working wireless to infrared converter prototype
Use the iPad as a media center where we can control all infrared devices
9
2. Structure and management of the project
2.1 Feasibility study
A feasibility study is a study where we try to uncover the strengths and
weaknesses of the existing project proposal. We use the TELOS factors as criteria
to judge feasibility.
Technology and system feasibility
Our group exists out of 3 students: Maxim Gladines (Digital Design & Media),
Vicente Ruiz (Computer software & Management), Jose Ignacio Busca (Electronics
& Automatism). All three students have sufficient knowledge to complete this
project.
Economic feasibility
The main costs of our product are the “Arduino Uno Shield” and the “WiFly
Shield”. Besides the main costs we have some smaller costs, the casing and the
power adapter.
Arduino Uno
Shield
21,00 €
WiFly Shield
63,00 €
Polypropylene
0,50 €
Power adapter
7,30 €
Total 91,80 €
fig 2. Economic feasibility table
10
The total production costs are € 91.80 to create one converter, but this price can
be reduced by 18% if we produce it on a larger scale. The cost for the WiFly shield
decreases by € 13.00 / piece and the Arduino Uno board by € 4.00 / piece. This
brings us to a total production cost of € 75.00 /piece. If we choose a 33% (€
24.75) benefit margin, we can sell the converter for € 99.00. The application will
be provided free of charge because without the application, the converter is
useless.
Legal feasibility
CENELEC EN 55016‐1‐2 ((Amendment ‐ 2006): "Specification for radio
disturbance and immunity measuring apparatus and methods ‐‐ Part 1‐2:
Radio disturbance and immunity measuring apparatus ‐ Ancillary equipment ‐
Conducted disturbances".
CENELEC EN 61000‐3‐3 (1995): "Electromagnetic compatibility (EMC) ‐‐ Part 3‐
3: Limits ‐ Limitation of voltage changes, voltage fluctuations and flicker in
public low‐voltage supply systems, for equipment with rated current <= 16 A
per phase and not subject to conditional connection".
CENELEC EN 61000‐4‐3 (2006): "Electromagnetic compatibility (EMC) ‐‐ Part 4‐
3: Testing and measurement techniques ‐ Radiated, radio‐frequency,
electromagnetic field immunity test".
CENELEC EN 61000‐4‐6 (2009): "Electromagnetic compatibility (EMC) ‐‐ Part 4‐
6: Testing and measurement techniques ‐ Immunity to conducted
disturbances, induced by radio‐frequency fields".
ETSI EN 300 127 (V1.2.1): "Electromagnetic compatibility and Radio spectrum
Matters (ERM); Radiated emission testing of physically large
telecommunication systems".
ITU‐T Recommendation V.10 (1993): "Electrical characteristics for unbalanced
double‐current interchange circuits operating at data signalling rates
nominally up to 100 kbit/s".
ETSI TR 101 651 (1999): "Electromagnetic compatibility and radio spectrum
matters (ERM); Classification of the electromagnetic environment conditions
for equipment in telecommunication networks".
11
Operational feasibility
Our solution will satisfy the major requirements stated in 2.3 Requirements
Schedule feasibility
We lack the experience of working in team, but in general, project deadlines
shouldn’t cause any problems.
More information can be found in 2.5 Time management
2.2 Goals & Objectives
The goal of this project is to make people use our product so they can control all
there infrared devices from one place.
Create a physical converter, which converts a WIFI‐signal to an infrared‐signal
Create an application that allows the user to interact with the converter
2.3 Requirements
Our group will be evaluated using the following general criteria
Answer the functionality requirements
Answer the technology requirements
Answer the aesthetic requirements
Answer the cost requirements
Functionality requirements
The key functionality requirement is to control all infrared (IR) devices from
anywhere in the house.
The application running on the tablet has some other functionality requirements:
Add an IR‐remote
Remove an IR‐remote
Control an IR‐remote (volume, Change channel, stop, pause, play…)
Browse IR‐remotes
12
Technology requirements
The key technology requirement is to create the converter that will convert the
incoming wireless signal to an outgoing infrared signal.
Aesthetic requirements
Because the converter is a physical device and has to be in line of sight of the
infrared‐devices we have an aesthetic priority.
“It has to look nice”.
Cost requirements
The cost requirement is to sell the product (and be profitable) with a total price
limit of €100.
2.4 Scope management
Scope definition
To reach our goal, two products have to be build
A converter, which receives data wirelessly and emits this data using an
infrared signal
An iPad application, which sends out the necessary data
Each task is subdivided into multiple tasks as shown in the following WBS
fig 3. Work Breakdown Structure
13
2.5 Resource pool
This resources pool describes every resource (people, software, materials) we
used for our project. Our group consists of 3 people, each with there own specific
technical skill.
New media designer with experience in iOS application
Electronics engineer
Programmer with experience in network programming
The images below states all the resources used in this project. Software and
materials will be explained in 3. Project components
fig 4. Resource pool
14
2.6 Time management
After setting the two milestones (Interim report & Final report). We estimated the
duration from every activity based on the project scope and project resources.
Interim report: 24 / 03 / 11
Final report: 01 / 07 / 11
Gantt chart
Responsibility matrix
Matrix Table
P ‐ Primary Responsibility
S ‐ Secondary Responsibility
Maxim
Gladines
Vicente Ruiz
Jose Busca
Software research P S
User Interface Design P S
User Interface Programming P S
Data programming S P
Deployment P S
Software Testing P S
Hardware research S P
PCB Design S P
Microprocessor Programming S P
Assembling S P
Hardware testing S P
fig 6. Responsibility Matrix
fig 5. Gantt Chart
15
3. Project components
3.1 Hardware
Arduino is an open‐source electronics prototyping platform based on flexible,
easy‐to‐use hardware and software. It's intended for artists, designers, hobbyists,
and anyone interested in creating interactive objects or environments.
Source: Arduino 2011
The Arduino is a board, where the outputs and inputs are situated at the edge of
the board. This makes them very accessible for the user and creates the
possibility of controlling several physical outputs such as sensors, motors, lights,
etc.
There are many kinds of Arduino boards, all with their own unique capabilities
based on the users' needs. Some of them have a more powerful microprocessor
(more I/O, faster) and others have special features such as Bluetooth or wireless
connecting capabilities.
The Arduino board uses his own programming language, which is a simplified
version of C. The IDE (=Integrated Development Environment) used is called
“Arduino alpha” and can be downloaded for free. This IDE allows the user to see
the USB‐connected board running in real time.
Another advantage of using Arduino is the existence of many open source
libraries that can be integrated into our code without any problem. Another
reason why Arduino is so easy to use is the wide range of supported components
that can be connected easily to the main board (same size, shape and pin
configuration).
For our project, we went with the Arduino Uno platform. More information will
be explained in the next topic.
16
3.1.1 Hardware comparison table
After we decided to go for Arduino, we still had to investigate which board to
choose. This comparison table shows the advantages and disadvantages of
different Arduino boards and wireless shields.
Arrangements Advantages Disadvantages
Mega Board Serial / USB programmable 54 Digital I/O & 16 analog I/O
Costs
Uno Board USB programmable 14 Digital I/O & 6 Analog I/O Latest Version Price
To many features?
Pro Board Reduced version of Uno Slow microprocessor
Nano Board Similar to Uno No power jack
Mini Board Similar to Uno Extra adapter for usb programming Slow microprocessor
Wi‐Shield Async Lab With or without external antenna 802.11b /g protocol Plug & Play function
Stil need to be configured
Xbee Wi‐Shield 802.15.4 protocol Not the protocol we need
WiFly Shield Rolving Networks
802.11 b /g protocol Takes power from attached board No drivers needed Automatic TCP/IP configuration
Costs
fig 7. Hardware comparison table
17
3.1.2 Arduino Uno
The Arduino Uno platform is a board based on the AtMega328P microcontroller;
it has 14 digital inputs/outputs pins, of which 6 can be used as PWM pins, 6
analog inputs and a crystal oscillator of 16MHz (you can work with less speed
using the prescaler function). It can get the power directly from the USB cable or
from an external power jack.
As it gets the power from the USB connection, it works with 5V DC input
(recommended to use between 7V‐12V), and the highest current you can get
from the I/O is 40mA. The AtMega328P has a flash memory of 32KB and 1KB of
EEPROM (read only memory).
Some of the pins have special function such as Serial TTL data transmission (pins 0
& 1), external interrupts (pins 2 & 3), PWM function (pins 3,5,6,9,10 & 11) and SPI
serial connection (pins 10,11,12 & 13). Using the ADC, the user can get a
resolution of 1024 different values (10bits). It also contains the possibility of using
the I2C serial communication protocol.
We chose this platform because it satisfied our needs, it was already assembled,
it carried all the communications pins we needed, it's small size, it's reasonable
price and is already preconfigured when adding other shields (=preconfigured
components with their own special function).
fig 8. Arduino blueprint
18
3.1.3 Wifly shield
The Wifly shield is a board attached to the Arduino that makes it possible to
connect to a 802.11b/g wireless networks. This board contains a wireless module
RN‐131G from Roving Network and a SC16IS750 SPI to UART chip, which works
faster and frees up the Arduino´s UART port.
This module (shield) takes the power directly from the Arduino (Vin pin, regulated
to 3.3V), and provides both, the RN‐131G and the SPI to UART Bridge; so it
doesn't need an external power supply. The communication between the Arduino
and this shield is regulated over the SPI pins (10, 11, 12 and 13 digital pins). There
is also a small prototyping area provided where components can be soldered on.
As we mentioned before, there are some pre‐assembled boards that were
specially made for the Arduino, and this board is one of them. The shape of this
shield is the same as the Arduino´s, which allows the user to just solder the
headers to the Wifly shield and connect it to the main board (Arduino). Thus,
allows the transmission of the data from one board to the other.
The features from the RN‐131G are the following:
Works in the 2.4GHz band
According to the IEEE 802.11b/g standard wireless communication, a data
rate of 1Mbps
An UART hardware interface
Input voltage of 3.3V
On board TCP/IP stack
On board ceramic antenna (optionally expandable)
Supports adhoc connections
Secure Wi‐Fi authentication (WEP & WPA)
128KB RAM and 2MB ROM
Consumes a maximum of 0.7W when transmitting data and a maximum of
0.13W when receiving data.
19
Before using the Wifly shield, we need to configure it. The user connects to the
board using Telnet from the PC; there are two different ways of connecting,
through the USB cable, or wirelessly in adhoc mode (To know more about the
shield´s configuration, see the user´s manual).
The SC16IS750 SPI to UART Bridge supports 4 Mbit/s maximum SPI clock speed
and has a 64 bytes FIFO (transmitter and receiver). To make a connection possible
between the Wi‐Fi shield and the Arduino, both need to be set up to the same
baud rate, in our case at 9600 bauds; otherwise the data transmitted from one
board to the other will be wrong.
The database contains more detailed information about the specifications and the
features of this module. The Wifly shield is shown below.
3.1.4 IR LED (NTE3027)
An infrared light‐emitting diode (LED) is an electronic device that emits infrared
light not visible to the naked eye. An infrared LED operates like a regular LED, but
uses different materials to produce infrared light. This infrared light can be used
for a remote control, to transfer data between devices, to provide illumination
for night vision equipment, or for a variety of other purposes.
Source: http://www.wisegeek.com/what‐is‐an‐infrared‐led.htm
The Infrared emitting diode (NTE3027) is used for emitting an IR‐signal from the
Arduino. After the Arduino (microprocessor) receives data, the data gets decoded
and checks to which protocol the input data belongs to. Once known, the
program selects the protocol and emits the data from the IR led, shaped as an
infrared signal.
fig 9. WiFly Shield
20
The signal coming out from the Arduino´s pin, comes out as a PWM signal, so we
can digitally control the shape of this signal (manipulating the counters of the
microcontroller, we can get different percentages of the duty cycles on the
signal).
Some of the features are the following:
Suitable for DC and High Pulse Current Operation
Low power consumption (0.21W at most)
Maximum range of 10 meters
In this project we use 5 different IR protocols:
Sony SIRC
NEC (used in Apple and LG)
Samsung
Philips RC5
Philips RC6
These protocols are explained later on.
fig 10. Infrared LED blueprint
21
3.1.5 Wireless Router
The 3Com 3CRWE55G72T Wireless Router has been used to test our project. Our
solution works with every router but this is the one is the one we used to
configure our network and test the socket connection between the iPad and the
converter. It has the following specifications and features:
Shared Internet Access
‐ Wired and Wireless user support: up to 253 users (128 Wireless) sharing a
single DSL or cable connection.
‐ Flexible broadband support: Supports either cable or DSL modem
connections.
High Speed Wireless connectivity
‐ IEEE 802.11g 54 Mbps Wireless Connections: almost five times faster than
IEEE 802.11b connections.
‐ Backward compatible with 11b users
Robust Security
‐ WPA (Wi‐Fi Protected Access) and WEP (Wired Equivalent Privacy)
‐ Multi‐level wireless security
Flexible Routing
Ease of use
‐ Set‐up wizards, pre‐set defaults, and intuitive browser interface
fig 11. 3Com Wireless router
22
3.2 Software
3.2.1 Arduino
The open‐source Arduino environment makes it easy to write code and upload it
to the I/O board. It runs on Windows, Mac OS X, and Linux. The environment is
written in Java and based on Processing, avr‐gcc, and other open source software.
Source: Arduino 2011
It has a text editor where the user can write their code (called sketches), and then
very easily upload the program into the Arduino. This software can support
different kind of file extensions as (.pde), (.c), (.cpp), (.h).
The Arduino software has a text console (Serial Monitor) which shows the
program´s output when it is running. This screen shows the serial data sent from
the Arduino board. This is very useful for checking errors in the code. With the
“serial print” command, it is possible to see the value of the variables or any other
item the user wants to see on their display; these prints can be seen through the
serial monitor. On the other hand, the software doesn't have a debugger
included, which makes it a little more difficult finding and solving coding mistakes.
An advantage of this software is that the user can create, and afterwards add
libraries to their program. This is a way of making programming easier and less
time consuming. As it is open source, many libraries can be found on the Internet,
and included into the code.
3.2.2 Adobe CS5 Suite
To design and develop the iPad application we used Flash, Illustrator, Photoshop
and Flash Builder. These 4 applications are all part of the Adobe CS5 Suite.
Illustrator and Photoshop were used to design the application; Flash builder and
Flash were used to develop it. Flash builder was used to manage and test the data
management part of the project. It is based on the well‐known Integrated
Development Environment Eclipse and let users create applications fast and easily
using the Flex framework and Actionscript. In the end, all code was glued together
in Flash.
23
3.2.3 TeraTerm
TeraTerm (Pro) is a free terminal emulator (communication program) for MS‐
Windows. It supports VT100 emulation, telnet connection, serial port connection,
and more.
Source: TeraTerm 2011
This Software was used to connect the PC to the WiFly shield. The configuration
and data transmission of the shield were done using this platform.
There are two ways to connect:
Through USB cable. Run TeraTerm program and select “Serial connection”, by
pressing $$$, command‐mode is enabled where he is able to configure it.
Through adhoc mode. Run TeraTerm program and select TCP/IP protocol.
(More information can be found in )
3.2.4 Lita
Lita is simple application used to administrate SQLite databases, it is free and
open source and it has a version for each of the most common operative systems:
Linux, Apple Mac OS X, and Microsoft Windows. It lets users edit, create and
modify databases and its structures with a very intuitive and good‐looking
graphical user interface (GUI).
Its main functions are the following:
Open, create, compact, and manage SQLite databases
Create, rename, delete, and empty tables
Create, rename and delete columns
Create, modify and delete records
Encrypt or decrypt databases
Run, import and export your custom SQL statements
Create and delete indices
24
4. The converter
4.1 Introduction
The Wireless to infrared converter is the core of the project. The converter
consists of the Arduino board, the WiFly shield and the IR led and is responsible
for receiving wireless incoming data, converting it to an infrared (IR) signal where
it then gets send through the infrared led to the device we want to control.
Nowadays, almost all electronic devices are controlled by infrared (TV, DVD
player, Hi‐Fi, TV satellite, projector… and for every device created there is one
remote, what makes it not unusual having 3 or 4 remotes lying around. Another
inconvenience is that the remote needs to be aligned with the device to control it.
The solution we came up with was fairly easy. The idea was to control all infrared
devices from a PDA, iPhone, iPad or a similar device through WI‐FI. The converter,
also connected to the wireless network, receives outgoing data from the iPad or
iPhone, converts it, and gets emitted through the IR led.
fig 12. The converter
25
4.2 Infrared Protocols
IR data transmission is also employed in short‐range communication among
computer peripherals and personal digital assistants. These devices usually
conform to standards published by IrDA, the Infrared Data Association. Remote
controls and IrDA devices use infrared light‐emitting diodes (LEDs) to emit
infrared radiation, which is focused by a plastic lens into a narrow beam. The
beam is modulated, i.e. switched on and off, to encode the data. The receiver
uses a silicon photodiode to convert the infrared radiation to an electric current.
It responds only to the rapidly pulsing signal created by the transmitter, and
filters out slowly changing infrared radiation from ambient light. Infrared
communications are useful for indoor use in areas of high population density. IR
does not penetrate walls and so does not interfere with other devices in adjoining
rooms. Infrared is the most common way for remote controls to command
appliances.
Source: Wikipedia
Our converter supports 5 different Infrared protocols:
NEC protocol
Sony SIRC protocol
Philips RC5 protocol
Philips RC6 protocol
Samsung protocol
26
4.2.1 NEC protocol (Also supported by Apple and LG)
This protocol uses the encoding method “Pulse Distance Encoding”. This means
the length of the pulse burst (mark) is always the same, the time between
consecutive bursts differs, and depends on whether a logical '0' or logical '1' is
being transmitted.
This signal is sent in a carrier wave of 38 KHz.
Logical '0': a 562.5µs pulse burst followed by a 562.5µs space, with a total
transmit time of 1.125ms.
Logical '1': a 562.5µs pulse burst followed by a 1.6875ms space, with a total
transmit time of 2.25ms.
The standard message has these features and consists on the following:
A 9ms leading pulse burst (16 times the pulse burst length used for a logical
data bit)
A 4.5ms space
The 8‐bit address for the receiving device
The 8‐bit logical inverse of the address
The 8‐bit command
The 8‐bit logical inverse of the command
A final 562.5µs pulse burst to signify the end of message transmission.
The first bit of all the bytes sent is the LSB. The total duration of the command is
67.5ms.
fig 13. Standard NEC message
27
4.2.2 Sony SIRC protocol (supported by Sony)
This protocol uses the encoding method “Pulse Length Encoding”. This means the
length of the pulse burst (mark) is different for a logical '0' and a logical '1', with
logical '1' requiring a longer burst. There are three versions of the protocol: 12, 15
and 20 bits. All three versions have a Command and Device word; the 20‐bit
version only has an 8‐bit extended word.
This signal is sent in a carrier wave of 40 KHz.
Logical '0': a 600 µs pulse burst followed by a 600 µs space, with a total
transmit time of 1.2 ms.
Logical '1': a 1200 µs pulse burst followed by a 600 µs space, with a total
transmit time of 1.8 ms.
The standard message consists out of the following:
The frame timing is based on multiples of a 600 μs pulse width T.
A 2.4 ms leading pulse burst.
A 600 µs space.
The 7‐bit command
The 5, 8 or 12‐bit address
The first bit of all the bytes sent is the LSB. The total duration of the command is
24 ms (12 bits), 29.4 ms (15 bits) or 38.4 ms (20 bits).
fig 14. Standard Sony message
28
4.2.3 Philips RC5 protocol (Philips & many unknown brands)
This protocol uses the encoding method “Manchester Encoding”. This means all
bits are of equal length, with half of the bit‐period being a pulse burst (mark) and
the other half being a space. A logical '0' is represented by a burst in the first half
of the bit‐period and a space in the second. A logical '1' is represented by a space
in the first half of the bit‐period and a burst in the second.
This signal is sent in a carrier wave of 36 KHz.
Logical '0' – an 889us pulse burst followed by an 889us space, with a total
transmit time of 1.778ms.
Logical '1' – an 889us space followed by an 889us pulse burst, with a total
transmit time of 1.778ms.
The standard message consists out of the following:
Two Start bits (S1 and S2), both logical '1'.
A Toggle bit (T). This bit is inverted each time a key is released and pressed
again. (5.334ms to transmit the Start and Toggle bits (S1, S2 and T))
The 5‐bit address for the receiving device
The 6‐bit command.
The first bit of all the bytes sent is the MSB. The total duration of the command is
24.892 ms.
fig 15. Standard Philips RC5 message
29
4.2.4 Philips RC6 (Mode 0) protocol (supported by Philips)
Mode 0 is a dedicated Philips Consumer Electronics mode. The RC6 is supposed to
be the successor of the RC5. This protocol uses the encoding method
“Manchester Encoding”, as well as the RC5 protocol. This means all bits are of
equal length, with half of the bit‐period being a pulse burst (mark) and the other
half being a space. A logical '0' is represented by a burst in the first half of the bit‐
period and a space in the second. A logical '1' is represented by a space in the first
half of the bit‐period and a burst in the second.
This signal is sent in a carrier wave of 36 KHz.
Logical '0' – a 444us pulse burst followed by an 444us space, with a total
transmit time of 888us.
Logical '1' – a 444us space followed by an 444us pulse burst, with a total
transmit time of 888us.
The standard message consists out of the following:
A leader with a mark time of 2.666 ms
A space time of 889 us
Starting bit; always is a “1”, used to calibrate the receiver´s timing
3 mode bits, in this case 000, because we are in mode 0
A Trailer bit; twice as long as normal bits.( 889us mark and 889us space)
The 8‐bit command and address for the receiving device
A no data period of 2.666 ms.
The first bit is the MSB. The total duration of the command is 25.759 ms.
fig 16. Standard Philips RC6 message
30
4.2.5 Samsung protocol (supported by Samsung)
This protocol uses the encoding method “Pulse Distance Encoding”. This means
the length of the pulse burst (mark) is always the same, but the time between
consecutive bursts differs, depending on whether a logical '0' or logical '1' is being
transmitted. Samsung protocol is very similar to NEC protocol as shown below:
This signal is sent in a carrier wave of 37.9 KHz.
Logical '0': a 560 µs pulse burst followed by a 560 µs space, with a total
transmit time of 1.120 ms.
Logical '1': a 560 µs pulse burst followed by a 1.69 ms space, with a total
transmit time of 2.25ms.
The standard message has these features and consists on the following:
a 4.5ms leading pulse
a 4.5ms space
the 8‐bit address (send it two times)
the 8‐bit command
the 8‐bit logical inverse of the command
a final 560 µs pulse burst to signify the end of message transmission.
The first bit of all the bytes sent is the LSB. The total duration of the command is
108 ms.
fig 17. Standard Samsung message
31
4.3 Wifly shield
4.3.1 Connecting to the Arduino
As mentioned before, the wifely shield is preconfigured, allowing it to be attached
directly to the Arduino, where the Arduino is the master and the shield a slave.
The only thing that is not configured is the communication between these two
boards.4.3.1 Configuration of the WiFly shield.
There are two modes available in the WiFly module, data ‐and command mode. In
data mode, the module is ready to either accept incoming connections or initiate
outgoing connections. To configure the parameters and to view the current
configuration, the module must be put into command mode (also called
configuration mode). At any given time, the module will either be in command
mode or in data mode. There are two ways of configuration for the shield,
through USB or wirelessly with a PC in Adhoc mode.
USB Mode:
When the USB (B type) cable is connected from the PC to the Arduino, both the
Arduino board and Wifly shield get power. The leds PIO4 (green led) and PIO5
(yellow led), attached to the Wifly shield, start blinking quickly, what means that
the shield is searching for a network (LAN) to connect to. To make a connection,
the user has to use Telnet (terminal emulator) on there pc. When the user enters
Telnet, selects Serial mode and the port which is going to be used (i.e. COM3 ). To
enter command mode, the “$$$” characters must be sent. The device will
respond with “CMD” indicating it is in command mode. Now it's possible to make
changes in the configuration. ASCII characters can be sent through the terminal
emulator connected to the UART or via Telnet. When using the UART interface,
communications settings should match the stored settings used by the WiFly
module. The default is 9600 bauds, 8 bits, No Parity, 1 stop bit, and hardware flow
control disabled.
32
Adhoc mode:
To make this connection possible, both board have to be joined together. Before
powering the boards, the pin PIO9 of the shield has to be in a short circuit. Once
the power is given, the four LEDs start blinking; which means the shield is in
adhoc mode waiting to be connected. When entering this mode, an adhoc
network is created with the following configuration:
SSID: WiFly‐GSX‐XX, where XX is the final two bytes of the devices
MAC‐address.
Channel: 1
DHCP: OFF
IP address: 169.254.1.1
Netmask: 255.255.0.0
The user connects to the WiFly‐GSX‐XX network. This is an open network that
does not require a pass phrase or pass key. Currently the WiFly shield only
supports OPEN mode for creating adhoc networks. The IP address assigned by
Auto IP must be on the subnet 169.254.x.y subnet otherwise the WiFly GSX
module will not be accessible. Once connected and having a good IP address,
telnet into the WiFly module on port 2000 telnet 169.254.1.1 2000. The display
should answer with *HELLO*. Now it is possible to configure the module.
4.3.2 Connecting to a network
Once it has achieved entering command mode, the shield needs to be configured
to connect to a desired network. In command mode the user has the possibility of
changing the parameters of a network as the IP, SSID, channel, DCHP, password,
baudrate….
33
There are five different categories of instructions:
SET COMMANDS: Take effect immediately, permanently (when save
command is issued).
GET COMMANDS: Retrieve the permanently stored information
STATUS COMMANDS: Gets status of the interface, IP status, etc.
ACTION COMMANDS: Performs actions such as scan, connect, disconnect.
FILE IO COMMANDS: Upgrade, load & save configuration and delete files.
For more information see the user´s manual in the appendix.
After configuration, changes in the shield must be saved by typing “save” in the
command window. To exit from command mode “exit” must be type, the window
will answer with "EXIT". The WiFly shield will enter back in data mode, where
transmitting and receiving data is allowed.
Unless changes are made, the shield will try connecting to that specific network.
In case the user wants to connect to another network, changes must be made.
After configuring the shield, a connection can be made. The PIO5 (yellow led) and
PIO4 (green led) will keep on blinking quickly and searching for a network with
the fixed parameters. When connected, the yellow led will stop blinking and the
green led blinking will slowdown, which means the shield is successfully
connected, the IP address is ok, and is prepared to receive or transmit data. When
this happens, the PIO6 (red led) blinks every time the sender types the return key,
indicating the user that data has been received by the shields Wi‐Fi card.
34
4.4 Initializing the Arduino and Wifly shield
As mentioned in the specifications of the Arduino, the board can be powered
using USB or an external jack. It is recommended to use an external jack with a
voltage no less than 6V; when supplying through USB or an external jack with 5V,
the pins that provide voltage, such as the “5V pin” or the “3.3V pin” will provide
less than these value.
After configuration, the shield is ready to connect to a network and the
microcontroller of the Arduino can be configured. Jesús M. Gómez de Gabriel has
written some of the configuration code.
Communication between the shield and the Arduino is done using the SPI port,
where pins (10, 11, 12 and 13) have to be set up. To make communication
possible between both boards, identical baudrate (9600 bauds) has to be set. This
parameter is set by default and is very important for transmitting/ receiving data.
The clock frequency of the Arduino has a maximum of 16 MHz, which makes it a
hardware limitation set by the SPI to the UART chip integrated on the Wifly shield
After setting the clock frequency, the SPI port has to be opened. This port handles
data transmission and happens byte per byte. As said before, it isn't possible to
transmit more than one ASCII character at a time. More characters can be sent,
but this will be stored into a shield buffer with a capability of 64 bytes.
An image of the Arduino and WiFly shield attached together is shown below
fig 18. Arduino UNO and WiFly shield
35
4.5 Incoming data to the Arduino
To get the application working, the converter and the users' iPad or laptop has to
be connected to a wireless network. When the user selects a remote to control,
data gets send from the iPad through the router to the converter. The wireless
network uses the 802.11b/g protocol, which sends encrypted frames containing
both headers and tails. Since the shield incorporates a TCP/IP stack, the data,
which is read by the microprocessor, is the real data (payload). The data send
from the iPad is formatted as a string. This string contains information about the
desired function to call, characters indication the protocol and the amount of bits
4.6 Processing data
When data is received, both the device code and amount of bits are stored into
variables inside the micro‐controller. Incoming string data gets converted into a
hexadecimal format, which makes it possible to use it in a function inside the
micro‐controller. Once the information is processed, the device code gets
matched to its corresponding IR protocol and gets emitted by the IR led.
4.7 Selecting IR protocol
As mentioned before, we are supporting five different IR protocols. The micro‐
controller has to know which protocol we are using and therefor we implemented
an algorithm that recognizes the characters attached to the device code as an
indicator for which protocol to use.
4.8 Arduino libraries
Three extra libraries have been used in this program. These libraries were
specifically designed for the Arduino, are fully compatible and were necessary for
the application to function correctly. The SPI library was written by Cam
Thompson and the IR library by Ken Shirriff.
36
Listed below are the three libraries, explained one by one:
SPI library: Used to make a connection possible between the Arduino and the
WiFly shield. This library includes all the parameters and constants that are
useful for the previous configuration of the SPI port.
IRremoteInt library: This library includes all constants and variables used in
the IR protocol.
IRremote library: This library contains the five subroutines corresponding to
the five different protocols used in the program. It supports NEC, Sony SIRC,
Philips RC5/6 and Samsung IR protocols. These subroutines also control the
duration of the duty cycle of the outgoing signal, which differs from one
protocol to another.
4.9 Signals output
After data has been received by the micro‐controller and converted into a
hexadecimal form, the device code is emitted from the IR led. This code goes
through the send‐function and is sent three times. The reason why it's emitted
three times is because sometimes some specific devices have to receive the code
more than once to call the function effectively. Some IR LEDs can handle 100 mA
to reach their maximum range. In our case it wasn't possible to get 100 mA
because of the fact that the pins of the micro‐controller only give a maximum of
50mA. What we did was connect the IR LED directly to an output pin of the micro‐
controller (pin 3), where the absorbing current by IR led is 40 mA. Even though
the current was relatively low, the range we achieved was about 8 meters.
The way of transmitting an IR wave with a microcontroller is by controlling the
duty cycle of it, that is to say, with PWM pulses. Pulse Width Modulation is a
technique to control power electronically. By switching on and off the signal, the
average value of voltage changes, this way we can save energy. These kinds of
waves are a square shaped, and a frequency where the signal varies depending on
the application that will be used. In this case the signal frequency will vary from
36 KHz to 40 KHz.
37
4.10 Flowchart
fig 19. Converter flowchart
38
4.11 Different ideas applicable to this project
Apart from the solution used to fulfill the needs of this project, we also came up
with other ideas and variations in hardware.
4.11.1 Recording IR led (learning remote)
When working on the project, we realized there was another way of creating the
converter. The idea was just the opposite to what we were making. Instead of
having libraries containing IR protocols code, we could learn the codes from the
remotes by an infrared receiver attached to the Arduino and then store them in
the iPad/laptop. The process is explained below.
The hardware part is almost identical to the hardware we used in the project but
with an IR receiving led. First, the user would select the remotes' brand on the
application (iPad) followed by being asked to press all buttons on the remote. The
user would point the remote to the IR receiver and press the necessary buttons,
where the micro‐controller would record the incoming signal. Once the signal is
recorded, it gets sent and from the converter to the iPad / laptop and stored
locally. This is one‐time‐only process for each remote you want to add.
The good thing about this idea is that the database would only hold the desired
remotes instead of having hundreds of them. The biggest disadvantage of this
idea is that the user is required to enter all buttons of each remote, one by one.
Image of the setup
fig 20. IR learning method
39
4.11.2 Chip with codes inside
This idea was based on adding a chip to the Arduino, which contains the most
used IR protocols. This approach is similar to our setup and much easier to
implement. But the problem was that the only integrated circuits that are being
sold on the internet are just for one or two IR protocols. Another disadvantage
was cost of these chips.
The user would choose the device brand and the remote from the iPad/laptop,
which he or she wants to use. After choosing, the iPad/laptop would send a code
to the converter, and automatically to the chip. Depending on the code that was
sent, an IR protocol would be chosen and emitted through the IR led.
4.11.3 More range with the IR LED
The IR LED we use has a range of around 8 meters. We thought about making a
small change. This change consists of adding a transistor and resistor to the IR
LED, which will increase the maximum range considerately. The output pins of the
micro‐controller give out a maximum of 40 mA but the IR LEDS can hold 150mA
(the more current, the more range the IR wave has. The disadvantage of using this
technique is that it consumes more power and would increase the converters' size
due the adding of three more components.
fig 21. Chip with protocols stored inside
fig 22. IR range increasing circuit
40
4.12 Tests and results of the IR signals
All the tests have been done in IHK laboratory, using its equipment and
instrumentation. These tests consist of measuring some parameters of the
outgoing IR signal, such as the peak to peak voltage (Vpp), the period, the
frequency, pulses duration….
As shown, the tests were done with every protocol, so it gets possible to compare
results and theory. Most of the times there is a small difference between the
theory and reality. Different tests of the protocols are shown in this order, NEC,
SONY, PHILIPS RC5, PHILIPS RC6 and Samsung as follows:
41
4.12.1 NEC protocol
In the picture below, you can see what the NEC protocol looks like. In this case
the sent code is for Apple Mac Book, and the action is to turn up the volume
(hexadecimal code: 0x77E1307F and the nº of bits: 32).
Below the picture of the wave and his details
Period: 72 ms
Frequency: 38.023 KHz
Vpp: 1.75 V
Initial pulse duration: 9.05 ms
Initial space duration: 4.52 ms
Final pulse duration: 562 µs
Logical ‘0’ duration: 1.156 ms
Logical ‘1’ duration: 2.257 ms
fig 23. NEC IR wave shape
42
4.12.2 SONY protocol
Shown below is the SONY´s protocol. To test this protocol we used a code to
switch on/off a TV (Hexadecimal code: 0x9CB9C and the nº of bits: 20).
Below the picture of the wave and his details
Period: 33.29 ms
Frequency: 39.85 KHz
Vpp: 1.75 V
Initial pulse duration: 2.41 ms
Initial space duration: 606 µs
Logical ‘0’ duration: 1.22 ms
Logical ‘1’ duration: 1.80 ms
fig 24. Sony IR wave shape
43
4.12.3.PHILIPS RC5 protocol
Shown below is the Philips RC5 protocol. In this case the code sent is to switch
on/off a TV (Hexadecimal code: 0x100C and the nº of bits: 13).
Below the picture of the wave and his details
Period: 25.075 ms
Frequency: 36.036 KHz
Vpp: 1.75 V
S1 pulse duration: 1.788 ms
S2 pulse duration: 1.788 ms
Logical ‘0’ duration: 1.794 ms
Logical ‘1’ duration: 1.794 ms
fig 25. Philips RC5 IR wave shape
44
4.12.4 PHILIPS RC6 protocol
Shown below is the RC6 protocol. In this case the code sent is to switch on/off a
TV (Hexadecimal code: 0xFCDF3 and the nº of bits: 20).
Below the picture of the wave and his details
Period: 22.854 ms (without the signal free at the end)
Frequency: 36.036 KHz
Vpp: 1.75 V
Header pulse duration: 2.68 ms
Header space duration: 904 µs
Logical ‘0’ duration: 906 µs
Logical ‘1’ duration: 894 µs
fig 26. Philips RC6 IR wave shape
45
4.12.5 SAMSUNG protocol
Shown below is the Samsung protocol. In this case the code sent is to switch
on/off a TV (Hexadecimal code: 0xE0E040BF and the nº of bits: 32). This protocol
is very similar to the NEC´s protocol as shown in the picture below:
Period: 61.2 ms
Frequency: 38 KHz
Vpp: 1.75 V
Initial pulse duration: 4.51 ms
Initial space duration: 4.56 ms
Logical ‘0’ duration: 1.17 ms
Logical ‘1’ duration: 2.19 ms
fig 27. Samsung IR wave shape
46
From our tests we can conclude that the obtained results are slightly different
from what the theory says. The biggest difference is seen in the pulses (marks).
The reason behind this is that the hardware is not able to switch from OFF to ON
quickly, which makes the marks longer than in theory. This doesn't happen to the
spaces, where the transition from ON to OFF is almost done immediately. The
result the increasing total period time and a small variation in frequency due to
the hardware and equipment used.
After testing the IR led, we came to the conclusion that attaching it directly to the
Arduino, without any transistor, the achieved range was around 7 to 8 meters,
which we thought was sufficient. The next thing we did was test the reflection
from the IR beam onto surfaces to check if the converter could be placed without
being aligned to the IR device and still reach the IR receiver. We verified that
reflecting the IR breams works but that it wasn't able to overstep objects or
obstacles.
4.12.6 Consumption values
Shown below are the consumption values from the different parts used in the
project.
VOLTAGE CURRENT POWER
Arduino 7 V 100 mA 0.7 W
Wifly shield 3.3 V 210 mA 0.693 W
IR LED 1.3 V 150 mA 0.195 W
Total
consumption
1.588 W
fig 28. Consumption table
47
4.13 Design of the converter
We created four concept designs related to the shape, look and feel of the
converter. We also wrote down possible (dis) advantages for every shape
Arrangements Advantages Disadvantages
Box‐shaped converter Suitable for stacking Boring, old‐fashioned To many boxes around the house. Difficult for a 360° infrared‐emitting
Ball‐shaped converter Organic form, Different, Modern look, fun. Suitable for blending into environment 360° possible
Only suitable for stacking when placed on top. Needs more space than a box‐shaped converter
Triangle‐shaped converter Different, fun 360° possible
Sharp, dangerous for children, Only suitable for stacking when placed on top Needs more space than a box‐shaped converter You could stab someone with this
Platonic‐shaped converter Looks amazing! Impossible within budget
fig 29. Converter shape comparison
48
Properties Value
Name Hades
Info Ball
Properties Value
Name Magneto
Info Platonic kept in the air by a magnetic field. Pushbutton to turn on and off
fig 30. Ball shaped converter
fig 31. Platonic shaped converter
49
Properties Value
Name Flash
Info Can be turned on / of by twisting the top part
Properties Value
Name The Cube
Info Can be turned on / of by using the pushbutton integrated in the top
fig 32. Cylindrical shaped converter
fig 33. Cube shaped converter
50
4.14 Difficulties
One difficulty we had when designing the converter was to communicate
between the WiFly shield and the PC wirelessly. We didn't realize the clock speed
of the SPI to UART Bridge was slightly different to the one set on the Arduino,
which caused the characters to not be displayed properly. The configuration of
the shield was also complicated due the fact that not much information on this
topic was available.
Another difficulty was creating the algorithm to change string values into
hexadecimal values. This was done because our functions only use hexadecimal
values.
51
5. Network
Our network environment was created with a 3Com 3CRWE55G72T Wireless
Router, and as said in the hardware part of the report, it works with the IEE
802.11g standard which makes it perfect to work with data transmission of the
application because the WiFly board supports this standard too.
The IEE 802.11g emits in the same propagation band (2.4GHz) as the older IEE
802.11b but what really improved in this new standard is the data transmission
rate, which is almost five times faster, it has a data transmission index of 54Mbps
instead of the 11Mbps of 802.11b. The WiFly Board is capable of working with the
802.11b standard, so it won’t be a problem if the final user doesn’t have a router
with the newest standard, but it's better to work with this one rather than
802.11b. In the chart below there is a comparison with both standards:
Wireless Technology Comparison Chart Wireless Standard
802.11b 802.11g
Popularity Widely adopted. Readily available everywhere
New technology with rapid growth expected
Speed 11 Mbps
Up to 11 Mbps (note: cable modem service typically averages no more than 4 to 5Mbps).
54 Mbps
Up to 54 Mbps (5X greater than 802.11b).
Relative Cost € Inexpensive €€ Relatively inexpensive
Frequency 2.4 GHz
More crowded 2.4GHz band. Some conflict may occur with other 2.4GHz devices like cordless phones, microwave ovens, etc.
2.4 GHz
More crowded 2.4GHz band. Some conflict may occur with other 2.4GHz devices like cordless phones, microwave ovens, etc.
Range 100‐150
Good range. Typically up to 100‐150 feet indoors, depending on construction, building materials, room layout.
100‐150
Good range. Typically up to 100‐150 feet indoors, depending on construction, building materials, room layout.
Public Access �
The number of public “hotspots” is growing rapidly, allowing wireless connectivity in many airports, hotels, college campuses, public areas, and restaurants.
�
Compatible with current 802.11b hotspots (at 11Mbps). Also, it is expected that most 802.11b convert to 802.11g
Compatibility OK 802.11b
Widest adoption OK
802.11g
Interoperates with 802.11b networks (at 11Mbps).
fig 34. Wireless Technology Comparison Chart
52
Wireless Network security
During the development phase of our project we set up a wireless network on the
router, the SSID identifier for our wireless network was “WIFI2IR” and had a WiFi
Protected Access password (WPA) “converter”. It is important for the final user to
set up a high level of security in the network, WPA is a good option but setting a
MAC address restriction would be better (most of the routers have this security
option). The MAC address is a unique id for each network device. Allowing only a
certain group of MAC addresses will be more secure for the user.
If anyone would break into the user Wireless Network and that person has an
Apple iPad with the IRPad application installed, he will be able to control all the
multimedia devices the user has at home.
53
6. The application
6.1 Software design process
6.1.1 Introduction
iPad applications, also called iOS applications are designed using apple's
guidelines on human interface design. These guidelines were created to optimize
usability and desirability of the application.
We've chosen several guidelines, which stood in relation to our application
Minimize the effort required for user input
De‐emphasize settings (avoid including settings)
Use UI elements consistently
Add physicality and realism
Make targets fingertip size
Based on these guidelines we created two designs using Adobe Photoshop and
Adobe Illustrator. The first design (fig 36.) is based on standard UI elements
provided by Apple. But we quickly decided to change to a more realistic and
physical looking design (fig 37.). Every button is fingertip size and has 2 states:
TouchDown, when the button is pressed and TouchUP, when the button is
released.
All images used in the application were designed in Photoshop and afterwards
exported with PNG compression and finally imported into Flash.
fig 35. Button states
54
6.1.2 Portable Network Graphic
PNG or Portable Network Graphic supports palette‐based images (with palettes of
24‐bit RGB or 32‐bit RGBAcolors), grayscale images (with or without alpha
channel), and RGB[A] images (with or without alpha channel). PNG was designed
for transferring images on the Internet, not for professional‐quality print graphics,
and therefore does not support non‐RGB color spaces such as CMYK.
Source: Wikipedia
The reason why we used PNG compression was for its transparency, file size and
lossless data compression. Compared to the JPEG compression, PNG has a lot less
noise and irregular pixels and has an excellent support in Flash.
6.1.3 Vectors
After every image in Photoshop was sliced, exported and ready to be imported
into Flash. We realized that Flash was well known for using vector graphics in
there applications. The advantage of using vector graphics is that they can be
scaled endlessly without having any form of quality loss, which was needed for
the iPad screen.
Vector graphics use geometrical primitives such as points, lines, curves, and
shapes or polygon(s), which are all based on mathematical equations, to
represent images in computer graphics.
Source: Wikipedia
Due the fact that some of our images couldn't be remade using vectors (because
of their complexity) we ended up using a combinations of both Bitmaps (PNG)
and Vector graphics.
55
fig 36. User‐Interface design 1
56
fig 37. User‐Interface design 2
57
6.2 Development process
6.2.1 Introduction
iPad and iPhone applications (= iOS applications) are developed in the objective‐c
programming language. But due the fact that none of our group members knew
this language, we had to go for alternatives.
We were lucky that one group‐member was experienced in both JavaScript and
AS 3.0 wherein we were capable to create iOS application. Both scripts are ECMA‐
script based and have a steep learning curve. We also were experienced in Java
but this was not an option due the fact that until today, there is no possibility to
convert java‐applications into iOS applications.
After weighing the advantages versus the disadvantages, we came to the
conclusion that AS3.0 was the best language to go for.
Our choice was based on:
One team member had a fair amount of knowledge in AS 3.0
iOS applications can't be written in Java
Large community
Good IDE (Integrated Development Environment)
Build‐in flash to iOS application converter
The programming was divided into two parts. The first part was programming the
user‐interface and the second part was programming the data flow.
Programming the user‐interface consists of handling user‐interaction and placing
all necessary objects on the screen.
Data programming consists of the wireless communication between the iPad and
the converter. Before any data can be send or received, the infrared remote
(television, dvd‐player, radio...) needs to be configured on the iPad. This
information is stored locally into a SQLite database and loaded when necessary.
58
Connection Request
Connection established and
ready to send/receive in
both directions
Another important aspect of data programming is how this data is sent to the
converter. For managing this information we had to create a specific data
structure and find a way of sending this data. The data consist of infrared codes
from the supported remotes and its corresponding information. The connection
between the iPad and the converter is established using a TCP (Transmission
Control Protocol) socket connection through the Wireless Local Area Network
(WLAN).
6.2.2 Sockets
A socket consists of two basic elements, an IP address and a port number. In
many cases the client knows the IP and the port number of the server side, in our
case the WIFly board has a static IP (= 192.168.2.20) and port number (=2000).
The server side of our application is the WiFly shield inside of the converter,
which will remain waiting for a connection as it is connected to the same WLAN as
the iPad. Within this process, the program will attempt to connect to the WiFly
and if everything goes right, a communication channel between both devices will
be setup, which will allow transmission of data packages. It is important to say
that data can be sent in both directions but in our application, data is only being
sent from the iPad to the converter.
If everything goes fine the communication will be established and the sockets
ready to write or receive data:
Server IP: 192.168.2.20
Port: 2000
Listening…
Client IP: 192.168.2.100
Port: 2000
Server IP: 192.168.2.20
Port: 2000
Listening…
Client IP: 192.168.2.100
Port: 2000
fig 38. Socket connection
59
6.2.3 TCP Protocol
As said before, the socket connection uses the Transmission Control Protocol, it is
documented on the RFC 793 and it works on the transport layer. Our transmission
requires a reliable way of sending data and with no errors, TCP has its own
method to recover lost data packets and let us ensure that all the data will be
received in the same order as it was sent and without errors, so it covers our
needs perfectly.
The TCP has many functions, below are described:
Connection oriented: a connection is established between two computers to
exchange data, both sides of the connection are synchronized and they
manage the congestion of the network.
Full duplex operation: the connection works in two directions and only these
systems are able to use the connection.
Error Checking: A checksum technique is used to check for possible errors or
corrupted data packets.
Acknowledgements: About receiving or not one or more data packets, the
receiver sends an acknowledgement to the sender and that’s how the sender
knows if the packet has to be resent or whether the connection must be
closed because the receiver is not in the connection anymore.
Data Flow Control: If the sender is sending too many packages so the receiver
cannot manage them, the receiver will discard packages so the failed
acknowledgements will tell the sender to reduce the transfer rate or to stop
transmitting.
Packet Recovery Service: the receiver is able to ask for the transmission of
another packet again if it is not notified as received (ACK), so the sender
transmits de data packet again.
60
A TCP Data Segment Structure follows the scheme below:
Port numbers fields are used to Multiplex/Demultiplex data from/to upper
layers.
The 32 bits Sequence number and Acknowledgement number fields are used
in order to have a reliable data transfer as said before.
The Window Size field consist of 16 bits and is used just to manage the flow
control.
The Header length field of 4 bits specifies the length of the TCP header in 32‐
bit words.
The 16‐bits Checksum field indicates if the package was corrupt or not.
The 32‐bits Options field is used when the sender and the receiver negotiates
the maximum data packet size.
The Flag fields are used for different purposes to manage the data
transmission when it takes place.
32 Bits
Source Port Number Destination Port Number
Sequence number
Acknowledgement number
Header length
Unused URG
ACK
PSH
RST
SYN
FI N
Receiver Window Size
Checksum Urgent
Options
DATA
fig 39. TCP Data segment
61
6.2.4 Sending data
Once we know how the socket connection works, it is time to explain how the
data is sent and which kind of data is transmitted. When the connection is
established, every time the user ask for a function, two different Strings are sent,
the first String refers to the infrared code, below is explained with an example:
First of all is needed to explain that there are five infrared protocols implemented
in our application, these protocols are indicated in our database:
The values for this example will be the following:
Selected Brand: “Apple”
Selected Remote: “Apple_Mac”
Selected Function: ”VOLUP”
With that information, the query made against the database will retrieve the
following information:
Hex
Character Predata Function Code Postdata
Protocol
Symbol
0x 77E1 D03F !
id name symbol Brands working
1 Sony “#” Sony
2 NEC “!” Apple, LG
3 RC5 “%” Philips
4 RC6 “&” Philips
5 Samsung “/” Samsung
fig 40. Protocol symbols
fig 41. String code example
62
The Hex Character is present in every code we send, it is placed in the predata
field of the database so if predata information doesn't exist, the field will only
hold the Hex character “0x”, for example in this case the predata field will store
“0x77E1”, which is fixed in every code sent through the infrared. The function
code is a string with the Hex characters of the function, in this case “VOLUP”, this
code varies for every function of the remote, next we have the postdata field,
which is only present for a few remotes, but it has to be taken into account. In
this case the string is empty, so it won’t affect the String generated at the end.
Finally the protocol symbol is needed just to let the Arduino Board know which
protocol has to be used with this code, this is because some remotes have
different ways of sending infrared codes, indicated by the database.
So at the end a String such as the following: “0x77E1D03F!” will be sent and a
data transmission will be done, the Arduino Board will convert the Data from
String to Hex, but that’s not all, finally the Arduino Board needs information about
how many bits we have to send, in this case, as we have 8 Hexadecimal
characters, 32 bits are needed, so another data transmission will be done with the
following String: “32+” therefore two transmissions are done every time the user
presses a button on the iPad screen.
63
6.3 Database
To store and retrieve all the necessary information we use a local SQLite database
and it has the following structure:
The database consists of five tables:
tblTypes consists of an id and the name of the type, this table indicates what
kind of device we are using whether a DVD player, a Laptop or a Television.
tblBrands is a table that contains information about the brands that our
application supports.
tblProtocols gives us information on which protocol is needed to send the
infrared code once the information is on the Arduino Uno board.
tblDevices has all the useful information about the remote controllers
supported by the application. The predata and postdata fields are common in
every code sent by a device; this is why they are in this table and not in
tblCodes. Another important field is the number of bits, to let the Arduino
Board know how big the data package will be in order to send it through
infrared, in addition there is the isFavourite field, which is a Boolean that
indicates if the user added the remote before, if so, it will be loaded on the
user favourite remotes next time the application starts.
tblCodes stores all the infrared codes from every remote that the application
supports, the field name refers to a function on the remote and has a
common name for every remote e.g.: VOLUP, VOLDOWN, CHANUP etc.
fig 42. Database design
64
The database has six different usages:
The first one is a very simple query, which retrieves all the available Brands of
remotes from the database:
SELECT name
FROM tblBrands;
The second query shows in the screen the remotes of a specific brand that the
user has chose before.
E.g.: the selected brand is “Apple”
SELECT D.devname
FROM tblDevices D, tblBrands B
WHERE D.brandId=B.id AND B.name=”Apple”;
The third query is executed once the user pick a remote from the list and it
retrieves an Array with all the information needed, the predata, code, postdata,
and function names for this remote so the application is ready to send the data.
e.g.: the selected remote is “Apple_Mac”
SELECT D.devname, D.bits, D.predata, C.name, C.code, D.postdata, P.symbol
FROM tblProtocols P, tblDevices D, tblCodes C
The fourth query just list the favourite remotes of the user, these will be those
with the isFavourite field with a true value.
SELECT devname
FROM tblDevices
WHERE isFavourite=”TRUE”;
65
The fifth query is made when a user sets a remote in the list of favourites and it
just change the isFavourite field value to true.
UPDATE tblDevices
WHERE devname=”Apple_Mac”
SET isFavourite=TRUE;
The sixth query let the user delete a remote from the favourite list, this is done by
setting a false value to the isFavourite field.
UPDATE tblDevices
WHERE devname=”Apple_Mac”
SET isFavourite=FALSE;
66
6.4 Information architecture
fig 43. Flowchart application
67
7. Proof of concept
In this section a brief overview of the whole project will be given. This overview
will be explained step by step, which will make it easier to understand.
Step 1: Selecting the desired device in the Ipad/laptop
The user selects the remote to control from the Ipad/laptop. As shown in the
picture, an interface has been created, which provides a list of remotes. After
selecting the remote, the user can choose an action to execute such as increase
the volume or change channel.
Step 2: Sending data from the Ipad/laptop to the converter
Once the user has selected the remotes' brand, model and action to be execute,
data (in string form) is sent through the Wi‐Fi from the Ipad/laptop to the
converter. The selected protocol is the IEEE 802.11g protocol. When data is
received in the shield, it gets stored in its buffer. The Arduino receives this data
from the SPI port and saves it into a variable. The data received is compound by
two strings. The first one contains the infrared code to be sent to the device, and
the second one contains the numbers of bits of the previous string.
fig 44. User‐Interface design 2
68
Step 3: Converting data
As the data is received in string form, it is necessary to convert it to another
format, as binary, hexadecimal, decimal….In this case the first string received has
been converted to hexadecimal format, because this format is more easier to
work with it. The second string has been converted to decimal because it contains
the number of bits of the previous code.
Step 4: Selecting the IR protocol
After the hexadecimal code and the number of bits are ready, we need to emit it
through the IR led. Before we do this, we have to know which protocol the code
belongs to. For this reason, when the data was sent from the Ipad/laptop, it
contains a character at the end of the first string, indicating the protocol to use.
So the program knows which protocol it has to use.
Step 5: Sending the IR code
The program uses the hexadecimal code in the sending function. Depending on
which IR protocol has been used, the code has to be sent at least twice; otherwise
the device will ignore the signal.
fig 45. Project scheme
69
8. Conclusion
The project consists of creating an application, which converts wireless ‐ into
infrared signals. This application will have the specific use of controlling infrared
devices around the house and filling the need for comfort. Our target consists of
people between the age of 15 and 60.
It was a big challenge to create a universal converter, but in the end, using a
database, our goal was achieved. The SQLite database the Actionscript 3
programming language provided us an easy way of managing data. We found a
way of sending data through the wireless network, which can easily be converted
into hexadecimal and used for the Arduino board.
We also achieved multiple aims such as:
Establishing a connection between the Arduino and the WiFly shield through
the SPI port.
Finding a suitable way of integrating the IR protocols in the micro‐processor
Implementing an algorithm to handle incoming data from the iPad/laptop.
Due the way the IR protocols were implemented, more protocols can be
introduced in the future.
We created an iOS application where users can browse and control remotes with
a user‐interface based on Apples' guidelines on Human Interface Design, which
caused an increase in usability and desirability.
As a final conclusion, we can say, the EPS program has been a very successful
experience for our group. By working as a team in an international group, we
have learned to combine our skills and knowledge to successfully find a solution
to our project.
70
9. References
http://arbiol.es/wordpress/2010/04/como‐configurar‐wifly‐shield‐con‐arduino/
http://www.arduino.cc/
http://www.sparkfun.com/tutorials/158
http://hombremecatronico.es/?p=247
http://www.arcfn.com/2009/08/multi‐protocol‐infrared‐remote‐library.html
http://wiki.altium.com/display/ADOH/Infrared+Communication+Concepts
http://www.sbprojects.com/knowledge/ir/ir.htm
http://www.arduino.cc/cgi‐bin/yabb2/YaBB.pl?num=1232316708
http://tthheessiiss.wordpress.com/2009/08/05/dirt‐cheap‐wireless/
http://lirc.sourceforge.net/remotes/
http://www.techdesign.be/projects/011/011.htm
http://zerocircuits.zobyhost.com/Protocolos/protocolo_RC6.php
http://blog.lucaseckels.com/2009/08/23/arduino‐ir‐transmitter/
http://www.ladyada.net/make/tvbgone/design.html
http://en.wikipedia.org/wiki/Feasibility_study
http://arbiol.es/wordpress/2010/04/como‐configurar‐wifly‐shield‐con‐arduino/
http://ec.europa.eu/consumers/cons_int/safe_shop/guarantees/index_en.htm
http://eur‐lex.europa.eu/en/index.htm
http://en.wikipedia.org/