Teknic-ClearPath / ClearPath-Arduino-Step-And-Direction

23 stars 20 forks source link

feature request: decelerate to stop #3

Open stephanschulz opened 3 years ago

stephanschulz commented 3 years ago

Thank you for making this library. It is super helpful.

I would love to have one more feature; a stopDecelerate(). Currently the stopMove() causes an abrupt stop, as your commands state.

Do you think there is any way to interrupt the current motion and quickly but safely decelerate? This would allow me to safely change directions when using your motors for live action motion changes.

Thank you for any help.

youcangetme commented 3 years ago

I would like to add to this the ability to check where the library thinks the current steps are at. Right now you command it to position X and did it really get there? Check the HLFB and if in an alert state, where am I?

And!

If I call stop, where did I stop? How many steps have been executed? I will now need to re-home to find my zero.

Right now I use the stop function during homing because my homing procedure is custom. I use relative positions which is good 99% of the time but if somebody hits the e-stop I have to re-home the application.

stephanschulz commented 3 years ago

I find "X.getCommandedPosition()" works very well to get the current position, even while a move() is still happening.

For now instead of adding to the library to achieve the stopDecelerate() I just ramp down the MaxVel and then call stopMove().

  if (rampDownVel == true) {
    curVel = curVel - 200;
    if (curVel <= 0) {
      rampDownVel = false;
      curVel = maxVel;
      X.stopMove();
    }
    X.setMaxVel(curVel);
  }
youcangetme commented 3 years ago

That call returns the position you commanded it too, not where you are...

stephanschulz commented 3 years ago

interesting.

in my case when printing via Serial.println(X.getCommandedPosition()); I get changing number


0
0
0
1
2
2
4
5
7
8
10
13
16
20
24
28
33
38
43
49
54
60
67
74
81
88
97
105
115
127
139
152
164
177
192
206
222
237
252
270
287
305
323
341
361
380
402
422
442
466
487
511
534
557
583
607
634
659
685
714
740
770
798
826
858
887
920
950
981
1015
1053
1095
1135
1178
1219
1265
1307
1354
1398
1447
1492
1542
1589
1641
1689
1742
1792
1847
1898
1950
2007
2061
2120
2175
2235
2291
2353
2411
2475
2534
2599
2659
2724
2784
2849
2909
2974
3034
3099
3159
3224
3284
3349
3409
3469
3534
3594
3659
3719
3784
3844
3909
3969
4034
4094
4159
4219
youcangetme commented 3 years ago

OK, correction. That call is not absolute position but steps executed. I also saw this pop up in my email inbox and didn't realize that this IS NOT the ClearCore libraries. I apologize for the confusion. I used these libraries briefly a while ago. I use the ClearCore libraries now.