Hi all,
I have a stepper motor driver project I'm working on. It's based on dspic33 MCU and I have not problem with hardware part of it. So would welcome any suggestions.
I have PID controller implemented for each winding and currently it requires motor parameters to determine PID parameters - Kp, Ki. So idea is to try to measure L/R time constant and use it to derive PID parameters.
Here is how I currently do the measurements:
1. PWM frequency set yo 32.765 kHz and very low duty cycle - around 7 percent.
2. ADC completion interrupt triggered when PWM reaches certain value and reading stored in the buffer, see question 4
3. Once 64 ADC reading obtained, I shutdown PWM and try to calculate time constant, see question 2.
My question is around software part.
1. Does it makes any sense to measure L/R to derive PID parameters? it seems commercial ICs doesn't do that and still works very well. What parameters to choose than?
2. I think I might need to measure few times with different duty cycles or may be different number of readings, to address the following questions
2.1 How to detect that what was measured is actually exponent. what if load is pure resistance?
2.2 Does current reached steady stat, what do do if not? re-measure for longer time or increase duty cycle?
2.3 Currently I calculate steady state voltage though applied to the motor by multiplying PWM duty cycle by my rail voltage, should work well if I have inductance load, not so well if it's only resistance load.
3. Currently I have PI controller, but it has issue retaining current at required level, as it keeps oscillating (this leads to low frequency hum in a few kHz range, very annoying) unless I set PID parameters really low, and which case current raise time get unacceptable (so it can't step as fast as I want to). So I want to explore full PID controller option, as differential part of the controller should calm the oscillation while allowing to keep controller gain high. Does it make any sense to use full PID controller?
4. Last one is more about MCU, if I decide to go with time constant auto measurement, I need a buffer to keep ADC reading during the calibration (let say i need 128 Q16 readings for each winging), but once parameters are determined I don't really need that buffer, so what would you suggest for that? I don't really want to go for a full heap management solution. Any lightweight solutions? Driver is written in C, so wants to avoid any assembler if I can help it.