' PWM mit Timer: Servoansteuerung. 2 Servos unabhängig ansteuern.
' In: -
' Out: b.1 PWM-Signal 1 (f_PWM ca. 61 Hz -> T_PWM ca. 16 ms)
' Out: b.2 PWM-Signal 2 (f_PWM ca. 61 Hz -> T_PWM ca. 16 ms)
'
$regfile = "m8def.dat" 'Chip: ATmega8
$crystal = 1000000 'Frequenz: 1 MHz
$swstack = 50
$hwstack = 50
$framesize = 50
Config Portb.1 = Output
Config Portb.2 = Output 'fuer PWM/Analogausgabe
Config Timer1 = Pwm , Pwm = 10 , Compare A Pwm = Clear Up , Compare B Pwm = Clear Up , Prescale = 8
Servo1 Alias Pwm1a
Servo2 Alias Pwm1b
Dim Position As Word
Const Links = 895 '2 ms
Const Rechts = 960 '1 ms
Do
Servo1 = Rechts
Servo2 = Rechts
Wait 2
Servo1 = Links
Servo2 = Links
For Position = Links To Rechts Step 5
Servo2 = Position
Waitms 100
Next Position
Loop
End