Conversation started Sep 22, 2017 at 8:50.
Sep 22, 2017 08:50
hmm, I think I'm still not getting the idea of combining a constant current source with a PWM modulation
like, it doesn't seem that simply interrupting the circuit would produce credible current results
certainly not the right way to measure wind speed...
I'm trying to understand this
lots of text, tl;dr but driving an LED with a pwmd constant current sounds like dimming, though I probably would not do it that way but build an adjustable current drive
@PlasmaHH what's the difference?
@BartekBanachewicz flickering
Sep 22, 2017 09:01
@PlasmaHH isn't that how most e.g. automotive LED headlights are driven?
They all flicker in high-speed shots
well, I was specifically aiming for high efficiency, as this is supposed to run off a battery
yep, they suck
you know buck converters?
@PlasmaHH yep
before you go any further though
so far my plan was to measure the current with a MCU and adjust pwm accordingly controlling a mosfet
I've opened the TL4242 diagram and well
many ways to skin a cat
that's just what it is.
the key is that since LEDs are current driven what you want is to have the control loop control the current, not the voltage as it is traditionally done
Sep 22, 2017 09:05
@PlasmaHH again, the idea was to use a known resistor and measure voltage drop on it
but this can't be done directly since the lower that goes, the lower the voltage you're supposed to measure drops
and obviously the lower the better because it's just causing losses there
you can amplify the voltage drop over a shunt resistor
thats how daves µcurrent does it and likely his gw121 too
@PlasmaHH what's a shunt resistor?
the resistor you measure voltage drop over to get the current through it
oh okay
@PlasmaHH oh yeah. The PDF I linked uses an op-amp there if I'm reading this correctly
you can also have the µC create a voltage that sets the wanted current for an all analogue boost converter
Sep 22, 2017 09:08
that was my idea as well
@PlasmaHH doesn't that operate on voltages as well?
lets step back a moment and look at a linear regulator like thing. you have a voltage going into an opamp, and the opamp drives a pass transistor and gets the feedback from the transistors output voltage. so that voltage at the beginning controls the voltage of the transistor
then you can change that into taking the voltage drop over a shunt resistor as an input, so it gets a current source.
@PlasmaHH I see
then you make it so the reference voltage comes from a µC and you have a linear current source controlled by a µC
so the only change here is that the uC doesn't have to do the analog measurement
then you replace the opamp+transistor by a buck converter that gets the feedback from the shunt resisotr
it also doesn't control the pwm that drives the buck converter
usually a µC is rather slow compared to opamps and stuff to react to necessary changes when the load or input voltage chaange
Sep 22, 2017 09:14
well, in this case the only changes should be the LED warming up and battery draining; I've already constructed the battery measuring circuit which seems to work well, even if it's a tad inaccurate
I think I like the idea of having the current set outside of the mcu though
as I said, many ways to skin a cat
@PlasmaHH this part I didn't understand though, despite my best efforts
so in the opamp case, the measured current (drop over shunt) is added to the PWM from uC and fed to the transistor
nope
oh
so I got lost even before that ;)
at least not if you mean the case I described
Sep 22, 2017 09:17
> you have a voltage going into an opamp
you know how the basic job of an opamp is to drive its output in way that the difference between its innputs is 0 ?
@PlasmaHH well, I thought I did
ok, so let the µC produce a voltage, say 1V
you feed that to the opamp as the reference
then you feed the voltage drop of the shunt resistor to the other side, as the feedback, and the output of the opamp drivers the transistor
so the opamp will now do whatever is necessary to the trasnsitor to make the current through the shunt drop 1V
@PlasmaHH I think I sorta meant that but worded myself badly
so if the shunt drops 1V at 1A you make the µC output 2V to have 2A curretn etc.
Sep 22, 2017 09:21
ok, how about when it drops very little? like 0.001V?
I obviously can't output 2000V from a pin
you have two choices (or anything in between that). You create such a low voltage, or you amplify that voltage
2000V would be 2000A ^^
so it also depends on the wanted range.
@PlasmaHH ok so I kinda see where I got lost, I mixed two things we're doing here: amplifying the shunt voltage drop and keeping the current constant.
0.001V to 10V over a shunt is going to be rather difficult
Sep 22, 2017 09:23
@PlasmaHH well the LED is rated at around 3.7V
you drive one or many of them?
and at what current range?
and what input voltage? 12V car battery?
@PlasmaHH it's one Luxeon K2, supposedly 5W. Driven from a 6V 5-cell NiMH pack
that being said, I am not sure if the lamp itself doesn't have some additional compoents; I don't see the LED, as that's enclosed, and there are 3 wires going out. I am not even sure what the third one is for.
what does the datasheet say?
@PlasmaHH that in order to get the maximum power it shouldn't need more than 3-something V, but I tried with 5 and only got about 60mA of current
I haven't actually tried bringing this up even more. Now that I have the PSU it should be safe to kinda crank it up a bit
you might have fried it, don't put 5V onto a 3.7V LED
Sep 22, 2017 09:28
it still lights up
well I was observing the current and slowly raising the voltage
and the current and produced light was nowhere near what I'd expect
Have you observed the drop over the LED? also, even when it lights up it might be damaged. Also you might have a fake device, who knows.
and you should cnosult the datasheet about the third "wire".
@PlasmaHH I hooked the meter right next to the battery. And it's not fake, it worked before, it's just the controller that died.
you should measure over the LED
@PlasmaHH There's none.
no datasheet?
Sep 22, 2017 09:31
@PlasmaHH I mean, the LED is inside a lamp, right. So the LED datasheet doesn't mention the third wire, it's something the manufacturer might have put there
like a temp sensor for example
uh, oh, so further disassemble it? ^^
@PlasmaHH I'd rather not if I don't have to I guess
anways, back to the shunt resistor. Lets take 100mΩ and when you run 1.5A through it that means 150mV drop that should be plenty of room to deal with
you will ahve little choice, obviously its not just the LED in there, or you have a different device than you thought
@PlasmaHH I guess
well I'll try taking this apart today then to see what's actually inside
@PlasmaHH so my PWM would need to range from 0 to 150mV?
It should be not much of a problem for a µC to create some voltage between 0 and 150mV and for increased accuracy you could use a divider and have the µC create higher ranges
Sep 22, 2017 09:34
yeah, I was planning to operate on 3.3V, so 0.15 is about 5%
(if you want to use the µC pwm to create that voltage you obviously have to filter it to make it (near) DC, and if the µC has an analogue input pin you can measure that voltage too)
wait, measure the voltage I'm putting out myself to control the opamp?
0-3V divide by 20 could work
yes, pwm isn't a voltage itself, its just a square wave, you have to filter that to make it like DC ... if your µC has a DAC output then that would be easier though
I don't think it does
but yeah, good point; so far I've been driving a MOSFET directly, with the idea that the average needs to be right
in this case it would probably make sense to make sure it's an actual DC voltage
so what frequency is your pwm? make a simple low pass filter way below that and you have it output mainly DC
feedback that DC to the µC for increased accuracy and adjust pwm accordinly
Sep 22, 2017 09:38
@PlasmaHH I didn't think that would ever be necessary, huh.
@PlasmaHH I was planning to use ATTiny 13
well maybe, maybe not, as I said, increased accuracy, many ways to skin the cat
way too many :)
at least anything like this will make it much easier on the coding side of the µC and it will make it possible for you to split it into two independent parts
you can program the µC to output the DC and until you get that right you can feed into your opamp some DC from another source taht is not the µC to test that and at the end connect both modules
imho much easier as a project when you are not experienced
@PlasmaHH yeah I've been trying to modularize it, so far I've split it into 4 parts - battery measurement, UC power, UC itself/PWM, power control
 
Conversation ended Sep 22, 2017 at 9:41.