PICAXE servo command


Closed Thread
Results 1 to 4 of 4
  1. #1

    Question PICAXE servo command

    Hello,

    I do a lot of work with servo's and I am coming up against a wall with synchronizing them. I usually do the following:

    portb.0 = 1
    pauseus (servo1 * 4) + 960 ; scaling factor to give me 2.0ms full scale.
    portb.0 = 0

    If I repeat the above 4 or more times I am going to see the signals staggered in time. 1ms at the least and 2ms at the most between each routine. The picaxe seems to be able to start all servo's at once and update on the fly each servo (8 servos). Has anyone tried to do this?

    I am thinking about using a 20ms interrupt to seed ADC values, synchronously start low to high output on 8 pins and decrement variables in main. Like the following:


    intMe: ; interrupt every 20ms
    asm
    portb = 1
    load ADC0 into counter 1
    load ADC1 into counter 2
    etc
    etc

    return from interrupt

    end asm




    Main:

    if servo1 > 0 then
    servo1 = servo1 - 1
    else
    portb.0 = 0
    endif

    if servo2 > 0 then
    servo2 = servo2 - 1
    else
    portb.1 = 0
    endif

    etc
    servo3 ~ servo8

    pauseus 100
    goto main

    Is there a better way of doing the above mentioned? I can't shake the feeling that it seems too brute force and there should be a more elegant way of doing this.

    Nick

  2. #2
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: PICAXE servo command

    I'm certainly no expert with servos, but can't Darrel's SSPWM do this?
    Charles Linquist

  3. #3
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Default Re: PICAXE servo command

    Hi,

    The common trick is to use a free running timer and the " interrupt on match " feature of a CCP module ...

    you "launch" all the servos signals together and reset relative output when CCP detects their duration reached ...

    Much Better done in assembly than Basic , for the interrupt stubb ...

    Alain

    BTW : Picaxe ??? Does that thing really exist ???
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  4. #4
    Join Date
    May 2007
    Posts
    604


    Did you find this post helpful? Yes | No

    Default Re: PICAXE servo command

    Quote Originally Posted by Acetronics View Post
    Hi,

    BTW : Picaxe ??? Does that thing really exist ???
    Not only do they exist but doing well with worldwide distribution http://www.picaxe.com/Distributors
    Why pay for overpriced toys when you can have
    professional grade tools for FREE!!!

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts