Android Universal Remote

flosssnailsMobile - Wireless

Dec 10, 2013 (3 years and 8 months ago)

78 views

Android Universal Remote
Control

Steve Jian

Matt Madeja

Introduction



Remote control batteries can be expensive to replace
in the long run.


Difficult to find the remote one needs.


Exploit 'All in One' nature of smartphones.


Removes the need for direct line of sight for the user.


Goals



To allow Android smartphones to control electronic
devices


To allow users to learn new codes from remote
controls


To provide Intuitive user interface to manage the
virtual remote control

Project Overview

Project Components



IR Transceiver



Board level hardware that sends and receives IR signals


PIC 18F4520 Micro
-
controller


Photo Diode


IR LED


Android Application



User interface to control learning, managing and sending
IR codes


User touch controlled interface


File management


Bluetooth communication


Bluetooth Module


Bluetooth stack encapsulated on circuit board with DIP packaging


Communicates to phone via Bluetooth and PIC via UART

Android App


It stores the IR code it received from the controller into its permanent
memory.


It persists the data structure onto permanent memory.


It dynamically builds a remote control GUI for each device.


It allows the users to modify their remote control devices.

Android App

Android App

Android App

Bluetooth Module


Third
-
party chip implementing the Bluetooth
Protocol stack.


Creates a virtual RS
-
232 communication channel
between the Android Phone and the micro
-
controller.

Bluetooth Communication


Bluetooth Module acts as master (server)



Android Phone acts as slave (client)



Phone broadcasts its mac address(Discovery Stage)



Bluetooth Module observes all incoming broadcasts, looks
out for the phone's mac address and establishes a
connection with the phone when it sees it.


Blocking Read: communication thread waits and hangs
until the expected data is read.


Communication Protocol

Learn Code Protocol
Transmit Protocol
Android
PIC
Android
PIC
Connect
Connect
Connect
Connect
CMD_LEARN
CMD_TX
CMD_LEARN
CMD_TX
CMD_CANCEL (Optional)
Start, Data, End
Capture Code
Transmit Code
Start, Data, End
Done
Ack
IR Code


RC
-
5 is one example of IR Code


Overview


Code is repeated every 114ms


Code is made up of 14 bits


Each bit is made up of 32 cicli if binary one
and low if binary 0


Each cicli is 36KHz with of duty cycle of
25%
-
33%


We capture the high and low timings of the cicli
for playback

IR Transceiver


PIC


Capture module is used to capture timing values for the cicli in the IR code


Compare module is used to generate a pulse to drive an IR LED based on the
timing data


Data is buffered on the board on an SRAM chip


Photodiode


Wide spectrum IR receiver


The voltage across a series resistor is used to determine if the diode is
conducting or not due to incedent IR


IR LED


Wide spectrum IR transmitter centered around 940nm


Used to transmit code data from the board to the phone


Current sourced from NMOS gated by the PIC's Capture Compare PWM pin


Bluetooth Module


Transfers data between the phone and board


Communicates to chip via UART


Communicates with phone via Bluetooth

IR Transceiver

Bluetooth Module

IR LEDs

SR RAM

Micro
-
controller

IR Diode

External
Clock

IR Transceiver Embedded Software

PIC18F4520


40MHz external clock oscillator


Sleep mode in between commands


Clock at 1MHz


UART communication with Bluetooth


9600 Baud


Buffers data on external SRAM

Learning IR Codes


All IR codes of interest have bits made up
of smaller cicli pulses


Capture/Compare/PWM (CCP)



Capture reads timing values and generates an
interrupt


Determine “High”, ”Low” and “Long Low”
duration for each bit


Count Cicli

High

Low

Long low between bits

Quantanization Error

Clock

IR Code

Learned IR Code


Duty Cycle window: 25
-
33% => .08*27.8us = 2.224us


2.224us*10MHz =22 Timer Cycles


22 Timer cycles ~.1us


Transmitting Codes


Data is sent from Phone to PIC


High, Low and Long low timing values


Number of Cicli per bit


CCP Compare mode generates interrupts
based on timing values and toggles output


CCP interrupt adds the next timing value
into CCP register for next cicli edge


Highs and lows are generated for each
cicli

IR Transmitter

Power Consumption

Learning
Playing
Idle
Learning
Playing
Idle
PIC
20mA
20mA
10uA
100mW
100mW
50uW
@5v
Bluetooth
30mA
30mA
8mA
99mW
99mW
26.4mW
@3.3v
SRAM
132mA
22mA
22mA
660mW
110mW
110mW
@5v
LEDs
0
85mA
0mA
0mW
425mW
0mW
@5v
Testing Learn


Software Testing


Debug points to view capturing timing data


Counters verify that no cicli were missed


Debug points in Droid to affirm transfer accuracy PIC
to Droid


Debug points to affirm transfer accuracy Droid to PIC


Hardware Testing


Probe PIC signal output to verify frequency and duty
cycle

Testing Learn

Logic 1 for PIC

Photo Diode Output

Good Distance

Too Far

Too Close (LPF)

Test Results

*Spec:


36
KHz


25
%
-
33
% Duty Cycle

Learning Distance vs. Duty Cycle
-20.0%
-10.0%
0.0%
10.0%
20.0%
30.0%
40.0%
50.0%
5
6
7
8
9
10
11
Distance(cm)
Duty Cycle
Actual Duty Cycle
Learned Duty Cycle
Error
Test Results

Operating distance for learning

Distance [cm]
Control Status
4
No
4.25
Yes
4.5
Yes
5
Yes
6
Yes
7
Yes
8
Yes
9
Yes
10
Yes
11
Yes
11.5
Yes
12
No
Code from Remote Control RC
-
5

Code from Remote Control RC
-
5

Vol+ Generated Signal

Channel
8
Button

Menu Button Signal

Remote

Board

Board
Close Up

Challenges


Occasional data loss in BT communication


IR diode output varies due to changes in distance and
direction


Capturing large quantity of timing data


16bit timing values at 72,000values per second equals 144kbs




Future Improvements


Add redundancy in data transmission to reduce the effect
of data loss.


Refine metric for deciding the correctness of the learned
code.


Utilize the smartphone's higher computing power to
analysis the data and use the micro
-
controller solely for IR
I/O purposes.


Use faster micro
-
controller to match the sampling and
transfer rate to IR signal rate.