|
|
|
@ -42,9 +42,9 @@ https://github.com/danithebest91/ServoStrap
|
|
|
|
|
|
|
|
|
|
// ------------- CONSTANTE DU PID -------------
|
|
|
|
|
|
|
|
|
|
float KP = 5 ; //Porportionnel
|
|
|
|
|
float KI = 0.1; // Intergrale
|
|
|
|
|
float KD = 2.0; // derive
|
|
|
|
|
float KP = 3 ; //Porportionnel
|
|
|
|
|
float KI = 2; // Intergrale
|
|
|
|
|
float KD = 15; // derive
|
|
|
|
|
|
|
|
|
|
// ------------- CONSTANTE DU PID -------------
|
|
|
|
|
|
|
|
|
@ -70,9 +70,9 @@ long previousMillis = 0; // will store last time LED was updated
|
|
|
|
|
long interval = 5; // interval at which to blink (milliseconds)
|
|
|
|
|
|
|
|
|
|
//for motor control ramps 1.4
|
|
|
|
|
bool newStep = false;
|
|
|
|
|
bool oldStep = false;
|
|
|
|
|
bool dir = false;
|
|
|
|
|
//bool newStep = false;
|
|
|
|
|
//bool oldStep = false;
|
|
|
|
|
//bool dir = false;
|
|
|
|
|
|
|
|
|
|
void setup() {
|
|
|
|
|
pinModeFast(2, INPUT);
|
|
|
|
@ -189,6 +189,8 @@ void docalc() {
|
|
|
|
|
sumError = iMin;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Serial.println(motorspeed);
|
|
|
|
|
|
|
|
|
|
if(motorspeed > 0){
|
|
|
|
|
if( motorspeed >= 255) motorspeed=255;
|
|
|
|
|
digitalWrite ( MotorIN1 , LOW );
|
|
|
|
@ -226,15 +228,19 @@ void doEncoderMotor0(){
|
|
|
|
|
else {
|
|
|
|
|
encoder0Pos-- ; // CCW
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void countStep(){
|
|
|
|
|
//dir=digitalRead(DIR_PIN)==HIGH;
|
|
|
|
|
dir = (PINC&B0000001); // dir=digitalRead(dir_pin) read PC0, 14 digital;
|
|
|
|
|
//dir = (PINC&B0000001); // dir=digitalRead(dir_pin) read PC0, 14 digital;
|
|
|
|
|
//here will be (PINB&B0000001) to not use shift in the stable version
|
|
|
|
|
if (dir) target1++;
|
|
|
|
|
else target1--;
|
|
|
|
|
if (PINC&B0000001) {
|
|
|
|
|
target1++;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
target1--;
|
|
|
|
|
}
|
|
|
|
|
}
|