A few simple questions on programming servos!

Translate This Thread From English to

Threaded View
Hello, I'm working on a pole climbing robot
(http://img.photobucket.com/albums/v412/Stompy1/climbrobotclimb.jpg )
for my individual project at Uni, and its come to the stage where I
must programme it! This, I am not very good at, but I am making some
progress. I'm programming in BASIC for a PICAXE microcontroller, if
this helps.

I'm at the stage where I can tell a servo to move to a specific
postion, I've also been fiddling with microswitches, so a press of the
switch causes the servo to do some stuff:

      symbol RARM = 2

      main: if pin3 = 0 then loop
                goto main

      loop: servo RARM,75
          pause 1000
          servo RARM,220
          pause 1000
          if pin3 = 1 then main
          goto loop

(Its a little over-complicated, but only because I'm using it to
investigate how it works.)

The two things I would like to know are as follows:

1) How do I programme the servo to move more slowly?
2) I want a microswitch to - when depressed - interrupt the servo's
movement, regardless of its position (i.e: on my robot, a microswitch
has been mounted at the limit of its arm's gaits. The arm reaches the
limit, the microswitch is depressed, which means the servo must go back
again.


Many Thanks,

James


Re: A few simple questions on programming servos!

      symbol RARM = 2


start = 75
stop = 220
DELAY = speed to move servo


      main: if pin3 = 0 then loop  ;if button = pressed, then move
servo
              goto main                    ;otherwise wait for button
press


      loop:

              for i = 1 to 100
              servo RARM,start
              if pin3 = 0 then main
              pause DELAY
              next i

              for i = 1 to 100
              servo RARM,stop
              if pin3 = 0 then main
              pause DELAY
              next i

              if pin3 = 1 then main
              goto loop





You need to read about the
              servo RARM,stop   command for your
CPU..  How long does the signal get sent after
you give the command?

You might have to use another command if
you want to slow the servo down.

R


Re: A few simple questions on programming servos!



I assume you are using standard R/C servos.  They are controlled by pulse
widths which basically tell the servo which position to go to - and they
gother as quickly as they can given the power suply.  the make them move
slowly, you'd have to know where they already are and then slowly ramp up
[or sdown] the pulse width to get where you want to be.

For this type of thing, it _might_ be better to miodify your ervos so you
can adjust the resistance in the potentiometer that it uses to 'sense' its
position.  Thus, you wouild provide a fixed pulse width signal to the servo,
but you would bypass the internal pot and  use some type of digital pot to
fool the servo.  This would also allow you to calibrate the servo position
with the pot value and you could change it very slowly to get the behavior
you need.

You'd still probably wnat your limit switches so you can verify where the
servos are.

Good luck.

Jim

PS I wish they had such fun projects when I was in school...






Re: A few simple questions on programming servos!

Thanks to both of you, you've been very helpful!

On a slightly different note, every example I've seen have had servos'
extents at 75 and 225, with 150 in the middle. For one of my servos, at
least it seems the limits are around 40 and 180? Is it unusual for
this, or am I just being an idiot?!

Also, one of my servos seems to be struggling, moving slower, not
moving the full distance and making a loud buzzing noise when powered.
Is the the sign of a knackered servo, or what?!

Many thanks,

James


Re: A few simple questions on programming servos!


All servos are different...  That isn't unusual.

the buzzing struggler sounds like it may be knackered.  :-)

Rich


Re: A few simple questions on programming servos!


The "180" (I assume 1800 usec or 1.8 milliseconds) is below spec for any
servo, so this one is bad. Anything under 1.0 milliseconds, or over 2.0
milliseconds, is extended range that is not part of the standard spec.
If your servo handles it great, but if not, you can't complain to the
manufacturer because they don't promise a larger range. However 1.8
milliseconds is under range, so I'd consider this one defective.

Is the buzzing servo also the one that only goes to 1.8 milliseconds?
Makes sense if they are one in the same.

-- Gordon

Re: A few simple questions on programming servos!

could you tell me how a specific programming language(like Basic)
control machines, i m abit new to this field
                   thanks


Re: A few simple questions on programming servos!


There are devices (eg. motors), and controlers (electronic circuits
driving (electrically) the devices), and interfaces (electronic
circuits allowing the communication between the processor and the
controlers).

The interfaces are usually seen from the processors as a set of memory
locations:  controler registers can be read and/or written as if they
where normal memory.  

Therefore processor can send commands and parameters to the controlers
by writing to some memory location, and can get status information by
reading from some memory location.


In a programming language like BASIC, this translates to the PEEK and
POKE instructions.


In a programming language like C, you'd just define a pointer to these
memory locations:

volatile unsigned char* controler_register=(unsigned char*)0x40000001;
/* assuming for example that 0x40000001 is the address of the memory
   location where the controler register is mapped */
(*controler_register)=0xff; /* send a byte to the controler */

On some processors, the interfaces are seen as "ports", that is, some
memory locations in a special plane, accessed with special processor
instructions (eg. INP and OUT).  Then instead of accessing directly
the controler register with a pointer variable, we must use a little
assembler function, like PEEK and POKE in BASIC.

--
__Pascal Bourguignon__                     http://www.informatimago.com/

Pour moi, la grande question n'a jamais été: «Qui suis-je? Où vais-je?»
comme l'a formulé si adroitement notre ami Pascal, mais plutôt:
«Comment vais-je m'en tirer?» -- Jean Yanne

Site Timeline