Upload
chrystal-norah-nelson
View
219
Download
3
Embed Size (px)
Citation preview
2011/9/30 1Wireless Sensor Network And Labs fall 2011
OutlinePlatforms and microcontrollers
Software
Electronics, schematics and datasheets
2011/9/30Wireless Sensor Network And Labs fall 2011 2
WSN PlatformA hardware device that enable wireless
sensor network researchTypical components
MicrocontrollerRadioPower supplySensors and/or actuatorsPeripherals
USB interface Storage
2011/9/30 3Wireless Sensor Network And Labs fall 2011
What Do We HaveTelosB (Taroko/TmoteSky/TIP700CM)
Original design: UC Berkeley
2011/9/30Wireless Sensor Network And Labs fall 2011 4
Crossbow TelosB
Moteiv Tmote Sky
CHNDS Taroko
Maxfor TIP700CM
CrossbowOriginal design: UC Berkeley
Commercial product: Crossbow
Other products from Crossbow Cricket Imote2 IRIS
2011/9/30Wireless Sensor Network And Labs fall 2011 5
Mica2MicaZ
IRISImoteCricket
Others (Research)BTnode (ETH Zurich)
Commercialized
XYZ (Yale University)
MSB (Freie Universitat Berlin)Modular Sensor Board (MSB)
2011/9/30 6Wireless Sensor Network And Labs fall 2011
Others (Commercial)Dustnetworks (spun out of UC Berkeley)
iDwaRF – NodeBoard
Worldsens – WSN430
2011/9/30Wireless Sensor Network And Labs fall 2011 7
Others (Industrial Control)Accsense
MicroStrain
Sensicast
2011/9/30Wireless Sensor Network And Labs fall 2011 8
Now !
2011/9/30Wireless Sensor Network And Labs fall 2011 9
TarokoOriginal design version TelosB
by UC BerkeleyModified version
Taroko (CHNDS, Taiwan)TelosB (Crossbow, USA)Tmote Sky (Moteiv, USA)TIP700CM (Maxfor, Korea)
2011/9/30 10Wireless Sensor Network And Labs fall 2011
On TarokoMicrocontroller
TI (Texas Instruments) MSP430F1611RadioTI Chipcon CC2420250kbps, 2.4GHzUSB interface8M-bit flash memoryExtension connectorsOptional sensorsLight, Humidity and Temperature
2011/9/30 11Wireless Sensor Network And Labs fall 2011
Microcontroller (MCU)The heart of the WSN platform
Control everything
It is all about programming this chip
2011/9/30 12Wireless Sensor Network And Labs fall 2011
What Is A MicrocontrollerNo general definitionCommon features
low speed Microcontroller -> ARM/DSP -> Pentium/AMD
no hierarchical MemoryBits – usually 8-bit, or 16-bitPower – consume less powerCost – usually it is much cheaperInput/Output (I/O) peripherals
many on chip peripherals available
2011/9/30Wireless Sensor Network And Labs fall 2011 13
List of MCUTexas Instruments (TI): MSP430Silabs: C8051Fxxx
There are many other companies making 8051 architecture microcontrollers
including Intel, Atmel, Dallas Semiconductor, and etc.
Microchip Technology: PICAtmel: ATmega128Freescale Semiconductor (Motorola): 68HCxxMany others
AMCC (IBM), Altera, Cypress MicroSystems, Infineon, Holtek, National Semiconductor, Parallax, Rabbit Semiconductor, NEC, STMicroelectronics, Analog Devices, Xemics, ZiLOG, NXP, OKI semiconductor, Renesas Technology, Samsung, and etc.
2011/9/30Wireless Sensor Network And Labs fall 2011 14
Today’s Personal Computer
2011/9/30Wireless Sensor Network And Labs fall 2011 15
Memory (DRAM)>1GB
CPU
IDE
SATA
Audio
VGAEthern
etFirewir
eWifi
USBComPo
rt
Peripherals
Keyboard, Mouse,
Monitor, Printer, etc
Motherboard
DMA
Storage (Harddisk)>120GB
Microcontroller Block Diagram
2011/9/30Wireless Sensor Network And Labs fall 2011 16
Clock System
Memory (RAM)10KB
ALU
GPIO
Timer
ADC
UART
SPI
I2C
DAC
USBEthern
et
Peripherals
Sensors and actuators
External storage, other
ICs, other circuits
Host PC, PDA, etc.
Microcontroller
DMA
Storage (Flash)48KB
Pins
2011/9/30Wireless Sensor Network And Labs fall 2011 17
Clock System
LEDsSwitches
Radio Chip
Motor
USB Chip
PC
Light Sensors
Temp/HumiditySensor
Infrared Sensors
MSP430 Family16-bit Reduced Instruction Set
Computer (RISC) CPU1K to 128K bytes Flash128 bytes to 10K bytes RAM14- to 100-pin I/O Ultra-low Power
2011/9/30Wireless Sensor Network And Labs fall 2011 18
Clock SignalAn oscillate signal generated by some
hardware
All processors, as well as many peripherals require clocks
Clock frequency is the speed of the processor
Usually, higher speed consume large energy
2011/9/30Wireless Sensor Network And Labs fall 2011 19
CrystalsA small block of quartz
Apply a voltage, it will vibrate
For a block of given size, it will vibrate at a
given and fixed frequency
They require a drive circuit to make them go
2011/9/30Wireless Sensor Network And Labs fall 2011 20
Generate ClockOscillator module
include crystal and drive circuit
Internal drive circuit + crystalmost common case
Digitally Controlled Oscillatoran oscillator circuit constructed
by some electrical componentscan control its frequencyfrequency varies with
temperature, voltage, and from device to device
2011/9/30Wireless Sensor Network And Labs fall 2011 21
MSP430 Clock system
Flexible clock sourcesAlways-on low frequency crystal (eg. 32.768KHz)On-demand high speed DCO (up to 25MHz)
DCO on and stable in < 1μs
2011/9/30Wireless Sensor Network And Labs fall 2011 22
Flexible Clock Sources in MSP430Oscillator consume energyHigher the speed, larger the energy
consumptionUse high speed DCO
for CPU for high speed peripheralswake up and get things done, go to sleep as
soon as possibleUse low frequency crystal oscillator
for peripherals that require always onSave energy
2011/9/30Wireless Sensor Network And Labs fall 2011 23
An Example: RTCReal-Time clock (RTC)
software routine that records second, minute, and hour
Calendar clocksecond, minute, hour, day, month, year.
Implementationconfigure a timer (counter), use low frequency
osc. (32.768KHz) as clock sourcewhen the timer counts to 32768 (exactly 1
second), it generates an interruptprocessor wake-up, execute the RTC routines
2011/9/30Wireless Sensor Network And Labs fall 2011 24
MemoryRAM (Random Access Memory)
volatile storagestore variables, stack, and etc.
Flashnon volatile storagestore program code, and data
Info Segments (on MSP430)A special segment in flashUsually use to store parameters
2011/9/30Wireless Sensor Network And Labs fall 2011 25
Memory Map of MSP430
PeripheralsTo communicate with the external worldSensors
switches, light, temperature, accelerometer, infrared, humidity, pressure, acoustic, camera, and etc.
Actuators and output controlsmotor, on/off control, LEDs, LCD display, and
etc.Other ICs or circuit
flash memory IC, SD card, USB flash disk, DSP processor, and etc.
Host PC, PDA, Industry PC, and etc.2011/9/30
Wireless Sensor Network And Labs fall 2011 26
Ways to CommunicateProgrammed I/O
The processor accepts or delivers data at times convenient to it
Interrupt-driven I/OExternal events control the processor by
requesting the current program be suspended and the external event be serviced
Direct Memory Access (DMA)DMA allows data to be transferred from I/O
devices to memory directly without the continuous involvement of the processor
2011/9/30Wireless Sensor Network And Labs fall 2011 27
Microcontroller Block Diagram
2011/9/30Wireless Sensor Network And Labs fall 2011 28
Clock System
Memory (RAM)10KB
ALU
GPIO
Timer
ADC
UART
SPI
I2C
DAC
USBEthern
et
Peripherals
Sensors and actuators
External storage, other
ICs, other circuits
Host PC, PDA, etc.
Microcontroller
DMA
Storage (Flash)48KB
GPIOGeneral purpose input/outputA pin on the MicrocontrollerFunction
Set as input or outputWhen input
Read the “value” on the pin (high/low) Generate an interrupt when transition occur
When output Set the output of the pin to high/low voltage
Usage Control LEDs, read switches input, communication,
etc2011/9/30
Wireless Sensor Network And Labs fall 2011 29
TimerIt is a counterMeasures time intervals
2011/9/30Wireless Sensor Network And Labs fall 2011 30
Internal Clock
SourceTimer
External Source
Setting
Generate Interrupt
PWM
Other Outputs(ex. count to
32768)
(ex. 32.768kHz Crystal)
Analog to Digital Converter(ADC)Convert Voltage to a digital numberSignal Path
2011/9/30Wireless Sensor Network And Labs fall 2011 31
Sensors Signal Conditioning
(if necessary)
Convert to voltage
• Amplification• Filtering
• Light• Temperature• Acceleration• Humidity• Pressure• etc.
• Resistance• Capacitance• Current• Voltage• etc.
Analog to Digital
Conversion
(ADC)
10011101
Produce a proper output
voltage level
Converts voltage to
digital number
Digital CommunicationsSending bits between each other
Serial communicationSending bits one by oneUART, SPI, I2C, USB, etc.
Parallel communicationSending multiple bits at one timeEthernet
A B10011101
A B1 0 0 1 1 1 0 1
A B
1
111
1
00
0
Our focus
2011/9/30 32Wireless Sensor Network And Labs fall 2011
Pins
2011/9/30Wireless Sensor Network And Labs fall 2011 33
Clock System
LEDsSwitches
Radio Chip
Motor
USB Chip
PC
Light Sensors
Temp/HumiditySensor
Infrared Sensors
ArduinoHardware
platformOpen source
Based on ATmega8MCU
Cheap, easily availableSparkfun
2011/9/30Wireless Sensor Network And Labs fall 2011 34
Arduino ShieldsBoards that can be plugged on top of the
Arduino PCB
2011/9/30Wireless Sensor Network And Labs fall 2011 35
Arduino Projects2d accelerometer + flash 3d stars
http://www.youtube.com/watch?v=49WBPIIo3EE
InteractionSoapBox based on Arduinohttp://www.youtube.com/watch?v=TwhOYmNC
qrgPiezo Film + flash
http://www.youtube.com/watch?v=nXLDyBFsqdg
Weekend Project: Arduino Rumble Robotshttp://www.youtube.com/watch?v=Qc6DKDFw
g9c2011/9/30Wireless Sensor Network And Labs fall 2011 36
Taroko “Shields”
2011/9/30Wireless Sensor Network And Labs fall 2011 37
Robot Cars
2011/9/30Wireless Sensor Network And Labs fall 2011 38
TI Embedded Processing Portfolio32-bit ARM
Cortex™-M3MCUs
16-bit ultra-low power MCUs
DSPDSP+ARM
ARM Cortex-A8 MPUs
Stellaris®
ARM® Cortex™-M3MSP430™Sitara™
ARM® Cortex™-A8& ARM9
C6000™
DaVinci™video processors
TI Embedded ProcessorsDigital Signal Processors (DSPs)Microcontrollers (MCUs) ARM®-Based Processors
OMAP™
Software & Dev. Tools
Up to 100 MHz
Flash8 KB to 256 KB
USB, ENET MAC+PHY CAN, ADC, PWM, SPIConnectivity, Security,Motion Control, HMI,Industrial Automation$1.00 to $8.00
300MHz to >1GHz
Cache, RAM, ROMUSB, CAN,PCIe, EMAC Industrial computing, POS & portable data terminals$5.00 to $20.00
Up to 25 MHz
Flash1 KB to 256 KB Analog I/O, ADCLCD, USB, RF
Measurement,Sensing, General Purpose
$0.25 to $9.00
300MHz to >1Ghz +Accelerator
Cache RAM, ROM
USB, ENET, PCIe, SATA, SPI
Floating/Fixed PointVideo, Audio, Voice,Security, Conferencing $5.00 to $200.00
32-bit real-time MCUs
C2000™
Delfino™
Piccolo™
40MHz to 300 MHz
Flash, RAM16 KB to 512 KB
PWM, ADC, CAN, SPI, I2CMotor Control, Digital Power, Lighting, Ren. Enrgy
$1.50 to $20.00
Ultra Low power DSP
C5000™
Up to 300 MHz+Accelerator
Up to 320KB RAMUp to 128KB ROMUSB, ADC McBSP, SPI, I2C
Audio, Voice
Medical, Biometrics
$3.00 to $10.00
Multi-coreDSP
C6000™
24.000 MMACS
Cache RAM, ROM
SRIO, EMACDMA, PCIe
Telecom test & meas, media gateways, base stations$40 to $200.00
2011/9/30Wireless Sensor Network And Labs fall 2011 39
MSP430F1xx
2011/9/30Wireless Sensor Network And Labs fall 2011 40
MSP430F4xx
2011/9/30Wireless Sensor Network And Labs fall 2011 41
MSP430F2xx
2011/9/30Wireless Sensor Network And Labs fall 2011 42
2011/9/30Wireless Sensor Network And Labs fall 2011 43
What Has Changed?1xx 2xx 4xx 5xx
Basic Clock System Basic Clock System + FLL, FLL + Unified Clock System UCS
Core voltage same as supply voltage
Core voltage same as supply voltage
Core voltage same as supply voltage
Programmable Core Voltage with integrated PMM
16-bit CPU 16-bit CPU, CPUX 16-bit CPU, CPUX 16-bit CPUXV2
GPIO GPIO w/ pull-up and pull-down
GPIO GPIO w/pull-up and pull-down, drive strength
N/A N/A N/A CRC16
Software RTC Software RTC Software RTC with Basic Timer, Basic Timer + RTC
True 32-bit RTC w/Alarms
USART USCI, USI USART, USCI USCI, USB, RF
DMA up to 3-ch DMA up to 3-ch DMA up to 3-ch DMA up to 8-ch
MPY16 MPY16 MPY16, MPY32 MPY32
ADC10,12 ADC10,12 ADC12 ADC12_A
4-wire JTAG 4-wire JTAG, some devices with Spy-Bi-Wire
4-wire JTAG 4-wire JTAG and Spy-Bi-Wire
2011/9/30Wireless Sensor Network And Labs fall 2011 44
F5xx vs. Prior MSP430 Generations2xx 4xx 5xx
CPU Clock (max) 16MHz 8MHz 25MHz
*Active Current
(3.0V, typ)
515uA @ 1MHz
4.2mA @ 8MHz
9.1mA @ 16MHz
600uA @ 1MHz
4.8mA @ 8MHz
N/A
290uA @ 1MHz
1.84mA @ 8MHz 230 uA/MHz
8.90mA @ 25MHz
120KB / 8KB (Flash / RAM) 120KB / 8KB (Flash / RAM) 256KB / 16KB (Flash / RAM)
Wake-up Time From LPM3 1us 6us 5us
Standby LPM3 Current 0.9 – 1.1uA 1.1 – 2.5uA 2.6uA (with active true RTC)
LPM4 Current 0.1uA 0.1uA 1.6uA (LPM4) / 0.1uA (LPM5)
Flash ISP Minimum DVCC 2.2V 2.7V 1.8V
Port I/O Interrupt Capability P1/P2 P1/P2 P1/P2
Some devices also P3/P4
Prog. Port Pin Drive Strength N/A N/A All port pins
Prog. Pull-ups/-downs All port pins N/A All port pins
Available MCLK Sources DCO
LFXT1
XT2 (if available)
VLO
FLL
LFXT1
XT2 (if available)
FLL
LFXT1
UCS XT2 (if available)
VLO
REFO
Available FLL Reference Clocks
N/A LFXT1 LFXT1, REFO, & XT2 (if available)
MSP430 Roadmap
100+ devices
2xx-Catalog• 16 MIPS• 120 kB Flash• 8 kB RAM• 500 nA Standby• 1.8 – 3.6V
75+ devices
1xx-Catalog• 8MIPS• 60 kB Flash• 10 kB RAM• 1.8 – 3.6 V
G = Value LineF = FlashFR = FRAM
100+ devices
4xx: LCD • 16 MIPS• 120 kB Flash• 8 kB RAM• LCD Controller, 160
segments• 1.8 – 3.6V
F23x0
The New Generation
5xx-6xx• 25MIPS• 256 kB Flash• 16 kB RAM• 1.8 – 3.6V• FRAM, USB, RF• 6xx: LCD Controller• 160 uA/MIPS
Production
Development
Device
F23x-F24x
F261xF241x
F20xxF21x1
F21x2
F22xx
F13x-F14xF15x-F16x
F541x F543xA
Fx42x0Fx42x
F44x
Fx43x
FG461x
FE42x2
F47x4
Fx47xF43x
F23x0
F11xxF12xx
F41xF41x2
FR57xxFRAM
F550x USB
F51x2Lighting
L0920.9V Native
F53xxGen Purpose
F6/563xBGM, Catalog
G2xx1
F552xUSB
CC430RF
G2xx2G2xx5
F471xx
2011/9/30Wireless Sensor Network And Labs fall 2011 45
The eZ430 Family of MSP430 Tools The eZ430 is a tradition of low-cost, easy-to-use tools for MSP430
Options include RF, energy-harvesting, RFID, even a wireless sports watch development kit!
2011/9/30Wireless Sensor Network And Labs fall 2011 46
Programming Tools Parallel FET
Supports ALL MSP430 devices Supports 4-Wire JTAG mode
only Fixed output voltage of 2.8V No JTAG fuse blow Simple hardware circuit,
possible to implement as part of a product
USB FET Supports ALL MSP430 devices Supports 4-Wire and 2-Wire
(Spy-Bi-Wire) JTAG Adjustable output voltage:
1.8 - 3.6V, 100mA JTAG fuse blow Fast operation
2011/9/30Wireless Sensor Network And Labs fall 2011 47
Gang Programmer GANG430
2011/9/30Wireless Sensor Network And Labs fall 2011 48
Target Boards for Device Programming
100-pin target board exclusive to the F543x(A) / F541x(A) devices
Development board with 100-pin TSSOP (PW) ZIF socket (MSP-TS430PZ5x100)
All pins brought out to pin headers for easy access
Programming via JTAG, Spy-bi-wire or BSL
A FET board exists for most variants of MSP430
Only $49
2011/9/30Wireless Sensor Network And Labs fall 2011 49
MSP430 Software ToolsWireless Networking Protocols
Z-Stack (CC2520 + MSP430F5438 ZigBee)TI-MACSimpliciTI (on MSP430 MediaWiki) DASH7 Wireless M-Bus6LoPAN
Example Code for the MSP-EXP430F5438 Experimenter Board (www.ti.com/msp430tools)Drivers for hardware peripherals, LCD, USB conn.
Operating SystemsuC-OSIIIAR PowerPacSalvo FreeRTOS2011/9/30
Wireless Sensor Network And Labs fall 2011 50
www.ti.com/msp430
User’s GuidesDatasheetsCode Libraries100+ Application Reports1000+ Code ExamplesProduct BrochureLatest Tool Software3rd Party ListingSilicon Errata
2011/9/30Wireless Sensor Network And Labs fall 2011 51
2011/9/30Wireless Sensor Network And Labs fall 2011 52
Typical PC Program
2011/9/30Wireless Sensor Network And Labs fall 2011 53
# include# define…….
main () { do something;
wait for input; terminate;}
1. Other sub-functions ()
External response (mouse/keyboard)
Typical Structure of Our Program
2011/9/30Wireless Sensor Network And Labs fall 2011 54
# include# define…….
main () { System and Peripherals initialization
for(;;) // forever loop { 1. wait for interrupt(sleep) 2. do something after return from interrupt }}
1. Peripherals initialization routines ()
2. Other sub-functions ()
(ISR) Interrupt Service Routines () { 1. Quickly do something or Setting flags}
Internal/External Events
InitializationConfigure hardware into a proper stateHow to configure
set registersRegisters
each hardware subsystem has its own registersstore configuration, status, buffer, and etc.set these registers properly in order to get it
worksHow to set the registers properly
MSP430x1xx family user ‘s guide2011/9/30
Wireless Sensor Network And Labs fall 2011 55
InterruptA specific internal/external event occur that
suspend current program
Mostly, it is defined by you
some exceptions, for example – reset
Usually, you have to handle it immediately
You have to define how to react while this
event occur
2011/9/30Wireless Sensor Network And Labs fall 2011 56
maskable/non-maskableNon-maskable interrupts
Interrupts that cannot be disableeg. reset, oscillator fault
Maskable interruptsInterrupts that can be disable in the programMost of the interrupts you need to handle is
maskable
2011/9/30Wireless Sensor Network And Labs fall 2011 57
What happen when it occur
2011/9/30Wireless Sensor Network And Labs fall 2011 58
main() {
for(;;) { MCU is executing or sleeping }}
1. Set interrupt flag2. Main program suspended3. Store state variables 4. Jump to ISR
(ISR) Interrupt Service Routines () { 1. Quickly do something or setting flags}
2. Restore state variables3. Return to main program, resume process
Interrupt flag: a special register indicates a particular interrupt occurState variables: information CPU will need to resume to normal processing
Where to JumpInterrupt vector
a special segment in the memorystore the address of the ISRby following code
#progma vector=0xFFFA__interrupt void Timer_B0 (void)
where is the interrupt vector specified in datasheet
2011/9/30Wireless Sensor Network And Labs fall 2011 59
Memory Map of MSP430
Address of Interrupt Vector
More than oneMore than one interrupts occur simultaneously
serve higher priority firstWhen one interrupt is being serve, it will
disable the other interruptsmeans the other ISR cannot execute before this
one finishif more than one occur while serving one
interrupt wait until it finish, serve the highest priority one first
You can enable interrupt in the ISRnot recommended
2011/9/30Wireless Sensor Network And Labs fall 2011 60
Masked twiceWhile interrupt A is being serve, interrupt B
occurred, twicewhen interrupt A is finished, the ISR of
interrupt B will be serve, only onceyou miss one event!!
KEEP YOUR ISR SHORT!!!!
2011/9/30Wireless Sensor Network And Labs fall 2011 61
Protect Your DataExample:
2011/9/30Wireless Sensor Network And Labs fall 2011 62
Packet receive interrupt occurred{ 1. packet stored in a receive buffer 2. copy receive buffer to temporal buffer 3. return}
In main program{ 1. copy temporal buffer to some data structure 2. process data}
Another packet receive interrupt occurred in the middle of copying data
In main program{ 1. disable global interrupt 2. copy temporal buffer to some data structure 3. enable global interrupt 4. process data}
Software ArchitecturesRound Robin with Interrupts
Problem: no proirity
2011/9/30Wireless Sensor Network And Labs fall 2011 63
for(;;) // forever loop { 1. wait for interrupt(sleep) if( Event 1 occurred) { do something } if( Event 2 occurred) { do something } if( Event 3 occurred) { do something } }
(ISR) Interrupt Service Routines 1 () { 1. do critical things 2. set event 1 occurred flag}(ISR) Interrupt Service Routines 2 () { 1. do critical things 2. set event 2 occurred flag}(ISR) Interrupt Service Routines 3 () { 1. do critical things 2. set event 3 occurred flag}
Software ArchitecturesFunction-Queue-Scheduling
Worst wait for highest priority taskbounded by the longest function
2011/9/30Wireless Sensor Network And Labs fall 2011 64
for(;;) // forever loop { 1. wait for interrupt(sleep) While (function queue is not empty) { call first function on queue } }
(ISR) Interrupt Service Routines 1 () { 1. do critical things 2. put function_1 on queue}
(ISR) Interrupt Service Routines 3 () { 1. do critical things 2. put function_3 on queue}
(ISR) Interrupt Service Routines 2 () { 1. do critical things 2. put function_2 on queue}
Software ArchitecturesReal-Time Operating System (RTOS)
load an operating system into the MCUthere are many RTOS availableit is beyond the scope of this class
2011/9/30Wireless Sensor Network And Labs fall 2011 65
How To Program
2011/9/30Wireless Sensor Network And Labs fall 2011 66
FET (Flash Emulation Tool)A tool that allow you to program and debug MSP430Connects to the JTAG port on MSP430A generic term used in MSP430 world
JTAG (Joint Test Action Group)IEEE 1149.1 standard: “standard Test Access Port and
Boundary-Scan Architecture”A standard interface defined for testing and debugging
Video
2011/9/30Wireless Sensor Network And Labs fall 2011 67
TinyOS“System architecture directions for network
sensors”, Jason Hill, Robert Szewczyk, Alec Woo, Seth Hollar, David Culler, Kristofer Pister . ASPLOS 2000, Cambridge, November 2000
System software for networked sensorsTiny Microthreading Operating System: TinyOS
Component-basedEvent-driven
TinyOS is written in nesC programming language
2011/9/30Wireless Sensor Network And Labs fall 2011 68
TinyOS is very powerful Modern operating system and language
techniques in an embedded systemA lot of libraries, support code, and community
development“TinyOS has a steep learning curve”
It can take time to use all of its capabilities
Wireless Sensor Network And Labs fall 2011
Why TinyOS?
Slides from TinyOS-IPSN20092011/9/30 69
nesCnesC programming language
An extension to CDesigned for sensor network nodes
Basic concepts behind nesCSeparation of construction and composition
Many components, “wired”(link) those you wantComponent provide a set of interfacesInterfaces are bidirectional
Command (down call), event (up call)
nesC compiler signals the potential data races
2011/9/30Wireless Sensor Network And Labs fall 2011 70
Support Multiple Platforms Hardware platforms
eyesIFXv2, ETH Zurich TI MSP430F1611, Infineon TDA5250
Intelmote2, Intel PXA271 XScale Processor, TI (Chipcon) CC2420
Mica2, UCB Atmel128, TI (Chipcon) CC1000
Mica2dot, UCB Atmel128, TI (Chipcon) CC1000
Micaz, UCB Atmel128, TI (Chipcon) CC2420
Telosb, UCB (Taroko) MSP430F1611, TI (Chipcon) CC2420
Tinynode, EPFL Switzerland MSP430F1611, Semtech radio transceiver XE1205
Three different microcontrollers, four different radio transceivers and many other peripheral ICs
2011/9/30Wireless Sensor Network And Labs fall 2011 71
ContikiContiki – a dynamic operating system for
networked embedded systemsLoadable modules, multiple network stacks,
multiple threading modelsOpen source; 3-clause BSD licence
Small memory footprintDesigned for portability
14 platforms, 5 CPUs in current CVS codeMany pioneering featuresProvides IP communication, both
for IPv4 and IPv6.
2011/9/30Wireless Sensor Network And Labs fall 2011 72
Demohttp://www.youtube.com/watch?
v=ievpE6nkj0Q
2011/9/30Wireless Sensor Network And Labs fall 2011 73
2011/9/30Wireless Sensor Network And Labs fall 2011 74
Something To NoteYou won't get very far without at least a very
rudimentary understanding of electronicsBut electronics is a vast and complex fieldWhat we provide here is just some very basic
principlesWe assume you have some common sense
about electronicsWe will try to make it as simple as possible
2011/9/30Wireless Sensor Network And Labs fall 2011 75
Voltage, Current and PowerVoltage
Symbol: VUnit: Volt, (V)
CurrentSymbol: IUnit: Ampere, (A)
PowerP = V * IUnit: Watt, (W)
2011/9/30Wireless Sensor Network And Labs fall 2011 76
DC and ACDC: Direct Current
Definition: current that travels in one direction we usually refer to constant voltage
AC: Alternating CurrentDefinition: opposed to DCwe usually refer to varying voltage
DC component vs AC componentDC component: average of signalAC component: the varying signal
2011/9/30Wireless Sensor Network And Labs fall 2011 77
Relationship between V and IOhm’s Law
V = I * RResistor
Most widely used elementSymbol: RUnit: Ohm (Ω)Schematic symbol:
2011/9/30Wireless Sensor Network And Labs fall 2011 78
Variable resistor
Resistors in seriesResistors in series
2011/9/30Wireless Sensor Network And Labs fall 2011 79
=R = R1 + R2
V
V1
V2I2I1
I
21
2
1
21
2
21
1
III
RR
RVV
RR
RVV
Resistors in parallelResistor in parallel
2011/9/30Wireless Sensor Network And Labs fall 2011 80
=21
21
21
11
1
RR
RR
RR
R
V
V1
V2I2
I1
I21
2
1
21
21
1
2
21
2
1
III
RR
RI
R
VI
RR
RI
R
VI
VVV
CapacitorsCapacitor store chargeSymbol: CUnit: Farads (F)
Typical range we use is from μF to pFCircuit symbols
Bipolar: no polarityUnipolar: has a positive and a negative lead
2011/9/30Wireless Sensor Network And Labs fall 2011 81
Charge and dischargeApply a voltage chargingRemove voltage discharging
Provide a temporary voltage and current source
DecouplingStable the DC voltage source
2011/9/30Wireless Sensor Network And Labs fall 2011 82
DiodesPass a current in one direction, block it from
anotherSymbol: D Forward voltage drop
A voltage different between anode and cathodeExample
For a typical voltage drop of 0.7V If Vanode is 3.3V, than Vcathode is 2.6V
This value will be specified in datasheet
2011/9/30Wireless Sensor Network And Labs fall 2011 83
Vanode Vcathode
LEDsLight-emitting diode (LED)Limited amount of current can pass through
Will damage if current is too largeNeed a current-limiting resistor
If voltage drop of this LED is 1.6V, and we want 20mA pass through
2011/9/30Wireless Sensor Network And Labs fall 2011 84
3.3V
Ground
Vanode Vcathode
R
I
8502.07.1
7.13.3 _
IVR
VVVV dropvoltagecathode
Other componentsCrystals
Symbol: X, YSwitches
symbols: SWInductors
symbol: L
2011/9/30Wireless Sensor Network And Labs fall 2011 85
Understanding Schematic
2011/9/30Wireless Sensor Network And Labs fall 2011 86
Component
Net Labels
Power Ports
Nets Crossing
Nets Cross Multiple Sheet
Real Schematic -- Taroko
2011/9/30Wireless Sensor Network And Labs fall 2011 87
Reading DatasheetEvery component should have a datasheetContain every information about the componentIf you are designing you own embedded system
Read it thoroughly and feel you understandGo back and reread itGet the latest datasheets and errata
Lets take a look at the MSP430F1611 datasheet
2011/9/30Wireless Sensor Network And Labs fall 2011 88
Next Two LabsLab 1: GPIO
Control LEDsReading switches, keypads input
Lab 2: TimerGenerate different time intervalGenerate PWM signal, control servo motor
2011/9/30Wireless Sensor Network And Labs fall 2011 89
LEDsThis is a typical connectionWhen P1.1 set to high
DVcc = VP1.1
no current flowWhen P1.1 set to low
VP1.1 = 0Current flow through, turn on the LED
GPIO can use as an On/Off control
DVcc
Vanode Vcathode
R
2011/9/30 90Wireless Sensor Network And Labs fall 2011
SwitchesOperation
Open: A and B are not connected in normal state
Close: When you press the button, A and B are connected
Typical circuitWhen the switch is open, voltage of USERINT stay at highWhen the switch is close, voltage of will be low
A B
2011/9/30 91Wireless Sensor Network And Labs fall 2011
KeypadThis is a 3x4
matrix keypadWhen you press a
button, a pin in X and a pin in Y is connected
How to interface to MSP430?
2011/9/30 92Wireless Sensor Network And Labs fall 2011
Next Two LabsLab 1: GPIO
Control LEDsReading switches, keypads input
Lab 2: TimerGenerate different time intervalGenerate PWM signal, control servo motor
2011/9/30Wireless Sensor Network And Labs fall 2011 93
Time IntervalsGenerate different time intervals Flash different LED with different time
interval
2011/9/30Wireless Sensor Network And Labs fall 2011 94
Robot CarServo motors
Robot Power (Vcc)
RedRobot Ground
(GND) Black
Robot SignalWhite Battery
GroundBlack Battery
PowerRed
2011/9/30 95Wireless Sensor Network And Labs fall 2011
Pulse Width Modulation
Pulse Width Modulation (PWM)varying the pulse width
Usage of PWMControl motor, telecommunication, voltage
regulation, and etc.
Pulse
Pulse width
Period
2011/9/30 96Wireless Sensor Network And Labs fall 2011
Pulse
Pulse width
Period ≈ 20 ms
Servo MotorA PWM input controls it angular position
Pulse width = 1.5 ms; position = 90o (neutral)Example
pulse width = 1.25 ms; position = 0o
pulse width = 1.75 ms; position = 180o
Varies between brands and models
The servo motor we used is Continuous Rotation modelOther models will just move to the
programmed position and stop
2011/9/30 97Wireless Sensor Network And Labs fall 2011
Control Servo Motor
The servo motors we used are 1.5 ms neutralIf pulse width = 1.5 ms stopIf pulse width > 1.5 ms rotate in one directionIf pulse width < 1.5 ms rotate in another
direction
Pulse
Pulse width
Period ≈ 20 ms
2011/9/30 98Wireless Sensor Network And Labs fall 2011
Install IARWe will begin our labs next weekInstall the programming software ahead
Go to www.ti.comClick Microcontroller In MSP430 menu, click Tools & SoftwareFind IAR-KICKSTART and click on itDownload software and install
2011/9/30Wireless Sensor Network And Labs fall 2011 99