台形制御用ライブラリ

Dependents:   kisoken_PenPlotter

Revision:
1:15adfb7ee64c
Parent:
0:a7573f3f2207
Child:
2:a43e90cb271c
--- a/trapezoidalMotionCal.cpp	Thu Aug 03 06:50:03 2017 +0000
+++ b/trapezoidalMotionCal.cpp	Thu Aug 03 12:42:12 2017 +0000
@@ -13,10 +13,6 @@
     shortMode = 0;
     revMode = 0;
     
-    step_accel = (f_max * f_max - f_start * f_start) / (2 * a_up);
-    step_decel = (f_stop * f_stop - f_max * f_max) / (2 * a_down);
-    
-    
 }
 
 void trapezoidalMotionCal::setTarg(int32_t targ){
@@ -28,7 +24,9 @@
         targSteps *= -1;
     }
     
+    step_accel = (_f_max * _f_max - _f_start * _f_start) / (2 * _a_up);
     step_const = (double)targSteps - step_accel - step_decel;
+    step_decel = (_f_stop * _f_stop - _f_max * _f_max) / (2 * _a_down);
     
     if (step_const <= 0) {
         shortMode = 1;