I've come across a few transistor current limiter schematics, similar to this one:
However, I am not entirely sure how I could implement microcontroller functionality to control this. I think Rsense would cause Q2 to conduct if at a threshold (0.65V assumably) and Rbias will determine how much it will be limited, however that is unclear to me, especially if Rsense will be somewhere highside and just turning on Q2 with my uC seems to not do anything (in simulation at least)
How would I come up with the formulas for a variable limit that I can control? I would rather not have to use a digital potentiometer in place of R2, if I can somehow have sense voltage compared with a comparator with a voltage my uC defines, that'd be great! But how could I start the limiting? What do I "turn on" when the sense resistor shows enough current? Does Rbias have to be there to limit it to a certain level, and I'll end up having to use a digipot anyway?
Any solutions to a uC controlled current limiter would be great, that can be controlled easily with just a pin or two.