Пример #1
0
/** Configures the board hardware and chip peripherals for the demo's functionality. */
void SetupHardware(void)
{
  wdt_disable();
//     SETUP_CREATE_PWR_EN;
//     h_CREATE_PWR_EN;
//     SETUP_KIN_EN;
//     h_KIN_EN;
//     SETUP_ULIMIT;
//     SETUP_LLIMIT;
//     EN_ULIMIT_ISR;
//     EN_LLIMIT_ISR;

//     setupGeneralState();

//     setupMotors();
     setupADC();

    //start next adc read:
//     ADCSRA |= 0x40;
   
//     setupMusic();   
   
	/* Disable clock division */
	clock_prescale_set(clock_div_1);

	/* Hardware Initialization */
// 	Joystick_Init();
// 	LEDs_Init();
	DDRD |= 0xf0; /* set LEDs to output */
	PORTD &= 0x0f; /* set LEDs to output */
SetupMotors();
 EnableMotors();
	USB_Init();
	
}
Пример #2
0
void ProcessMessage(SMBData *smb)
{
  if (smb->state != SMB_STATE_WRITE_REQUESTED)
  {
    smb->state = SMB_STATE_IDLE;
    return;
  }

  switch (smb->rxBuffer[0]) // Command code.
  {
  case DRV_WHO_AM_I:
    WhoAmI(smb);
    break;
  case DRV_SET_DIRECTION:
    SetDirection(smb);
    break;
  case DRV_SET_SPEED:
    SetSpeed(smb);
    break;
  case DRV_DRV_ENABLE:
    EnableMotors(smb);
    break;
  case DRV_SET_ADDRESS:
    SetAddress(smb);
    break;
  case DRV_DRV_DISABLE:
    DisableMotors(smb);
    break;
  default:
    UndefinedCommand(smb);
  break;
  }
}
Пример #3
0
// Goes to home position (without interrupt), then lowers the build platform to
// the PDMS in order to calibrate and/or start a print
bool Motor::GoToStartPosition()
{
    EnableMotors();
    
    GoHome(false);
    
    std::vector<MotorCommand> commands;
    
    // set rotation parameters
    commands.push_back(MotorCommand(MC_ROT_SETTINGS_REG, MC_JERK, 
                                    _settings.GetInt(R_START_PRINT_JERK)));
    commands.push_back(MotorCommand(MC_ROT_SETTINGS_REG, MC_SPEED, 
                   R_SPEED_FACTOR * _settings.GetInt(R_START_PRINT_SPEED)));
      
    int startAngle = _settings.GetInt(R_START_PRINT_ANGLE) / R_SCALE_FACTOR;
    if (startAngle != 0)
    {
        // rotate to the start position
        commands.push_back(MotorCommand(MC_ROT_ACTION_REG, MC_MOVE, 
                                                                startAngle));
    }
    
    // set Z motion parameters
    commands.push_back(MotorCommand(MC_Z_SETTINGS_REG, MC_JERK,
                                    _settings.GetInt(Z_START_PRINT_JERK)));
    commands.push_back(MotorCommand(MC_Z_SETTINGS_REG, MC_SPEED,
                   Z_SPEED_FACTOR * _settings.GetInt(Z_START_PRINT_SPEED)));

    // move down to the PDMS
    commands.push_back(MotorCommand(MC_Z_ACTION_REG, MC_MOVE, 
                                    _settings.GetInt(Z_START_PRINT_POSITION)));
    
    // request an interrupt when these commands are completed
    commands.push_back(MotorCommand(MC_GENERAL_REG, MC_INTERRUPT));
    
    return SendCommands(commands);
}