Oops to fast to rule out the comp.
Gear required 48 is there but nothing on output so there must be something else wrong in comp.
Code:
FUNCTION(_){
int actual, message, motor_max_speed;
int i;
// These need to be edited to suit the gearbox
int speeds[12] = {0, 255, 325, 430, 540, 715, 900, 1190, 1500, 2000, 2500, 0x1P30};
int reqd_gear[12] = {0x0, 0x01, 0x21, 0x02, 0x22, 0x04, 0x24, 0x08, 0x28, 0x10, 0x30, 0x0};
if (spindle_speed_in == 0) return;
actual = (gear_high * 0x20 + gear_A * 0x10 + gear_B * 0x08 + gear_C * 0x04 + gear_D * 0x02 + gear_E * 0x01);
for (i = 0; spindle_speed_in > speeds[i] && i < 10; i++);
gear_required = reqd_gear[i];
if (gear_required == actual && gear_required != 0x0){ // We are in the right gear
spindle_enable_out = spindle_enable_in;
motor_speed_out = speeds[10] * (spindle_speed_in / speeds[i+1]);
message = 0;
} else {
int j;
motor_speed_out = 0;
spindle_enable_out = 0;
for (j = 0; j < 10; j++) { message(j) = 0; }
message(i) = 1;
}
}