Wednesday, November 2, 2011

Pythagoras: Moving the Steppers

How do I move the steppers now? I can no longer simply send a position, like in version one. Something else will have to be cooked up.

After much thought...

I decided on a method quite similar to how version one was controlled in that incremental sense. However, I will have to extend the "moving in increments" to the motors too. In a nutshell, the manipulator moves a small increment forward along the path. Through inverse kinematics, I then get a set of new arm angles. Given the current angles of the arm, I then calculate the number of stepper steps it will take for all the arms to reach the new angles. I then distribute the steps for all of the arms so that they all finish at the same time, providing a good enough approximation for straight line travel. Confusing, isn't it?

Example time!

Given the arms angles are all at zero degrees. The step size is five degrees. Every program cycle, an arm either steps or doesn't step.

Then, the manipulator moves. The requested arm angles are 10, 20, and 30 degrees for arms one, two, and three, respectively. This means it will take the steppers at least six steps to meet the requested arm angles (30 degrees difference, 5 degrees step, 30 / 5 = 6 steps). So this means each cycle, arm one moves 1.67 degrees, arm two 3.33 degrees, and arm three 5 degrees. But arms one and two move less than one stepper step size each cycle. What do?

We create an auxiliary set of arm angles. They represent the ideal positions of the arms, following the increments of the step even if they are less than a step size.

At the end of program cycle one, we have:
  • Ideal:  Motor 1: 1.67 Motor 2: 3.33 Motor 3: 5
  • Actual: Motor 1: 0    Motor 2: 0    Motor 3: 0
The difference for motor three is greater than or equal to one stepper step size, so it takes a step, its actual angle updates to 5. Continuing, the pattern,
  • Ideal:  Motor 1: 3.33 Motor 2: 6.66 Motor 3: 10
  • Actual: Motor 1: 0    Motor 2: 0    Motor 3: 5

Updates to:
  • Ideal:  Motor 1: 3.33 Motor 2: 6.66 Motor 3: 10
  • Actual: Motor 1: 0    Motor 2: 5    Motor 3: 10
Fast forwarding:  
  • Ideal:  Motor 1: 5.00 Motor 2: 10   Motor 3: 15
  • Actual: Motor 1: 5    Motor 2: 10   Motor 3: 15

  • Ideal:  Motor 1: 6.16 Motor 2: 13.3 Motor 3: 20
  • Actual: Motor 1: 5    Motor 2: 10   Motor 3: 20

  • Ideal:  Motor 1: 8.33 Motor 2: 16.6 Motor 3: 25
  • Actual: Motor 1: 5    Motor 2: 15   Motor 3: 25

  • Ideal:  Motor 1: 10.0 Motor 2: 20.0 Motor 3: 30
  • Actual: Motor 1: 10   Motor 2: 20   Motor 3: 30

As you can see, all the motors reach their targets at the same time! However, how do you control motor speed then? The same as in version one, by using small increments of the manipulator. Since the algorithm is set to "consumes" at least one cycle, even if no stepper moves, by having very small increments the algorithm spends most of its time moving the manipulator and not much time moving the steppers.

Just the nasty details of actually implementing it. Its a good thing I already did it. Of course, the obligatory video:

The steppers here are moving slowly at 1/2 microstepping, so they are quite loud. But it is a good demonstration of the capability for different speeds, as well as a proof of concept.

There is one problem

Lack of experience with analog signals has come to get me. Noise is all over the place in the feedback from the potentiometers, so much that the manipulator home position differs by an inch between resets. That's not very good precision there. Coming up is the solution. Hint: Twisted wires, op-amp buffers, analog low pass filters supplementing hardcore digital filters.