mecha

Dependents:   2019NHK_A_manual_red 2019NHK_A_manual_red 2019NHK_A_manual_blue

Files at this revision

API Documentation at this revision

Comitter:
ec30109b
Date:
Thu Oct 03 08:42:09 2019 +0000
Parent:
5:1d0e66198bb4
Commit message:
Schmidt trigger only one.

Changed in this revision

towelest.cpp Show annotated file Show diff for this revision Revisions of this file
towelest.h Show annotated file Show diff for this revision Revisions of this file
diff -r 1d0e66198bb4 -r 9f932b9adee5 towelest.cpp
--- a/towelest.cpp	Mon Sep 23 12:21:49 2019 +0000
+++ b/towelest.cpp	Thu Oct 03 08:42:09 2019 +0000
@@ -1,21 +1,17 @@
-#include "towelest.h"
+#include "towelest.h"               //manual mode
 
-towelest::towelest(Serial* RS485,int address,PinName Limit0,PinName Limit1,PinName Limit2):
-pid(4.0, 0, 0.001, 0.01),
-LimitSW0(Limit0),
-LimitSW1(Limit1),
-LimitSW2(Limit2)
+towelest::towelest(Serial* RS485,int address,PinName Limit0):
+pid(7.0, 0, 0, 0.01),
+LimitSW0(Limit0)
 {
-    Motor = new ikarashiMDC*[3];
+    Motor = new ikarashiMDC*[2];
     Motor[0] = new ikarashiMDC(address,0,SM,RS485);
-    Motor[1] = new ikarashiMDC(address,1,SM,RS485);
-    Motor[2] = new ikarashiMDC(address,2,SM,RS485);      
+    Motor[1] = new ikarashiMDC(address,1,SM,RS485);     
       
     Motor[0]->braking = true;
     Motor[1]->braking = true;
-    Motor[2]->braking = true;
     
-    pid.setInputLimits(-1800, 1800);
+    pid.setInputLimits(-6000, 6000);
     pid.setOutputLimits(-0.6,0.6);
     pid.setBias(0.0);
     pid.setMode(AUTO_MODE);
@@ -27,39 +23,14 @@
 {
     if(LimitSW0.read() == 1){
         Motor[0]->setSpeed(0);
-        Motor[1]->setSpeed(0);
     }else{
         Motor[0]->setSpeed(-0.2);
-        Motor[1]->setSpeed(0);
     }
 }
 
 void towelest::close()
 {
     Motor[0]->setSpeed(0.2);
-    Motor[1]->setSpeed(0);
-}
-    
-void towelest::lift()
-{
-    if(LimitSW1.read() == 1){
-        Motor[0]->setSpeed(0);
-        Motor[1]->setSpeed(0);
-    }else{
-        Motor[0]->setSpeed(0);
-        Motor[1]->setSpeed(0.8);
-    }
-}
-
-void towelest::descent()
-{
-    if(LimitSW2.read() == 1){
-        Motor[0]->setSpeed(0);
-        Motor[1]->setSpeed(0);
-    }else{
-        Motor[0]->setSpeed(0);
-        Motor[1]->setSpeed(-0.8);
-    }
 }
 
 void towelest::setPoint(int target)
@@ -76,14 +47,13 @@
 {
     pid.setProcessValue(loli);
     compute = pid.compute();
-    Motor[2]->setSpeed(compute);
+    Motor[1]->setSpeed(compute);
         //pc.printf("%d  %d  %f \n\r",Limit1,Limit2,Limit3,RotationDistance);
 }
 
 void towelest::allstop()
 {
     Motor[0]->setSpeed(0);
-    Motor[1]->setSpeed(0);
-    Motor[2]->setSpeed(0);
+//    Motor[1]->setSpeed(0);
 }
 
diff -r 1d0e66198bb4 -r 9f932b9adee5 towelest.h
--- a/towelest.h	Mon Sep 23 12:21:49 2019 +0000
+++ b/towelest.h	Thu Oct 03 08:42:09 2019 +0000
@@ -11,11 +11,9 @@
 class towelest 
 {
 public:
-    towelest(Serial* RS485,int address,PinName Limit0,PinName Limit1,PinName Limit2); 
+    towelest(Serial* RS485,int address,PinName Limit0); 
     void open();                 //展開
     void close();                //!展開
-    void lift();                 //機構昇降
-    void descent();              //機構降下
     void setPoint(int target);   //pid目標値
     void setPulse(int Loli);     //毎ループで呼び出し
     void pid_compute();          //毎ループで呼び出し
@@ -24,8 +22,6 @@
     ikarashiMDC **Motor;
     PID pid;
     DigitalIn LimitSW0;
-    DigitalIn LimitSW1;
-    DigitalIn LimitSW2;
     Timer timer;
     float compute;
     float time;