I'm building an engine speed controller using a 16 bit microcontroller for a gasoline engine. I have a 1.8 degree resolution stepper motor coupled to the throttle plate which moves the throttle angle to the target position.
The objective is to regulate the speed of the engine to one fixed setpoint in terms of RPM. I'm measuring the engine speed with a magnetic pickup and calculating RPM in the microcontroller. My stepper motor driver simply works by setting a direction and number of steps which is generatred from the micro.
I'm trying to set up a good PID control loop. I have implemented some code, but am a bit confused over some of the algorithm options. I'm considering using a velocity form (incremental). Basically, the engine speed is the feedback which is subtracted from a reference RPM and fed to the PID controller. The output of the controller would be throttle angle (I think?). The throttle angle then results in a certain engine RPM for a given load (highly non-linear of course).
The problem I'm having is a conceptual one as to how to treat the stepper motor and the associated input to the "plant". I understand that a stepper motor is a "self integrating" device, but I don't have a good intuitive feel for what that means in real-life.
Is the proper way to implement?:
- Use an incremental algorithm to calculate my *change* in throttle angle for each sample period.
- Take this delta, and translate it to stepper motor steps (and direction) based on the change in throttle angle.
- Update this calculation each sample period
The unknowns to me are:
- Can I use a positional algorithm instead of incremental by taking the PID output and subtracting the last position to generate a delta and send that to the stepper? I have tried implemented the algorithm as positional and simply send the PID output (after translating to # of steps) and send that directly to the stepper - this seems to function but do I wind up with an extra, unwanted integration? In this scenario I interpreted the output of the PID as a delta position as opposed to absolute position, and to my surprise is seems to function reasonably well.
- I am presently running the stepper motor at a fixed speed and always microstepping to 1/8 step. I could conceivably play with both the step speed and the step resolution in real time to create acceleration. Would this be of any benefit.
- I've read about Three-Position Pulse Output type algorithms, which seems to be similiar to what I'm doing - how does this apply?
- My PID sampling period is 30ms. With the current stepper speed, I would take upwards of 200ms for it to travel its entire stroke. This means my actuator would not be finished positioning when the next PID loop rolls around. Is this a problem?
Thanks for any feedback,