Loading ...
Sorry, an error occurred while loading the content.

1026Re: [ScorbotUserGroup] Re: Arduino Control of Scorbot

Expand Messages
  • Keith Mc
    Jan 4, 2014
    • 0 Attachment
      Walker Archer {warcher1@...} wrote:
      > I see what you're saying now.
      > I very much underestimated the number of ports I'm going to need.
      > The L298N board needs one PWM {bit} for the enable pin and
      > two digital {bits} for the input pins.
      > So 3 {bits} per motor... a total of 15 ports just for the motors.
      > That almost leaves nothing left to read the limit switches and encoders.
      > I'll have to build this with a Mega.

      Actually, if you are building your own shields for the L298 interface,
      you can get away with a LOT less pins than (N*3) for N motors.
      (Summary - It will become "N+3", which I will describe momentarily...)

      On a L298, there are two full H-bridges. For each one:
      - The "In1" pin determines which way the "left side" of the bridge pulls (1=up, 0=down).
      - Similarly, the "In2" pin controls the "right side" of the bridge (up or down)
      For any motor straddling the two halves, the combination of the
      In1 and In2 pins either set a direction to run, or a "brake" mode.
      - Each of the two ENABLE leads is logically ANDed to all four
      MOSFETS on one bridge. Once the direction/mode is set, it
      is then used for On, Off, or PWM speed control.

      So... Instead of using lots of I/O leads, you can shift the
      data for an ARBITRARY number of In1 and In2 sets by
      simply using one of more SIPO shift registers (with an
      output latch) tied in series. You then tie the In1 and In2
      lines from each H-bridge to the various outputs along
      the shift register chain.

      The entire "direction/mode" chain is now controlled by
      just 3 bits of output on the micro -- DATA, SHIFT, and LOAD.
      (The motor ENABLE lines are still controlled by individual
      output bits, as before.)

      To use it: create a subroutine to pack up all of the
      directional "mode" data for all motors into a long word,
      and shift it out serially through the register chain
      with DATA and SHIFT.
      Once everything is sent, you hit LOAD to present
      the entire data set to the various L298s "as an Update".
      This sets the current direction (or "brake") mode for each motor.

      You now run the various Enables with either 0=stop, 1=full_on,
      or pulse each one with the PWM for that partial motor's speed.

      Whenever you wish to change any one of the motor's directions,
      you clock a new set of direction data through the registers again,
      and hit LOAD, as before to save and present it to the L298s.

      Note that this entire write ritual is done by calling an "update"
      subroutine, which is written ONCE.

      NOW... Instead of needing (N*3) bits to control N motors,
      it only require (N+3) bits, and you get exactly the same
      full behavior control as before. That's a LARGE savings
      in micro outputs bits, for a couple of bucks in chips!

      ...BTW, given a fast enough micro (and a bit more external
      logic), there are similar tricks for saving leads on multiple encoders.

      Taken together, you may be able to reduce the needed I/O
      bits enough to port this to a much smaller I/O micro version.

      Does this make sense, or will I need to present a link
      to a schematic somewhere?

      - Keith Mc.
    • Show all 27 messages in this topic