Shop OBEX P1 Docs P2 Docs Learn Events
Is shutting down cogs OK when 8 is not enough? — Parallax Forums

Is shutting down cogs OK when 8 is not enough?

My project uses seven cogs. I am using one cog to control four servos. I want to use four DC motors instead of four servos to control a robotic arm. By attaching a pot to a motor I can control it like a servo but I can only control one motor per cog. The problem I have with multiple dc motors is controlling overshoot.
One solution would be to experiment with PASM. The second idea is to control two motors with two cogs at a time. I'm tying up both counters to control motor speed so I'd have to reinitialize the counters each time I switched motors. Is this advisable?
My goal is to scale this thing up so I can make it do useful work.

Comments

  • kwinnkwinn Posts: 8,697
    Not enough info in your post for a definitive answer, but it would depend on how much processing needs to be done for controlling each motor. I would look at the calculations to see if a cog has enough memory for the code and variables needed for the four motors.
  • What sort of resolution and frequency to these motors need?

    There are a variety of PASM PWM drivers for use with multiple motors.

    I'm pretty sure I have a PWM driver which produces four signals from a single cog (I have one which also reads four quadrature encoders with the same cog).

    If you describe your requirements in more detail, I bet we could help you find an appropriate driver.
  • Duane Degn wrote: »
    What sort of resolution and frequency to these motors need?

    There are a variety of PASM PWM drivers for use with multiple motors.

    I'm pretty sure I have a PWM driver which produces four signals from a single cog (I have one which also reads four quadrature encoders with the same cog).

    If you describe your requirements in more detail, I bet we could help you find an appropriate driver.
    The motors don't need much resolution. I'm using Chip's mcp3208 driver and I set it to return 0 to 63. The concept and the code is simple. I rotate a potentiometer and then the motor, which is also connected to a pot, rotates until it matches the value I sent it. It works well. If there's just one motor I can also adjust the pwm duty cycle and avoid problems with the motor overshooting the commanded position.
    This is what it looks like:
    Repeat
          MyPot := ptest.get_temp1       
          MotorPot := ptest.get_temp2         
          If MyPot > MotorPot                    
            main(3000, 0)
          elseif MyPot <  MotorPot                      
            main(0, 3000)
          elseif MyPot ==  MotorPot 
            main(0, 0)
    
    When I tried testing two motors I could see that this approach didn't work.
  • kwinnkwinn Posts: 8,697
    One cog running a PASM version of that simple program using integer math should easily handle 4 motors, particularly if you take advantage of the high speed MCP3208 object.

    If needed it could even be modified to decelerate as the motors approach the desired position.
  • User NameUser Name Posts: 1,451
    edited 2016-11-29 19:37
    lardom wrote: »
    One solution would be to experiment with PASM.
    Can't endorse that highly enough. big-thumbs-up-smiley-emoticon.gif
  • User Name wrote: »
    Can't endorse that highly enough. big-thumbs-up-smiley-emoticon.gif

    I'm just about ready to tackle my first pasm project. The newest thing for me is "flags". I'll start off with small test code.
  • lardom wrote: »
    My project uses seven cogs. I am using one cog to control four servos.

    My goal is to scale this thing up so I can make it do useful work.

    Based on the above statements, if budget will allow it, I would suggest closing the servo-loops with incremental encoders (like real robots). With only one cog available, you might want to consider motion control co-processors via RS485, such as:

    http://www.jrkerr.com/icproducts.html
  • @Mickster, Thanks, I bookmarked the page.
Sign In or Register to comment.