I have a motor driver whose voltage input ranges 12~30V, and max continuous current can be up to 30A.
Here, I want to power up a big dc motor, whose nominal voltage is 24V, and nominal current 15A.
What I'm worry about is that when I start the motor, the starting current is expected to be larger than the motor driver's capacity. to prevent this excessive current burn my motor driver, I made this psudo-code. basic idea is gradually increasing PWM signal's duty cycle from 0 to 255.
Arduino pin 12 - Motor driver "enable" pin (setting this high lets motor driver run in one direction)
Arduino pin 10 - Motor driver "PWM" pin
Arduino pin 2 - a toggle switch
A motor slowly decelerates by itself when power is removed. Why do you think you need to augment that?
If you are just performing a "soft start" of the motor, the actual timing will depend on the motor, the application, the power supply, etc., but no matter what those are, you should control the timing in code, not leave it to the arbitrary timing of the loop() function. As you add more code to loop(), the motor timing would become slower and slower, unless you do that... also it would be more difficult to know exactly what the timing is...
A motor slowly decelerates by itself when power is removed. Why do you think you need to augment that?
Because I haven't studied enough. I'll make a note here, sudden stop of DC motor doesn't cause surge current...
anyway I think I can figure out that "timing" with some experiment. a way too slow acceleration can matter in terms of efficiency or speed... whatever, but not excessive surge current. right?
A sudden stop will generate a surge if you apply electromagnetic braking. If you want to stop it dynamically, that is a similar but different problem. In that case, there is no static friction in the armature to overcome. With most driving circuits, in the absence of explicit braking, there would still be some braking due to absorption of back EMF in the driver protection diodes.
The appropriate method of finding the correct timing is your personal choice as a designer. But I strongly advise you to utilize a controlled timing source such as the millis() function, rather than depending on, and perhaps having to play around with the code.
Also, some power supplies safely limit the current, so that the power supply itself might provide the protection from start up currents that you need.
I wasn't able to think about power supply. I have 24V SMPS, maximum current 20A. so there will be no such a large current that may burn my motor driver.
May I ask why do I need to try conencting the motor directly to the supply?
I am planning to power a number of small motors with the power supply. I don't think I need to run them at the same time.