Shop OBEX P1 Docs P2 Docs Learn Events
Control servos through shift register — Parallax Forums

Control servos through shift register

kevinb2050kevinb2050 Posts: 56
edited 2008-08-14 08:24 in BASIC Stamp
I have a BS2e controlling a 74HC595 shift register (ran out of output pins) I need to control 6 servos conected to the 74HC595 and control their possition over the 180deg movement any code ideas would be appreciated

Comments

  • metron9metron9 Posts: 1,100
    edited 2008-08-14 04:04
    First you need to calculate the speed of the processors code, communication with the shift register (74hc595) to see if it is possible to turn on and off one bit for the required shortest period of time. then you have to do that for seven pins every 20 mS with some time left over to process your sensors and calculate values of the new data.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think Inside the box first and if that doesn't work..
    Re-arrange what's inside the box then...
    Think outside the BOX!
  • kevinb2050kevinb2050 Posts: 56
    edited 2008-08-14 04:11
    Thanks - is this a recomended way of increasing IO (outputs) for servos or is this just for Leds etc is their a better way to increase outputs for servo use
  • Mike GreenMike Green Posts: 23,101
    edited 2008-08-14 04:31
    For servos, because of their continuing requirement for control pulses (every 20ms), it's better to offload the timing. The Parallax Servo Controller is kind of overkill with its ability to control up to 16 servos, but it's a nice unit ($40). Other choices are nearly as expensive. The ServoPAL is $10 per servo ... expensive for 6 servos.

    It's not that you can't do the control with the BS2e, but you're starting to very much complicate your BS2e programming to feed a bunch of servos with time sensitive repeated control pulses. By offloading the timing, you will be freeing up the BS2e to do decision making while the servo controller will continue to keep the servos going and can even do some ramping (positioning over a fixed interval) independently.

    Post Edited (Mike Green) : 8/14/2008 4:37:37 AM GMT
  • kevinb2050kevinb2050 Posts: 56
    edited 2008-08-14 04:45
    Thanks Mike - that was what I thought I would have to do - have ordered the servo controller today - a bit more expensive here in Australia
    PS- what about using shift registers with inputs ? does this become a timing issue as well say if you had IR sensors or ping sensors .
  • Mike GreenMike Green Posts: 23,101
    edited 2008-08-14 05:12
    Using external shift registers (or any external I/O expander) takes extra time. In the case of the 74HC595 for output or the 74HC165 for input, you can latch the outputs or the inputs all at once. For outputs, they would all change at the same time. For inputs, you'd sample them all at the same time. You can then output the next setting or read the samples "at your leasure". With the BS2e, that's about 1000 to 2000 8-bit samples a second which is plenty fast for most things like switches or LEDs, but maybe too slow for IR sensors or PING sensors or servos with good resolution.
  • kevinb2050kevinb2050 Posts: 56
    edited 2008-08-14 05:21
    Thanks Again Mike
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-08-14 07:42
    If you wanted to do this with a logic chip and if you had enough extra processing time to keep that many servos in pulses (which, as Mike correctly points out, is unlikely), a better choice than a 74HC595 would be a 74HC237 3-to-8-line demultiplexer. With this, you could theoretically control eight servos with four control lines. Three lines (A0, A1, A2) would be used to address the servo getting the next pulse, and one line (OE0) would be used to send the pulse.

    -Phil

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Still some PropSTICK Kit bare PCBs left!
  • kevinb2050kevinb2050 Posts: 56
    edited 2008-08-14 08:24
    Thanks Phil for the idea - I have some concern over timing so will go with the Parallax Servo Controller
Sign In or Register to comment.