PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Servo und RC5



creep77
07.11.2006, 16:51
hy zusammen,

ich habe da ein kleines problem, weil ich die funktionen GETRC5 und SERVO im gleichen programm verwenden möchte. diese benutzen ja denselben Timer interrupt 0. gibt es eine möglichkeit z.b. für GETRC5 den Timer 1 zu verwenden? eine idee wäre das pwm für den servo softwaremässig zu programmieren, aber vielleicht gehts ja auch eleganter... 8-[

mfg
stefan


$regfile = "m8def.dat"
$crystal = 3686400

Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 , Db7 = Portd.7 , E = Portd.3 , Rs = Portd.2
Config Lcd = 16 * 2
Config Portd = Output

Dim Pulsweite As Single

Pulsweite = 100

Ddrb = &B00100000
Portb = &B00010000

'Config Servos = 1 , Servo1 = Portb.5 , Reload = 100


Enable Interrupts

Config Rc5 = Pinb.4


Dim Address As Byte , Command As Byte
Dim Flag As Bit

Flag = 1

Cls
Cursor Off
Lcd "Servo Pulsweite"
Locate 2 , 1
Lcd Pulsweite ; " "

Do

Getrc5(address , Command)

If Address <> 255 Then
Reset Command.7
Select Case Command
Case 1 : If Pulsweite = 100 Then
Pulsweite = 100
Else
Pulsweite = Pulsweite + 0.5
Locate 2 , 1
Lcd Pulsweite ; " "
End If
Case 2 : If Pulsweite = 20 Then
Pulsweite = 20
Else
Pulsweite = Pulsweite - 0.5
Locate 2 , 1
Lcd Pulsweite ; " "
End If
End Select


End If

'Servo(1) = Pulsweite

Loop
End

linux_80
07.11.2006, 18:10
Hast Du schon mal in die Hilfe vom Bascom geschaut ?
da steht u.a.


CONFIG RC5 = pin [,TIMER=2]

TIMER Must be 2. The micro must have a timer2 when you want to use this option. This additional parameter will cause that TIMER2 will be used instead of the default TIMER0.

creep77
07.11.2006, 19:30
hy linux_80,

oh ich habe ur bei servo in der hilfe geschaut 8-[ besten dank für deinen tip...

mfg
stefan