Rc Servo Accel/Decel
Ignorant question here. I am designing a tool changer (CNC mill) and am considering using a rc servo to position the carousel under the spindle then retract it out of the way. I would like for this action to happen fast (90deg in .2 seconds) but anticipate it banging against the ends of the travel. Any way to add acceleration/deceleration ramps to this? Mainly deceleration. Im assuming M280 will just rotate to the servos specified position as fast as possible and stop.
M280 just sets a pulse width. The servo picks how it responds. To do accel, etc. from the Duet, the pulse width would have to be "ramped over time". Anything can be done in firmware... but...
I'd consider making this desire for a "speed profile" (ramp up, move at this speed, ramp down) a part of the toolchanger. An Arduino Mini, either PWM or I2C from the duet, PWM to the servo. If the arduino "knows" the distance of move (I'm on tool 3 and need to go to 4, or 10, or ...) it can do more intelligent ramping.
Fairly simple code in the Arduino. Probably much more simple than modifying Duet/RepRap (unless you can talk Dave into offering this feature).
Great suggestion Danal. Probably best to reserve requesting DC's time for something more significant.
You should be able to get some degree of acceleration control by adjusting the supply voltage. If acceleration is too fast when running the servo on 5V, try putting a 1N400x diode in series with the positive supply to it, to reduce the supply voltage a little. Also put a 100uF capacitor between the servo positive supply and ground wires (or 220uF for larger servos) so that during deceleration the motor energy has somewhere to go.
I know there are servos you can program with accel/decel custom ramps, or with torque limits...
A Former User last edited by A Former User
openservo might be feasible now that you can get (assembled) boards from jlcpcb relatively cheap. but not sure if the board is actually too small for their service. but that allows you to upgrade a regular servo to a pretty smart one.
(seems the original project is long since abandoned but the v2 should be relatively simple to build)
3DPMicro last edited by 3DPMicro
I have been flying RC helicopters and airplanes for years and havent come across anything that controls accel/decel of the servo. However most transmiters have a function thats called Exponential (Expo) that kind of accomplishes this but not on the Rx end. Futaba and FrySky do have servos controlled by S-Bus. Totally over my head but maybe thats a possibility.
this Pololu servo controller states it can control acceleration. Can it be interfaced with a Duet 2?
or would it be simpler to go with Danals suggestion using an Arduino Mini?
Danal last edited by Danal
That polulu controller does 5V Serial TTL, so the Duet could control it. Needs a level converter (maybe, often 5V in logic will correctly respond to 3.3V out). Also looks like the acceleration command does what you want... but... there is no ramp down (decel). If you can live with accel control but no deccel, it looks like a very good choice.
If you need both accel and deccel, an arduino like device (for a one off) or an ATTiny (for production quantities) in the toolchanger seems like a really good answer. It can also be customized for other behaviors that benefit the toolchanger.
Note that ESP8266s are now cheaper than the cheapest arduino clone (unless you wait six or more weeks for asian shipping). About $4 each, with Amazon prime. They can be programmed in the Arduino IDE.
Gcode could contain something like M261 Ann Btt where nn is the i2c address of the toolchanger controller and tt is the tool number desired.
If you pursue this, let me know if you desire help with the code in the ESP8266.
If you are looking for a small device with hardware I²C slave, look at the ATtiny 841. I'm using it for a couple of projects, and it is very nice. A little bit pricy, though, but it is very flexible, have a lot of ADC, timers, etc...
3DPMicro last edited by 3DPMicro
Thanks for the advice Gents. I captured a couple screen shots to show what I'm thinking. I'm just sketching at this point and working through the design elements but I think the concept is solid. The wire frame sketch is a top view showing the ATC in position and retracted. The baby blue rectangle represents the servo which will have additional bearing support for the (yellow) swing arm. The pink rectangle is a nema 8 stepper driving the the green ring gear with 9:1 reduction = .2 deg per step resolution. So the servo swings the carousel in and out and the stepper rotates the carousel which rotates about the center hub via bearings. I have roughed out the sequence for the tool change macro and there will need to be some conditional code. My coding skills are pathetic so I will be begging for help in that department. The ATtiny is a good choice to operate the servo but should I go with an Arduino Mini since my minimal experience is with Arduino IDE (and Duet/RRF)? The Pololu wont work if it doesnt control decel since that would be the main requirment
my previous posts on machine
Arduino Pro Mini would be my choice for the prototype. I can help with the script, when you get ready.
The Pololu driver can't be controlled directly from the Duet, as it needs some specific protocol.
For the ATtiny841, you can have a look at my servo_node project:
It should not be complicated to add ramps in the main loop, at the CMD_MOVE FSM state...
Another solution is to used this device :
and reprogram it so it takes a servo signal as input, and control a servo on its output, managing the ramp. I used it to implement a specific behaviour with such in/out RC controls:
Again, you could implement the ramp in the main loop.
I think both can be programmed using Arduino IDE.
Thanks again for the input. Good to know there are options. I will get to work making it.