Shop OBEX P1 Docs P2 Docs Learn Events
Ref: constrolling servos: — Parallax Forums

Ref: constrolling servos:

nomadnomad Posts: 276
edited 2007-07-03 16:26 in Propeller 1
Ref: constrolling servos:

hi
i have a problem with the control of servos.
as attachment:
1) legServoTest13.spin
2) Servo32_Demo2.spin

the problem with code no 1:
the movement of the servos are verry shacking
but maximal direction is verry good, (+60 degrees / -60 degrees)

here i think its problem with:

pulsetime1 += (clkfreq / 100_000)
pulsetime4 -= (clkfreq / 100_000)


the problem is with code no 2:
the maximal movement of a servo is only (+45 degrees / -45 degrees)
but the movement of the servos are verry smooth.

i look for suggestion of both worlds:
- smooths movements
- big maximal-direction-movements (+60 deg / -60 deg)

have anybody a suggestions for this problem?
thanks for your helps
regards
nomad

Comments

  • Beau SchwabeBeau Schwabe Posts: 6,560
    edited 2007-07-02 04:07
    nomad,

    In answer to number 2,· you will need to look at the servo32.spin file... In the section of code that reads...
    PUB Set(Pin, Width)                                                             'Set Servo value
          Width := 1000 #> Width <# 2000                                            'limit Width value between 1000uS and 2000uS
            Pin :=    0 #>   Pin <# 31                                              'limit Pin value between 0 and 31
          ServoData[noparse][[/noparse]Pin] := clkfreq / _1uS * Width                                  'calculate # of clocks for a specific Pulse Width
          dira[noparse][[/noparse]Pin] := 1                                                            'set selected servo pin as an OUTPUT
          ServoPinDirection := dira                                                 'Read I/O state of ALL pins
    


    ...The pulse width is limited to a value between 1000 and 2000 as a standard and for servo safety reasons.· (<--If you go to far outside the range that a standard servo was designed for, you can damage your servo.)· You will need to find the specs for the particular servo that you are using and manually make the adjustments in the section above.· I will test to see what the width limitation is and update this post with the information, but I think you can comfortably set the Width up to 3500 without a problem... On the low end you can go down to Zero, but that would be pointless.· I will check and let you know what the·maximum range is for this object.

    Update Edit:

    A single loop of each Servo Zone requires about 428 clocks (worst case)... A processor running at 80 MHz·would require 5350 nano seconds (12.5nS x 428 = 5350nS) or 5.35uS (micro Seconds).
    So the maximum value for the Pulse Width would be the value for ZonePeriod (default = 5000) minus the 5.35uS or 4994 would·be the maximum value·... you might be able to go higher until you reach a value equal to ZonePeriod (default = 5000) , but what starts to happen is that you will affect adjacent servo channels.· The difference of 6uS is simply software overhead required to update the servo's correctly.


    ·

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.

    Post Edited (Beau Schwabe (Parallax)) : 7/2/2007 6:08:08 AM GMT
  • nomadnomad Posts: 276
    edited 2007-07-02 07:21
    hi beau,
    thanks for your help
    today, (monday) i make the tests
    regards
    nomad
  • nomadnomad Posts: 276
    edited 2007-07-02 11:10
    hi beau,
    thanks for the help
    with some changes in my code
    i can control 2 legs with 6servos with a 6PushButton-Board
    the servos run verry smoothly.
    as attachment my new code
    and a drawing of a leg
    regards
    nomad
  • RinksCustomsRinksCustoms Posts: 531
    edited 2007-07-02 13:30
    nice work with the code/documentation! Kudos. It is a very good example of what a program should look like on the inside.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Definetly a E3 (Electronics Engineer Extrodinare!)
    "I laugh in the face of imposible,... not because i know it all, ... but because I don't know well enough!"
  • edited 2007-07-03 03:57
    Hi Nomad.. I see you are working on a Lynxmotion + Propeller Pod, I am really glad to see another fellow forum member working on this robotic plattform...!! smile.gif

    I see that on your code, under "Contributions:" you mentioned my original posted code "Lynxmotion Extreme Hepapod III Simple Walking Routine using Servo32.Spin Object" since then I worked some more on the code, and I actually added "touch sensors" switches at the tip of the legs, nothing fancy, pretty much a "Poor's Man" take on terrain sensing for the walking hexapod. but the results are quite cool, I posted the idea on how to add the touch sensors to the Lynxmotion Pods (either quadrapods or hexapods) here:

    http://joebotics.googlepages.com/addingsensors

    Since I was running out of precious pins on my Propeller (18 pins are dedicated to the 18 servos on the Hexapod) I decided to expand the ports with a MAX7300 I2C I/O Port Expander, a really cool little IC that comes in DIP package and allows you to control 20 pins as any combination of inputs and outputs, (each pin can individually be configured as either output, input or input with weak pull-up), and I dedicated this IC to the non-glorious task of sensing the state of the switches; each touch sensor goes to a pin on the MAX7300 configured as input with weak pull-up, and the other end of the switch to ground, and when the leg touches the ground, it closes the circuit, and I get a Logic 0 on that sensor, I finished the code that cautiously walks forward, sensing the front legs, and when it reaches the border of the stairs, it pulls back, kind of funny to watch, it behaves like a bug when it reaches the border of a table... I still have to produce a video of the Hexapod in action, I will get it as soon as I can, in the meantime here is the code..... smile.gif

    Well, I guess this thread should be moved to the "Robotics" forum.... smile.gif

    I hope this helps!!.... Happy Roboting!!...

    Post Edited (Joe "Bot" Red) : 7/3/2007 4:09:42 AM GMT
  • nomadnomad Posts: 276
    edited 2007-07-03 06:45
    hi joe,
    thanks for your code.
    but i am working on quad-bot not on a lynxmotion-platform
    it's new constructions with 12 servos with 247Ncm each on 6volt
    weight: ca. 5kg
    your snippets on waitcnt is verry usefull.
    servos running verry smootly.
    Snippets:
    'LEG1
    SERVO.Set(Leg1_ShoulderServo1,temp11)
    waitcnt (5_000 + cnt)
    SERVO.Set(Leg1_ShoulderServo2,temp12)
    waitcnt (2_500 + cnt)
    SERVO.Set(Leg1_KneeServo3,temp13)
    waitcnt (2_500 + cnt)
    thanks for your help
    regards
    nomad
  • nomadnomad Posts: 276
    edited 2007-07-03 16:26
    hi joe and rinks customs,
    re: MAX7300 I2C I/O Port Expander
    My Sensors
    : -> 3 * PingSensors + 1 x IR-Sensor and every Leg have Pressure-Sensor
    for my plattform i would work with 3 propStickUSB-Boards:
    Board No1. == MasterBoard:
    control Board no2 no3, make the math and reading the sensors, and the communications
    Board No2 == control Leg1 & Leg2 (every Servo have a cog (6 cogs)), the rest:
    cog 0 master, cog 2 communications
    Board No3 == control Leg3 & Leg4 and the same stuff as no2.
    i hope so blush.gif

    in the moment i have some troubles with my servos and the batterie.
    the old version
    12volt Bat 3,7Ah to L7806 1.5Ah -> servos 6volt (max under load 700mA)
    but its idiotic ;-[noparse]:)[/noparse]
    tomorow i have a 6Volt Bat with 12Ah direct connection to the servos
    i hope......
    as attachment a little drawing from my idea
    regards
    nomad
    860 x 600 - 51K
Sign In or Register to comment.