This time I approach the community to ask for help regarding security measures for a project with Arduino nano.
The project consists of a cable camera (the code is available on github https://github.com/olveragit/cablecam-OLVERA/releases) and has the following characteristics:
Control is done by radio frequency
LiPo batteries are used
Modified action camera with optical zoom lens
Arduino nano
Nema 17 stepper motor
Driver TMC2209
Servos to control zoom and focus
hcsr04 ultrasonic sensors to stop movement at a certain distance.
I wonder if anyone knows a way to program a slowdown of the stepper motor in a smooth way when distance is very short, to avoid a complete braking that would be the equivalent of the device crashing on the edge.
You could also try my MobaTools library. It contains a stepper class with acceleration and deceleration. All methods to control the stepper are not blocking, and the steps are created by timer interrupts in the background. So you don't have to bother with step generation in your sketch. Documentation and examples are provided.
That looks good. Is Sparkfun Redboard Turbo supported (SAM D21)?
Looks like the maximum step rate is 1000 steps / sec. Is that the case?
A quick look at the docs seems to indicate variable acceleration is not supported?
You need to do that in your own code outside MobaTools?
No, unfortunately the SAM D21 is not yet supported
The max. steprate depends on the target platform. For AVR processors it is 2500 steps/sec. If you use less than 6 steppers and no other functions that load the timer interrupt ( softleds ) this can be set up to 5000 steps/sec ).
ESP32 and STM32F1 reach more than 20000 steps/sec.
What do you mean with 'variable acceleration'? You can change the acceleration at any time - even while the motor is accelerating/decelerating.