PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Servos ansteuern



Arne
14.01.2005, 21:48
Hallo,

ich habe im Forum schon gesucht und auch einiges gefunden. Leider funktioniert nichts.

Ich benutze ein Graupner C507 Servo, rot +5V, schwarz Masse und orange ist Impuls.

Mein Versuch sieht so aus:


'Test zur Ansteuerung von Servos
Config Portb = Output
Enable Interrupts
Config Servos = 1 , Servo1 = Portb.1 , Reload = 10


Servo(1) = 150

Was mache ich falsch?
Liegt es an der Software oder Hardware?
Mega16 mit 16MHz Quarz

Kann mir vielleicht jemand ein 100% funktionierendes kl. Testprogramm schicken, damit ich meinen Fehler finden kann.

Danke

FoCus
15.01.2005, 18:00
Hi weiss nicht obs dir was hilft... hab dir mal mein servo Test mitgeschickt..

ist allerdings in ASM..sollte allerdings nicht stören... schau dir halt einfach die Unterschiede an.

Kannst ihm per uart die Stellung mitteilen.
Der µC sendet dir dann fortlaufend seinen aktuellen Stellwert zu.
Anbei auch das dazu passende Windows Programm...

Gruss
Michael

Andree-HB
15.01.2005, 18:34
schau doch in die Hilfe :



Example

'--------------------------------------------------
' (c) 2001 MCS Electronics
' servo.bas demonstrates the SERVO option
'---------------------------------------------------

'Servo's need a pulse in order to operate
'with the config statement CONFIG SERVOS we can specify how many servo's we
'will use and which port pins are used
'A maximum of 16 servos might be used
'The SERVO statements use one byte for an interrupt counter and the TIMER0
'This means that you can not use TIMER0 anymore
'The reload value specifies the interval of the timer in uS
Config Servos = 2 , Servo1 = Portb.0 , Servo2 = Portb.1 , Reload = 10
'we use 2 servos with 10 uS resolution

'we must configure the port pins used to act as output
Config Portb = Output

'finally we must turn on the global interrupt
Enable Interrupts

'the servo() array is created automatic. You can used it to set the
'time the servo must be on
Servo(1) = 100 '1000 uS on
Servo(2) = 200 ' 2000 uS on


Dim I As Byte
Do
For I = 0 To 100
Servo(1) = I
Waitms 1000
Next

For I = 200 To 0 Step -1
Servo(1) = I
Waitms 1000
Next
Loop
End