Silicon Laboratories Stepper Machine Manual de usuario Pagina 28

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 36
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 27
AN155
28 Rev. 1.1
putc('>');
}
//-----------------------------------------------------------------------------
void delay (void) // used by main
{
unsigned char i,j;
for(i=255;i>0;i--) // simple delay for display update
{
for(j=255;j>0;j--);
}
}
//-----------------------------------------------------------------------------
void doneMsg(void) // called from Timer_ISR
{
putc('\r'); // overwrite final position
putuint(Position); // display int as string
newline();
puts("done!"); // indicate move complete
newline();
putc('>'); // display prompt
doneFlag=0;
}
//-----------------------------------------------------------------------------
void INT0_ISR (void) interrupt 2 // external interrupt 0 used for switch
{
if(LED==OFF) // ignore switch if moving
{
if(Position==0) // if home move to 100
{
move(1600);
}
else // if not home move to home
{
move(0);
}
}
}
//-----------------------------------------------------------------------------
// move
// This function calculates the profile and initializes the stepper
// motor. Function will abort if the target equals the Position or if
// the motor is still moving. Forward is set to 1 if target>Position.
// the length is calculated as the absolute value of Position minus
// target. For short moves less than 1024, MaxTableIndex is length
// divided by 4. For long moves, MaxTableIndex is set to 255.
//
// slewCount = length - 2 * MaxTableIndex - 1
//
// The slewcount is calculated by subtracting MaxTableIndex twice and
// decrementing. The TableIndex is initialized to zero.
//
void move (unsigned int target)
{
unsigned int length; // used to calculate length of move
if (target != Position) // abort if already there
Vista de pagina 27
1 2 ... 23 24 25 26 27 28 29 30 31 32 33 34 35 36

Comentarios a estos manuales

Sin comentarios