Thanks Jim, I actually moved off of the default servos as I was trying to free of the hardware serial port. Actually it would be good for James to try your current brat code with the current beta and see if it is working properly or not. IE if you hit button 2 on the remote does it make a reasonable step.
Here is an extracted code that simply calls movement with the calculated, values for speed and servo location. He should easily be able to change the servo pin number constants and the number of servo groups to make it work on the default pins…
Note, I think I am still using all of the default calculations. I was wondering about the calculations from Angle to HServo value that used a constant of 166.6 steps per degree as the HSERVO value in the manual goes from -12000 to 12000 so if I wanted 90 degrees it would give a value of 14994… But that could simply be a documentation issue…
Now back to the code:
[code]debug con 1
; Try TV Remote Brat taking one step forward with HSERVO. Nothing else in the program
;System variables
righthip con p11
rightknee con p10
rightankle con p5 ; was p9 but that is speaker
lefthip con p8
leftknee con p7
leftankle con p6
;Interrupt init
USE_HSERVO con 1
HSERVO_GROUPS con 3
ENABLEHSERVO
; We simply want to emulate the gosub movement command for one step forward
; we will precalculate all of the speeds and the like
; if(command = 1 or command = 116) then ;(Button 2 or joystick up) Walk Forwards
; RA RK RH LA LK LH SPEED
; gosub movement -7.0, 20.0, 20.0, 7.0,-20.0,-20.0, 500.0]
; gosub movement 7.0, 20.0, 20.0, -7.0,-20.0,-20.0, 500.0]
; gosub movement 7.0,-20.0,-20.0, -7.0, 20.0, 20.0, 500.0]
; gosub movement -7.0,-20.0,-20.0, 7.0, 20.0, 20.0, 500.0]
;Movement: 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000
gosub movement [0,0, 0,0, 0,0, 0,0, 0,0, 0,0]
pause 2000
;Movement: -7.0000000000 20.0000000000 20.0000000000 7.0000000000 -20.0000000000 -20.0000000000 500.0000000000
gosub movement -1166,46, 3331,133, 3331,133, -1166,46, 3331,133, 3331,133]
;Movement: 7.0000000000 20.0000000000 20.0000000000 -7.0000000000 -20.0000000000 -20.0000000000 500.0000000000
gosub movement [1166,93, 3331,0, 3331,0, 1166,93, 3331,0, 3331,0]
;Movement: 7.0000000000 -20.0000000000 -20.0000000000 -7.0000000000 20.0000000000 20.0000000000 500.0000000000
gosub movement [1166,0, -3331,266, -3331,266, 1166,0, -3331,266, -3331,266]
;Movement: -7.0000000000 -20.0000000000 -20.0000000000 7.0000000000 20.0000000000 20.0000000000 500.0000000000
gosub movement -1166,93, -3331,0, -3331,0, -1166,93, -3331,0, -3331,0]
pause 2000
gosub movement [0,0, 0,0, 0,0, 0,0, 0,0, 0,0]
loop
goto loop
;Should never need to edit anything below this line. Add user subroutines above this and below main.
lefthippos var sword
leftkneepos var sword
leftanklepos var sword
righthippos var sword
rightkneepos var sword
rightanklepos var sword
lhspeed var word
lkspeed var word
laspeed var word
rhspeed var word
rkspeed var word
raspeed var word
movement [rightanklepos,raspeed, rightkneepos,rkspeed, righthippos,rhspeed, leftanklepos,laspeed, leftkneepos, lkspeed,lefthippos,lhspeed]
#ifdef DEBUG
serout S_OUT, i2400, |
sdec (rightanklepos), “(”, dec raspeed, ") ",|
sdec (rightkneepos), “(”, dec rkspeed, ") " , |
sdec (righthippos), “(”, dec rhspeed, ") ", |
sdec (-leftanklepos), “(”, dec laspeed, ") ", |
sdec (-leftkneepos), “(”, dec lkspeed, “) “, |
sdec (-lefthippos),”(”, dec lhspeed, “)”, 13, 10]
#endif
hservo [lefthip\lefthippos\lhspeed, |
righthip\righthippos\rhspeed, |
leftknee\leftkneepos\lkspeed, |
rightknee\rightkneepos\rkspeed, |
leftankle\leftanklepos\laspeed, |
rightankle\rightanklepos\raspeed]
hservowait [lefthip,righthip,leftknee,rightknee,leftankle,rightankle]
return
[/code]