department of electronic & electrical engineering embedded system aims: introduction to:...

28
Department of Electronic & Electrical Engineering Embedded system Aims: Introduction to: Hardware. Software Ideas for projects ? Robotics/Control/Sensors DEMO

Upload: rosalyn-norton

Post on 25-Dec-2015

217 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Department of Electronic & Electrical Engineering Embedded system Aims: Introduction to: Hardware. Software Ideas for projects ? Robotics/Control/Sensors

Department of Electronic & Electrical Engineering

Embedded system

Aims: • Introduction to:

• Hardware.• Software

• Ideas for projects ?• Robotics/Control/Sensors

• DEMO

Page 2: Department of Electronic & Electrical Engineering Embedded system Aims: Introduction to: Hardware. Software Ideas for projects ? Robotics/Control/Sensors

Department of Electronic & Electrical Engineering

Content:

• What is a microcontroller.• Architecture (what is on the chip and how it is connected). • IO (how we interact with the chip)• Applications• PIC16F84A (example microcontroller)• Machine code / Assembly code.• MPLABX (programming environment)• PICKIT3 hardware to program the PIC• Single board computers• High level languages

Page 3: Department of Electronic & Electrical Engineering Embedded system Aims: Introduction to: Hardware. Software Ideas for projects ? Robotics/Control/Sensors

Department of Electronic & Electrical Engineering

What is a microcontroller?

It is a computer on a single chip.

• Processing unit

• Memory

• Input / output

Typically used in an embedded system (no need to reprogram)

Page 4: Department of Electronic & Electrical Engineering Embedded system Aims: Introduction to: Hardware. Software Ideas for projects ? Robotics/Control/Sensors

Department of Electronic & Electrical Engineering

Applications

● Car industry● Telephones● Appliances● Cameras● Displays● Gadgets● Remote controls● Student projects

Page 5: Department of Electronic & Electrical Engineering Embedded system Aims: Introduction to: Hardware. Software Ideas for projects ? Robotics/Control/Sensors

Department of Electronic & Electrical Engineering

Typical Input and output

● Switches● LEDs● LCD● Sensors(light, sound, humidity, position )

● Analogue signals -> ADC->digital

● DAC -> analogue output● Control Power Electronics

Page 6: Department of Electronic & Electrical Engineering Embedded system Aims: Introduction to: Hardware. Software Ideas for projects ? Robotics/Control/Sensors

Department of Electronic & Electrical Engineering

Example --- PIC16F84A

Made by Microchip Technology

Peripheral Interface Controller

Example: low end device PIC16F84A.

● Simple ( 35 instructions RISC )● Cheap ( ~ £3 )● Robust (I haven't broken one yet!!!)

Page 7: Department of Electronic & Electrical Engineering Embedded system Aims: Introduction to: Hardware. Software Ideas for projects ? Robotics/Control/Sensors

Department of Electronic & Electrical Engineering

PIC 16F84A pin layout

Page 8: Department of Electronic & Electrical Engineering Embedded system Aims: Introduction to: Hardware. Software Ideas for projects ? Robotics/Control/Sensors

Department of Electronic & Electrical Engineering

Summary of pins

OSC1/CLKIN : Oscillator crystal input.

OSC2/CLKOUT : Oscillator crystal output.

MCLR(inv) : Master clear(reset)input. Programming voltage input.

RA0 - RA3 : Bi-directional I/O port.

RA4/T0CKI : Bi-directional I/O port. Clock input to the TMR0 timer.

RB0/INT : Bi-directional I/O port. External interrupt pin.

RB1 - RB7 : Bi-directional I/O port.

VSS : Ground

VDD : Positive supply(+2.0V to +5.5V)

Page 9: Department of Electronic & Electrical Engineering Embedded system Aims: Introduction to: Hardware. Software Ideas for projects ? Robotics/Control/Sensors
Page 10: Department of Electronic & Electrical Engineering Embedded system Aims: Introduction to: Hardware. Software Ideas for projects ? Robotics/Control/Sensors

Department of Electronic & Electrical Engineering

PIC development.

Programmer Development Board

Page 11: Department of Electronic & Electrical Engineering Embedded system Aims: Introduction to: Hardware. Software Ideas for projects ? Robotics/Control/Sensors

Department of Electronic & Electrical Engineering

Schematic for development board

4MHz Oscillator

Program/Run

Page 12: Department of Electronic & Electrical Engineering Embedded system Aims: Introduction to: Hardware. Software Ideas for projects ? Robotics/Control/Sensors

Department of Electronic & Electrical Engineering

Page 13: Department of Electronic & Electrical Engineering Embedded system Aims: Introduction to: Hardware. Software Ideas for projects ? Robotics/Control/Sensors

Department of Electronic & Electrical Engineering

Page 14: Department of Electronic & Electrical Engineering Embedded system Aims: Introduction to: Hardware. Software Ideas for projects ? Robotics/Control/Sensors

Department of Electronic & Electrical Engineering

Machine Instructions (PIC16F84A)

● Each instruction is 14 bits● For example 000010 0 0100000

● 000010 --- subtract the contents of a register from W● 0 --- were we put result (W or file register)● 010000 --- which register

Page 15: Department of Electronic & Electrical Engineering Embedded system Aims: Introduction to: Hardware. Software Ideas for projects ? Robotics/Control/Sensors

Department of Electronic & Electrical Engineering

Assembly code

We would go mad trying to program in machine code so we use

ASSEMBLY CODE

For example 000010 0 0100000 is written as

subwf 20h, w

Subtract W from register number 20h and put the result in W.

A program called an assembler converters assembly code into machine code (MPLABX uses mpasm).

Page 16: Department of Electronic & Electrical Engineering Embedded system Aims: Introduction to: Hardware. Software Ideas for projects ? Robotics/Control/Sensors

Department of Electronic & Electrical Engineering

Simple program

We we want to do: NUM_2 = NUM_1 + 101;Assembly code:

NUM_1 EQU 15 ; address of file register

NUM_2 EQU 16

movf NUM_1,w ; Copy the variable NUM_1 to W

addlw D'101' ; Add the literal constant 101 decimal to it

movwf NUM_2 ; Copy NUM_1+101 into NUM_2

Machine code:

001000 0 0001111

111110 0 1100101

000000 1 0010000

Page 17: Department of Electronic & Electrical Engineering Embedded system Aims: Introduction to: Hardware. Software Ideas for projects ? Robotics/Control/Sensors

Department of Electronic & Electrical Engineering

input->PORTA PORTB ->output

Page 18: Department of Electronic & Electrical Engineering Embedded system Aims: Introduction to: Hardware. Software Ideas for projects ? Robotics/Control/Sensors

Department of Electronic & Electrical Engineering

Example: copying data from portA to portB

bsf STATUS,5 ;select bank 1 movlw B'00000000' ;set up port B as all

outputs movwf TRISB

movlw B'00001111' ;set up port A 0-3 as inputs

movwf TRISA bcf STATUS,5 ;select bank 0

loop movfw PORTA ; input PORTA movwf PORTB ; output to PORTB goto loop ; loop forever end

Page 19: Department of Electronic & Electrical Engineering Embedded system Aims: Introduction to: Hardware. Software Ideas for projects ? Robotics/Control/Sensors

Department of Electronic & Electrical Engineering

Voltmeter demo.

Page 20: Department of Electronic & Electrical Engineering Embedded system Aims: Introduction to: Hardware. Software Ideas for projects ? Robotics/Control/Sensors

Department of Electronic & Electrical Engineering

Other Microchip devices

Page 21: Department of Electronic & Electrical Engineering Embedded system Aims: Introduction to: Hardware. Software Ideas for projects ? Robotics/Control/Sensors

Department of Electronic & Electrical Engineering

Typical Features of microcontrollers.

● GPIO (general purpose IO pins)● Interfaces:

● SPI I2C UART Ethernet USB

● PWM generators (motor control)● ADC (less common DAC) ● Signal processing● Timers● Interrupts

Page 22: Department of Electronic & Electrical Engineering Embedded system Aims: Introduction to: Hardware. Software Ideas for projects ? Robotics/Control/Sensors

Department of Electronic & Electrical Engineering

Some manufacturers

• Microchip• PIC8 PIC10 ... PIC32

● Texas Instruments•e.g. MSP430 signal processing

● Atmel•AVR general purpose •ARM (Samsung tablet)

Page 23: Department of Electronic & Electrical Engineering Embedded system Aims: Introduction to: Hardware. Software Ideas for projects ? Robotics/Control/Sensors

Department of Electronic & Electrical Engineering

High level languages

Different devices have different:

● Architectures● Instruction sets

A compiler can translates a high level language program (e.g. C C++ . . .) into machine code for the target device

– Still need to understand the device architecture to do Input/Output

Page 24: Department of Electronic & Electrical Engineering Embedded system Aims: Introduction to: Hardware. Software Ideas for projects ? Robotics/Control/Sensors

Department of Electronic & Electrical Engineering

Single board computers?

• Microprocessor / microcontroller + • Other chips on the board maybe:

• memory• IO• ADC• etc

Page 25: Department of Electronic & Electrical Engineering Embedded system Aims: Introduction to: Hardware. Software Ideas for projects ? Robotics/Control/Sensors

Department of Electronic & Electrical Engineering

Arduino

. . is an open-source electronics prototyping platform

● Various boards (different manufacturers)● Open source IDE (Linux, Windows, mac OS X)● High level C++ based programming language.● Libraries to help you do things like input/output !!!!

Page 26: Department of Electronic & Electrical Engineering Embedded system Aims: Introduction to: Hardware. Software Ideas for projects ? Robotics/Control/Sensors

Department of Electronic & Electrical Engineering

Arduino IDE

Showing how easy it is to write to the LCD display!

Page 27: Department of Electronic & Electrical Engineering Embedded system Aims: Introduction to: Hardware. Software Ideas for projects ? Robotics/Control/Sensors

Department of Electronic & Electrical Engineering

Odroid-X2 (quad core arm 1.7GHz)

This is the processor that drives samsung tablet.

• Android• Linux

Page 28: Department of Electronic & Electrical Engineering Embedded system Aims: Introduction to: Hardware. Software Ideas for projects ? Robotics/Control/Sensors

Department of Electronic & Electrical Engineering

Summary• Microcontroller chips.

• Cheap £3-20

• Can be programmed in assembly or C,C++ etc

• Need a programmer e.g. PICKIT3 (expensive 30-70 pounds)• Single board computers.

• Arduino• About £16 but

• has bootstrap program so no programmer required.

• High level programming.

• Ideal for student projects – control – sensors

• Rasp-PI/Beagleboard/Odroid• £30-150

• Linux/Android OS

• Typically no built in ADC but general purpose digital IO