Upload
-
View
646
Download
0
Embed Size (px)
DESCRIPTION
1 Microcontroller overview 1.1 Industrial automation systems overview 1.2 Microcontroller architecture 1.3 The pedagogical robot 1.4 Digital Inputs/Outputs 1.5 Embedded C Language
Citation preview
Microcontroller Lab.Eng.Khaled Tamizi
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 1
PPU IUT Cachan
Mechanical DepartmentMechatronic
1 Microcontroller overview
Microcontroller in an industrial system
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 2
PTC Khadoury IUT Cachan
1.1 Industrial automation systems overview
1.2 Microcontroller architecture
1 Microcontroller overview
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 3
1.3 The pedagogical robot
1.4 Digital Inputs/Outputs
1.5 Embedded C Language
1.1 Industrial automation systems overview
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 4
1.1 Industrial automation systems overview
Energy
Commands Pre-
actuatorsActuators
Energy
othermicrocontrollers
other systems
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 5
User
Operative part
Informations
Command
Part
Sensors
Human-MachineInterface Interface
Energy
Commands Pre-
ActuatorsActuators
Energy Actuators
Electric
Actuators :
Motors
othermicrocontrollers
other systems
1.1 Industrial automation systems overview
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 6
Command
Part
User
Operative part
InformationsSensors
Human-MachineInterface Interface
Command
PartPneumatic
or hydraulic
actuators :
cylinders
Energy
Commands Pre-
ActuatorsActuators
Energy
1.1 Industrial automation systems overview
othermicrocontrollers
other systems
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 7
User
Operative part
InformationsSensors
Human-MachineInterface Interface
Command
Part
Energy
Commands Pre-
ActuatorsActuators
Energy
Pre-Actuators
Motor
drives / inverters
1.1 Industrial automation systems overview
othermicrocontrollers
other systems
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 8
User
Operative part
InformationsSensors
Human-MachineInterface Interface
Command
Part
electropneumatic
or electrohydraulic valves
Energy
Commands Pre-
ActuatorsActuators
Energy
1.1 Industrial automation systems overview
othermicrocontrollers
other systems
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 9
User
Operative part
InformationsSensors
Human-MachineInterface Interface
Command
Part
Energy
Commands Pre-
ActuatorsActuators
Energy
othermicrocontrollers
other systems
Sensors
optical detectorinductive detector
contact
detector
1.1 Industrial automation systems overview
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 10
User
Operative part
InformationsSensors
Human-MachineInterface Interface
Command
Part
optical detectorinductive detector
Optical encoder
(for motor axes)
detector
Camera
Energy
Commands Pre-
ActuatorsActuators
Energy
1.1 Industrial automation systems overview
othermicrocontrollers
other systems
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 11
User
Operative part
InformationsSensors
Human-MachineInterface Interface
Command
Part
Energy
Commands Pre-
ActuatorsActuators
Energy
othermicrocontrollers
other systems
Human-Machine Interface
1.1 Industrial automation systems overview
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 12
User
Operative part
InformationsSensors
Human-MachineInterface Interface
Command
Part
Touch screens
Lights and buttons
1.1 Industrial automation systems overview
Which device for command part ?
Few systems : for example Factory AutomationLow development costQuick and safe development
PLC (programmable logic controller)
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 13
Many systems : for example Automotive Brake systemCheap and small device
(programmable logic controller)
Microcontroller
1.1 Industrial automation systems overview
Microcontroller applications
Automotive : safety, comfort, motor control…
Embedded control : inverter, PLC (!), hover, wash machine
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 14
Automotive : safety, comfort, motor control…
Multimedia devices : phones, PDA, …
1.2 Microcontroller architecture
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 15
Commands
1.2 Microcontroller architecture
Output
communicationperipherals
CentralProcessing
Unit(CPU)
othercommandparts
Program memory(Flash)
Datamemory(RAM)
Da
ta b
us
control signals
control signals
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 16
information
Outputperipherals
inputsperipherals
UserCommands
Userinformation
internalperipherals
Da
ta b
us
control signals
control signals
control signals
control signals
Commands
Output
CentralProcessing
Unit(CPU) Digital
Outputs
communicationperipheralsother
commandparts
Program memory(Flash)
Datamemory(RAM)
Da
ta b
us
1.2 Microcontroller architecture
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 17
Information
UserCommands
UserInformation
Outputperipherals
Inputperipherals
Internalperipherals
DigitalInputs
Fast counting
Inputs
Timers
Internalclock
PWM Outputs(Pulse WidthModulation)
Analog todigital
converter
Da
ta b
us
Commands
1.2 Microcontroller architecture
Output
communicationperipherals
CentralProcessing
Unit(CPU)
othercommandparts
Program memory(Flash)
Datamemory(RAM)
Da
ta b
us
control signals
control signals
CPU
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 18
information
Outputperipherals
inputsperipherals
UserCommands
Userinformation
internalperipherals
Da
ta b
us
control signals
control signals
control signals
control signals
Commands
1.2 Microcontroller architecture
Output
communicationperipherals
CentralProcessing
Unit(CPU)
othercommandparts
Program memory(Flash)
Datamemory(RAM)
Da
ta b
us
control signals
control signals
CPU
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 19
information
Outputperipherals
inputsperipherals
UserCommands
Userinformation
internalperipherals
Da
ta b
us
control signals
control signals
control signals
control signals
Commands
1.2 Microcontroller architecture
Output
communicationperipherals
CentralProcessing
Unit(CPU)
othercommandparts
Program memory(Flash)
Datamemory(RAM)
Da
ta b
us
control signals
control signals
ProgramMemory
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 20
information
Outputperipherals
inputsperipherals
UserCommands
Userinformation
internalperipherals
Da
ta b
us
control signals
control signals
control signals
control signals
Commands
1.2 Microcontroller architecture
Output
communicationperipherals
CentralProcessing
Unit(CPU)
othercommandparts
Datamemory(RAM)
Da
ta b
us
control signals
control signals
ProgramMemory
Program memory(Flash)
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 21
information
Outputperipherals
inputsperipherals
UserCommands
Userinformation
internalperipherals
Da
ta b
us
control signals
control signals
control signals
control signals
Commands
1.2 Microcontroller architecture
Output
communicationperipherals
CentralProcessing
Unit(CPU)
othercommandparts
Program memory(Flash)
Datamemory(RAM)
Da
ta b
us
control signals
control signals
DataMemory
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 22
information
Outputperipherals
inputsperipherals
UserCommands
Userinformation
internalperipherals
Da
ta b
us
control signals
control signals
control signals
control signals
Commands
1.2 Microcontroller architecture
Output
communicationperipherals
CentralProcessing
Unit(CPU)
othercommandparts
Da
ta b
us
control signals
DataMemory
Program memory(Flash)
Datamemory(RAM)
control signals
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 23
information
Outputperipherals
inputsperipherals
UserCommands
Userinformation
internalperipherals
Da
ta b
us
control signals
control signals
control signals
control signals
Commands
1.2 Microcontroller architecture
Output
communicationperipherals
CentralProcessing
Unit(CPU)
othercommandparts
Program memory(Flash)
Datamemory(RAM)
Da
ta b
us
control signals
control signals
Databus
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 24
information
Outputperipherals
inputsperipherals
UserCommands
Userinformation
internalperipherals
Da
ta b
us
control signals
control signals
control signals
control signals
Commands
1.2 Microcontroller architecture
Output
communicationperipherals
CentralProcessing
Unit(CPU)
othercommandparts
Da
ta b
us
control signals
Databus
Program memory(Flash)
Datamemory(RAM)
control signals
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 25
information
Outputperipherals
inputsperipherals
UserCommands
Userinformation
internalperipherals
Da
ta b
us
control signals
control signals
control signals
control signals
1.2 Microcontroller architecturesemiconductors manufacturers
8 bits microcontrollers- Microchip- Freescale (ex. Motorola)- Cypress (µC and PSoC)- Nec, Toshiba, ST, Philips,…
16 bits microcontrollers- Renesas (ex. Mitsubishi / Hitachi)
5%
37%
27%
31%
4 bits 8 bits
16 bits 32 bits
2004 : 12 Milliards $
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 26
- Renesas (ex. Mitsubishi / Hitachi)- Microchip (µC and Digital Signal Controller)- Infineon (ex. Siemens)- Atmel, Freescale, Intel, Texas Instruments, Toshiba…
32 bits microcontrollers- Atmel (Arm core)- Infineon (TriCore : Risc, Cisc & DSP)- Freescale (Arm, PowerPC or Coldfire 68000 core)- Renesas, Nec, Texas Instruments, Toshiba…
source IC Insights
1.3 The pedagogical robot
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 27
1.3 The pedagogical robot
1.3 The pedagogical robot
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 28
1.3 The pedagogical robot
Pulse width modulation
controldataUltrasonic
Lead battery
Microcontroller
Synoptic
Optical sensors
Analog and digital sensors data
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 29
dataUltrasonic sensor
Microcontroller board
Power electronic board
Optical encoders
Line
Obstacle
Angular positions
Buttons LCD
jack &
Commands
Energy
I2C
PWMOutputs
Digital
communicationperipherals
1.3 The pedagogical robot
Chopper
+ Motors
ultrasonic
telemeter
UART
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 30
LCD Display
jack &buttons
line info
Micro-
controller
DigitalInput
Analog to digital
converter
Digitaloutputs
Fast counting
Inputs
Analog to digital
converter
Infrared
sensors
Motors
encoders
positioninfo
Potentio-meter
1.3 The pedagogical robot
Speed & positioncontrol
The robot follows the line
The robot starts and stops
Obstacle detection
Shortcutdetection
THERACE
An
alo
g t
o D
igit
al C
on
ve
rte
r
Ba
sic
Sta
te M
ac
hin
e
De
ve
lop
me
nt
too
lsD
igit
al In
pu
ts/O
utp
uts
Tim
ers
/ C
ou
nte
rsP
uls
e W
idth
Mo
du
lati
on
Co
mm
un
ica
tio
n P
eri
ph
era
lsIn
terr
up
ts
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 31
An
alo
g t
o D
igit
al C
on
ve
rte
r
Ba
sic
Sta
te M
ac
hin
e
De
ve
lop
me
nt
too
lsD
igit
al In
pu
ts/O
utp
uts
Tim
ers
/ C
ou
nte
rsP
uls
e W
idth
Mo
du
lati
on
Co
mm
un
ica
tio
n P
eri
ph
era
lsIn
terr
up
ts
1.4 Digital inputs / outputs
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 32
1.4 Digital inputs / outputs
communicationperipherals
Da
ta b
us
control signals
Program memory(Flash)
Datamemory(RAM)
control signals
CentralProcessing
Unit(CPU)
Output
control signals
VCC = 5V
Example of device plugged on a digital input : a pushbutton
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 33
internalperipherals
Da
ta b
us
control signals
control signals
control signals
Outputperipherals
inputsperipherals
control signals
control signals
VCC = 5V
GND
4,7
kO
hm
s
BPx
5 V
i=0 A
VR=0 VVR=5 V
i=1 mA
0 V
pushbutton pressed : logic level 0pushbutton not pressed : logic level 1
RB3
1.4 Digital inputs / outputs
VCC = 5V
CentralProcessing
Unit(CPU)
Otherperipherals
Example of device plugged on a digital input : a pushbutton
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 34
8-b
it d
ata
bus
Enable
reading PORTB
VCC = 5V
GND
4,7
kO
hm
s
BPx
RB3
Tri-state buffer
1.4 Digital inputs / outputs
communicationperipherals
Da
ta b
us
control signals
Program memory(Flash)
Datamemory(RAM)
control signals
CentralProcessing
Unit(CPU)
control signals
Example of device plugged on a digital output : a led
RA6Output 01
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 35
internalperipherals
Da
ta b
us
control signals
control signals
control signalsinputs
peripherals
control signals
control signals
GNDLogic level 0 : the led is OFFLogic level 1 : the led is ON
RA6Outputperipherals
680 O
hm
s
0
VA
6=
0V
i = 0 mA
1
VA
6=
5V
i = 6 mA
1.4 Digital inputs / outputs
CentralProcessing
Unit(CPU)
Otherperipherals
Example of device plugged on a digital output : a led
RA6
latch
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 36
8-b
it d
ata
bus
writing onPORTA
GND
RA6
680 O
hm
s
1.4 Digital inputs / outputs
communicationperipherals
Da
ta b
us
control signals
Program memory(Flash)
Datamemory(RAM)
control signals
CentralProcessing
Unit(CPU)
Example of device plugged on digital in/outputs : LCD display
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 37
internalperipherals
Da
ta b
us
control signals
control signals
Input / Outputperipherals
control signals
Parallel Port
4RD0-RD3
1.4 Digital inputs / outputs
CentralProcessing
Unit(CPU)
Otherperipherals
latch Tri-statebuffer
Example of device plugged on digital in/outputs : LCD display
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 38
8-b
it d
ata
bus writing on
PORTD
readingPORTD
Tri-statebuffer
RD0
En
En
selectinginput or
output mode
1.4 Digital inputs / outputs
Generic Input / output pin schematic
Tri-state bufferto select input or output mode
selecting
output latch
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 39
selecting mode circuit
Tri-state bufferfor input reading
2nd step, configure RB3 as an input
TRISB x x x 1 x x xx
1.4 Digital inputs / outputs
How to program input reading (for example the state of a pushbutton bp0 plugged on RB3)
1st step, define a variable to store the state of the pushbutton
char bp0;
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 40
RB3 is configured as an inputchar bp0;
TRISB = TRISB | 0b00001000;
3rd step, read the value of RB3 and store it in bp0
bp0 = PORTBbits.RB3;
orbp0 = PORTB & 0b00001000;
1st step, configure RA6 as an output
TRISA 0 x x x x x xx
1.4 Digital inputs / outputs
How to program output writing (for example switching on a led plugged on RA6)
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 41
RA6 is configured as an outputTRISA = TRISA & 0b10111111;
2nd step, write a value of RA6PORTAbits.RA6 = 1;
orPORTA = PORTA | 0b01000000;
1st step, configure RA6 as an output
TRISA 0 x x x x x xx
1.4 Digital inputs / outputs
How to program output writing (for example switching off a led plugged on RA6)
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 42
RA6 is configured as an outputTRISA = TRISA & 0b10111111;
2nd step, write a value of RA6PORTAbits.RA6 = 0;
orPORTA = PORTA & 0b10111111;
1.5 Embedded program flow chart
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 43
Peripherals configuration
variables definition and initialization
1.5 Flow chart
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 44
Inputs reading
Treatment
Outputs writing
Variables definition and initializations
peripherirals configuration
while (1) {Inputs reading
main(){
1.5 Flow chart
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 45
Inputs reading
treatments
Outputs writing}
}