BasicMicroUK - Forums

www.basicmicro.co.uk
It is currently Tue Oct 23, 2018 9:44 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: ARC32 - programming problem
PostPosted: Thu Feb 14, 2013 11:41 pm 
Offline
Guru

Joined: Fri Feb 10, 2012 9:34 pm
Posts: 73
Hi All,
I have modified one of the brat biped programs to understand the "movement" subroutine.

In my code I ask for a delay to be entered and then a command. The code looks like this
Code:
   hserout ["enter delay 4 chars ", 13]
   hserin [str delay\4\13]
;   hserout [ "You entered delay of ", str delay,13]

main
   
   hserout ["Enter a move command ", 13]
   hserin [str cmd\2\13]

   command = cmd
    gosub move
    pause delay
 

goto main


The move referenced above is a long subroutine where it formats and calls the movement subroutine - small snippet here
Code:
move:
     if(command = 1) then                     ; Walk Forward
         hserout ["Forward",13]
         ;Note, movement subroutine arguments are Rightankle,Rightknee,Righthip,Leftankle,Leftknee,Lefthip,speed
         gosub movement [  7.0,-20.0,-20.0, -7.0, 20.0, 20.0, 500.0]
         pause delay
         gosub movement [ -7.0,-20.0,-20.0,  7.0, 20.0, 20.0, 500.0]
                  pause delay
         gosub movement [ -7.0, 20.0, 20.0,  7.0,-20.0,-20.0, 500.0]
                  pause delay
         gosub movement [  7.0, 20.0, 20.0, -7.0,-20.0,-20.0, 500.0]
                  pause delay
      elseif(command = 2)                     ; Walk Backwards
           hserout ["Back",13]
         gosub movement [ -7.0,-20.0,-20.0,  7.0, 20.0, 20.0, 500.0]
                  pause delay
         gosub movement [  7.0,-20.0,-20.0, -7.0, 20.0, 20.0, 500.0]
                  pause delay
         gosub movement [  7.0, 20.0, 20.0, -7.0,-20.0,-20.0, 500.0]
                  pause delay
         gosub movement [ -7.0, 20.0, 20.0,  7.0,-20.0,-20.0, 500.0]
                  pause delay
     elseif(command = 3)                     ; Long Stride Forward


What I am seeing is that the program when executed never even goes in to move!!!!

Any ideas ?

Thanks
Gopal


Top
 Profile  
 
 Post subject: Re: ARC32 - programming problem
PostPosted: Fri Feb 15, 2013 3:59 am 
Offline
Master

Joined: Tue Nov 21, 2006 5:34 pm
Posts: 662
The code:
Code:
   hserout ["Enter a move command ", 13]
   hserin [str cmd\2\13]

Is asking the user to enter a command. Assume you type something like 1<cr>
What will be stored in cmd is the Ascii values for those two characters:
In hex they would be something like: 0x31 0xd

Which will not match any of the command values in the function.
You might try something like:
hserin [dec cmd]
Which will allow you to type in characters and it will convert the ascii characters into a decimal number.

Kurt


Top
 Profile  
 
 Post subject: Re: ARC32 - programming problem
PostPosted: Sat Feb 16, 2013 12:43 am 
Offline
Guru

Joined: Fri Feb 10, 2012 9:34 pm
Posts: 73
Thanks Kurt, that worked! Now to figure out the angles in movement subroutine!
Gopal


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO