Hello OldSteve,
Fisrtly, I join the datasheet of my motor. Then, maybe I don't understand very well AccelStepper, I begin. I wrote the following code with AccelStepper, the motor achieved to rotate up to 1000 rpm without issue but the Arduino only sent me back one value at the end at the rotation of my motor. However, I would like to obtain the values "in live". The used rotational sensor works like this : it varies from 0 to 5V, according to the number of rotations (from 0 to 50).
Nevertheless,I don't know how introduce some code in AccelStepper...
int x=1; //incrementation
int a=20; //coefficient de multiplication
int Tempspulse; //durée totale d'une pulse
// Référence Moteur
byte dirPin=8; // broche de direction
byte stepPin=9; // broche des pas
byte Mode0=7; //fullstep or halfstep
void setup()
{
pinMode(dirPin, OUTPUT); //sortie
pinMode(stepPin, OUTPUT); //sortie
pinMode(Mode0, OUTPUT); //sortie
digitalWrite(Mode0, HIGH); //fullsteps activated
Tempspulse=1800-a*x; //initialisation de l'équation de décrémentation
Serial.begin(9600); //renvoi des infos en baud
}
void loop()
{
// phase Accélération = tant que le moteur n'a pas atteint la vitesse, il accélère
while(Tempspulse>300)
{Tempspulse=1800-a*x;
digitalWrite(stepPin, HIGH);
delayMicroseconds(10);
digitalWrite(stepPin, LOW);
delayMicroseconds(Tempspulse-10);
Serial.println(Tempspulse);
x++;}
// il a atteint la vitesse et la maintient
digitalWrite(stepPin, HIGH);
delayMicroseconds(10);
digitalWrite(stepPin, LOW);
delayMicroseconds(Tempspulse-10);
Serial.println(Tempspulse);
}
HelloRobin2,
I sent the following code, and I have changed 300µs by 500µs but the motor doesn't see the difference, it only rotates at the same speed, and if the serial monitor displays me the good information (980,960,940...=>300), the motor rotates at the same speed, it doesn't accelerate. Is it possible that the microprocessor keeps in mind old values and refuses to have new codes?
Your Simple Stepper Code is wonderful ! Thank !
// --- Programme Arduino ---
// Le 26/10/2015
/* Test moteur pas à pas bipolaire via DRV8825 en pulse dir avec accélération*/
int x=1; //incrementation
int a=20; //coefficient de multiplication
int Tempspulse; //durée totale d'une pulse
int Beginvalue = 1000; //valeur de départ (le moteur monte sans problème à cette valeur)
// Référence Moteur
byte dirPin=8; // broche de direction
byte stepPin=9; // broche des pas
byte Mode0=7; //fullstep or halfstep
void setup()
{
pinMode(dirPin, OUTPUT); //sortie
pinMode(stepPin, OUTPUT); //sortie
pinMode(Mode0, OUTPUT); //sortie
digitalWrite(Mode0, LOW); //fullsteps activated
Tempspulse=Beginvalue-a*x; //initialisation de l'équation de décrémentation
Serial.begin(9600); //renvoi des infos en baud
}
void loop()
{
// phase Accélération = tant que le moteur n'a pas atteint la vitesse, il accélère
while(Tempspulse>300)
{
digitalWrite(stepPin, HIGH);
delayMicroseconds(10);
digitalWrite(stepPin, LOW);
delayMicroseconds(Tempspulse-10);
Serial.println(Tempspulse);
x++;
Tempspulse=Beginvalue-a*x;}
// il a atteint la vitesse et la maintient
digitalWrite(stepPin, HIGH);
delayMicroseconds(10);
digitalWrite(stepPin, LOW);
delayMicroseconds(Tempspulse-10);
Serial.println(Tempspulse);
}
Thank a lot both for your quick and complete answers! Thanks !!!