Shop OBEX P1 Docs P2 Docs Learn Events
3 servos with 3 cogs (parallel) — Parallax Forums

3 servos with 3 cogs (parallel)

nomadnomad Posts: 276
edited 2007-02-25 14:51 in Propeller 1
hi,
i would develop a quadrobot 3DOF (hardware & software)
for this propose
now i·write some·spin-programs for one leg with 2 button for testing.

the leg are 3 servos and i would that on every servo are working 1 cog.
there, every servo have a different moving-direction and (for the
future) different speeds.

the 2 attachments are:
1) servoLeg1.spin = normal programm with 3 servos and 2 buttons
··· - 1 cog
··· its run verry smooth and fast
2) servoLeg2.spin = my trial with 3 servos·· = cog 1-3
············································ 2 buttons = cog 0
··· its running, but not so smooth and always slower.

have you some improments and tips for me and this program???

thanks for the help
regards
nomad

Comments

  • Graham StablerGraham Stabler Posts: 2,507
    edited 2007-02-24 14:18
    May I ask what a quadrobot is?

    Graham
  • MacGeek117MacGeek117 Posts: 747
    edited 2007-02-24 14:56
    Quadrapod - Walking robot with 4 legs.· See this page: http://www.lynxmotion.com/Category.aspx?CategoryID=34
    RoboGeek

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "I reject your reality and subsitute my own!"

    Adam Savage, Mythbusters
    www.parallax.com
    www.goldmine-elec.com
    www.expresspcb.com
    www.startrek.com
    ·
  • nomadnomad Posts: 276
    edited 2007-02-24 16:16
    hi

    that's right

    regards

    nomad
  • simonlsimonl Posts: 866
    edited 2007-02-24 16:54
    I think the servo32 object (object exchange) will do this without breaking a sweat...?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheers,

    Simon

    BTW: I type as I'm thinking, so please don't take any offense at my writing style smile.gif

    www.norfolkhelicopterclub.co.uk
    You'll always have as many take-offs as landings, the trick is to be sure you can take-off again ;-)
  • BergamotBergamot Posts: 185
    edited 2007-02-24 18:15
    Yeah, I ran 4 servos simultaneously off a single Basic Stamp, so I have a hard time believing that you need an entire cog just to run one.
  • Beau SchwabeBeau Schwabe Posts: 6,548
    edited 2007-02-24 20:12
    nomad,

    Simon is right, "I think the servo32 object (object exchange) will do this without breaking a sweat".

    The servo32 object can handle up to 32 servo's in the background (<-set and forget) using only 1 cog.
    If you need to make a position update simply assign the new value to the appropriate servo. There is no
    overhead maintenance other than when you want to change the servo position.

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

    IC Layout Engineer
    Parallax, Inc.
  • John R.John R. Posts: 1,376
    edited 2007-02-24 21:58
    Beau;

    I think what nomad is working toward (I'm thinking along similar lines myself for different reasons) is to make a "Leg" object that is somewhat "self aware" of how to move the servos to put itself in a given position, or based on timing, execute a walking gate. I don't think he's just after controlling the servos.

    That said, I've got a hexapod (six legs) with 3DOF legs (18 servos) and the Servo32 object works great! I just wish it had raming built in... That's were my "leg" objects will probably come in. I'll have the leg object do the raming, and send the appropriate postion updates to the Servo32 object. (Currently, all the work is being done of the PC side, and leg position commands are send to the Prop, and from there to Servo32.)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    John R.
    Click here to see my Nomad Build Log
  • nomadnomad Posts: 276
    edited 2007-02-25 10:10
    hi John R. and Beau,

    zitate:

    <<

    I think what nomad is working toward (I'm thinking along similar lines
    myself for different reasons) is to make a "Leg" object that is somewhat
    "self aware" of how to move the servos to put itself in a given position,
    or based on timing, execute a walking gate. I don't think he's just after
    controlling the servos.

    >>

    you are right, for me it's difficult to descrip my base-idea. (my bad english)
    for me is a leg a stateMachine.
    for research look rodney brooks at.al (MIT & genghis).

    a statemachine (AFN) have some rules (this rules are dynamical setting from sensors &
    the directives of a pc-program which running one of more artifical neural-nets.

    also. a leg is a masterStateMachine who thinK about his state and communicate with his
    leg-cogs· and the other-leg-cogs (the other 3 legs) and then after thinking he said the
    another cogs what they are doing for one leg.

    it's difficult to programm and to discuss, therefor, every servo is a statemachine
    also every servo is 1 cog!!

    my question is only: are statements of my spin-program correct i.e.
    - cog0 = 2buttons
    - cog1 = servo1
    - cog2 = servo2
    - cog3 = servo3

    !!! every servo can have different moving-directions & speeds

    and how can i program more smooth & speed???

    for any considerations and program-tips i am happy.
    thanks
    regards
    nomad
  • Graham StablerGraham Stabler Posts: 2,507
    edited 2007-02-25 14:36
    You can still use a seperate cog for driving the servos. Think of it as just a pulse generator. Each leg cog just needs to update the servo cog, to the servo cogs makes pulses but the leg cogs make decisions. You may want to make a different servo program than servo32 perhaps it would just take the raw servo pulse times (1-2ms) from the other cogs. That would free the cogs from the pulse timing side of things and allow them to concentrate on decision making.

    Graham
  • nomadnomad Posts: 276
    edited 2007-02-25 14:51
    hi graham,
    thanks for your answer,
    i am looking for (my bad english....)
    its so, the code is only for testing, when i build the hardware of the legs
    (position of the shoulder etc.)
    now my newest code.

    i find, its look better
    cognew() will call only 1 times·for every cog

    have somebody a better solution???
    thanks
    regards
    nomad
    { 
    servoLeg4.spin                                                                 
    ****************************************************************************
    References Schematics & Pins:
              
    Original Pins:
       - p0 is the Button S1 control the pulse +    
       - p1 is the Button S2 control the pulse -
       - p2 is for the servo-Pulse- Servo1 Shoulder (Swing For/Back)  
       - p3 is for the servo-Pulse- Servo2 Shoulder (Swing Up/Down)
       - p4 is for the servo-Pulse- Servo3 Elbow    (Swing Up/Down)
       
         
       - schematics ServoPulse = Px -> 4.7K -> to servoSignal
       - button-circuit: as my servoTestBoard_NEW.jpg 
         s1   pin 1 = gnd      -> 4.7K ->  to board VSS (p29)
              pin 2 = +3.3volt         ->  to board VDD (p32)
              pin 3 = signal           ->  to boardPin  p0
         S2   pin 3 = signal           -> to boardPin  p1
              pin 2 = +3.3volt         -> to board VDD (p32)
              pin 1 = gnd     -> 4.7K  -> to Board VSS (p29)
    
    ********************************************************************************
    }
    
    CON 
      _CLKMODE = RCFAST               
    '  _XINFREQ = 5_000_000          ' Frequency on XIN pin is 5 MHz
    VAR
      long cogStack1[noparse][[/noparse]12]             ' Stack space for new cog1
      long cogStack2[noparse][[/noparse]12]             ' Stack space for new cog2
      long cogStack3[noparse][[/noparse]12]             ' Stack space for new cog3
    VAR  
      long pulsetime1, pulsetime2, pulsetime3
      long periode1, periode2, periode3  
      long new_periode1, new_periode2, new_periode3   
      long timebase
    
    PUB Main
      Init
      cognew(ShoulderServo1,@cogStack1)
      cognew(ShoulderServo2,@cogStack2)
      cognew(ElbowServo3,@cogStack3)
       
      repeat
        ShoulderServo1
        ShoulderServo2
        ElbowServo3 
       
     
    PUB Init
      periode1 := ((clkfreq / 100_000) * 2000)       '  20ms      
      periode2 := ((clkfreq / 100_000) * 2000)       
      periode3 := ((clkfreq / 100_000) * 2000)       
      pulsetime1 := ((clkfreq / 100_000) * 150)      ' 1,5ms  
      pulsetime2 := ((clkfreq / 100_000) * 150)        
      pulsetime3 := ((clkfreq / 100_000) * 150)        
      dira[noparse][[/noparse]0]~    ' Pin1 set input (button s1) 
      dira[noparse][[/noparse]1]~    ' Pin2 set input (button s2)
      
      dira[noparse][[/noparse]2]~~   ' Pin2 set output  Servo1 
      outa[noparse][[/noparse]2]~    ' Pin2 set low
      dira[noparse][[/noparse]3]~~   ' Pin3 set output  Servo2 
      outa[noparse][[/noparse]3]~    ' Pin3 set low
      dira[noparse][[/noparse]4]~~   ' Pin4 set output  Servo3 
      outa[noparse][[/noparse]4]~    ' Pin4 set low
      timebase := cnt 
    
    PUB ShoulderServo1  ' generate servopulse  Servo1                                   
      outa[noparse][[/noparse]2]~~
      waitcnt (timebase += pulsetime1) 
      outa[noparse][[/noparse]2]~
      if ina[noparse][[/noparse]0] == 1                       'if taster pulsetime + 0,1ms 
        pulsetime1 += (clkfreq / 100_000)
      if ina[noparse][[/noparse]1] == 1                       'if taster pulsetime - 0,1ms 
        pulsetime1 -= (clkfreq / 100_000)
           
      new_periode1 := periode1 - pulsetime1    'periodendauer - pulsdauer
            
      waitcnt (timebase += new_periode1)       'wait for periode end
        
          
    PUB ShoulderServo2    ' generate servopulse  Servo2                                   
      outa[noparse][[/noparse]3]~~                                          
      waitcnt (timebase += pulsetime1) 
      outa[noparse][[/noparse]3]~
      if ina[noparse][[/noparse]0] == 1                         
        pulsetime2 += (clkfreq / 100_000)
      if ina[noparse][[/noparse]1] == 1                         
        pulsetime2 -= (clkfreq / 100_000)
            
      new_periode2 := periode2 - pulsetime2 
            
      waitcnt (timebase += new_periode2)    
        
    PUB ElbowServo3   ' generate servopulse  Servo3                                   
      outa[noparse][[/noparse]4]~~                                          
      waitcnt (timebase += pulsetime3) 
      outa[noparse][[/noparse]4]~
      if ina[noparse][[/noparse]0] == 1                         
        pulsetime3 += (clkfreq / 100_000)
      if ina[noparse][[/noparse]1] == 1                         
        pulsetime3 -= (clkfreq / 100_000)
            
      new_periode3 := periode3 - pulsetime3 
            
      waitcnt (timebase += new_periode3)    
          
    
    

    ·
Sign In or Register to comment.