Legacy Forum: Preserving Nearly 20 Years of Community History - A Time Capsule of Discussions, Memories, and Shared Experiences.

MOTORIN() command usage?

Hitec robotics including ROBONOVA humanoid, HSR-8498HB servos, MR C-3024 Controllers and RoboBasic
1 postPage 1 of 1
1 postPage 1 of 1

MOTORIN() command usage?

Post by Gerry52 » Sun Mar 16, 2008 11:26 pm

Post by Gerry52
Sun Mar 16, 2008 11:26 pm

Hi all,

Learning RN to react in the opposite way to tilt angle changes caused by (for example) pushing him a little backwards. Pushing him beyond a given threshold should trigger him to tilt a bit to the opposite direction. Using two thresholds, one for back and one for front tilt detection can keep him straight up somewhere between the thresholds. Something like a high gained P controller acting like basic on/off control, but correct me if I’m wrong on this.

The tilt position is measured by a 2 axis accelero meter connected to AD3/4. Only back/forward tilt is used (Y axis on input AD3). Tested tilt input readings by generating a beep on two thresholds, one for back and one for front tilting. This works fine.

Changing the servo position seemed to be somewhat harder.
I’m storing the actual (current) servo position in a byte variable using it to calculate (by just increasing or decreasing it by 1) the new (desired) position. I figured next piece of code should do this slight servo position job. This code is integrated in the standard remocon template program. “tilted_back and “tilted front” are GOTO’ed from subroutine “tilt_detection”, they are triggered by the thresholds mentioned before. “tilt_detection” is GOSUB’ed from MAIN.
All variables in this snippet are declared as bytes.


tilted_back:
GOSUB motor_pos
Lf = p1 + 1
Rf = p19 + 1
GOTO tilt_correct

tilted_front:
GOSUB motor_pos
Lf = p1 - 1
Rf = p19 - 1
GOTO tilt_correct

motor_pos:
MOTOR 1
p1 = MOTORIN(1)

MOTOR 19
p19 = MOTORIN(19)
RETURN

tilt_correct:
SERVO 1, Lf
SERVO 19, Rf
GOTO MAIN

Sometimes it works, RN then nicely tilts opposite by 1 degr. at a time till it’s straight up again. Corrections made are minimal, 1 or 2 degrees, 3 at most. However by now and then the servos are also traveling to unwanted positions making him fall down (after which I’m glad to see the desired stand up routine is executed, triggered by 2 other thresholds:-).

I tried to PEEK&POKE the internal memory to avoid the MOTORIN command as suggested in some posts. Values returned by MOTORIN are not reliable enough if understood correctly!? To directly address the internal memory I’ve not proper programming skills… yet! So for now I like to think “plain” robobasic commands can do the job for me as well… doesn’t?

Need some help here. Please request additional information as required, I can post or PM more code.

Grtz,

Gerry
Hi all,

Learning RN to react in the opposite way to tilt angle changes caused by (for example) pushing him a little backwards. Pushing him beyond a given threshold should trigger him to tilt a bit to the opposite direction. Using two thresholds, one for back and one for front tilt detection can keep him straight up somewhere between the thresholds. Something like a high gained P controller acting like basic on/off control, but correct me if I’m wrong on this.

The tilt position is measured by a 2 axis accelero meter connected to AD3/4. Only back/forward tilt is used (Y axis on input AD3). Tested tilt input readings by generating a beep on two thresholds, one for back and one for front tilting. This works fine.

Changing the servo position seemed to be somewhat harder.
I’m storing the actual (current) servo position in a byte variable using it to calculate (by just increasing or decreasing it by 1) the new (desired) position. I figured next piece of code should do this slight servo position job. This code is integrated in the standard remocon template program. “tilted_back and “tilted front” are GOTO’ed from subroutine “tilt_detection”, they are triggered by the thresholds mentioned before. “tilt_detection” is GOSUB’ed from MAIN.
All variables in this snippet are declared as bytes.


tilted_back:
GOSUB motor_pos
Lf = p1 + 1
Rf = p19 + 1
GOTO tilt_correct

tilted_front:
GOSUB motor_pos
Lf = p1 - 1
Rf = p19 - 1
GOTO tilt_correct

motor_pos:
MOTOR 1
p1 = MOTORIN(1)

MOTOR 19
p19 = MOTORIN(19)
RETURN

tilt_correct:
SERVO 1, Lf
SERVO 19, Rf
GOTO MAIN

Sometimes it works, RN then nicely tilts opposite by 1 degr. at a time till it’s straight up again. Corrections made are minimal, 1 or 2 degrees, 3 at most. However by now and then the servos are also traveling to unwanted positions making him fall down (after which I’m glad to see the desired stand up routine is executed, triggered by 2 other thresholds:-).

I tried to PEEK&POKE the internal memory to avoid the MOTORIN command as suggested in some posts. Values returned by MOTORIN are not reliable enough if understood correctly!? To directly address the internal memory I’ve not proper programming skills… yet! So for now I like to think “plain” robobasic commands can do the job for me as well… doesn’t?

Need some help here. Please request additional information as required, I can post or PM more code.

Grtz,

Gerry
Gerry52
Robot Builder
Robot Builder
Posts: 20
Joined: Thu Feb 28, 2008 9:51 pm
Location: Netherlands

1 postPage 1 of 1
1 postPage 1 of 1