Back to engineering archive

Record 068 / Firmware and control

IMU stabilised stepper platform

A stepper platform control application using IMU feedback.

Development work
IMUStepper controlFeedback control

Firmware flow

How angular error becomes a motor-speed request

Complete selected stabilisation routine.

Read the current angle, subtract it from the target, scale the error using the step settings and pass that value to the stepper speed function.

The computed value is passed to a speed setter, not to a position-move command. The excerpt does not establish closed-loop stability, tuning or a tested accuracy.

Read the implementation

stabilizeMotor · selected source lines 149–155. Source inspection is not a hardware test.

void stabilizeMotor() {
  float currentAngle = getMPUAngle();
  float angleError = mpuTargetAngle - currentAngle;
  float stepsToMove = angleError * (stepsPerRevolution * microstepSetting / 360.0); // Map angle to steps
  stepper.setSpeed(stepsToMove);
  stepper.runSpeed();
}
Open the exact source-level diagram
ActionRead the current angle
ActionCompare it with the target angle
ActionScale the angular errorUse steps per revolution and the microstep setting.
ActionSet the requested stepper speed
ResultRun the speed-control step

Technical notes

Direction control

moveLeft() and moveRight() provide explicit direction-control operations.

Sweep mode

toggleSweep() and sweepMotor() distinguish selecting a sweep mode from executing it. That separation gives a movement pattern its own ongoing state.

IMU feedback

The development work connects IMU orientation feedback with the stepper platform’s movement commands.

Engineering archiveArchive record

Project enquiries

Discuss your project.

Tell us what you’re developing and where you need engineering support.

Discuss your project