home wireless control students ehud ravitz lee blum instructor konstantin sinyuk part b final...

31
Home Wireless Control Home Wireless Control Students Ehud Ravitz Lee Blum Instructor Konstantin Sinyuk Part B Final Presentation Project B - 044169 Project B - 044169

Post on 19-Dec-2015

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Home Wireless Control Students Ehud Ravitz Lee Blum Instructor Konstantin Sinyuk Part B Final Presentation Project B - 044169

Home Wireless ControlHome Wireless Control

StudentsEhud RavitzLee Blum

InstructorKonstantin Sinyuk

Part B Final Presentation

Project B - 044169Project B - 044169

Page 2: Home Wireless Control Students Ehud Ravitz Lee Blum Instructor Konstantin Sinyuk Part B Final Presentation Project B - 044169

Project GoalsProject Goals

• Create a data and control wireless network over household appliances.

• Should be implemented on cheap hardware.

• Should be friendly to both users and application developers.

Page 3: Home Wireless Control Students Ehud Ravitz Lee Blum Instructor Konstantin Sinyuk Part B Final Presentation Project B - 044169

Web

iPaq

General Block DesignGeneral Block Design

Access PointAccess Point

End PointEnd Point

LegendLegend:: CANCAN

BTBT

Page 4: Home Wireless Control Students Ehud Ravitz Lee Blum Instructor Konstantin Sinyuk Part B Final Presentation Project B - 044169

Network StructureNetwork Structure

• Each household appliance will have an End Point embedded within it.

• In Each room in the house, an Access Point will control over all the End Points in the room using a Bluetooth wireless connection.

• All the Access Points will communicate with one another using a wired CAN network.

Page 5: Home Wireless Control Students Ehud Ravitz Lee Blum Instructor Konstantin Sinyuk Part B Final Presentation Project B - 044169

HouseholdAppliance

End Point DesignEnd Point Design

• A Microchip PIC18F452 controls a Philips Bluetooth unit using UART.

• The application on the PIC controls the appliance, according to Bluetooth data transfers with the Access Point.

UART

PIC18F452

Philips Bluetooth

Unit

BT

Page 6: Home Wireless Control Students Ehud Ravitz Lee Blum Instructor Konstantin Sinyuk Part B Final Presentation Project B - 044169

Access Point DesignAccess Point Design

Access Point

CANComm.

to other APs

CANComm.

to other APs

CAN controller

EndPoint

EndPoint

UART

BT

Philips BT Unit

PIC18F458

• Microchip PIC18F458 controller.

• Up to 127 Aps connected using CAN2.0A (CANopen)

• APs in rooms communicate with up to 128 End Points.

Page 7: Home Wireless Control Students Ehud Ravitz Lee Blum Instructor Konstantin Sinyuk Part B Final Presentation Project B - 044169

SpecificationsSpecificationsMicrochip PIC18F452/8Microchip PIC18F452/8

Operating Frequency

40 MHz

Program Memory(ROM)

32KBytes

Data Memory (RAM)1536 Bytes

USARTYes

CAN2: No ; 8: Yes

Phillips BluetoothPhillips Bluetooth

Frequency2.4GHz to 2.4835GHz

RangeUp to 15m (integral antenna)

Embedded Software

HCI interface Stack

Network Topology

Point to Multipoint (up to 7 slaves)

Power Supply3 to 3.4V (or from USB)

Dimensions45 x 48 x 7mm

Pic18fxx8 - Can ModuleCan Module

Implementation of the CAN protocol CAN 1.2, CAN 2.0A and CAN 2.0B

0 - 8 bytes data length

Programmable bit rate up to 1 Mbit/sec

Low power SLEEP mode

Page 8: Home Wireless Control Students Ehud Ravitz Lee Blum Instructor Konstantin Sinyuk Part B Final Presentation Project B - 044169

• CAN max. freq. is 1Mbps.

• Bluetooth effective freq. is 750KB/sec.

• PIC to BT UART connection is in 115,200 bps.

• PIC’s effective throughput is 10MIPS.

Work FrequenciesWork Frequencies

Page 9: Home Wireless Control Students Ehud Ravitz Lee Blum Instructor Konstantin Sinyuk Part B Final Presentation Project B - 044169

System’s AdvantagesSystem’s Advantages

• CAN and BT are standards, thus the HWC can be easily accessed from outside.

• Robust enough to handle intended rate of communications, mainly short data transfers for control functions.

• Cheap hardware:– CAN: Telephone wiring– BT: Cheap unit, wireless.

Page 10: Home Wireless Control Students Ehud Ravitz Lee Blum Instructor Konstantin Sinyuk Part B Final Presentation Project B - 044169

CANopenCANopen

• CANopen is an application layer over the CAN physical layer.

• Transmissions using Object Dictionary.• SDO (Service Data Object) for variable data

transmissions.• PDO (Process Data Object) for real time

transmissions.

Page 11: Home Wireless Control Students Ehud Ravitz Lee Blum Instructor Konstantin Sinyuk Part B Final Presentation Project B - 044169

CANopen implementationCANopen implementation

• Data Link Layer: CAN2.0A

• Can be easily transformed to CAN2.0B

• Static (and not dynamic) CAN ID allocation to reduce configuration effort.

• SDO was chosen over PDO since the PDO is limited to only 8 byte data transfers.

Page 12: Home Wireless Control Students Ehud Ravitz Lee Blum Instructor Konstantin Sinyuk Part B Final Presentation Project B - 044169

CANopen CANopen Protocol AdvantagesProtocol Advantages

• Standard

• Up to 127 units connected

• Connection is reliable and in sequence

• Liveliness maintained and failure detected

• Unlimited data messages length

Page 13: Home Wireless Control Students Ehud Ravitz Lee Blum Instructor Konstantin Sinyuk Part B Final Presentation Project B - 044169

The HWC LayerThe HWC Layer

• To Combine the BT and the CAN we needed to create a higher layer, the HWC Layer.– Controls the hybrid

network structure and maintenance.

– Transparently routes messages between the different networks.

Page 14: Home Wireless Control Students Ehud Ravitz Lee Blum Instructor Konstantin Sinyuk Part B Final Presentation Project B - 044169

HWC ProtocolHWC Protocol

• ConnectUpdate: Informs all EPs the BD address and HWC handle of the new EP.

• DisconnectUpdate: Informs all EPs a connected EP has disconnected.

• Data: Transfers Data from anyone to anyone. Data length limited to 119 bytes.

Page 15: Home Wireless Control Students Ehud Ravitz Lee Blum Instructor Konstantin Sinyuk Part B Final Presentation Project B - 044169

HWC protocolHWC handle

01234567891011121314151617181920212223

• The HWC handle include the following data:– 0-11: BT handle, 12 bits– 16-22: CAN id, 7 bits– 12-15+23: Class number, 5 bits

• AP handle includes its CAN id and zeros as the BT handler.

• EP handle includes the CAN id of the AP to which it connected and the BT handle that the AP received when it connected to it.

• The class number is saved for multicast usage.

Page 16: Home Wireless Control Students Ehud Ravitz Lee Blum Instructor Konstantin Sinyuk Part B Final Presentation Project B - 044169

HWC protocolHWC Packet header

012345678

• The HWC packet header include the following data:– 0-2: From, HWC handle, 3 bytes– 3-5: To, HWC handle, 3 bytes– 6: OpCode, 1 byte– 7-8: Data length, 2 bytes

• OpCodes:– 7 - ConnectUpdate– 8 - DisconnectUpdate– 9 - Data

Page 17: Home Wireless Control Students Ehud Ravitz Lee Blum Instructor Konstantin Sinyuk Part B Final Presentation Project B - 044169

MemoryMemoryModuleModule

BT base BT base ModuleModule

Control the BT unitControl the BT unit

BluetoothBluetoothModuleModule

Manage the Bluetooth Manage the Bluetooth protocolprotocol

Interrupt-DrivenInterrupt-Driven

Module dependency diagram Module dependency diagram (AP)(AP)

CAN base CAN base ModuleModule

Control the CAN unitControl the CAN unit

CANOPENCANOPENModuleModule

Manage the CANOPEN Manage the CANOPEN protocolprotocol

Interrupt-DrivenInterrupt-Driven

HWC moduleHWC moduleManage the HWC protocolManage the HWC protocol

Page 18: Home Wireless Control Students Ehud Ravitz Lee Blum Instructor Konstantin Sinyuk Part B Final Presentation Project B - 044169

Memory moduleMemory module

• Memory allocation

• Shared between the different modules.

• 50 memory packets (12 bytes) in RAM.

• Managed by special FIFOs.

Page 19: Home Wireless Control Students Ehud Ravitz Lee Blum Instructor Konstantin Sinyuk Part B Final Presentation Project B - 044169

CAN base moduleCAN base module• Gets CAN receive buffers

interrupts and place data in CAN FIFO.

• Send CAN messages by placing in CAN buffers.

• If busy, puts message in CAN FIFO, and transmit on first interrupt.

Page 20: Home Wireless Control Students Ehud Ravitz Lee Blum Instructor Konstantin Sinyuk Part B Final Presentation Project B - 044169

CANopen moduleCANopen module• Checks for received CAN packets in a CANopen FIFO.• Implements the following CANOPEN layers:

– NMT – Network ManagemenT• Emergency.• Node/Life Guarding.

– SDO – Service Data Object• HWC Index 2240 / 1

Page 21: Home Wireless Control Students Ehud Ravitz Lee Blum Instructor Konstantin Sinyuk Part B Final Presentation Project B - 044169

BT Base moduleBT Base module

• Checks for interrupts in the UART receive register.

• When has full BT packet, places it in the BT HCI FIFO.

• On interrupt transmits 1 byte from UART FIFO.

Page 22: Home Wireless Control Students Ehud Ravitz Lee Blum Instructor Konstantin Sinyuk Part B Final Presentation Project B - 044169

BLUETOOTH HCI moduleBLUETOOTH HCI module• Gets received BT packets from

BT HCI FIFO.• Implements The HCI layer to

control the BLUETOOTH protocol.• Notify the HWC on any new

connection or disconnection.• Transfer to the HWC all the data

from the data packets received.

Page 23: Home Wireless Control Students Ehud Ravitz Lee Blum Instructor Konstantin Sinyuk Part B Final Presentation Project B - 044169

HWC moduleHWC module

• Connected to CAN and BT modules (FIFOs).• Updates any new connection or

disconnection in the HWC protocol.• Routes received HWC packets to the

designated destination.

Page 24: Home Wireless Control Students Ehud Ravitz Lee Blum Instructor Konstantin Sinyuk Part B Final Presentation Project B - 044169

Design ToolsDesign Tools

• Microchip PIC18F452/8 on PICDEM2 boards

• MCC18 compiler using MPLab IDE

• Philips Bluetooth units• CAN2USB

Page 25: Home Wireless Control Students Ehud Ravitz Lee Blum Instructor Konstantin Sinyuk Part B Final Presentation Project B - 044169

Old Debugging MethodsOld Debugging Methods

• MPLab Debugger: not reliable

• LCD module: Too big

• 3 of the 4 LEDs were blocked by CAN ports.

Page 26: Home Wireless Control Students Ehud Ravitz Lee Blum Instructor Konstantin Sinyuk Part B Final Presentation Project B - 044169

New Debugging MethodsNew Debugging Methods

• Accessing Assembly code, PIC registers down to hardware level.

• We have developed both CAN and BT simulators in MSDEV6.

• One LED as a blinker to present data.

Page 27: Home Wireless Control Students Ehud Ravitz Lee Blum Instructor Konstantin Sinyuk Part B Final Presentation Project B - 044169

PIC18F DifficultiesPIC18F Difficulties

• We reached almost all We reached almost all limitations of the PIC:limitations of the PIC:– Used all RAM (1.5k/1.5k)Used all RAM (1.5k/1.5k)– Used 80% of ROM (26K/32K). Used 80% of ROM (26K/32K). – Program calls and interrupts Program calls and interrupts

increased while limited to max 31 in increased while limited to max 31 in the return address stack.the return address stack.

– More interrupts and long interrupt More interrupts and long interrupt run time may cause loss of run time may cause loss of interrupts on big, busy networks.interrupts on big, busy networks.

Page 28: Home Wireless Control Students Ehud Ravitz Lee Blum Instructor Konstantin Sinyuk Part B Final Presentation Project B - 044169

MCC18 DifficultiesMCC18 Difficulties

• Most MCC18 libraries are Most MCC18 libraries are problematic and complicated to problematic and complicated to work with.work with.

• MCC18 initialization is limited MCC18 initialization is limited and cannot be trusted to initiate and cannot be trusted to initiate the static memory.the static memory.

• MCC18 has some bugs, especially MCC18 has some bugs, especially in the optimizations it makes.in the optimizations it makes.

Page 29: Home Wireless Control Students Ehud Ravitz Lee Blum Instructor Konstantin Sinyuk Part B Final Presentation Project B - 044169

DEMONSTRATIONDEMONSTRATION

Page 30: Home Wireless Control Students Ehud Ravitz Lee Blum Instructor Konstantin Sinyuk Part B Final Presentation Project B - 044169

SummarySummary

• The HWC project was much harder than anticipated, even after finishing part I. Although we had to work on it about 30 hours a week during a year and a half we are glad we’ve chosen this project.

• We learned a lot more than just the CAN and BT protocols. We learned how to work with a very limited hardware and how to find advanced solutions to problems we thought “can not be solved”.

Page 31: Home Wireless Control Students Ehud Ravitz Lee Blum Instructor Konstantin Sinyuk Part B Final Presentation Project B - 044169

Thank youThank you