Bonjour,
je contrôle deux Nema17 avec deux EasyDriver et un Arduino nano
c'est une motorisation de télescope
j'envoie les ordres par l'ordinateur (USB) selon des séquences dépendant les unes des autres
par exemple j'actionne les moteurs d’azimut et d'altitude pour changer de cible
cette action prend un certain temps que je ne connais pas forcément précisément
aussi, après avoir atteint la nouvelle cible, l'ordi envoie les ordres de suivi
le soucis c'est quand les ordres de suivi arrivent avant ou longtemps après la fin de la première séquence
dans les deux cas, j'ai des décalages sur les cibles
bref, j'ai essayé de générer des messages en début et fin d'actions mais j'ai l'impression qu'il doit y avoir d'autres solutions
par ex est-ce possible de séquencer correctement les ordres (sans qu'il y ait chevauchements (les moteurs n'appréciant pas du tout les changements de vitesse inopinés))
void azrotate(int steps, float vitesse){
int a=1;
steps=abs(steps);
if (steps>800) {
azmodule(steps);
a=0;
}
if (a==1){
Serial.print("occupe");
digitalWrite(azimEnablePin, LOW); //Enabling the motor, so it will move when asked to
int direction;
if (azdir > 0){
direction = HIGH;
}else{
direction = LOW;
}
vitesse = 1/vitesse * 50; //Calculating speed
vitesse=abs(vitesse);
digitalWrite(azimDirectionPin, direction); //Writes the direction (from our if statement above), to the EasyDriver DIR pin
/*Steppin'*/
for (int i = 0; i < steps; i++){
digitalWrite(azimStepPin, HIGH);
delayMicroseconds(vitesse);
digitalWrite(azimStepPin, LOW);
delayMicroseconds(vitesse);
}
//digitalWrite(azimEnablePin, HIGH); //Disbales the motor, so it can rest untill the next time it is called uppond
}
Serial.print("libre");
}
//******************************************************
void azmodule(int steps){
Serial.print("occupe");
int debut;
int milieu;
int fin;
int vitess;
digitalWrite(azimEnablePin, LOW); //Enabling the motor, so it will move when asked to
int direction;
if (azdir > 0){
direction = HIGH;
}else{
direction = LOW;
}
debut=50;
fin=50;
int debut2=100;
int fin2=100;
milieu=steps-300;
vitess = 5000; //Calculating speed
digitalWrite(azimDirectionPin, direction); //Writes the direction (from our if statement above), to the EasyDriver DIR pin
for (int i = 0; i < debut; i++){
digitalWrite(azimStepPin, HIGH);
delayMicroseconds(vitess);
digitalWrite(azimStepPin, LOW);
delayMicroseconds(vitess);
}
vitess = 2500; //Calculating speed
for (int i = 0; i < debut2; i++){
digitalWrite(azimStepPin, HIGH);
delayMicroseconds(vitess);
digitalWrite(azimStepPin, LOW);
delayMicroseconds(vitess);
}
vitess = 1000;
for (int i = 0; i < milieu; i++){
digitalWrite(azimStepPin, HIGH);
delayMicroseconds(vitess);
digitalWrite(azimStepPin, LOW);
delayMicroseconds(vitess);
}
vitess = 2500; //Calculating speed
for (int i = 0; i < fin2; i++){
digitalWrite(azimStepPin, HIGH);
delayMicroseconds(vitess);
digitalWrite(azimStepPin, LOW);
delayMicroseconds(vitess);
}
vitess = 5000;
for (int i = 0; i < fin; i++){
digitalWrite(azimStepPin, HIGH);
delayMicroseconds(vitess);
digitalWrite(azimStepPin, LOW);
delayMicroseconds(vitess);
}
delayMicroseconds(5000);
//digitalWrite(azimEnablePin, HIGH); //Disbales the motor, so it can rest untill the next time it is called uppond
Serial.print("libre");
}
//*************************************************
void altmodule(int steps){
Serial.print("occupe");
int debut=50;
int milieu;
int fin=50;
int vitess;
int debut2=100;
int fin2=100;
digitalWrite(altEnablePin, LOW); //Enabling the motor, so it will move when asked to
int direction;
if (aldir > 0){
direction = HIGH;
}else{
direction = LOW;
}
milieu=steps-300;
vitess = 5000; //Calculating speed
digitalWrite(altDirectionPin, direction); //Writes the direction (from our if statement above), to the EasyDriver DIR pin
for (int i = 0; i < debut; i++){
digitalWrite(altStepPin, HIGH);
delayMicroseconds(vitess);
digitalWrite(altStepPin, LOW);
delayMicroseconds(vitess);
}
vitess = 2500; //Calculating speed
for (int i = 0; i < debut2; i++){
digitalWrite(altStepPin, HIGH);
delayMicroseconds(vitess);
digitalWrite(altStepPin, LOW);
delayMicroseconds(vitess);
}
vitess = 1000;
for (int i = 0; i < milieu; i++){
digitalWrite(altStepPin, HIGH);
delayMicroseconds(vitess);
digitalWrite(altStepPin, LOW);
delayMicroseconds(vitess);
}
vitess = 2500;
for (int i = 0; i < fin2; i++){
digitalWrite(altStepPin, HIGH);
delayMicroseconds(vitess);
digitalWrite(altStepPin, LOW);
delayMicroseconds(vitess);
}
vitess = 5000;
for (int i = 0; i < fin; i++){
digitalWrite(altStepPin, HIGH);
delayMicroseconds(vitess);
digitalWrite(altStepPin, LOW);
delayMicroseconds(vitess);
}
delayMicroseconds(5000);
//digitalWrite(altEnablePin, HIGH); //Disbales the motor, so it can rest untill the next time it is called uppond
Serial.print("libre");
}
//****************************************
void alrotate(int steps, float vitesse){
steps=abs(steps);
int a=1;
if (steps>800) {
altmodule(steps);
a=0;
}
if (a==1) {
Serial.print("occupe");
digitalWrite(altEnablePin, LOW); //Enabling the motor, so it will move when asked to
int direction;
if (aldir > 0){
direction = HIGH;
}else{
direction = LOW;
}
vitesse = 1/vitesse * 70; //Calculating speed
vitesse=abs(vitesse);
digitalWrite(altDirectionPin, direction); //Writes the direction (from our if statement above), to the EasyDriver DIR pin
for (int i = 0; i < steps; i++){
digitalWrite(altStepPin, HIGH);
delayMicroseconds(vitesse);
digitalWrite(altStepPin, LOW);
delayMicroseconds(vitesse);
}
delayMicroseconds(5000);
//digitalWrite(altEnablePin, HIGH); //Disbales the motor, so it can rest untill the next time it is called uppond
}
Serial.print("libre");
}
merci de m'avoir lu