From 1165a683e20c98aaf4dd9aaca5daaaa8dabf9573 Mon Sep 17 00:00:00 2001 From: Vincent M Date: Thu, 10 Mar 2016 18:02:07 +0100 Subject: [PATCH] nouvvelle version du code servostrap --- .../ServoStrapPortManipulationLD293D_1_3.ino} | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) rename Moteur DC/ServoStrap/{ServoStrapPortManipulationLD293D_1_2/ServoStrapPortManipulationLD293D_1_2.ino => ServoStrapPortManipulationLD293D_1_3/ServoStrapPortManipulationLD293D_1_3.ino} (94%) mode change 100755 => 100644 diff --git a/Moteur DC/ServoStrap/ServoStrapPortManipulationLD293D_1_2/ServoStrapPortManipulationLD293D_1_2.ino b/Moteur DC/ServoStrap/ServoStrapPortManipulationLD293D_1_3/ServoStrapPortManipulationLD293D_1_3.ino old mode 100755 new mode 100644 similarity index 94% rename from Moteur DC/ServoStrap/ServoStrapPortManipulationLD293D_1_2/ServoStrapPortManipulationLD293D_1_2.ino rename to Moteur DC/ServoStrap/ServoStrapPortManipulationLD293D_1_3/ServoStrapPortManipulationLD293D_1_3.ino index c6c53b4..04ae617 --- a/Moteur DC/ServoStrap/ServoStrapPortManipulationLD293D_1_2/ServoStrapPortManipulationLD293D_1_2.ino +++ b/Moteur DC/ServoStrap/ServoStrapPortManipulationLD293D_1_3/ServoStrapPortManipulationLD293D_1_3.ino @@ -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); @@ -188,6 +188,8 @@ void docalc() { } else if(sumError < iMin){ sumError = iMin; } + + Serial.println(motorspeed); if(motorspeed > 0){ if( motorspeed >= 255) motorspeed=255; @@ -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--; + } }