Skip to Content

Motor Control

Posted in

Motor Control

The time-lapse engine supports control of up to four motors.  Each motor's settings are independant from the other motors, allowing distinct control of the behavior of each axis.

Note: motor movements are made incrementally to ensure proper performance.  That is, any movements needed by motor 0 will be made before motor 1, which will be made before motor 2.  This prevents timing issues during motor move execution that may cause jerkiness or un-reliability of a particular axis' movements.

 

The following controls are provided for each motor:

  • Motor Enable
  • Steps per Move
  • Maximum Steps
  • Linear Ramp Rate (output video speed control)
  • Execute Down Ramp
  • Direction
  • Set Home
  • Go Home
  • Move Steps Now
  • Backlash Compensation

 

Additionally, several settings control motor behavior:

  • Sleep Driver Between Moves
  • Mininum Step Delay
  • Maximum Step Delay
  • Camera Safe Wait

 

Motor Speed Ramping

 

With stepper motors, it is essential that speed (delay between each step request) be generally increased and decreased throughout the movement.  By coming up to speed from a stopped position, and slowing down as you come back to a stop, you not only excersize the torque band of the motor better, you also prevent missed steps and jerky movements.  A stepper motor coming to an abrupt shot may also over-step several steps as the braking torque of the motor is exceeded by the force of the camera or other axes in motion.

For the time-lapse engine, a linear speed ramping during movement is used.  The default rate of the ramp is to utilize the first and last 33% of the total steps to be taken to linearly come up to speed, or down from speed.  These points in the step cycle are called shelfs - the low shelf for bringing up to speed, and the high shelf for coming down from speed.  As the motor's movement approaches the low shelf, the time between steps is decreased linearly until the minimum step delay is reached.  As the motor's movement crosses the high shelf, the delay time is increased until the last step taken is the maximum step delay after the previous step.

Delays, or time between steps, are expressed in micro-seconds (uS).  Obviously, certain movement combinations can result in ramp rates of less than one microsecond, which would result in no change in motor speed.  The engine automatically detects this, and will reduce the shelves by 10% until a delay change rate of at least 1uS is achieved.  See the minimum/maximum step delay information below.

 

Motor Enable

 

The motor enable control allows to turn on or off a given axis during program execution.  You may disable a motor at any time during exection.  If a motor is disabled during program execution, everything about its status is remembered when re-enabled, such as the steps taken so far, where in the linear output ramp it is, etc.  To flush this remembered inormation, you will have to issue a program clear control.

 

Steps per Move

 

The steps per move control defines how many steps the motor should take between exposures.  If an output speed ramp is set, the steps per move setting is the maximum output video speed to be ramped and/or down to. 

The time-lapse engine is not aware of the gear ratio, microstepping ratio, or steps per revolution of your motor.  If you wish to control movement in degrees of a circle, for example, your calling application would need to distill this information to a specified number of steps.

Valid values for Steps per Move are 1-65,536.

 

Maximum Steps

 

The maximum steps control specifies the maximum distance to move a given motor during the execution of a program.  It monitors total steps moved, no matter their direction, and will not allow the given axis to move any further than this - no matter what other settings (such as linear ramping) are used.  Maximum steps may be specified from 0 (disabled) to 4,294,967,296.

 

Linear Ramp Rate

 

The linear ramp rate provides control over how the speed of the motor's motion is perceived in the final output video.  This control allows the motor to move further between shots until the Steps per Move rate is achieved.  For example, you may define that at the beginning of the motors movement, it takes ten exposure cycles to reach the full step rate.  This allows for natural, smooth starts and stops in the output video.

 

The motor ramp control value ranges from 1 to 255, with 1 being no ramp.

 

If a maximum step movement is defined, the linear ramp up and down are designed such that you are always gauranteed that:

  • The number of linear ramp steps you define will always be achieved
  • That the maximum step count will not be exceeded

However, you are not gauranteed that you will actually take the maximum step count steps during program execution.  The algorithm is designed such that it calculates when the steps should start and stop, such that it gaurantees the ramp takes at least as many cycles as you defined.  This results in certain combinations, an single incomplete full-step rate motion.  This motion is eliminated to prevent over-stepping or incorrect ramping down and poor motion in the output video.

The Linear Ramp Rate is specified as an integer, in how many shot cycles to take before the full step rate should be achieved.  For example, if a linear ramp rate of 10 is defined, it will take ten exposure cycles to reach  the defined Steps per Move for the given motor.  If no maximum step count is defined, then it will not programmatically determine when to start ramping down to no movement - you will have to trigger this via a running control (see below).

Note: some ramp rates and steps per move combination may result in no change between some exposure cycles, for example - a ramp rate of 100, and a steps per move count of 10, would result in a change of movement of 1 step every 10 exposures.  Preference should always be given to make ramp rate a factor of the step amount (or vice-versa), e.g.: if step count is 100, an appropriate ramp rate would be 10, 30, 50 or 1000.

 

Execute Down Ramp

 

The execute down ramp control is useful when no maximum step count has been defined, but a linear ramp rate for a motor has been used.  This control alows you to make a decision about when to start ramping down the step rate for a given axis.  This is an especially useful control when executed as an action with a keyframe, for example, I can state that I want the movement for a particular axis to begin slowing down after 500 shots, rather than slowing down to achieve a total amount of movement.

If this control is executed while the motor is currently ramping up to full movement, this may result in a poor output movement.  You should generally only use this control while the motor is moving at its full step rate.

Once the down ramp has been completed, the down ramp control for that motor will be disabled, and the motor will be disabled to prevent any further movement.

 

Direction

 

The direction control determines which direction the motor will move in.  It uses a simple boolean value of 1 or 0.  Which direction this results in is determined by how you wire your motor, what type of gearing you use, and the physical design of your setup.

 

Set Home

 

The set home control allows you to set the current position of a given axis as the 'home' position.  It erases any previously set home position for this axis, and enables you to utilize the go to home control to return to this position at a later time. 

The default home position for any axis is the position of the axis at power on.  If you do not use the set home control, this will be the position that the axis returns to when the go home control is used.

 

Go Home

 

The go home control forces a given axis to immediately return to its home position.  It will do so, without any ramping, at the maximum capable speed.  This is primarily designed to return to a given position between program executions. 

If this control is executed while a program is running, and the given axis is engaged, it will continue to operate properly according to the given program once it has returned home.  For example, if it is halfway through a down ramp, moving left, when this control is called, after returning home, the axis will complete its ramp, moving to the left, no matter which direction was required to go home.

 

Move Steps Now

 

The move steps now control allows you to cause an axis to move a specified number of steps immediately.  This is primarily designed for positioning an axis before executing a program.  However, it can be called while a program is executing.  If called while a program is executing, the axis will continue to move as defined after completing this move -- in the same manner as the go home control.

 

Backlash Compensation

 

Unfortunately, many motor gear chains have some backlash.  Backlash results in missed steps as the final output drive will not move until the backlash has been consumed when changing directions.  This setting allows you to set the amount of backlash to compensate for when changing motor directions, specified in steps.  You may specify from 0-255 steps of backlash compensation.

 

 

Built-in Settings

 

The built-in settings control global aspects of motor movement related to your design and implementation. 

 

Sleep Drivers Between Moves

 

For hardware setups that are capable of cutting power to the motors between moves, a single pin is used from the Arduino to connect to all motor drivers' sleep lines.  (If your drivers support them.)  This setting allows one to control whether the drivers should be put to sleep between each movement of a stepper motor or left running.  For hardware with appropriate gearing and design, this can greatly reduce wasted power andreduce motor/driver over-heating. making it an excellent option for long-term timelapse or field use.

 

Minimum Step Delay

 

The minimum step delay is expressed in micro-seconds.  It determines the minimum amount of time between step pulses. 

You must configure this amount to a safe amount for your motor/controller combination.  Too low of a value, and your motor will miss steps, too high of a value and your movements will take longer than they should.

Valid values are 1uS to 65,536uS.

 

Maximum Step Delay

 

The maximum step delay is also expressed in micro-seconds, it is the longest delay between step pulses.

The difference between this and the minimum step delay determines the overall velocity when making a series of steps.  There should be enough difference between these two to smoothly ramp up to speed.  For clean velocity ramps, one should set the maximum step delay to be several times larger than the minimum step delay.

Valid values are 1uS to 65,536uS.  

 

Camera Safe Wait

 

This is the minimum amount of time to delay after motor movements before triggering an exposure.  It is defined in milli-seconds.  If the combination of all times (alt trigger, post-delay, motor move execution times, any keyframe execution, etc.) exceed the interval cycle time, this timer will be used to prevent the camera from firing immediately after the motor movement executes, allowing a small amount of time for any motion to settle.  This setting is not available via the serial protocol and must be controlled via a #define in the sketch.