Пример #1
0
// Set the index LED, property with the value
int StepperOsc_PropertySet( int index, int property, int value )
{
  switch ( property )
  {
    case 0:
      Stepper_SetActive( index, value );
      break;
    case 1:
      Stepper_SetPosition( index, value );
      break;
    case 2:
      Stepper_SetPositionRequested( index, value );
      break;
    case 3:
      Stepper_SetSpeed( index, value );
      break;
    case 4:
      Stepper_SetDuty( index, value );
      break;
    case 5:
      Stepper_SetHalfStep( index, value );
      break;
    case 6:
      Stepper_SetBipolar( index, value );
      break;
    case 7: // step
      Stepper_Step( index, value );
      break;
  }
  return CONTROLLER_OK;
}
Пример #2
0
int main(void) {
    int i;
    unsigned short pattern;
    char j,k;

    SERIAL_Init();
    AD1PCFG = 0xFF;
    INTEnableSystemMultiVectoredInt();
    //enable LED bank 1
    TRISDbits.TRISD6 = 0;
    TRISDbits.TRISD11 = 0;
    TRISDbits.TRISD3 = 0;
    TRISDbits.TRISD5 = 0;
    //enable LED bank 2
    TRISFbits.TRISF6 = 0;
    TRISGbits.TRISG7 = 0;
    TRISDbits.TRISD7 = 0;
    TRISGbits.TRISG8 = 0;

    printf("\nHello World!");
    Stepper_Init(stepSpeed);
    printf("\nStepping forward 420 steps");
    Stepper_SetSteps(FORWARD,420);
    while(Stepper_GetRemainingCount() > 1) {
        printf("\t%u,%u",Stepper_GetRemainingCount(),stepSpeed);
        DELAY();
#ifdef STEPPER_RAMPS
        if (Stepper_GetRemainingCount() % 10) {
            Stepper_SetSpeed( (stepSpeed / 4) + stepSpeed );
        }
#endif
    }
    printf("\nForward steps done");

    DELAY();

    Stepper_SetSteps(REVERSE,220);
    while (Stepper_GetRemainingCount() > 1) {
        printf("\t%u",Stepper_GetRemainingCount());
        DELAY();
    }
    Stepper_End();

    TRIS_COIL_A_DIRECTION = 0;
    TRIS_COIL_A_ENABLE = 0;
    TRIS_COIL_B_DIRECTION = 0;
    TRIS_COIL_B_ENABLE = 0;

    ShutDownDrive();
    ADisable();
    ADirectionOff();
    BDisable();
    BDirectionOff();
    printf("\n Turning on COIL_B_DIRECTION (PortZ-07");
    for (j=0;j<10;j++) {
        printf("o");
        DELAY();
    }
    while (1) {
        COIL_B_DIRECTION ^= 1;
        DELAY();
        printf(".");
    }
    return 0;
}