I'm trying to use a mosfet as an electronic load to measure the IV curve of a solar cell, but if I use it in linear region it dissipates too much power. I was thinking that I could use it in switching mode like sending a PWM value from a microcontroller, and set the output over drain pin, signal which should be a pwm as well as its input, but with the real value like modulate and demodulate the signal using a low pass filter. I have tried that and it works, the problem is that it doesn't produce the real IV curve, it shows a linear function. Could you advice me how can I use this mosfet in switching mode to produce that electronic load?. In the picture there's a scheme that I have used to achieve it.
In the circuit Current sensor is a ACS712 for 20Amps and the voltage circuit is just a voltage divider, both filtered signals go to a ESP32 Microcontroller.
Thanks, I'm a little frustrated and I would like to know the reason why this method is not as effective as a electronic load in linear region.