Beispiel #1
0
void motor_y_step_p(){
  //GPIO_ResetBits(Y_ENABLE_PORT, Y_ENABLE_PIN);
  GPIO_SetBits(Y_DIR_PORT, Y_DIR_PIN);
  motor_delay(Motor_Delay); 

  GPIO_ResetBits(Y_STEP_PORT, Y_STEP_PIN);
  motor_delay(Motor_Delay);   //need change
  GPIO_ToggleBits(Y_STEP_PORT, Y_STEP_PIN);
  motor_delay(Motor_Delay);

  //GPIO_SetBits(Y_ENABLE_PORT, Y_ENABLE_PIN);
}
Beispiel #2
0
void motor_z_step_n(){
 // GPIO_ResetBits(Z_ENABLE_PORT, Z_ENABLE_PIN);
  GPIO_ResetBits(Z_DIR_PORT, Z_DIR_PIN);
  motor_delay(Motor_Delay); 

  GPIO_ResetBits(Z_STEP_PORT, Z_STEP_PIN);
  motor_delay(Motor_Delay);   //need change
  GPIO_ToggleBits(Z_STEP_PORT, Z_STEP_PIN);
  motor_delay(Motor_Delay);

 // GPIO_SetBits(Z_ENABLE_PORT, Z_ENABLE_PIN);
}
Beispiel #3
0
void motor_x_step_n(){
  //GPIO_ResetBits(X_ENABLE_PORT, X_ENABLE_PIN);
  GPIO_ResetBits(X_DIR_PORT, X_DIR_PIN);
  motor_delay(Motor_Delay); 

  GPIO_ResetBits(X_STEP_PORT, X_STEP_PIN);
  motor_delay(Motor_Delay);   
  GPIO_ToggleBits(X_STEP_PORT, X_STEP_PIN);
  motor_delay(Motor_Delay);

  //GPIO_SetBits(X_ENABLE_PORT, X_ENABLE_PIN);
}
Beispiel #4
0
/*
motor - x, y or z motor, can be 'motor_x', 'motor_y' or 'motor_z'
dir - direction, can be 'positive' or 'negative'
speed - speed, number in mm/s
*/
void motor_step(Motor_Typedef motor, Motor_Direction dir, float speed){
  uint32_t delay;
  delay = (int)((float)1/(((float)speed/2)*200)*1000000); //Need change if different stepping methods implemented

  if(dir == positive)
    GPIO_SetBits(MOTOR_DIR_PORT[motor], MOTOR_DIR_PIN[motor]);
  if(dir == negative)
    GPIO_ResetBits(MOTOR_DIR_PORT[motor], MOTOR_DIR_PIN[motor]);
  
  motor_enable(motor);  //enable 
  GPIO_ResetBits(MOTOR_STEP_PORT[motor], MOTOR_STEP_PIN[motor]);
  motor_delay(delay/2);   //need change
  GPIO_ToggleBits(MOTOR_STEP_PORT[motor], MOTOR_STEP_PIN[motor]);
  motor_delay(delay/2); 
}
Beispiel #5
0
void Go()
{	 //步进电机控制程序四线双极性单四拍工作
    PH1 = 0;  
    I01 = 0;
		I11 = 0;  
	

		PH2 = 0;  
		I02 = 1;
		I12 = 1;   

		motor_delay(speed);
		
		PH1 = 0;  
		I01 = 1;  
		I11 = 1;
	
	
		PH2 = 1;  
		I02 = 0;  
		I12 = 0;

		motor_delay(speed);
		
		PH1 = 1;   
    I01 = 0;   
		I11 = 0;
	

		PH2 = 1;  
		I02 = 1;  
		I12 = 1;
	           
		motor_delay(speed);
		
		PH1 = 1;   
		I01 = 1;
		I11 = 1;
	

		PH2 = 0;  
		I02 = 0;
		I12 = 0;

		motor_delay(speed);
               
}