Bonjour,
J'ai un moteur pas à pas Nema24 branché sur un shield qui gère le circuit de puissance.
Le shield est un VMA03. Pour le contrôler il a 2 pins qui sont consacrés à la direction de la l'alimentation des bobines et 2 pins consacrés à la puissance.
Je voudrais utiliser la librairies AccelStepper qui permet de gerer les moteurs pas à pas mais je ne trouve pas comment déclarer mon moteur sachant que pour les moteurs bipolaires, ils ne demandent que 2 pins.
J'ai cherché sur des posts anglais où ils disent qu'il faut déclarer les pins de directions mais je ne comprends pas comment gerer les 2 autres pins et ne voit pas comment cela permet de gerer la vitesse sachant que la vitesse dépend du temps entre l'alternance de l'alimentation des bobines.
J'espère que vous m'avez compris car je ne suis pas sûr d'utiliser les bons mots.
Voici mon code actuel pour faire tourner le moteur pour le moment :
void moteur_move(){
if(step_to_go != 0)
{
int _sub = step_to_go % 8;
switch(_sub)
{
case 0:
// Starting position (if repeated, full step (4))
// in this case, both our power are high.
// Therefore both coils are activated, with their standard polarities for their magnetic fields.
digitalWrite(pinA_power,HIGH);
digitalWrite(pinB_power,HIGH);
digitalWrite(pinA_dir,HIGH);
digitalWrite(pinB_dir,HIGH);
break;case 1:
//Half step (½)
//In this case, only out b-coil is active, still with it's stand polarity.
digitalWrite(pinA_power,HIGH);
digitalWrite(pinB_power,LOW);
digitalWrite(pinA_dir,HIGH);
digitalWrite(pinB_dir,LOW);
break;case 2:
//Full step (1)
// In this case, the b-coil is activated as in previous cases.
// But the a-coil now has it's direction turned on. So now it's active, but with the reversered polarity.
// By continuing this pattern (for reference: http://www.8051projects.net/stepper-motor-interfacing/full-step.gif) , you'll get the axis to turn.
digitalWrite(pinA_power,HIGH);
digitalWrite(pinB_power,HIGH);
digitalWrite(pinA_dir,HIGH);
digitalWrite(pinB_dir,LOW);
break;case 3:
// Half step (1½)
digitalWrite(pinA_power,LOW);
digitalWrite(pinB_power,HIGH);
digitalWrite(pinA_dir,LOW);
digitalWrite(pinB_dir,LOW);
break;case 4:
// Full step (2)
digitalWrite(pinA_power,HIGH);
digitalWrite(pinB_power,HIGH);
digitalWrite(pinA_dir,LOW);
digitalWrite(pinB_dir,LOW);
break;case 5:
// Half step (2½)
digitalWrite(pinA_power,HIGH);
digitalWrite(pinB_power,LOW);
digitalWrite(pinA_dir,LOW);
digitalWrite(pinB_dir,LOW);
break;case 6:
// Full step (3)
digitalWrite(pinA_power,HIGH);
digitalWrite(pinB_power,HIGH);
digitalWrite(pinA_dir,LOW);
digitalWrite(pinB_dir,HIGH);
break;case 7:
// Half step (3½)
digitalWrite(pinA_power,LOW);
digitalWrite(pinB_power,HIGH);
digitalWrite(pinA_dir,LOW);
digitalWrite(pinB_dir,HIGH);
break;
}
if(step_to_go>0){step_to_go--;} //decrement of remaining halfsteps of forward rotation
if(step_to_go<0){step_to_go++;}
}
else{
digitalWrite(pinA_power,LOW);
digitalWrite(pinB_power,LOW);
digitalWrite(pinA_dir,LOW);
digitalWrite(pinB_dir,LOW);
}
}
Mais ce code ne gère pas l’accélération, la decceleration et le frenage à l'arret.
Merci d'avance pour votre aide
Thomas