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
3. 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
4. 1.1 Industrial automation systems overview
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 4
5. 1.1 Industrial automation systems overview
Energy
Commands Pre-
actuators
Actuators
Energy
other
microcontrollers
other systems
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 5
User
Operative part
Informations
Command
Part
Sensors
Human-
Machine
Interface Interface
6. Energy
Commands Pre-
Actuators
Actuators
Energy Actuators
Electric
Actuators :
Motors
other
microcontrollers
other systems
1.1 Industrial automation systems overview
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 6
Command
Part
User
Operative part
Informations
Sensors
Human-
Machine
Interface Interface
Command
Part
Pneumatic
or hydraulic
actuators :
cylinders
7. Energy
Commands Pre-
Actuators
Actuators
Energy
1.1 Industrial automation systems overview
other
microcontrollers
other systems
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 7
User
Operative part
Informations
Sensors
Human-
Machine
Interface Interface
Command
Part
8. Energy
Commands Pre-
Actuators
Actuators
Energy
Pre-Actuators
Motor
drives / inverters
1.1 Industrial automation systems overview
other
microcontrollers
other systems
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 8
User
Operative part
Informations
Sensors
Human-
Machine
Interface Interface
Command
Part
electropneumatic
or electrohydraulic valves
9. Energy
Commands Pre-
Actuators
Actuators
Energy
1.1 Industrial automation systems overview
other
microcontrollers
other systems
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 9
User
Operative part
Informations
Sensors
Human-
Machine
Interface Interface
Command
Part
10. Energy
Commands Pre-
Actuators
Actuators
Energy
other
microcontrollers
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
Informations
Sensors
Human-
Machine
Interface Interface
Command
Part
optical detectorinductive detector
Optical encoder
(for motor axes)
detector
Camera
11. Energy
Commands Pre-
Actuators
Actuators
Energy
1.1 Industrial automation systems overview
other
microcontrollers
other systems
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 11
User
Operative part
Informations
Sensors
Human-
Machine
Interface Interface
Command
Part
13. 1.1 Industrial automation systems overview
Which device for command part ?
Few systems : for example Factory Automation
Low development cost
Quick and safe development
PLC
(programmable logic controller)
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 13
Many systems : for example Automotive Brake system
Cheap and small device
(programmable logic controller)
Microcontroller
14. 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, …
27. 1.3 The pedagogical robot
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 27
1.3 The pedagogical robot
28. 1.3 The pedagogical robot
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 28
29. 1.3 The pedagogical robot
Pulse width
modulation
control
dataUltrasonic
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
30. jack &
Commands
Energy
I2C
PWM
Outputs
Digital
communication
peripherals
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
Digital
Input
Analog to
digital
converter
Digital
outputs
Fast
counting
Inputs
Analog to
digital
converter
Infrared
sensors
Motors
encoders
position
info
Potentio-
meter
31. 1.3 The pedagogical robot
Speed &
position
control
The robot
follows
the line
The robot
starts and
stops
Obstacle
detection
Shortcut
detection
THE
RACE
AnalogtoDigitalConverter
BasicStateMachine
Developmenttools
DigitalInputs/Outputs
Timers/Counters
PulseWidthModulation
CommunicationPeripherals
Interrupts
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 31
AnalogtoDigitalConverter
BasicStateMachine
Developmenttools
DigitalInputs/Outputs
Timers/Counters
PulseWidthModulation
CommunicationPeripherals
Interrupts
32. 1.4 Digital inputs / outputs
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 32
33. 1.4 Digital inputs / outputs
communication
peripherals
Databus
control signals
Program
memory
(Flash)
Data
memory
(RAM)
control signals
Central
Processing
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
internal
peripherals
Databus
control signals
control signals
control signals
Output
peripherals
inputs
peripherals
control signals
control signals
VCC = 5V
GND
4,7kOhms
BPx
5 V
i=0 A
VR=0 VVR=5 V
i=1 mA
0 V
pushbutton pressed : logic level 0
pushbutton not pressed : logic level 1
RB3
34. 1.4 Digital inputs / outputs
VCC = 5V
Central
Processing
Unit
(CPU)
Other
peripherals
Example of device plugged on a digital input : a pushbutton
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 34
8-bitdatabus
Enable
reading PORTB
VCC = 5V
GND
4,7kOhms
BPx
RB3
Tri-state buffer
35. 1.4 Digital inputs / outputs
communication
peripherals
Databus
control signals
Program
memory
(Flash)
Data
memory
(RAM)
control signals
Central
Processing
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
internal
peripherals
Databus
control signals
control signals
control signals
inputs
peripherals
control signals
control signals
GND
Logic level 0 : the led is OFF
Logic level 1 : the led is ON
RA6Output
peripherals
680Ohms
0
VA6=0V
i = 0 mA
1
VA6=5V
i = 6 mA
36. 1.4 Digital inputs / outputs
Central
Processing
Unit
(CPU)
Other
peripherals
Example of device plugged on a digital output : a led
RA6
latch
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 36
8-bitdatabus
writing on
PORTA
GND
RA6
680Ohms
37. 1.4 Digital inputs / outputs
communication
peripherals
Databus
control signals
Program
memory
(Flash)
Data
memory
(RAM)
control signals
Central
Processing
Unit
(CPU)
Example of device plugged on digital in/outputs : LCD display
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 37
internal
peripherals
Databus
control signals
control signals
Input / Output
peripherals
control signals
Parallel Port
4
RD0-RD3
38. 1.4 Digital inputs / outputs
Central
Processing
Unit
(CPU)
Other
peripherals
latch Tri-state
buffer
Example of device plugged on digital in/outputs : LCD display
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 38
8-bitdatabus
writing on
PORTD
reading
PORTD
Tri-state
buffer
RD0
En
En
selecting
input or
output mode
39. 1.4 Digital inputs / outputs
Generic Input / output pin schematic
Tri-state buffer
to select input
or output mode
selecting
output latch
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 39
selecting
mode circuit
Tri-state buffer
for input reading
40. 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 input
char bp0;
TRISB = TRISB | 0b00001000;
3rd step, read the value of RB3
and store it in bp0
bp0 = PORTBbits.RB3;
or
bp0 = PORTB & 0b00001000;
41. 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 output
TRISA = TRISA & 0b10111111;
2nd step, write a value of RA6
PORTAbits.RA6 = 1;
or
PORTA = PORTA | 0b01000000;
42. 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 output
TRISA = TRISA & 0b10111111;
2nd step, write a value of RA6
PORTAbits.RA6 = 0;
or
PORTA = PORTA & 0b10111111;
43. 1.5 Embedded program flow chart
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 43
44. Peripherals configuration
variables definition and initialization
1.5 Flow chart
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 44
Inputs reading
Treatment
Outputs writing
45. 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
}
}