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

Expand Your Remcon.

Hitec robotics including ROBONOVA humanoid, HSR-8498HB servos, MR C-3024 Controllers and RoboBasic
19 postsPage 2 of 21, 2
19 postsPage 2 of 21, 2

Post by visuvius » Tue Feb 05, 2008 4:42 am

Post by visuvius
Tue Feb 05, 2008 4:42 am

Tim you're the man! Doing what you said worked like a charm.

However, what I can't figure out is that sometimes, I have 2 or 3 seconds after I hit the code bank key to hit the move key, other times I have to hit the move key immediately after I press the code bank key. At first I thought it had to do with the code banks; it seemed like I had several seconds with Bank1 but had to press the code immediately with the other banks but then I noticed it was more random.

Anyhow, just wanted to say it worked and thanks again. I'd still like to check out your code as it seems like a better alternative.

For reference, here is what my code looks like now:

MAIN:

A = REMOCON(1)
A = A - ID
IF A = 18 THEN GOTO BANK1
IF A = 32 THEN GOTO BANK2
IF A = 23 THEN GOTO BANK3
GOTO main

'--------------------------------------------------
BANK1:
A = REMOCON(1)
A = A - ID
IF A = 16 THEN GOTO MAIN
ON A GOTO BANK1
ON A GOTO MAIN,K1,K2,K3,K4,K5
GOTO MAIN
'==================================================
BANK2:
A = REMOCON(1)
A = A - ID
IF A = 16 THEN GOTO MAIN
ON A GOTO BANK2
ON A GOTO MAIN,A1,A2,A3,A4,A5
GOTO MAIN
'===================================================
BANK3:
A = REMOCON(1)
A = A - ID
IF A = 16 THEN GOTO MAIN
ON A GOTO BANK3
ON A GOTO MAIN,B1,B2,B3,B4,B5
GOTO MAIN
Tim you're the man! Doing what you said worked like a charm.

However, what I can't figure out is that sometimes, I have 2 or 3 seconds after I hit the code bank key to hit the move key, other times I have to hit the move key immediately after I press the code bank key. At first I thought it had to do with the code banks; it seemed like I had several seconds with Bank1 but had to press the code immediately with the other banks but then I noticed it was more random.

Anyhow, just wanted to say it worked and thanks again. I'd still like to check out your code as it seems like a better alternative.

For reference, here is what my code looks like now:

MAIN:

A = REMOCON(1)
A = A - ID
IF A = 18 THEN GOTO BANK1
IF A = 32 THEN GOTO BANK2
IF A = 23 THEN GOTO BANK3
GOTO main

'--------------------------------------------------
BANK1:
A = REMOCON(1)
A = A - ID
IF A = 16 THEN GOTO MAIN
ON A GOTO BANK1
ON A GOTO MAIN,K1,K2,K3,K4,K5
GOTO MAIN
'==================================================
BANK2:
A = REMOCON(1)
A = A - ID
IF A = 16 THEN GOTO MAIN
ON A GOTO BANK2
ON A GOTO MAIN,A1,A2,A3,A4,A5
GOTO MAIN
'===================================================
BANK3:
A = REMOCON(1)
A = A - ID
IF A = 16 THEN GOTO MAIN
ON A GOTO BANK3
ON A GOTO MAIN,B1,B2,B3,B4,B5
GOTO MAIN
visuvius
Robot Builder
Robot Builder
Posts: 23
Joined: Mon Jan 07, 2008 11:33 pm

Post by Tim » Tue Feb 05, 2008 10:48 am

Post by Tim
Tue Feb 05, 2008 10:48 am

Hi Visuvius

Glad to be of help ;-)

I suspect your latest problem is that when you push a key that falls outside the range of the valid options in the on .. goto statement for the bank you are in, it will cause the code to find its way back to MAIN: and you have to start over.

You can avoid all that by implementing the following approach where the bank select keys are just like any other 'move', except that they change the context (i.e. the bank). That context is picked up every time you process a move key. You'll see that I've kept the default behaviour for all banks except for the first say 2 - 6 moves where I have new code. This means the favourites like walk forward/backward cartwheel/tumble etc are always available if you so wish (not that this is a new feature), also note that you have to keep the K18,K23,K32 the same in each bank's on_goto so that you can change the bank! This is just what I blatted down after reading this thread so nothing exactly new here . . . .

'<snip>

DIM BANKSEL AS BYTE 'Used for code banking
'E key => BANKSEL = 0 => default routines
'F key => BANKSEL = 1 => dance and routines
'G key => BANKSEL = 2 => combat and sonar routines

'<snip>

GOSUB standard_pose
GOSUB gyro_setup
BANKSEL = 0 ' default bank

MAIN:
'GOSUB robot_voltage
GOSUB robot_tilt

'-----------------------------
IF RR = 0 THEN GOTO MAIN1

ON RR GOTO MAIN,K1,K2,K3,K4,K5,K6,K7,K8,K9,K10,K11,K12,K13,K14,K15,K16,K17,K18,K19,K20,K21,K22,K23,K24,K25,K26,K27,K28,K29,K30,K31,K32
GOTO main_exit
'-----------------------------
MAIN1: 'this is the remote control section
A = REMOCON(1)
A = A - ID

IF BANKSEL > 2 THEN BANKSEL = 2 'only three banks at the minute

ON BANKSEL GOTO default_bank, cute_bank, combat_bank

default_bank:
ON A GOTO MAIN,K1,K2,K3,K4,K5,K6,K7,K8,K9,K10,K11,K12,K13,K14,K15,K16,K17,K18,K19,K20,K21,K22,K23,K24,K25,K26,K27,K28,K29,K30,K31,K32
GOTO MAIN

cute_bank:
ON A GOTO MAIN,a1,a2,a3,a4,a5,a6,K7,K8,K9,K10,K11,K12,K13,K14,K15,K16,K17,K18,K19,K20,K21,K22,K23,K24,K25,K26,K27,K28,K29,K30,K31,K32
GOTO MAIN

combat_bank:
ON A GOTO MAIN,b1,b2,b3,K4,K5,K6,K7,K8,K9,K10,K11,K12,K13,K14,K15,K16,K17,K18,K19,K20,K21,K22,K23,K24,K25,K26,K27,K28,K29,K30,K31,K32
GOTO MAIN

'<snip>

k18: ' E
TEMPO 230
MUSIC "CDE"
BANKSEL = 0
GOTO main_exit

'<snip>

k23: ' G (not F!)
TEMPO 230
MUSIC "EF"
BANKSEL = 2 ' combat_bank
GOTO main_exit

'<snip>

k32: ' F
TEMPO 230
MUSIC "CCFC"
BANKSEL = 1 ' cute bank
GOTO main_exit


'==================================
' CUTE BANK

a1:
GOSUB butt_scratch
SPEED 10
GOSUB standard_pose
GOTO main_exit

a2:
GOSUB ymca
SPEED 10
GOSUB standard_pose
GOTO main_exit

a3:
GOSUB tip_toes
SPEED 10
GOSUB standard_pose
GOTO main_exit

a4:
GOSUB led_toggle
SPEED 10
GOSUB standard_pose
GOTO main_exit

a5:
GOSUB led_toggle2
SPEED 10
GOSUB standard_pose
GOTO main_exit

a6:
GOSUB govenor
SPEED 10
GOSUB standard_pose
GOTO main_exit
'===================================
' COMBAT BANK

b1:
GOSUB sonar_grab
SPEED 10
GOSUB standard_pose
GOTO main_exit
b2:
GOSUB map_right_attack
SPEED 10
GOSUB standard_pose
GOTO main_exit
b3:
GOSUB martial_arts_pose
DELAY 500
GOSUB standard_pose
GOTO main_exit

'<snip> That's all folks.


oh - to add a new move, say called 'hug' on key 9 in the cute_bank you need to do the following three things:-

1/ change the routine called when you hit key 9 in cute bank from k9 to a9, like so:

cute_bank:
ON A GOTO MAIN,a1,a2,a3,a4,a5,a6,K7,K8,a9,K10,K11,K12,K13,K14,K15,K16,K17,K18,K19,K20,K21,K22,K23,K24,K25,K26,K27,K28,K29,K30,K31,K32
GOTO MAIN

2/ add some code with label a9 to call your routine


a9:
GOSUB hug
SPEED 10
GOSUB standard_pose
GOTO main_exit

3/ implement your new code

hug:
'do something interesting.
RETURN


That should improve things for you :-)

Also, if you get tempted to make the bank_select tunes longer (the ones that play when you hit E,F,G), you might find RN-1 falls over. It would seem that the motors are relaxed whilst he is whistling, so my attempt at a (unfortunately high-pitched) recreation of an 8 note jaws theme for the combat section just meant he fell over whilst waiting for the tune to finish! F

Cheers
Tim
Hi Visuvius

Glad to be of help ;-)

I suspect your latest problem is that when you push a key that falls outside the range of the valid options in the on .. goto statement for the bank you are in, it will cause the code to find its way back to MAIN: and you have to start over.

You can avoid all that by implementing the following approach where the bank select keys are just like any other 'move', except that they change the context (i.e. the bank). That context is picked up every time you process a move key. You'll see that I've kept the default behaviour for all banks except for the first say 2 - 6 moves where I have new code. This means the favourites like walk forward/backward cartwheel/tumble etc are always available if you so wish (not that this is a new feature), also note that you have to keep the K18,K23,K32 the same in each bank's on_goto so that you can change the bank! This is just what I blatted down after reading this thread so nothing exactly new here . . . .

'<snip>

DIM BANKSEL AS BYTE 'Used for code banking
'E key => BANKSEL = 0 => default routines
'F key => BANKSEL = 1 => dance and routines
'G key => BANKSEL = 2 => combat and sonar routines

'<snip>

GOSUB standard_pose
GOSUB gyro_setup
BANKSEL = 0 ' default bank

MAIN:
'GOSUB robot_voltage
GOSUB robot_tilt

'-----------------------------
IF RR = 0 THEN GOTO MAIN1

ON RR GOTO MAIN,K1,K2,K3,K4,K5,K6,K7,K8,K9,K10,K11,K12,K13,K14,K15,K16,K17,K18,K19,K20,K21,K22,K23,K24,K25,K26,K27,K28,K29,K30,K31,K32
GOTO main_exit
'-----------------------------
MAIN1: 'this is the remote control section
A = REMOCON(1)
A = A - ID

IF BANKSEL > 2 THEN BANKSEL = 2 'only three banks at the minute

ON BANKSEL GOTO default_bank, cute_bank, combat_bank

default_bank:
ON A GOTO MAIN,K1,K2,K3,K4,K5,K6,K7,K8,K9,K10,K11,K12,K13,K14,K15,K16,K17,K18,K19,K20,K21,K22,K23,K24,K25,K26,K27,K28,K29,K30,K31,K32
GOTO MAIN

cute_bank:
ON A GOTO MAIN,a1,a2,a3,a4,a5,a6,K7,K8,K9,K10,K11,K12,K13,K14,K15,K16,K17,K18,K19,K20,K21,K22,K23,K24,K25,K26,K27,K28,K29,K30,K31,K32
GOTO MAIN

combat_bank:
ON A GOTO MAIN,b1,b2,b3,K4,K5,K6,K7,K8,K9,K10,K11,K12,K13,K14,K15,K16,K17,K18,K19,K20,K21,K22,K23,K24,K25,K26,K27,K28,K29,K30,K31,K32
GOTO MAIN

'<snip>

k18: ' E
TEMPO 230
MUSIC "CDE"
BANKSEL = 0
GOTO main_exit

'<snip>

k23: ' G (not F!)
TEMPO 230
MUSIC "EF"
BANKSEL = 2 ' combat_bank
GOTO main_exit

'<snip>

k32: ' F
TEMPO 230
MUSIC "CCFC"
BANKSEL = 1 ' cute bank
GOTO main_exit


'==================================
' CUTE BANK

a1:
GOSUB butt_scratch
SPEED 10
GOSUB standard_pose
GOTO main_exit

a2:
GOSUB ymca
SPEED 10
GOSUB standard_pose
GOTO main_exit

a3:
GOSUB tip_toes
SPEED 10
GOSUB standard_pose
GOTO main_exit

a4:
GOSUB led_toggle
SPEED 10
GOSUB standard_pose
GOTO main_exit

a5:
GOSUB led_toggle2
SPEED 10
GOSUB standard_pose
GOTO main_exit

a6:
GOSUB govenor
SPEED 10
GOSUB standard_pose
GOTO main_exit
'===================================
' COMBAT BANK

b1:
GOSUB sonar_grab
SPEED 10
GOSUB standard_pose
GOTO main_exit
b2:
GOSUB map_right_attack
SPEED 10
GOSUB standard_pose
GOTO main_exit
b3:
GOSUB martial_arts_pose
DELAY 500
GOSUB standard_pose
GOTO main_exit

'<snip> That's all folks.


oh - to add a new move, say called 'hug' on key 9 in the cute_bank you need to do the following three things:-

1/ change the routine called when you hit key 9 in cute bank from k9 to a9, like so:

cute_bank:
ON A GOTO MAIN,a1,a2,a3,a4,a5,a6,K7,K8,a9,K10,K11,K12,K13,K14,K15,K16,K17,K18,K19,K20,K21,K22,K23,K24,K25,K26,K27,K28,K29,K30,K31,K32
GOTO MAIN

2/ add some code with label a9 to call your routine


a9:
GOSUB hug
SPEED 10
GOSUB standard_pose
GOTO main_exit

3/ implement your new code

hug:
'do something interesting.
RETURN


That should improve things for you :-)

Also, if you get tempted to make the bank_select tunes longer (the ones that play when you hit E,F,G), you might find RN-1 falls over. It would seem that the motors are relaxed whilst he is whistling, so my attempt at a (unfortunately high-pitched) recreation of an 8 note jaws theme for the combat section just meant he fell over whilst waiting for the tune to finish! F

Cheers
Tim
Tim
Robot Builder
Robot Builder
Posts: 22
Joined: Sun Jan 06, 2008 8:03 am
Location: Glasgow

Post by grisuzone » Sun Mar 16, 2008 10:24 pm

Post by grisuzone
Sun Mar 16, 2008 10:24 pm

Am there Novelty?
Have you optimized the code for remocon?
You can post him/it thanks from all the NewByes
Am there Novelty?
Have you optimized the code for remocon?
You can post him/it thanks from all the NewByes
grisuzone
Savvy Roboteer
Savvy Roboteer
Posts: 27
Joined: Sat Feb 16, 2008 5:03 pm

Post by LOtrobot » Fri Jan 16, 2009 4:01 am

Post by LOtrobot
Fri Jan 16, 2009 4:01 am

Hi guys, I would like to incorporate your codes into my Remote so that it has additional banks. Which part of the codes do I copy and paste onto the robo basic template? I am completely noob about programming so need some guide on this. Thanks.
Hi guys, I would like to incorporate your codes into my Remote so that it has additional banks. Which part of the codes do I copy and paste onto the robo basic template? I am completely noob about programming so need some guide on this. Thanks.
LOtrobot
Robot Builder
Robot Builder
Posts: 8
Joined: Mon Jan 12, 2009 4:01 am

Previous
19 postsPage 2 of 21, 2
19 postsPage 2 of 21, 2