Microstepping with optical feedback

From RepRap
Revision as of 21:01, 11 October 2010 by Fdavies (talk | contribs) (Optical encoder)
Jump to: navigation, search
Crystal Clear action run.png
Microstepping with optical feedback

Release status: unknown

FD microstep04 board front view.JPG
Description
Microstepping with optical feedback
License
unknown
Author
Contributors
Based-on
Categories
CAD Models
External Link


Overview

The idea is to make a module that is a functional substitute for a 400 step stepper motor and a "dumb" stepper driver board. Stepper motors with fewer than 400 steps per rotation are easy to find as surplus equipment, either by themselves, or in old computer printers. Optical encoder strips and quadrature optical encoders are easy to get from junk ink-jet printers. In order to allow retrofitting of existing systems, it is desirable to have a setup that can take the PULSE and DIRECTION command signals usually accepted by stepper motor driver boards. These items can be combined to make high precision motion control setup that is quite useful. (Similar ideas can be applied to DC motors -- see RepRapServo 1 0).

Interface to gcode interpreter

My intent was to make this setup act like a stepper motor driver board, which it does. Because the step signal (PULSE) is being sampled by firmware, I have a simple pulse stretcher circuit that makes the pulses a little longer. I am using reprap-gen3-firmware-2009-08-05 (slightly tweaked) on the Arduino that generates the step and direction pulses. It makes 5 microsecond step pulses. This is a bit fast for my approx 30 KHz interrupt to detect reliably.

Stepper motor

This is a NEMA 17 motor on one axis, and larger cylindrical stepper on the other axis.

Drive Circuit

<schematic> The drive circuit uses a L298. I was pleasantly suprised that I could run it at about 30 KHz, but it seems to be working fine. This is connected directly to the stepper motor in a bipolar configuration. There is no output filtering on this signal, but I have not had EMI problems.

Feedback Loop

This system is a little different from a servo loop with a DC motor. If you put a voltage across the terminals of a DC motor, it revs up to a certain speed and will continue to rotate at that speed while the voltage is present. If you put voltages on the terminals of a stepper motor, it moves to a certain position, and then holds that position. This actually makes things easier. The feedback algorithm has a feedforward term that directly increments (or decrements) the phase when a pulse is received. There is also an integral error term that adds an offset proportional to the difference between where it is and where it is supposed to be (this is added to the phase repeatedly, which is what makes it integrate).

      +---------------------------------------------+
      |                                             |
      V         +---------------------------+       |
 +-----------+  |                           |  +---------+
 |Quadrature |->|XENC +-------+   SINE-->PWM|->|         |
 |encoder    |  |  |  | Feed  |    ^        |  |         |
 +-----------+  |  V  | back  |    |        |  | Stepper |
                |  +->| algor |->PHASE      |  | Motor   |
 +-----------+  |  ^  | ithm  |    |        |  |         |
 |Stepper    |  |  |  +-------+    V        |  |         |
 |COMMAND    |->|COMMAND        COSINE-->PWM|->|         |
 |pulses     |  |        Arduino            |  +---------+
 +-----------+  +---------------------------+

Firmware

See attached file. This is an Arduino type .PDE file and can be compiled with the arduino development software. It does use a custom made interrupt routine, though.

Optical encoder

This is a quadrature optical encoder removed from a inkjet printer. It has built-in signal conditioning which means that it has digital outputs that can go directly to the arduino pins. They are also strong enough to drive a pair of diagnostic LEDs. These let you check the alignment of the optical strip. I use the optical strip from the same printer as the encoder, since the encoder is optimized for a certain stripe spacing.

http://objects.reprap.org/wiki/Optical_encoders_01

Features

This was worth the trouble to make for the following reasons:

1. Stepper motor slips (missed steps) are immediately corrected. This means that I can use a smaller stepper than I would have otherwise been able to. It also means that I don't find an overnight print with a sideways slip in the middle of it.

2. The stepper is a lot quieter. This is because it is being driven with smoothly varying sinewaves, not abrupt square waves.

3. The stepper runs cooler. I am running a unipolar stepper in a bipolar way. This is not a unique advantage of this technique, I know, but it is an improvement in the way that I was doing things before.

Downloads

Photos and Drawings