
allora, il codice in questione è questo:
Code:
void dda_move(long micro_delay)
{
long max_delta;
long x_counter;
// initialise Heartbeat
//=====================
InitialiseHeartBeat(true);
// enable our steppers
//====================
enable_steppers();
// figure out our deltas
//======================
max_delta = delta_steps.x;
// init stuff
//===========
x_counter = -max_delta/2;
// our step flags
//===============
x_can_step = false;
if (micro_delay >= 16383)
milli_delay = micro_delay / 1000;
else
milli_delay = 0;
#ifdef DEBUG
Serial.print("MaxDelta: ");
Serial.print(max_delta, DEC);
Serial.print(" MilliDelay: ");
Serial.print(milli_delay, DEC);
Serial.print(" MicroDelay: ");
Serial.println(micro_delay, DEC);
#endif
// do our DDA line!
do
{
// see if user hit eStop
//======================
eSTOP();
x_can_step = can_step(FC_HOME, FC_LIMIT, current_steps.x, target_steps.x, x_direction);
if (x_can_step)
{
x_counter += delta_steps.x;
if (x_counter > 0)
{
do_step(BIG_EASY_DRIVER_STEP);
x_counter -= max_delta;
if (x_direction)
current_steps.x++;
else
current_steps.x--;
}
}
current_units.x = to_units(unit_X_MM, float(current_steps.x));
if (!x_can_step)
return;
// wait for next step
//===================
if (milli_delay > 0)
delay(milli_delay);
else
delayMicroseconds(micro_delay);
Heartbeat();
} while (x_can_step);
// set our current to target
//==============================
/*if (!free_run_end_exec){
current_units.x = target_units.x;
Serial.print("current_units.x= ");
Serial.println(current_units.x);
}
else{
target_units.x = current_units.x;
}*/
Serial.print("current_units.x= ");
Serial.println(current_units.x);
Serial.print("target_units.x= ");
Serial.println(target_units.x);
//current_units.x = target_units.x;
calculate_deltas();
// reset Heartbeat
//================
InitialiseHeartBeat(false);
}
{
long max_delta;
long x_counter;
// initialise Heartbeat
//=====================
InitialiseHeartBeat(true);
// enable our steppers
//====================
enable_steppers();
// figure out our deltas
//======================
max_delta = delta_steps.x;
// init stuff
//===========
x_counter = -max_delta/2;
// our step flags
//===============
x_can_step = false;
if (micro_delay >= 16383)
milli_delay = micro_delay / 1000;
else
milli_delay = 0;
#ifdef DEBUG
Serial.print("MaxDelta: ");
Serial.print(max_delta, DEC);
Serial.print(" MilliDelay: ");
Serial.print(milli_delay, DEC);
Serial.print(" MicroDelay: ");
Serial.println(micro_delay, DEC);
#endif
// do our DDA line!
do
{
// see if user hit eStop
//======================
eSTOP();
x_can_step = can_step(FC_HOME, FC_LIMIT, current_steps.x, target_steps.x, x_direction);
if (x_can_step)
{
x_counter += delta_steps.x;
if (x_counter > 0)
{
do_step(BIG_EASY_DRIVER_STEP);
x_counter -= max_delta;
if (x_direction)
current_steps.x++;
else
current_steps.x--;
}
}
current_units.x = to_units(unit_X_MM, float(current_steps.x));
if (!x_can_step)
return;
// wait for next step
//===================
if (milli_delay > 0)
delay(milli_delay);
else
delayMicroseconds(micro_delay);
Heartbeat();
} while (x_can_step);
// set our current to target
//==============================
/*if (!free_run_end_exec){
current_units.x = target_units.x;
Serial.print("current_units.x= ");
Serial.println(current_units.x);
}
else{
target_units.x = current_units.x;
}*/
Serial.print("current_units.x= ");
Serial.println(current_units.x);
Serial.print("target_units.x= ");
Serial.println(target_units.x);
//current_units.x = target_units.x;
calculate_deltas();
// reset Heartbeat
//================
InitialiseHeartBeat(false);
}
sarebbe da gestire con interrupt o qualcosa di simile, al momento è gestito da un ciclo do{} che "blocca" il ciclo all'interno di esso..
mediante scheduler ho evitato che il codice mi si bloccasse sul serio all'interno del loop, ma non è sufficiente per poter gestire il display senza ritardi nel invio degli impulsi di step

se riuscite a postarmi un esempio per una gestione ottimale di un interrupt (timer) con arduinodue vi sarei molto grato!!!









saluti
kattivik76
