rcarlyle / StepperSim

Simulates stepper motor driver systems
MIT License
100 stars 11 forks source link

THB6128: Mixed decay "forced fast decay" mode has some incorrect edge cases #29

Open rcarlyle opened 8 years ago

rcarlyle commented 8 years ago

When the THB6128 is in mixed decay and the on-phase blanking time is entirely above the target current for its entire duration, the driver switches to fast decay for the entire remainder of that PWM cycle. This primarily comes into play during falling-current microsteps to let the driver hit the target faster.

The way the sheet captures this behavior is to check if the tick is in a blanking period, and if so, check if the initial current in that tick is above the target current. This works ok, but some edge cases cause it to not work properly: 1) If the current rises above the target during a blanking period, and a new tick is created after that, so the last tick within the blanking period only "sees" the portion that is above the target. 2) If extremely high back-emf causes the current to drop from above the target to below the target during the blanking period. (Super unlikely)