how do you achieve a limited constant current?
By feedback control. Your processor will know what the current is at any given time by the current feedback measurement it reads. If the current raises above the set value then it reduces the voltage output of the regulator to keep the current at the set value.
Keep in mind that there can be up to three different possible control modes your power supply can be operated in if that is your desire, Constant current, current limited, and constant voltage.
In constant current mode, your program will either raise or lower the regulators output voltage to keep the current exactly at the desired current value. It can maintain a constant current only up to the maximum output voltage capacity of the voltage source. However it can maintain a constant current value into a direct short to ground by lowering the output voltage to just above 0vdc depending on the actual resistance of the ‘short circuit’.
In current limit mode, your program will keep the regulators output voltage at the desired constant voltage unless the programmed current limit is reached, where it will only then reduce the output voltage by the amount needed to keep the current at the programmed limit.
In constant voltage mode your program will just keep the regulator’s output voltage at the desired amount. Only if the current draw exceeds the maximum rating of the regulator where it should either shutoff or enter a current limit control mode where it reduces the output voltage as needed to keep the current at less then the supplies maximum limit.
Some bench supplies don’t include the constant current mode, just the constant voltage or constant voltage with current limit mode. However working with high power LED circuits the constant current mode is a nice feature.
You will have to study the software program you are planning to port over to see which modes it supports and either add or take out any mode you don’t wish to implement.