I have used Qspice for digital control with advanced efficient digital PWM generation for almost 3 years, anyway my coding style was never user friendly and it hindered wider use by the community.
So, this time I tried to make a template for Qspice C-block template/example for digital control application that is hopefully easy to understand and modify to suit the user need.
Welcome to let me know on how to refactor the code to make it easier to understand and modify. and also how to improve the PPT explanation.
**the PPT is generated by gemini though… still lazy to make proper explanation…haha
Digital Control C++ Template Guide.pdf (1.8 MB)
2 Likes
welcome to try the Gemini generated html based template generator
digital_controller_template.html.txt (24.1 KB)
*note: after you download this, remove the .txt
I tried quickly, and it can compile fine
The template generator is now added to my website
1 Like
nice work ! also ill take a look on you git stuff
Welcome to let me know for any feedback
A few calculation macro commonly used in digital control SMPS has been added to the template.
PI controller
Limiter
Low Pass Filter
SOGI → very useful as Band Pass Filter
A modification of discontinuity direct hit algorithm has been developed that is inpired from PLECS user manual, from “Zero-crossing function” section for C-script.
The key trigger is: "If any one signal changes its sign during the current integration step, the step size is reduced so that the next major time step occurs just after the first zero-crossing. ".
From which I modify the timestep algorithm to target just slightly right after the target time. Additional modification is also performed to change how the if(stepped) used.
The result for the simple SR buck circuit is quite wild. it leads to 50% total simulation time reduction in my laptop from 10.x sec to 5.x sec with around half the total solver steps (1292310 vs 602207).
Note: a slight extra jitter on the modified method can be observed. Thus, both timestep direct hit is provided when using the code generator with the modified method as the default.
The updated timestep control algorithm is now provided in the code generator in my website.
1 Like