Shop OBEX P1 Docs P2 Docs Learn Events
Golf Challenge: Controlling 2 servos with one pin - Page 2 — Parallax Forums

Golf Challenge: Controlling 2 servos with one pin

2»

Comments

  • ercoerco Posts: 20,256
    edited 2013-01-10 17:06
    You magnificent FIEND!
  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2013-01-10 18:34
    I would go with a cheap chip: 74HC164. Add a diode, resistor, and a cap, and you can drive 8 servos from one I/O pin.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-01-10 19:00
    I would go with a cheap chip: 74HC164. Add a diode, resistor, and a cap, and you can drive 8 servos from one I/O pin.
    Schematic and code, or it didn't happen. :)

    -Phil
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-01-10 19:10
    Continuing the "practicum," here's the scope output from the code in post #31 driving the circuit in post #29 (using 2x NEC2501, 2x 1K input divider, and 510R pull-downs on the outputs):

    attachment.php?attachmentid=98580&d=1357873819

    -Phil
    640 x 480 - 15K
  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2013-01-10 20:38
    I would go with a cheap chip: 74HC164. Add a diode, resistor, and a cap, and you can drive 8 servos from one I/O pin.
    Schematic and code, or it didn't happen. :)

    -Phil
    {{
                 ┌───────────────────────┐
      3.3v ┬─┬─┐│__                   Q0├─
              └┤MR                   Q1├─
         ┌─┻─┻─┳┤DSA      74HC164     Q2├─
         └─┐  └┤DSB                  Q3├─
    PIN ────┻───┤CP                   Q4├─
                 │                     Q5├─
                 │                     Q6├─
                 │                     Q7├─
                 └───────────────────────┘
    
            C = 0.01µF
      vert. R = 270KΩ
     horiz. R = 10KΩ
    }}
    
    CON
      PIN = 0
    
    PUB SetServos(s1, s2, s3, s4, s5, s6, s7, s8) | tmp
    {{ Parameters are times in uSec }}
      OUTA[PIN]~
      DIRA[PIN]~~
    
      s1 #>= 500
      s2 #>= 500
      s3 #>= 500
      s4 #>= 500
      s5 #>= 500
      s6 #>= 500
      s7 #>= 500
      s8 #>= 500
      s1 #<= 2200
      s2 #<= 2200
      s3 #<= 2200
      s4 #<= 2200
      s5 #<= 2200
      s6 #<= 2200
      s7 #<= 2200
      s8 #<= 2200
    
      tmp := clkfreq / 1_000_000 ' Microsecond
      s1 *= tmp
      s2 *= tmp
      s3 *= tmp
      s4 *= tmp
      s5 *= tmp
      s6 *= tmp
      s7 *= tmp
      s8 *= tmp
    
      tmp = cnt+(clkfreq/200) ' 5 milliseconds to charge up the cap and allow a logic high into the serial input.
      OUTA[PIN]~~
      waitcnt(tmp)
      OUTA[PIN]~
      tmp = cnt+s1
      OUTA[PIN]~~ ' Load the first bit into the register, and begin timing for first servo
      waitcnt(tmp)
      OUTA[PIN]~
      tmp = cnt+s2
      OUTA[PIN]~~ ' Begin timing for second servo
      waitcnt(tmp)
      OUTA[PIN]~
      tmp = cnt+s3
      OUTA[PIN]~~ ' Begin timing for ...
      waitcnt(tmp)
      OUTA[PIN]~
      tmp = cnt+s4
      OUTA[PIN]~~ ' Begin timing for ...
      waitcnt(tmp)
      OUTA[PIN]~
      tmp = cnt+s5
      OUTA[PIN]~~ ' Begin timing for ...
      waitcnt(tmp)
      OUTA[PIN]~
      tmp = cnt+s6
      OUTA[PIN]~~ ' Begin timing for ...
      waitcnt(tmp)
      OUTA[PIN]~
      tmp = cnt+s7
      OUTA[PIN]~~ ' Begin timing for ...
      waitcnt(tmp)
      OUTA[PIN]~
      tmp = cnt+s8
      OUTA[PIN]~~ ' Begin timing for ...
      waitcnt(tmp)
      OUTA[PIN]~
    
  • ercoerco Posts: 20,256
    edited 2013-01-10 21:00
    Hopefully all solutions work on the Stamp as well as the Prop. I listed this challenge in the Picaxe forum to draw off their knowledge base, since the Picaxe is somewhat Stamp-like.

    http://www.picaxeforum.co.uk/showthread.php?22991-Challenge-2-Servos-on-One-Pin
  • prof_brainoprof_braino Posts: 4,313
    edited 2013-01-11 06:23
    Here is the Challenge:
    Using only 1 pin and a Basic Stamp or Propeller, the object is to control two servo's using as few parts as possible.
    This circuit can drive 2 analog servos independently.
    One assumes the 1mS to 2mS PWM pulses are sequentially generated in software.
    1. The lower servo is pulled high directly by the Prop Pin for the required PWM time. Then the Pin is set to input.
    2. The upper servo is pulled high when the Prop Pin is pulled LOW for the required PWM time. Then the Pin is set to input.
    tonyp12 wrote: »
    Is this cheating? 2 parts: one tiny IC and 0.1uf cap

    Total cost of additional parts might play a factor. Is that IC costing less than the transistors and resistors?
  • jmgjmg Posts: 15,173
    edited 2013-01-11 12:53
    Morphing #36, and tristate-port ideas, it can be done in ONE part - a HEF4017 :)

    Connect 4017,Qn to 4017.CLK to Prop IO and then the Prop can self-sync. Less dead time than #36, and no passives.

    Prop Generates a CLK edge (which briefly overdrives the feeble 4017 Qn drive), then tri-states the IO pin to check if Qn is High yet.
    Once it reads-back a Hi, it has sync.
  • ercoerco Posts: 20,256
    edited 2013-01-11 13:44
    Very clever, jmg! Looks like you have time and pins to control 10 servos with that 4017. Great one-part solution. :)

    Is the court (Beau) pleased with this application?
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2013-01-31 10:08
    This is tough...


    Duane C. Johnson's post #9 provided the first schematic and a descrete 4 component solution.

    jmg's #2 post suggested using a PUMD9 part number (referenced in post #28), but still no schematic. The PUMD9 from this location...
    www.nxp.com/documents/data_sheet/PEMD9_PUMD9.pdf
    ...has a descrete component count of 6 and as he said still would require an inverter for one of the servo channels.

    Phil Pilgrim (PhiPi)'s post #29 although technically I said no IC's other than the processor, this soluition would require 6 descrete componets, but offers wider voltage operating range and a cleaner output signal

    ...And since the rules weren't stated clearly on an IC counting as a single component, jmg pulls it off with using a single 4017 decade/divider IC.


    Note: I have not had a chance to test the solutions here, but I will leave that to the scrutiny of our peers.

    So, with that in mind, the Winners are:

    Duane C. Johnson
    jmg
    Phil Pilgrim (PhiPi)


    Thanks for playing!!!
  • ercoerco Posts: 20,256
    edited 2013-01-31 13:25
    XLNT! Great challenge, congrats to the winners.

    jmg inspired me to order some 4017s, but I haven't had time to try them out.

    I had an offbeat relay/plywood level concept using a center-tapped transformer which, coupled with two diodes, would yield two different pulses, but I needed an isolation transformer and $50 was too rich for my blood.
Sign In or Register to comment.