Hello, I am implementing a MPPT state machine and I want to limit the duty cycle to be in a limited range (between min and max value). as you can see below, in the if-statements structure, you can see decrement and increment of the duty cycle. I want to avoid modifying the if-statements structure to make the duty cycle limited because it will complicate things a lot. I would rather see other approaches maybe using functions.
Any recommendation pls ?