Problem BAP beta or Vista or?

Ok, I tried both programs using 8.0.1.6 (not exp this time)

Kurte’s code and the BRAT code (when I tried to make it take a step) both made the robot curl up and swing the right leg while moving the right ankle to odd angles… weird…

I am also using 8.0.1.6 at present, and am seeing somewhat erratic behavior. I get the Hip and Knee servos locked into place pretty well, but they oscillate a bit and do not settle down until I attempt to move the servos manually.

I have seen my brat’s ankle servos do as you describe, but they are not doing that now after I rearranged my code a bit. I can get completely different behaviors, depending on where I have things arranged in my code. This acts like a memory accessing problem of some sort - maybe something is getting over written that shouldn’t be.

8-Dale

Been chatting with Nathan. He is aware of a problem with hservo and 8.0.1.6. He told me he will look at it tonight. I personally programmed one of our BRAT’s with 8.0.1.3 and it’s working, but I don’t remember what problems 8.0.1.3 had. I’m just trying to get you an IDE to use in the meantime.

Sounds good. I believe 8.0.1.3 was one of the builds that HSERVO appeared to work on it’s own, but a serout may hang the processor. Something about a register being corrupted in hservo.

I have had the best luck with 8.0.0.0, but I don’t think that one is available anymore. But hopefully he will find the problem tonight and have the fix for it.

In the mean time I may spend some time on the Rover, trying to hookup the 4 inputs from the two encoders and see if I can reliably determine how far it has gone.

(I am a little worried about one of the encoders as the power line to the servo fell out when I was building the rover and while I was resoldering it back in (Jamb in to below the encoder board and try to get solder in from above, The motor runs, but I am afraid I may have damadged the encoder). But that is another story…

They’re out of stock, but I have a few laying around, so let me know. I will take care of it. 8)

Thanks Jim, you are a great company. I finished making the connectors, and have them hooked up to P16-P19 with 18 and 19 connected to the first encode level of each encoder. I will try using IRQ2 and IRQ3 to get these. At first one did not look like it was working but I think my Oscilloscope connection below it or my poor job of making connectors may have gotten in the way. But once I pushed it down some more it appears like both are working :smiley:

Now it is off to coding! Thanks again and I supposed I should not hijack my own thread.

Found the problem with 8.0.1.6 It was something I added monday when I didn’t have the Brat(just a scope). The commands worked with the test program but not with commands using speed settings. I’ve fixed it(I was trashing a register used to calculate the next position when using speed) but I can’t get on our FTP server until tomorrow. Stay tuned for the link sometime tomorrow morning.

Great news, Once you have it up all give it a shot. I assume you when you said Monday, you were refering to a week ago Monday as you posted 8.0.1.6 on Monday Jan 28th.

Yay! 8)

Here is the link.

www.basicmicro.com/downloads/software/B … p_8017.exe

I loaded up 8.0.1.7, and it seems solid so far. I get some jitter and noise, but I think that is due to a weak servo in the left knee - it’s the only one that has trouble going to center when the BRAT is in a semi laying down position. All other servos go right to center position and stay there. :slight_smile:

8-Dale

If you are using the IRPD/Brat code add an enable to the begining of each interrupt handler. This will remove the jitter caused by the interrupts. You will still have any jitter caused by the HS-422 servos themselves.

[code];System variables
righthip con p15
rightknee con p14
rightankle con p13
lefthip con p12
leftknee con p11
leftankle con p10

;calibrate steps per degree.
stepsperdegree fcon 166.6

;calibrate servos to “zero”.
;When homed in and servos are at 0 degrees
;the robot should be standing strait with
; irpd pointing up and AtomPro chip pointing forward.
righthip_start con -560
rightknee_start con -720
rightankle_start con 0

lefthip_start con -560
leftknee_start con -480
leftankle_start con -160

;Interrupt init
ENABLEHSERVO

ONINTERRUPT WKPINT_3,handle_irpd
ONINTERRUPT TIMERAINT,handle_timera
PMR5.bit3 = 1
TMA=4 ;increments on clock/256
ENABLE WKPINT_3
ENABLE TIMERAINT

lasttime var long
overflowtime var long
currenttime var long
diff var long
datacount var byte
irpd_data var word
command var byte

lasttime = -1 ;indicate next data should be a startpulse
;End of System setup. Add user variables below this line.

;Init positions
;Note, movement subroutine arguments are Rightankle,Rightknee,Righthip,Leftankle,Leftknee,Lefthip,speed
gosub movement 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
low 1
low 2
pause 1000

command=0xFF
main
if(command<>0xFF)then
if(command = 1) then ;(Button 2) Walk Forwards
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]
elseif(command = 4) ;(Button 5) Walk Backwards
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]
elseif(command = 18) ;(Up Vol) long stride forward
gosub movement -12.0, 45.0, 45.0, 12.0,-45.0,-45.0, 750.0]
gosub movement 12.0, 45.0, 45.0,-12.0,-45.0,-45.0, 750.0]
gosub movement 12.0,-45.0,-45.0,-12.0, 45.0, 45.0, 750.0]
gosub movement -12.0,-45.0,-45.0, 12.0, 45.0, 45.0, 750.0]
elseif(command = 19) ;(Dn Vol) long stride backward
gosub movement -12.0,-45.0,-45.0, 12.0, 45.0, 45.0, 750.0]
gosub movement 12.0,-45.0,-45.0,-12.0, 45.0, 45.0, 750.0]
gosub movement 12.0, 45.0, 45.0,-12.0,-45.0,-45.0, 750.0]
gosub movement -12.0, 45.0, 45.0, 12.0,-45.0,-45.0, 750.0]
elseif(command = 2) ;(Button 3) Kick
gosub movement 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 500.0]
gosub movement 42.0, 0.0, 0.0,-14.0, 0.0, 0.0, 500.0]
gosub movement 0.0,-32.0, 41.0,-23.0, 0.0, 0.0, 500.0]
gosub movement 0.0, 24.0,-20.0,-23.0, 0.0, 0.0, 250.0]
gosub movement 0.0, 0.0, 0.0,-18.0, 0.0, 0.0, 500.0]
gosub movement 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 500.0]
sound 9,[50\3960]
pause 50
sound 9,[50\4400]
pause 50
sound 9,[50\3960]
elseif(command = 16) ;(Channel Up) Get up from front
gosub movement 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 500.0]
gosub movement 0.0, 90.0, 45.0, 0.0, 90.0, 45.0, 500.0]
gosub movement 40.0, 90.0,-37.0, 0.0, 90.0, 45.0, 500.0]
gosub movement 0.0, 90.0,-65.0, 0.0, 90.0,-65.0, 500.0]
pause 500
gosub movement 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 750.0]
sound 9,[50\4400]
pause 50
sound 9,[50\4400]
pause 50
sound 9,[50\3960]
elseif(command = 17) ;(Channel Dn) Get up from back
gosub movement 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,1000.0]
gosub movement 0.0,-90.0, 5.0, 0.0,-90.0, 5.0,1000.0]
gosub movement 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,1000.0]
pause 1000
gosub movement 0.0, 22.0,-80.0, 0.0, 22.0,-80.0,1000.0]
gosub movement 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,1000.0]
sound 9,[50\3960]
pause 50
sound 9,[50\3960]
pause 50
sound 9,[50\4400]

   elseif(command = 0)                                    ;(Button 1) Home Position 
     gosub movement   0.0,  0.0,  0.0,  0.0,  0.0,  0.0, 500.0] 
     sound 9,[50\4400] 
     pause 50 
     sound 9,[50\4400] 
     pause 50 
     sound 9,[50\4400] 
  elseif(command = 5)                                    ;(Button 6) Headbutt 
     gosub movement   0.0,  0.0,  0.0,  0.0,  0.0,  0.0, 500.0] 
     gosub movement   0.0,-50.0,-90.0,  0.0,-50.0,-90.0, 500.0] 
     gosub movement   0.0, 32.0,-58.0,  0.0, 32.0,-58.0, 400.0] 
     pause 200 
     ;gosub movement   0.0,-11.0,  7.0,  0.0,-11.0,  7.0, 500.0] 
     gosub movement   0.0,  0.0,  0.0,  0.0,  0.0,  0.0, 500.0] 
     sound 9,[50\4400] 
     pause 50 
     sound 9,[50\3960] 
     pause 50 
     sound 9,[50\3960] 
  elseif(command = 6)                                    ;(Button 7) Turn 
     gosub movement   0.0,-35.0,-40.0,  0.0, 35.0, 37.0,500.0] 
     gosub movement   0.0, 35.0, 37.0,  0.0,-35.0,-40.0,500.0] 
     gosub movement -14.0, 35.0, 37.0, 20.0,-35.0,-40.0,500.0] 
     gosub movement -14.0, 35.0, 37.0, 20.0, 35.0, 37.0,500.0] 
     gosub movement  20.0, 35.0, 37.0,-14.0, 35.0, 37.0,500.0] 
     gosub movement  20.0,-35.0,-40.0,-14.0, 35.0, 37.0,500.0] 

     ;gosub movement   0.0,-35.0,-70.0,  0.0, 35.0,  7.0,500.0] 
     ;gosub movement   0.0, 35.0,  7.0,  0.0,-35.0,-70.0,500.0] 
     ;gosub movement -14.0, 35.0,  7.0, 20.0,-35.0,-70.0,500.0] 
     ;gosub movement -14.0, 35.0,  7.0, 20.0, 35.0,  7.0,500.0] 
     ;gosub movement  20.0, 35.0,  7.0,-14.0, 35.0,  7.0,500.0] 
     ;gosub movement  20.0,-35.0,-70.0,-14.0, 35.0,  7.0,500.0] 

  elseif(command = 3)                                    ;(Button 4) Rest Position 
     gosub movement   0.0, 45.0, 45.0,  0.0, 45.0, 45.0, 500.0] 
  endif 
  Command=0xFF 

endif
goto main

;Should never need to edit anything below this line. Add user subroutines above this and below main.
lefthippos var float
leftkneepos var float
leftanklepos var float
righthippos var float
rightkneepos var float
rightanklepos var float
last_lefthippos var float
last_leftkneepos var float
last_leftanklepos var float
last_righthippos var float
last_rightkneepos var float
last_rightanklepos var float
lhspeed var float
lkspeed var float
laspeed var float
rhspeed var float
rkspeed var float
raspeed var float
speed var float
longestmove var float
;movement [lefthippos,leftkneepos,leftanklepos,righthippos,rightkneepos,rightanklepos,speed]
movement [rightanklepos,rightkneepos,righthippos,leftanklepos,leftkneepos,lefthippos,speed]
if(speed<>0.0)then
gosub getlongest[lefthippos-last_lefthippos, |
leftkneepos-last_leftkneepos, |
leftanklepos-last_leftanklepos, |
righthippos-last_righthippos, |
rightkneepos-last_rightkneepos, |
rightanklepos-last_rightanklepos],longestmove
speed = ((longestmovestepsperdegree)/(speed/20.0))
gosub getspeed[lefthippos,last_lefthippos,longestmove,speed],lhspeed
gosub getspeed[leftkneepos,last_leftkneepos,longestmove,speed],lkspeed
gosub getspeed[leftanklepos,last_leftanklepos,longestmove,speed],laspeed
gosub getspeed[righthippos,last_righthippos,longestmove,speed],rhspeed
gosub getspeed[rightkneepos,last_rightkneepos,longestmove,speed],rkspeed
gosub getspeed[rightanklepos,last_rightanklepos,longestmove,speed],raspeed
else
lhspeed=0.0;
lkspeed=0.0;
laspeed=0.0;
rhspeed=0.0;
rkspeed=0.0;
raspeed=0.0;
endif
hservo [lefthip\TOINT (-lefthippos
stepsperdegree) + lefthip_start\TOINT lhspeed, |
righthip\TOINT (righthipposstepsperdegree) + righthip_start\TOINT rhspeed, |
leftknee\TOINT (-leftkneepos
stepsperdegree) + leftknee_start\TOINT lkspeed, |
rightknee\TOINT (rightkneeposstepsperdegree) + rightknee_start\TOINT rkspeed, |
leftankle\TOINT (-leftanklepos
stepsperdegree) + leftankle_start\TOINT laspeed, |
rightankle\TOINT (rightanklepos*stepsperdegree) + rightankle_start\TOINT raspeed]
hservowait [lefthip,righthip,leftknee,rightknee,leftankle,rightankle]
last_lefthippos = lefthippos
last_leftkneepos = leftkneepos
last_leftanklepos = leftanklepos
last_righthippos = righthippos
last_rightkneepos = rightkneepos
last_rightanklepos = rightanklepos
return

one var float
two var float
three var float
four var float
five var float
six var float
getlongest[one,two,three,four,five,six]
if(one<0.0)then
one=-1.0one
endif
if(two<0.0)then
two=-1.0
two
endif
if(three<0.0)then
three=-1.0three
endif
if(four<0.0)then
four=-1.0
four
endif
if(five<0.0)then
five=-1.0five
endif
if(six<0.0)then
six=-1.0
six
endif
if(one<two)then
one=two
endif
if(one<three)then
one=three
endif
if(one<four)then
one=four
endif
if(one<five)then
one=five
endif
if(one<six)then
one=six
endif
return one

newpos var float
oldpos var float
longest var float
maxval var float
getspeed[newpos,oldpos,longest,maxval]
if(newpos>oldpos)then
return ((newpos-oldpos)/longest)*maxval
endif
return ((oldpos-newpos)/longest)*maxval

handle_irpd
enable
currenttime=overflowtime+TCA
if(currenttime<0)then ;If we overflow to a negative number reset everything
overflowtime=0
currenttime=TCA
lasttime=-1
endif
if(lasttime<0)then ;If negtive lasttime, reset
datacount=0
lasttime=currenttime
else ;else process pulses
datacount=datacount+1
diff=currenttime-lasttime
irpd_data=irpd_data>>1
if(diff>175 AND diff<195)then ;If we get a start pulse reset datacount and irpd_data
irpd_data=0
datacount=0
elseif(diff>100 and diff<120) ;we got a “1” pulse
irpd_data.bit10=1
elseif(diff>65 and diff<85) ;we got a “0” pulse
irpd_data.bit10=0
else ;we got an invalid pulse so reset
lasttime=-1
resume
endif
if(datacount=11)then
lasttime=-1
command = irpd_data&0x7F
else
lasttime = currenttime
endif
endif
Resume

handle_timera
enable
overflowtime=overflowtime+256
resume[/code]

I am running my own code. My BRAT has HS-475HB servos.

8-Dale

Yep, I have played with this release some and it appears to be working much better. Also thanks for the tip, it does make my brat less jitterly.

You’ve got a complete BRAT built? with all the servos? When did you do that? Are you using Atom Pro?

Alan KM6VV

Yes, I got it for Christmas. :smiley: Yes, it has an Atom PRO on it. It does have a weak left knee, just like me.

8-Dale