Thanks again HackFridgeMagnet for your insights, and thanks T4P for jumping in!
To answer both your comments, I am using a Ledengin 10W RGB led that has R/G/B Fv of 2.0/6.4/3.2 and I am trying to find a good solution(here good also includes efficient although it's not my #1 priority) to control the three channels with one AtTiny. My goal is to build a current controller cheaper than "ready-to-go" package like the LT3518 I was using earlier or equivalents that cost $5 to $8. Turns out to be a very interesting challenge with lots of learning on the way
So I have built the design I sent two days ago. I used BC547/BC557 for the BJTs and a FQPF13N6L for the Mosfet. The inductor is 15uH, the LED capacitor 4.7uF and the zener is a 1N5361BG.
I have added two buttons that allow me to change the Ton period. The Ton+Toff is 8uS right now. All of this is breadboarded of course
This is a capture of the voltage at the gate (red) and at the drain (yellow) of the mosfet. You can see that it looks like the mosfet starts conducting current again before the beginning of the new period. I had never seen this in my simulation, any idea where that might come from?
Where do the huge oscillations at each state change come from? How could I reduce them?
This is what the PWM signal looks like out of the AtTiny (in red) and what the output of the RC filter looks like (in yellow). As you can see, it is extremely noisy but measuring this with my Fluke gives me very precisely what I expected (that is Idiode = Urcfilter * DutyCycle * 1/0.1ohm).
I have decoupling capacitors on VCC and on my 5V. I also added a 10nF capacitor on GND/VCC of the Attiny otherwise it kept resetting every time I increased the duty cycle. I am now fighting with the ADC converter, without gain and using VCC as the reference, it returns 2.5V for the rc output. This is not right... will look at this more tomorrow. I am hoping I will still be able to read something through the noise.
thomas