STM32 DAC controlling a current source

Thread Starter

ellij

Joined Nov 2, 2025
3
I want to control 2 H11F1M photofets in series using a STM32 12 bit DAC. I am using 2 as I need to get a lower on resistance. I had a play in LTspice and came up with a very basic circuit. I will have 5V available but also 12V I can regulate to a different voltage if needed. The DAC can output 0 to 3.3V and the photofets need 30mA each to be fully on.
Image 03-11-2025 at 15.38.jpeg
 

Thread Starter

ellij

Joined Nov 2, 2025
3
The control will be in series(anode cathode). The signal going through the optofet will be parallel (Terminal Terminal)
 

panic mode

Joined Oct 10, 2011
4,945
still not sure what you actual target circuit is.
but assuming you want DAC output that is 0-3.3V to translate to something close to 0-65mA and ... preferably linear, while using single supply like 5VDC that is already available...

first problem is that part of the range is lost (0-0.6V) since transistor does not get turn on by lower voltage.
the second is that you did not model the emitter diodes. their combined Vf is couple of volts and two resistors totaling 0.11 Ohm are poor model for something that consumes 0-60mA
the third is that you re using two photo-fets where one would do (or maybe none... have not seen actual circuit).

if my assumption is correct, something like this would give you much better control:
1762303222076.png
 
Last edited:

panic mode

Joined Oct 10, 2011
4,945
explanation, R1+R2 are voltage divider. objective is to bring V(in+) to some reasonably low value .
this limits voltage drop on R2 and R4 - giving plenty of range for load (D1). you can change values too
R1=330
R2=220
R4=22
to get similar results.

Basically U1 and Q1 form adjustable current sink - controlled by V(in+).
 

Thread Starter

ellij

Joined Nov 2, 2025
3
Thanks @panic mode.
I want the resistance through the photofets less than 100ohms which is why I am using 2 in parallel. They will be in a circuit that will attenuate a differential signal, ideally they would be close to 0ohms to fully attenuate but can live with 50ohms. Similar to an H-Pad with the photofets in the middle. I am using a MCU DAC rather than PWM because any ripple could/would effect the signal.
I had hoped to avoid using an op amp and control the transistor with just the output of the DAC. I have a voltage regulator that I will use to step down 12v for the circuit. The MCU has its own power supply as it can enter a low power standby mode.
I had thought about using an LDR (NSL32SR2) but these would be harder to control I believe.
I am
 
Top