Hi,
ich habe meinen Roboterarm jetzt schon fast fertig aufgebaut. Es fehlt nur noch der Greifer. Ich wollte jetzt ein bischen mit der Positionierung herumexperimentieren und bin auf ein sicherlich sehr einfach zu lösendes Problem gestoßen, nur komm ich nicht drauf.
Hier mal der Code:
Der kommt gar nicht aus der For-Schleife raus. Die Variable Shoulder_curr_pos geht immer auf 255 und springt dann auf 0. Damit bewegt er sich plötzlich auch 0 und dann gehts wieder weiter zu 255, usw.Code:$crystal = 8000000 $baud = 9600 Declare Sub Shoulder_move(byval Shoulder_goto_pos As Byte) Dim Shoulder_curr_pos As Byte Shoulder_curr_pos = 127 Hauptschleife: Wait 2 Call Shoulder_move(255) Goto Hauptschleife Sub Shoulder_move(byval Shoulder_goto_pos As Byte) Local Schritt As Integer If Shoulder_curr_pos < Shoulder_goto_pos Then Schritt = 1 Elseif Shoulder_curr_pos > Shoulder_goto_pos Then Schritt = -1 End If Open "comd.7:9600,8,n,1" For Output As #2 For Shoulder_curr_pos = Shoulder_curr_pos To Shoulder_goto_pos Step Schritt Print #2 , "#s" ; Chr(1) ; Chr(shoulder_curr_pos) Print #2 , "#s" ; Chr(2) ; Chr(shoulder_curr_pos) Waitms 30 Print " SCHRITT: " ; Schritt ; " CURR_POS: " ; Shoulder_curr_pos ; " GOTO_POS: " ; Shoulder_goto_pos Next Shoulder_curr_pos Close #2 Shoulder_curr_pos = Shoulder_goto_pos End Sub End
Habs mit 255 und 0 für Shoulder_goto_pos probiert. In beiden Fällen passiert das gleiche. An der Variable Schritt liegts nicht. Die ist immer richtig.
Oh man, das ist bestimmt total einfach und ich checks wieder nicht. Naja hoffentlich eine von euch.
mfg
jagdfalke[/code]







Zitieren

Lesezeichen