// Set the speed at which this steper moves
void StepperMotor::set_speed( float speed ){
- if (speed < 20.0)
- speed = 20.0;
+ if (speed < 20.0F)
+ speed = 20.0F;
// How many steps we must output per second
this->steps_per_second = speed;
- // How many ticks ( base steps ) between each actual step at this speed, in fixed point 64
+ // How many ticks ( base steps ) between each actual step at this speed, in fixed point 64 <--- REALLY? I don't think it is at the moment looks like 32bit fixed point
float ticks_per_step = (float)( (float)this->step_ticker->frequency / speed );
- float double_fx_ticks_per_step = (float)(1<<8) * ( (float)(1<<8) * ticks_per_step ); // 8x8 because we had to do 16x16 because 32 did not work
+ //float double_fx_ticks_per_step = (float)(1<<8) * ( (float)(1<<8) * ticks_per_step ); // 8x8 because we had to do 16x16 because 32 did not work
+ float double_fx_ticks_per_step = 65536.0F * ticks_per_step; // isn't this better on a 32bit machine?
this->fx_ticks_per_step = (uint32_t)( floor(double_fx_ticks_per_step) );
}
StepperMotor();
StepperMotor(Pin& step, Pin& dir, Pin& en);
- // Called a great many times per second, to step if we have to now
- inline void tick() {
- // increase the ( fixed point ) counter by one tick 11t
- fx_counter += (uint32_t)(1<<16);
-
- // if we are to step now 10t
- if (fx_counter >= fx_ticks_per_step)
- step();
- };
void step();
inline void unstep() { step_pin.set(0); };
bool remove_from_active_list_next_reset;
bool is_move_finished; // Whether the move just finished
+
+ // Called a great many times per second, to step if we have to now
+ inline void tick() {
+ // increase the ( fixed point ) counter by one tick 11t
+ fx_counter += (uint32_t)(1<<16);
+
+ // if we are to step now 10t
+ if (fx_counter >= fx_ticks_per_step)
+ step();
+ };
};
#endif