uint32_t total_move_ticks;
std::bitset<k_max_actuators> direction_bits; // Direction for each axis in bit form, relative to the direction port's mask
- // for laser TODO may be able to use 10 bits and put it in bit struct below
- float s_value;
-
// this is the data needed to determine when each motor needs to be issued a step
using tickinfo_t= struct {
int32_t steps_per_tick; // 2.30 fixed point
bool is_g123:1; // set if this is a G1, G2 or G3
volatile bool is_ticking:1; // set when this block is being actively ticked by the stepticker
volatile bool locked:1; // set to true when the critical data is being updated, stepticker will have to skip if this is set
+ uint16_t s_value:12; // for laser 1.11 Fixed point
};
};
}
// figure out the ratio of its speed, from 0 to 1 based on where it is on the trapezoid
+ // FIXME steps_per_tick can change at any time, potential race condition if it changes while being read here
float ratio= (float)block->tick_info[pm].steps_per_tick / block->tick_info[pm].plateau_rate;
return ratio;
const Block *block = StepTicker::getInstance()->get_current_block();
// Note to avoid a race condition where the block is being cleared we check the is_ready flag which gets cleared first,
- // as this is an interrupt if that flag is not clear then it cannot be cleared while this is running and th eblock will still be valid (albeit it may have finished)
+ // as this is an interrupt if that flag is not clear then it cannot be cleared while this is running and the block will still be valid (albeit it may have finished)
if(block != nullptr && block->is_ready && block->is_g123) {
- float requested_power = block->s_value / this->laser_maximum_s_value;
+ float requested_power = ((float)block->s_value/(1<<11)) / this->laser_maximum_s_value; // s_value is 1.11 Fixed point
+
// Ensure we can't exceed maximum power
- if (requested_power > 1) requested_power = 1;
+ if (requested_power < 0) requested_power = 0;
+ else if (requested_power > 1) requested_power = 1;
float ratio = current_speed_ratio(block);
power = requested_power * ratio;