Go to the source code of this file.
Macros | |
#define | SEGMENT_BUFFER_SIZE 10 |
Functions | |
void | stepper_init () |
Initialize and setup the stepper motor subsystem. More... | |
void | st_wake_up () |
Enable steppers, but cycle does not start unless called by motion control or realtime command. More... | |
void | st_go_idle () |
Immediately disables steppers. More... | |
void | st_generate_step_dir_invert_masks () |
Generate the step and direction port invert masks. More... | |
void | st_reset () |
Reset the stepper subsystem variables. More... | |
void | st_parking_setup_buffer () |
Changes the run state of the step segment buffer to execute the special parking motion. More... | |
void | st_parking_restore_buffer () |
Restores the step segment buffer to the normal run state after a parking motion. More... | |
void | st_prep_buffer () |
Reloads step segment buffer. Called continuously by realtime execution system. More... | |
void | st_update_plan_block_parameters () |
Called by planner_recalculate() when the executing block is updated by the new plan. More... | |
float | st_get_realtime_rate () |
Called by realtime status reporting if realtime rate reporting is enabled in config.h. More... | |
void st_generate_step_dir_invert_masks | ( | ) |
float st_get_realtime_rate | ( | ) |
void st_go_idle | ( | ) |
void st_parking_restore_buffer | ( | ) |
Restores the step segment buffer to the normal run state after a parking motion.
void st_parking_setup_buffer | ( | ) |
Changes the run state of the step segment buffer to execute the special parking motion.
void st_prep_buffer | ( | ) |
Reloads step segment buffer. Called continuously by realtime execution system.
Reloads step segment buffer. Called continuously by realtime execution system.
The segment buffer is an intermediary buffer interface between the execution of steps by the stepper algorithm and the velocity profiles generated by the planner. The stepper algorithm only executes steps within the segment buffer and is filled by the main program when steps are "checked-out" from the first block in the planner buffer. This keeps the step execution and planning optimization processes atomic and protected from each other. The number of steps "checked-out" from the planner buffer and the number of segments in the segment buffer is sized and computed such that no operation in the main program takes longer than the time it takes the stepper algorithm to empty it before refilling it. Currently, the segment buffer conservatively holds roughly up to 40-50 msec of steps.
< Check if we need to fill the buffer.
< Reset for new segment block
< Default velocity profile complete at 0.0mm from end of block.
< [Forced Deceleration to Zero Velocity]
< End of feed hold.
< [Normal Operation]
< Initialize as acceleration ramp.
< Enforce stop at end of system motion.
< Only occurs during override reductions.
< Deceleration-only.
< Flag to load next block as deceleration override.
< Either trapezoid or triangle types
< Trapezoid type
< Triangle type
< Deceleration-only type
< Acceleration-only type
< Force update whenever updating block.
< Maximum segment time
< Initialize segment time
< Time worker variable
< mm-Distance worker variable
< Speed worker variable
< New segment distance from end of block.
< Guarantee at least one step.
<
< Mid-deceleration override ramp.
< End of acceleration ramp.
<
< Acceleration only.
< End of cruise.
<
< Cruising only.
< case RAMP_DECEL:
< Used as delta speed (mm/min)
< Check if at or below zero speed.
< (mm)
< Typical case. In deceleration ramp.
< Segment complete. Exit switch-case statement. Continue do-while loop.
< Add computed ramp time to total segment time.
< Check for very slow segments with zero steps.
< Complete Exit loop. Segment execution time maxed.
< Complete Exit loop. Profile complete.
< Reload segment PWM value
< Convert mm_remaining to steps
< Round-up current steps remaining
< Round-up last steps remaining
< Compute number of steps to execute.
< Segment not generated, but current step data still retained.
< Apply previous segment partial step execute time
< Compute adjusted step rate inverse
< (cycles/step)
< At end of forced-termination.
< Bail!
< End of planner block
< Set pointer to indicate check and load next planner block.
void st_reset | ( | ) |
void st_update_plan_block_parameters | ( | ) |
void st_wake_up | ( | ) |
Enable steppers, but cycle does not start unless called by motion control or realtime command.
Enable steppers, but cycle does not start unless called by motion control or realtime command.
__________________________ /| |\ _________________ ^ / | | \ /| |\ | / | | \ / | | \ s / | | | | | \ p / | | | | | \ e +-----+------------------------+---+--+---------------+----+ e | BLOCK 1 ^ BLOCK 2 | d | time -----> EXAMPLE: Block 2 entry speed is at max junction velocity
The planner block buffer is planned assuming constant acceleration velocity profiles and are continuously joined at block junctions as shown above. However, the planner only actively computes the block entry speeds for an optimal velocity plan, but does not compute the block internal velocity profiles. These velocity profiles are computed ad-hoc as they are executed by the stepper algorithm and consists of only 7 possible types of profiles: cruise-only, cruise- deceleration, acceleration-cruise, acceleration-only, deceleration-only, full-trapezoid, and triangle(no cruise).
maximum_speed (< nominal_speed) -> + +--------+ <- maximum_speed (= nominal_speed) /|\ / \ / | \ current_speed -> + \ / | + <- exit_speed | + <- exit_speed / | | +-------------+ current_speed -> +----+--+ time --> ^ ^ ^ ^ | | | | decelerate_after(in mm) decelerate_after(in mm) ^ ^ ^ ^ | | | | accelerate_until(in mm) accelerate_until(in mm)
The step segment buffer computes the executing block velocity profile and tracks the critical parameters for the stepper algorithm to accurately trace the profile. These critical parameters are shown and defined in the above illustration.Stepper state initialization. Cycle should only start if the st.cycle_start flag is
< Normal operation
void stepper_init | ( | ) |
Initialize and setup the stepper motor subsystem.
Initialize and setup the stepper motor subsystem.
< waveform generation = 0100 = CTC
< Disconnect OC1 output
< Disconnect OC0 outputs and OVF interrupt.
< Normal operation
< Disable Timer0 until needed
< Enable Timer0 overflow interrupt