Why doesn't this calibration code work

I haven’t added the feedback portion of code yet because i cant even get my servos to move with this. can anybody help

;SYSTEM VARIABLES
LANKLE CON P4
LKNEE CON P5
LHIP CON P6
RANKLE CON P7
RKNEE CON P8
RHIP CON P10
COUNT1 VAR BYTE
COUNT2 VAR BYTE
COUNT3 VAR BYTE
RATE1 VAR BYTE
RATE2 VAR BYTE
RATE3 VAR BYTE
DELAY VAR BYTE
PX VAR BYTE
POSITION VAR SWORD
JOINTANGLE VAR SWORD
JOINTANGLE =(1500/90)
RATE1=90
RATE2=90
RATE3=6
DELAY=40
;BUTTON INTERFACE
BUTTON P12,0,DELAY,RATE1,COUNT1,1,ADDITION
BUTTON P13,0,DELAY,RATE2,COUNT2,1,SUBTRACT
BUTTON P14,0,DELAY,RATE3,COUNT3,1,BLANK
;START OF PROGRAM
INITIALSTATE
ENABLEHSERVO
HSERVO [LANKLE\0\0]
HSERVO [LKNEE\0\0]
HSERVO [LHIP\0\0]
HSERVO [RANKLE\0\0]
HSERVO [RKNEE\0\0]
HSERVO [RHIP\0\0]
IF COUNT3=0 THEN
GOTO INITIALSTATE
ELSE
GOTO JOINTTEST
ENDIF
JOINTTEST
IF COUNT3=1 THEN
PX=LANKLE
ELSEIF COUNT3=2
PX=LKNEE
ELSEIF COUNT3=3
PX=LHIP
ELSEIF COUNT3=4
PX=RANKLE
ELSEIF COUNT3=5
PX=RKNEE
ELSE
PX=RHIP
ENDIF
ADDITION
HSERVO [P4(JOINTANGLECOUNT1)\100]
GOTO JOINTTEST
SUBTRACT
HSERVO [PX(JOINTANGLE
COUNT1)-(1200)\100]
GOTO JOINTTEST
BLANK
GOTO JOINTTEST

We are going to need more info. Which processor, how is it wired, etc.

What setup do you have BOTBOARD I/II? etc?

Bot Board I/O Connection
*P4 Left Ankle
P5 Left Knee
P6 Left Hip
P7 Right Ankle
P8 Right Knee
P10 Right Hip
*
Make sure the Bot Board’s jumpers are set according to Table 2.

*Note, the VS to AX0 jumper enables the program to monitor the servo battery voltage. When the battery is low, the robot can beep in warning.

**Table2 **
Bot Board II Jumper Settings
Enable A, B, and C buttons
5v I/O Group 0-3
VS I/O Groups 4-7 and 8-11
Enable SPKEN (Speaker Enable)
Enable VS (Servo Voltage) to AX0 (P16)

just a guess… this isnt all the code.

[code];SYSTEM VARIABLES
LANKLE CON P4
LKNEE CON P5
LHIP CON P6
RANKLE CON P7
RKNEE CON P8
RHIP CON P10

COUNT1 VAR BYTE
COUNT2 VAR BYTE
COUNT3 VAR BYTE
RATE1 VAR BYTE
RATE2 VAR BYTE
RATE3 VAR BYTE
DELAY VAR BYTE
PX VAR BYTE

POSITION VAR SWORD
JOINTANGLE VAR SWORD

JOINTANGLE =(1500/90)

RATE1=90
RATE2=90
RATE3=6
DELAY=40

;BUTTON INTERFACE
BUTTON P12,0,DELAY,RATE1,COUNT1,1,ADDITION
BUTTON P13,0,DELAY,RATE2,COUNT2,1,SUBTRACT
BUTTON P14,0,DELAY,RATE3,COUNT3,1,BLANK

;START OF PROGRAM
INITIALSTATE

ENABLEHSERVO
HSERVO [LANKLE\0\0]
HSERVO [LKNEE\0\0]
HSERVO [LHIP\0\0]
HSERVO [RANKLE\0\0]
HSERVO [RKNEE\0\0]
HSERVO [RHIP\0\0]

IF COUNT3=0 THEN
GOTO INITIALSTATE
ELSE
GOTO JOINTTEST
ENDIF
JOINTTEST

IF COUNT3=1 THEN
PX=LANKLE
ELSEIF COUNT3=2
PX=LKNEE
ELSEIF COUNT3=3
PX=LHIP
ELSEIF COUNT3=4
PX=RANKLE
ELSEIF COUNT3=5
PX=RKNEE
ELSE
PX=RHIP
ENDIF

ADDITION
HSERVO [P4(JOINTANGLE*COUNT1)\100]
GOTO JOINTTEST

SUBTRACT
HSERVO [PX(JOINTANGLE*COUNT1)-(1200)\100]
GOTO JOINTTEST
BLANK
GOTO JOINTTEST[/code]

I will go out on a limb here and make some assumptions. If you are using the Atom Pro and hservo with IDE version 8.0.1.8.

In 8.0.1.8 Nathan changed the interrupt system. Prior to 1.8 interrupts were always being enabled even though most people weren’t using interrupts. That change required hservo and hserial to enable them. The required code was added for hserial, but it wasn’t done for hservo.

To make hservo work with 1.8 you need to add this command on a line by itself. Enable command is normally used followed by the command it controls, like enable hserial. But leaving the argument off enables global interrupts. Note the enable command should appear before any hservo command is used.

enable

Yes, I am using Bot Board II and Basic Atom Pro. I am using the IDE version 08.0.1.7
This is actually all of the code, I just haven’t added on the section of code that returns the values of the servo pulses.
I will check all of my jumpers, but i have used the buttons before.

What voltage do you have on the VS terminal? Do you have the VS=VL jumper removed? Do you have a 9vdc battery connected to VL?

Assuming your code is generating pulses the only thing to test is the voltage for the servos. Do you have the servos plugged in with the black wire closest to the outside of the board?

Thats the thing, I’m not sure that my code is actually generating the pulses as i want it to.

I programmed an Atom Pro with your code and connected a servo to pin 4. It’s holding position. I’m not sure what you want to have happen, but I am getting servo pulses.

I want the program to allow me to use the A, B and C buttons to move the servo to a desired position

;SYSTEM VARIABLES LANKLE CON P4 LKNEE CON P5 LHIP CON P6 RANKLE CON P7 RKNEE CON P8 RHIP CON P10 COUNT1 VAR BYTE COUNT2 VAR BYTE COUNT3 VAR BYTE RATE1 VAR BYTE RATE2 VAR BYTE RATE3 VAR BYTE DELAY VAR BYTE PX VAR BYTE POSITION VAR SWORD JOINTANGLE VAR SWORD JOINTANGLE =(1500/90) RATE1=90 RATE2=90 RATE3=6 DELAY=40 ;BUTTON INTERFACE BUTTON P12,0,DELAY,RATE1,COUNT1,1,ADDITION BUTTON P13,0,DELAY,RATE2,COUNT2,1,SUBTRACT BUTTON P14,0,DELAY,RATE3,COUNT3,1,BLANK ;START OF PROGRAM INITIALSTATE ENABLEHSERVO HSERVO [LANKLE\0\0] HSERVO [LKNEE\0\0] HSERVO [LHIP\0\0] HSERVO [RANKLE\0\0] HSERVO [RKNEE\0\0] HSERVO [RHIP\0\0] IF COUNT3=0 THEN GOTO INITIALSTATE ELSE GOTO JOINTTEST ENDIF JOINTTEST IF COUNT3=1 THEN PX=LANKLE ELSEIF COUNT3=2 PX=LKNEE ELSEIF COUNT3=3 PX=LHIP ELSEIF COUNT3=4 PX=RANKLE ELSEIF COUNT3=5 PX=RKNEE ELSE PX=RHIP ENDIF ADDITION HSERVO [P4\(JOINTANGLE*COUNT1)\100] GOTO JOINTTEST SUBTRACT HSERVO [PX\(JOINTANGLE*COUNT1)-(1200)\100] GOTO JOINTTEST BLANK GOTO JOINTTEST

Just look at the flow here. The button code is only used one time. Then I see ; start of the program. No where does the program jump back to the button commands.

You have this…

check buttons start: do stuff depending on the status of the buttons goto start

You need this…

start: check buttons do stuff depending on the status of the buttons goto start