habs gefunden unter Options->Compiler->Chip
Die Werte sind jetzt:
HW Stack = 128
Soft Stack = 256
Framesize = 32
Dennoch keine Änderung :(
Druckbare Version
habs gefunden unter Options->Compiler->Chip
Die Werte sind jetzt:
HW Stack = 128
Soft Stack = 256
Framesize = 32
Dennoch keine Änderung :(
Ich hab 2 247Ncm Servos direkt angeschlossen um's zu testen. Kann es sein, dass irgendwie durch Überbelastung was kaputt gegangen ist? Obwohl es ja eigentlich nicht so sein dürfte, da wie oben schon gesagt der Servo 3 in der ersten For-Schleife funktioniert. Nur in der 2. nicht.
hier nochmal der komplette Code:
mfgCode:
$crystal = 8000000
$baud = 9600
Declare Sub Stepper_move(byval Stepper_goto_pos As Word)
Declare Sub Elbow_move(byval Servo_goto_pos As Integer)
Declare Sub Shoulder_move(byval Servo_goto_pos As Integer)
Const Writepowerport_adr = &H72 'I2C Adr PCF 2
Const Readpowerport_adr = &H73 'I2C Adr PCF 2
Dim I2cdaten As Byte 'Datenbyte aus PCF8574
Dim I As Integer
$crystal = 8000000 'Quarzfrequenz
Config Scl = Portc.0 'Ports fuer IIC-Bus
Config Sda = Portc.1
I2cinit
Config Pind.6 = Output 'Schrittmotoren Ein/Aus
Config Pinc.5 = Output 'Schrittmotor Links Richtung
Config Pinc.3 = Output 'Schrittmotor Links Step
Config Pinc.4 = Output 'Schrittmotor Rechts Richtung
Config Pinc.2 = Output 'Schrittmotor Rechts Step
Portd.6 = 0 'Schrittmotoren einschalten
Dim Stepper_curr_pos As Integer
Stepper_curr_pos = 0
Dim Shoulder_curr_pos As Integer
Shoulder_curr_pos = 127
Dim Elbow_curr_pos As Integer
Elbow_curr_pos = 127
Dim Temp as Byte
Hauptschleife:
'Call Stepper_move(100)
'Wait 2
'Call Stepper_move(0)
'Wait 2
Wait 2
Call Elbow_move(255)
Wait 2
Call Elbow_move(0)
Goto Hauptschleife
Sub Shoulder_move(byval Servo_goto_pos As Integer)
Local Schritt As Integer
If Shoulder_curr_pos < Servo_goto_pos Then
Schritt = 1
Elseif Shoulder_curr_pos > Servo_goto_pos Then
Schritt = -1
Elseif Shoulder_curr_pos = Servo_goto_pos Then
Exit Sub
End If
Open "comd.7:9600,8,n,1" For Output As #2
For Shoulder_curr_pos = Shoulder_curr_pos To Servo_goto_pos Step Schritt
Print #2 , "#s" ; Chr(1) ; Chr(shoulder_curr_pos)
Print #2 , "#s" ; Chr(2) ; Chr(shoulder_curr_pos)
Next Shoulder_curr_pos
Close #2
Shoulder_curr_pos = Servo_goto_pos
End Sub
Sub Elbow_move(byval Servo_goto_pos As Integer)
Local Schritt As Integer
Print "elbow_move called"
If Elbow_curr_pos < Servo_goto_pos Then
Schritt = 1
Elseif Elbow_curr_pos > Servo_goto_pos Then
Schritt = -1
Elseif Shoulder_curr_pos = Servo_goto_pos Then
Exit Sub
End If
Open "comd.7:9600,8,n,1" For Output As #2
For Elbow_curr_pos = Elbow_curr_pos To Servo_goto_pos Step Schritt
Temp = Elbow_curr_pos
Print #2 , "#s" ; Chr(3) ; Chr(temp)
Print "Schritt: " ; Schritt ; " CURR: " ; Temp ; " GOTO: " ; Servo_goto_pos
Next Elbow_curr_pos
Close #2
Elbow_curr_pos = Servo_goto_pos
End Sub
Sub Stepper_move(byval Stepper_goto_pos As Intgeger)
Local Betrag As Integer
If Stepper_goto_pos > Stepper_curr_pos Then
Betrag = Stepper_goto_pos - Stepper_curr_pos
Portc.5 = 0 'Richtung
Portc.3 = 0
For I = 0 To Betrag Step 1
Portc.3 = 0
Waitms 5
Portc.3 = 1
Waitms 20
Next I
Stepper_curr_pos = Stepper_goto_pos
Print Stepper_curr_pos
Elseif Stepper_goto_pos < Stepper_curr_pos Then
Betrag = Stepper_curr_pos - Stepper_goto_pos
Portc.5 = 1 'Richtung
Portc.3 = 0
For I = 0 To Betrag Step 1
Portc.3 = 0
Waitms 5
Portc.3 = 1
Waitms 20
Next I
Stepper_curr_pos = Stepper_goto_pos
Print Stepper_curr_pos
End If
End Sub
End
jagdfalke
hab was neues rausgefunden:
wenn ich diesen code als hauptschleife benutze:
dann macht er die erste Bewegung, also Call Elbow_move(255) NICHT !!!! Call Elbow_move(0) macht er allerdings dann, und wenn er einmal soweit war macht er auch Call Elbow_move(255).Code:Hauptschleife:
Wait 2
Call Elbow_move(255)
Wait 2
Call Shoulder_move(0)
Wait 2
Call Shoulder_move(255)
Wait 2
Call Elbow_move(0)
Goto Hauptschleife
Er macht also alles, lässt aber Call Elbow_move(255) im allerersten Durchlauf aus (eigenlich lässt er ihn nicht aus, es bewegt sich einfach nichts, obwohl das Sub ausgeführt wird).
Vielleicht hilf das !?
mfg
jagdfalke
Ich muß erst noch Gartenarbeit machen, dann schau ich mir das gaaanz genau an.
Inzwischen mach auf jeden Fall eins:
Den Open COm#2 EINMAL vor die Hauptschleife und raus aus den Subs, den Close brauchst du garnicht, der nutzt eh nix.
Weil ich es genau testen will: Verwendest du RNS1 oder den RNKC10 vom Kjion ?
ich benutze den rns1
*hmm* Verwend' ich auch, nie was derartiges erlebt. *grmpf*
Mystisch.
Kannst du mal dein .Bas in der letztversion rein posten ?
ich muß das einfach sehen und 1:1 meinen BasCom rein pusten.
*zumeierlegenseheinfachnix"
Ich glaub ja nicht, daß es daran liegt, aber ich steuere den RNS1 mit der HW-UART. Vielleicht können wir so den Hund einkreisen, das ist ja lächerlich
Da hat mich doch das Ferkel unter dem H... ausgeloggt.
Ich bin's, der PicNick !
Hier mal der Code, der nicht funktioniert:
Das seltsame ist, dass diese Hauptschleife funktioniert:Code:
$crystal = 8000000
$baud = 9600
Declare Sub Stepper_move(byval Stepper_goto_pos As Word)
Declare Sub Shoulder_move(byval Shoulder_goto_pos As Integer)
Declare Sub Elbow_move(byval Elbow_goto_pos As Integer)
Const Writepowerport_adr = &H72 'I2C Adr PCF 2
Const Readpowerport_adr = &H73 'I2C Adr PCF 2
Dim I2cdaten As Byte 'Datenbyte aus PCF8574
Dim I As Integer
$crystal = 8000000 'Quarzfrequenz
Config Scl = Portc.0 'Ports fuer IIC-Bus
Config Sda = Portc.1
I2cinit
Config Pind.6 = Output 'Schrittmotoren Ein/Aus
Config Pinc.5 = Output 'Schrittmotor Links Richtung
Config Pinc.3 = Output 'Schrittmotor Links Step
Config Pinc.4 = Output 'Schrittmotor Rechts Richtung
Config Pinc.2 = Output 'Schrittmotor Rechts Step
Portd.6 = 0 'Schrittmotoren ausschalten
Dim Stepper_curr_pos As Integer
Stepper_curr_pos = 0
Dim Shoulder_curr_pos As Integer
Shoulder_curr_pos = 127
Dim Elbow_curr_pos As Integer
Elbow_curr_pos = 127
Dim Temp As Byte
Hauptschleife:
Call Elbow_move(0)
Wait 1
Call Shoulder_move(255)
Wait 1
Goto Hauptschleife
Sub Shoulder_move(byval Shoulder_goto_pos As Integer)
Local Schritt As Integer
If Shoulder_curr_pos < Shoulder_goto_pos Then
Schritt = 1
Elseif Shoulder_curr_pos > Shoulder_goto_pos Then
Schritt = -1
Elseif Shoulder_curr_pos = Shoulder_goto_pos Then
Exit Sub
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
Temp = Shoulder_curr_pos
Print #2 , "#s" ; Chr(1) ; Chr(temp)
Print #2 , "#s" ; Chr(2) ; Chr(temp)
Print "SHOULDER: " ; "Schritt: " ; Schritt ; " CURR: " ; Temp ; " GOTO: " ; Shoulder_goto_pos
Next Shoulder_curr_pos
Close #2
Shoulder_curr_pos = Shoulder_goto_pos
End Sub
Sub Elbow_move(byval Elbow_goto_pos As Integer)
Local Schritt As Integer
If Elbow_curr_pos < Elbow_goto_pos Then
Schritt = 1
Elseif Elbow_curr_pos > Elbow_goto_pos Then
Schritt = -1
Elseif Elbow_curr_pos = Elbow_goto_pos Then
Exit Sub
End If
Print "elbow"
Open "comd.7:9600,8,n,1" For Output As #2
For Elbow_curr_pos = Elbow_curr_pos To Elbow_goto_pos Step Schritt
Temp = Elbow_curr_pos
Print #2 , "#s" ; Chr(3) ; Chr(temp)
Print "ELBOW: " ; "Schritt: " ; Schritt ; " CURR: " ; Temp ; " GOTO: " ; Elbow_goto_pos
Next Elbow_curr_pos
Close #2
Elbow_curr_pos = Elbow_goto_pos
End Sub
Sub Stepper_move(byval Stepper_goto_pos As Intgeger)
Local Betrag As Integer
If Stepper_goto_pos > Stepper_curr_pos Then
Betrag = Stepper_goto_pos - Stepper_curr_pos
Portc.5 = 0 'Richtung
Portc.3 = 0
For I = 0 To Betrag Step 1
Portc.3 = 0
Waitms 5
Portc.3 = 1
Waitms 30
Next I
Stepper_curr_pos = Stepper_goto_pos
Print Stepper_curr_pos
Elseif Stepper_goto_pos < Stepper_curr_pos Then
Betrag = Stepper_curr_pos - Stepper_goto_pos
Portc.5 = 1 'Richtung
Portc.3 = 0
For I = 0 To Betrag Step 1
Portc.3 = 0
Waitms 5
Portc.3 = 1
Waitms 30
Next I
Stepper_curr_pos = Stepper_goto_pos
Print Stepper_curr_pos
End If
End Sub
End
diese aber nicht:Code:Hauptschleife:
Call Shoulder_move(255)
Wait 1
Call Elbow_move(0)
Wait 1
Goto Hauptschleife
hier bewegt sich die Schulter nach ewiger Zeit auf 255, dannach passiert nichts mehr, egal wie lange ich warte.Code:Hauptschleife:
Call Elbow_move(0)
Wait 1
Call Shoulder_move(255)
Wait 1
Goto Hauptschleife
mfg
jagdfalke
Ok, und das ganze nochmal auf deutsch bitte !?Zitat:
Zitat von Anonymous
Morgen !
Ich hab das Zeugs auf meiner RNBFRA 1.2 getestet. Da ich die Sevos über die eingebaute UART bediene, hab ich die Open und Close natürlich auskommentieren müssen und die "Print #2" auf normale "print" umgebaut. klaro
D.h. Am Programm ist deswegen kein Fehler zu finden, weil keiner da ist.Zitat:
Erwartungsgemäß geht das pipifein ohne Probleme.
Also irgendwas hats mit dem Open Com zu zun.
probier mal NUR EINEN Open VOR der Hauptschleife und sonst nix (close ist sowieso überflüssig)