Upload
ranulf-hellenbrand
View
219
Download
1
Embed Size (px)
Citation preview
Mik
roco
mpu
tert
echn
ikSE
RVO
-Kal
ibra
tion
s-Q
uick
ie
Prof
. J. W
alte
r St
and
Dez
embe
r 20
14
1
MikrocomputertechnikJürgen Walter
Servo-Kalibrations-QuickieKalibration eines Servosystems
Mik
roco
mpu
tert
echn
ikSE
RVO
-Kal
ibra
tion
s-Q
uick
ie
Prof
. J. W
alte
r St
and
Dez
embe
r 20
14
2
Lernziele:
· Ansteuerung eines Servomotors· Zusammenhang: Pulsweite – Winkelstellung· Kalibration eines Systems mit Servo· Belastung der CPU minimieren
Mik
roco
mpu
tert
echn
ikSE
RVO
-Kal
ibra
tion
s-Q
uick
ie
Prof
. J. W
alte
r St
and
Dez
embe
r 20
14
3
Voraussetzungen
· PWM-Servo-Quickie
· PWM-P-Quickie
Mik
roco
mpu
tert
echn
ikSE
RVO
-Kal
ibra
tion
s-Q
uick
ie
Prof
. J. W
alte
r St
and
Dez
embe
r 20
14
4
Wiederholung 1
• Special Function Register• PCA0CPL0• PCA0CPH0
· Impulsbreite· Winkelstellung
Mik
roco
mpu
tert
echn
ikSE
RVO
-Kal
ibra
tion
s-Q
uick
ie
Prof
. J. W
alte
r St
and
Dez
embe
r 20
14
5
Wiederholung 2
• 0,9ms 0F574h• 1,5ms 0EE6Ch• 2,1ms 0E764h
Mik
roco
mpu
tert
echn
ikSE
RVO
-Kal
ibra
tion
s-Q
uick
ie
Prof
. J. W
alte
r St
and
Dez
embe
r 20
14
6
T=21,84ms
U
t
Servo – PCA0 - Übersetzung
• Wiederholrate 45,77Hz 21,84ms• 0,9ms = 62836 – 2.1ms = 59236• Neutralposition: 1,5ms = 61036
0,9ms1,5ms2,1ms
Sysclk 300000021,84 65536
0,9 62836 F5741,5 61036 EE6C2,1 59236 E764
Mik
roco
mpu
tert
echn
ikSE
RVO
-Kal
ibra
tion
s-Q
uick
ie
Prof
. J. W
alte
r St
and
Dez
embe
r 20
14
7
Programm: SERVO_LR-HS-53
· Servo fährt in Mittenstellung· T2 – Servo fährt gegen Uhrzeiger· T3 – Servo fährt in Uhrzeiger
· Idee: · Nach ca. n*21,84ms entsteht Interrupt · der Inhalt von PCA0CPx wird um C_ADD
geändert · die Servostellung ändert sich.
Mik
roco
mpu
tert
echn
ikSE
RVO
-Kal
ibra
tion
s-Q
uick
ie
Prof
. J. W
alte
r St
and
Dez
embe
r 20
14
8
Vorgehensweise:
· Konstanten festlegen· Interrupt-Vektoren· Initialisierung (Configuration Wizard)
· Neutralstellung 1,5ms· Programmschleife· ISR_PCA0
· Sind n-Interrupts aufgetreten?· Taster 2?
· Richtung 0,9ms fahren – Addition: C_ADD· Taster 3?
· Richtung 2,1ms fahren – Subtraktion: C_ADD
Mik
roco
mpu
tert
echn
ikSE
RVO
-Kal
ibra
tion
s-Q
uick
ie
Prof
. J. W
alte
r St
and
Dez
embe
r 20
14
9
Interrupt PCA0 – Vector / ISR
ORG 05Bh ;Interrupt Vector PCAclr CF ;Interrupt bestaetigtcall ISR_PCA0 ;Aufruf Interrupt-Service-Routine
;PAC0RETI
ISR_PCA0:djnz R2,ISR_PCA_ENDE ;Sind bereits n Interrupts
;aufgetreten?mov R2,#PCA0_INT ;Wiederladen des Zaehlregisters..........ISR_PCA_ENDE:
Mik
roco
mpu
tert
echn
ikSE
RVO
-Kal
ibra
tion
s-Q
uick
ie
Prof
. J. W
alte
r St
and
Dez
embe
r 20
14
10
Programmteil: PCA0CPL0 – PCA0CPH0 addieren
mov A,PCA0CPL0 ;Compare 0 Low Byte in Akkuclr C ;Carry loeschenadd A,#C_ADDmov PCA0CPL0,A ;Low Byte wieder zurücksch.mov A,PCA0CPH0 ;High Byte Compare holenjnc KEINUEBERTRAG_1inc A ;+1 in HBKEINUEBERTRAG_1:mov PCA0CPH0,A ;HB Compare schreiben
BEMERKUNG: C_ADD <256
Mik
roco
mpu
tert
echn
ikSE
RVO
-Kal
ibra
tion
s-Q
uick
ie
Prof
. J. W
alte
r St
and
Dez
embe
r 20
14
11
Programmteil: PCA0CPx subtrahierenC_AB:jb P1.3,ISR_PCA_ENDE ;T3 betaetigt?mov A,PCA0CPL0 ;Compare 0 Low Byte in Akkuclr C ;Carry loeschensubb A,#C_ADDmov PCA0CPL0,A ;Wieder zurueckschreibenmov A,PCA0CPH0 ;High Byte Compare holenjnc KEINUEBERTRAG_2dec A ;-1 in HBKEINUEBERTRAG_2:mov PCA0CPH0,A ;High Byte Compare schreibenISR_PCA_ENDE:ret
Mik
roco
mpu
tert
echn
ikSE
RVO
-Kal
ibra
tion
s-Q
uick
ie
Prof
. J. W
alte
r St
and
Dez
embe
r 20
14
12
Programm: SERVO_LR-HS-53
· Die Programmierung erfolgt in der IDE von Keil.· Ebenso das Debuggen
Mik
roco
mpu
tert
echn
ikSE
RVO
-Kal
ibra
tion
s-Q
uick
ie
Prof
. J. W
alte
r St
and
Dez
embe
r 20
14
13
ÜBUNGEN:
• Ü01 Kalibrieren Sie ihren Servo auf 0°; 90°; 180°Ermitteln Sie die dazugehörigen Werte von PCA0CPx
• Ü02 Variieren Sie die Schrittweite• Ü03 Variieren Sie die Geschwindigkeit durch
Veränderung der „Interruptanzahl zur Änderung“• Ü04 Ermitteln Sie die maximale Geschwindigkeit °/s,
indem Sie zwischen T2: 0° und T3: 180° fahren und über 10 Messungen mitteln.
• Ü05 Bauen Sie jetzt einen Scheibenwischer der zwischen 0° und 180° wischt.
Mik
roco
mpu
tert
echn
ikSE
RVO
-Kal
ibra
tion
s-Q
uick
ie
Prof
. J. W
alte
r St
and
Dez
embe
r 20
14
14
Quickies – schnell und intensiv lernen
· Ziel erreicht!