Author Topic: RFC: 1-Wire PWM dimmer/motor controller for 12V vehicle systems  (Read 23257 times)

0 Members and 1 Guest are viewing this topic.

Offline LomaxTopic starter

  • Frequent Contributor
  • **
  • Posts: 565
  • Country: eu
  • Minimalist
Re: RFC: 1-Wire PWM dimmer/motor controller for 12V vehicle systems
« Reply #75 on: April 15, 2017, 10:33:29 pm »
I'm now updating the schematic to use the TPS1H100 high-side "smart switch" suggested by ovnr - a great little chip that solves several issues, and adds one or two bells/whistles. But I'm having trouble calculating the value of the programmable current limit resistor; the formula given in the datasheet refers to a value KCL, but doesn't explain what this is or how to derive it. In the application examples the value used for KCL is 2000, but again no explanation given. I assume this is because people who know this stuff don't need to have it explained to them - alas I'm not one of them... Can anyone help me understand?
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12853
Re: RFC: 1-Wire PWM dimmer/motor controller for 12V vehicle systems
« Reply #76 on: April 15, 2017, 10:47:42 pm »
K and KCL are specified as parameters - datasheet page 7
 
The following users thanked this post: Lomax

Offline LomaxTopic starter

  • Frequent Contributor
  • **
  • Posts: 565
  • Country: eu
  • Minimalist
Re: RFC: 1-Wire PWM dimmer/motor controller for 12V vehicle systems
« Reply #77 on: April 15, 2017, 11:43:56 pm »
Ah, there we are, thanks! Didn't come up when I searched for some reason.
 

Offline LomaxTopic starter

  • Frequent Contributor
  • **
  • Posts: 565
  • Country: eu
  • Minimalist
Re: RFC: 1-Wire PWM dimmer/motor controller for 12V vehicle systems
« Reply #78 on: April 16, 2017, 12:23:01 am »
Humm. I liked the look of the current limiting functionality on the TPS1H100 at first; since it's a closed loop I thought I might be able to use it to create a constant current source of sorts, but I see now that it's only got a precision of ±20% at 0.5 A. The LEDs I plan to use for general lighting want 200mA, but will run hot at 240mA, and noticeably dimmer at 160mA. I guess this is not the intended use for this function... Should I bother configuring it for the intended load current, or just set it so some safe, higher current?

Edit: Now looking at Allegro's A6217 Automotive-Grade, Constant-Current PWM Dimmable Buck Regulator LED Driver. Much better for lighting (no flicker, matching brightness on all LEDs, higher efficiency, less LED stress), but no good for controlling fans or other motors. Humm...

Edit: Nah, that won't work; the large difference between VIN and VOUTMax mean the lights would only work when VBAT is at or near its maximum. I do want to be able to use 12V LED modules, and they must produce a usable amount of light even when the house bank is close to being fully discharged (~11.5V). I shall have to sleep on it.
« Last Edit: April 16, 2017, 01:40:48 am by Lomax »
 

Offline ovnr

  • Frequent Contributor
  • **
  • Posts: 658
  • Country: no
  • Lurker
Re: RFC: 1-Wire PWM dimmer/motor controller for 12V vehicle systems
« Reply #79 on: April 16, 2017, 09:25:18 am »
The TPS1H100 current limit is intended to act as a fast, self-resetting fuse - it's not meant to regulate any current, just prevent it from exceeding a threshold.

Just PWM the LEDs, if they're basic 12V resistor-ballasted strips. If you need a closed-loop solution, sense their current and use that to inform whichever algorithm you use to choose the PWM setpoint. They're LEDs; it's not like you need to do this at a very high rate.

If you're using LEDs with integral drivers, you're out of luck on anything above on/off control, unless you really want to roll your own proper LED drivers.
 
The following users thanked this post: Lomax

Offline LomaxTopic starter

  • Frequent Contributor
  • **
  • Posts: 565
  • Country: eu
  • Minimalist
Re: RFC: 1-Wire PWM dimmer/motor controller for 12V vehicle systems
« Reply #80 on: April 16, 2017, 01:42:54 pm »
The TPS1H100 current limit is intended to act as a fast, self-resetting fuse - it's not meant to regulate any current, just prevent it from exceeding a threshold.
Yep, I realised this when I read the datasheet a bit more carefully. Still a nice feature.

Just PWM the LEDs, if they're basic 12V resistor-ballasted strips.
I'm not sure what you mean by "resistor-ballasted strips"? The LEDs in question are cheap 12V "under cabinet" modules, which may or may not work ok at higher voltages: I have purchased three different models for testing, two of which are fine at higher voltages, but the ones I would prefer to use (due to colour rendering, beam characteristics, and physical size) run very hot at higher voltages. Hence my interest in current limiting; 200mA provides full brightness (~2.5W) while leaving these LEDs nice and cool.

While I can approximate this with a gamma curve, it may be difficult to get all LEDs on a given power supply chain to be equally bright under varying levels of charge (there will be some voltage drop along the cable length). House bank battery voltage can vary between something like 14.5V and 11.5V, and while some change in brightness is acceptable I need the lights to function throughout this range. PWMing at too high a voltage might also stress the LEDs, even if they're not running hot; each "on" pulse would drive a higher current through the LED than it is designed for. I am not sure how important this is, but it's something I've been thinking about.

If you need a closed-loop solution, sense their current and use that to inform whichever algorithm you use to choose the PWM setpoint. They're LEDs; it's not like you need to do this at a very high rate.
This might be the way forward, but I'm not sure the current sensing ability of the TPS1H100 is precise enough?

If you're using LEDs with integral drivers, you're out of luck on anything above on/off control, unless you really want to roll your own proper LED drivers.
There are PWM dimmable LEDs with integrated drivers for automotive use; I have also been experimenting with four reading lights using dimmable G4 LED modules with built in drivers, which behave very well at all voltages and dim very well with PWM. In fact they're quite lovely, very similar to halogens. Maybe I should be looking for something similar for my in-ceiling lights.

Edit: Actually, looking at the datasheet again, the current sense precision is better than ±5% at the currents we're talking about here - that should be plenty good enough. So I'll need to integrate the current measurement with the PWM gamma curve. Should be doable.
« Last Edit: April 16, 2017, 02:02:48 pm by Lomax »
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12853
Re: RFC: 1-Wire PWM dimmer/motor controller for 12V vehicle systems
« Reply #81 on: April 16, 2017, 02:23:47 pm »
There is an alternative. other than replacing the resistor ballasted LEDs.  You could add a switching regulator (buck converter) in the feed to all the ceiling LEDs in one cabin to maintain a stable 12.0V supply to them as long as the battery voltage is above that level.  To minimise the standing current drain, either you'd have to use one with a very low quiescent power consumption, or one with a shutdown pin, with another BAE0910 controlling it, acting as a master switch for the lighting zone.

Another matter:  Have you considered what happens to a BAE0910 and the 1Wire bus if its local 5V supply is missing?   I suspect bad things happen, and tgat it will drag the bus down, with the possibility of latchup if power is reapplied to it while its connected to a powered 1Wire bus.   The cure would be a MOSFET switch between it and the bus that will isolate it if its not powered.  A 2N7002 should do the job, Source to DQ, Drain to the bus and gate pulled up to +12V via a fairly large resistor, so it can swing with the bus due to the gate to channel capacitance rather than adding extra capacitive loading.  When the +12V is present, there will be at least 7V of positive gate bias and the 2N7002 will be hard on.  When the +12V supply is absent, other loads will drag it down to 0V, and there will be 0V of gate bias, so the 2N7002 will be offr.
 
The following users thanked this post: Lomax

Offline LomaxTopic starter

  • Frequent Contributor
  • **
  • Posts: 565
  • Country: eu
  • Minimalist
Re: RFC: 1-Wire PWM dimmer/motor controller for 12V vehicle systems
« Reply #82 on: April 16, 2017, 03:30:42 pm »
There is an alternative. other than replacing the resistor ballasted LEDs.  You could add a switching regulator (buck converter) in the feed to all the ceiling LEDs in one cabin to maintain a stable 12.0V supply to them as long as the battery voltage is above that level.  To minimise the standing current drain, either you'd have to use one with a very low quiescent power consumption, or one with a shutdown pin, with another BAE0910 controlling it, acting as a master switch for the lighting zone.
Yep. I have looked at some 10-20V > 12V DC/DC converters with high efficiency (remember that I want to keep losses to a minimum). It might be an idea to have one large stabiliser for the whole house system, thus ensuring a reliable 12V at all times - but even a highly efficient one (>90%) feels like an unnecessary waste?

Another matter:  Have you considered what happens to a BAE0910 and the 1Wire bus if its local 5V supply is missing? I suspect bad things happen, and tgat it will drag the bus down, with the possibility of latchup if power is reapplied to it while its connected to a powered 1Wire bus. The cure would be a MOSFET switch between it and the bus that will isolate it if its not powered.  A 2N7002 should do the job, Source to DQ, Drain to the bus and gate pulled up to +12V via a fairly large resistor, so it can swing with the bus due to the gate to channel capacitance rather than adding extra capacitive loading.  When the +12V is present, there will be at least 7V of positive gate bias and the 2N7002 will be hard on.  When the +12V supply is absent, other loads will drag it down to 0V, and there will be 0V of gate bias, so the 2N7002 will be offr.
I had not. Thanks for pointing it out - I have added such a switch to the schematic. You reckon it should sit before or after the ferrite bead on the data input?

Still working on the updated schematic using the TPS1H100; since it wants 3-5V on the IN pin (7V max) I can't drive it with an opto @ 12V - should I drop the idea of a separate floating data GND? Kinda liked the concept, like a pseudo differential signalling scheme, but have no idea how much it would help improve 1-Wire noise rejection. Perhaps not worth the effort?

 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12853
Re: RFC: 1-Wire PWM dimmer/motor controller for 12V vehicle systems
« Reply #83 on: April 16, 2017, 04:01:20 pm »
I had not. Thanks for pointing it out - I have added such a switch to the schematic. You reckon it should sit before or after the ferrite bead on the data input?

After ferrite beads and any protection that clamps to ground.  Before any protection that clamps to any positive rail as those rails will be at 0V.

Still working on the updated schematic using the TPS1H100; since it wants 3-5V on the IN pin (7V max) I can't drive it with an opto @ 12V - should I drop the idea of a separate floating data GND? Kinda liked the concept, like a pseudo differential signalling scheme, but have no idea how much it would help improve 1-Wire noise rejection. Perhaps not worth the effort?


A simple potential divider will fix that.  You already need a pulldown resistor anyway, just add another resistor in series with the phototransistor.  Design for 3V level with the +12 supply at 9V, and you'll get 5V when the +12 supply is 15V, and it will tolerate 21V before that pin exceeds its +7V abs.max. rating.   If you need a wider range add a 4.7V Zener to clamp it.
 
The following users thanked this post: Lomax

Offline LomaxTopic starter

  • Frequent Contributor
  • **
  • Posts: 565
  • Country: eu
  • Minimalist
Re: RFC: 1-Wire PWM dimmer/motor controller for 12V vehicle systems
« Reply #84 on: April 16, 2017, 05:16:16 pm »
Ok, here's the updated schematic using a TPS1H100. There's a voltage divider on the opto output, and a switch on the data line. The low powered buck converter option has been removed. The part annotations have been updated. I suppose I don't really need the PTC on the 12V feed any more. Won't the current sense (CS) fluctuate in this configuration, as measured at the MCU's ADC pin? They do not share a ground reference...

 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12853
Re: RFC: 1-Wire PWM dimmer/motor controller for 12V vehicle systems
« Reply #85 on: April 16, 2017, 05:41:33 pm »
Yes, it will fluctuate.  You'd  need an OPAMP based differential amplifier to reference it to U1 Gnd, (see http://hyperphysics.phy-astr.gsu.edu/hbase/Electronic/opampvar6.html) and you are increasing the coupling between the 5V/1Wire bus and the power sides of the circuit to the point where the optocoupler may no longer be worth using.
 
The following users thanked this post: Lomax

Offline LomaxTopic starter

  • Frequent Contributor
  • **
  • Posts: 565
  • Country: eu
  • Minimalist
Re: RFC: 1-Wire PWM dimmer/motor controller for 12V vehicle systems
« Reply #86 on: April 16, 2017, 06:29:43 pm »
Yes, it will fluctuate.  You'd  need an OPAMP based differential amplifier to reference it to U1 Gnd, (see http://hyperphysics.phy-astr.gsu.edu/hbase/Electronic/opampvar6.html) and you are increasing the coupling between the 5V/1Wire bus and the power sides of the circuit to the point where the optocoupler may no longer be worth using.
How about using a dual opto?

Edit: By that I mean one with two photodiodes, one of which can be used in a feedback loop to ensure linearity.

Edit: Something like this:


« Last Edit: April 16, 2017, 06:53:14 pm by Lomax »
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12853
Re: RFC: 1-Wire PWM dimmer/motor controller for 12V vehicle systems
« Reply #87 on: April 16, 2017, 07:15:01 pm »
That could work, but its a lot of additional complexity and linear optos cost money.  Your board doesn't have true isolation anyway as the existing opto setup merely compensates for ground bounce and any offset between the power and signal grounds. 
 
The following users thanked this post: Lomax

Offline LomaxTopic starter

  • Frequent Contributor
  • **
  • Posts: 565
  • Country: eu
  • Minimalist
Re: RFC: 1-Wire PWM dimmer/motor controller for 12V vehicle systems
« Reply #88 on: April 16, 2017, 07:40:16 pm »
Yep. Even I, deep in my 1-Wire trance, can see that this is getting rather silly. And expensive.
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12853
Re: RFC: 1-Wire PWM dimmer/motor controller for 12V vehicle systems
« Reply #89 on: April 16, 2017, 08:14:24 pm »
We are over-thinking this:
Quote from: TPS1H100-Q1 datasheet
8.3.1 Accurate Current Sense
For version B, the high-accuracy current sense function is internally implemented, which allows a better realtime monitoring effect and more accurate diagnostics without further calibration. A current mirror is used to source 1/K of the load current, flowing out to the external resistor between the CS pin and GND, and reflected as voltage on CS pin.
K is the ratio of the output current and the sense current. It is a constant value across the temperature and supply voltage. Each device was internally calibrated while in production, so post-calibration by users is not required in most cases.
Because its fed by a current mirror, if you simply return all components connected to the CS pin to data ground rather than power ground, the voltage across the CS resistor will be relative to data ground!

However this does have some restrictions.  The abs.max ratings say the CS pin cant be taken more negative than 2.7V and the fault condition VCS,H (4.75V) on that pin will be referenced to power ground.   Otherwise we are back to a differential amplifier to shift the voltage by the difference in the grounds, with some trickery to keep the OPAMP inputs within the rails.
« Last Edit: April 16, 2017, 08:16:01 pm by Ian.M »
 
The following users thanked this post: Lomax

Offline ovnr

  • Frequent Contributor
  • **
  • Posts: 658
  • Country: no
  • Lurker
Re: RFC: 1-Wire PWM dimmer/motor controller for 12V vehicle systems
« Reply #90 on: April 16, 2017, 08:24:24 pm »
In the vein of "oh god this is such a pile of hacks": How about using a simple 555 circuit on the power side to digitize the CS voltage, pass it thru an opto, then filter it?

Alternatively, any way to get the BAEwhatever to do serial comms of any kind? I'd personally be tempted to drop a $0.50 MCU on the power side, then do isolated comms to that. And yes, I'd be happy to supply those if you want; I've got a tube of PIC12F1501s that I don't particularly like, that can be pre-programmed with the incredibly simple program needed.
 
The following users thanked this post: Lomax

Offline LomaxTopic starter

  • Frequent Contributor
  • **
  • Posts: 565
  • Country: eu
  • Minimalist
Re: RFC: 1-Wire PWM dimmer/motor controller for 12V vehicle systems
« Reply #91 on: April 16, 2017, 09:25:14 pm »
Because its fed by a current mirror, if you simply return all components connected to the CS pin to data ground rather than power ground, the voltage across the CS resistor will be relative to data ground!
Aha! You mean something like this?



However this does have some restrictions.  The abs.max ratings say the CS pin cant be taken more negative than 2.7V and the fault condition VCS,H (4.75V) on that pin will be referenced to power ground.
If I understand you correctly, swings of more than -(Vcs + 2.7)V relative to power GND might cause malfunction, or even damage the pin? And the fault condition voltage of 4.75V is not produced by this magical "current mirror", and hence will vary relative to data GND?


 

Offline LomaxTopic starter

  • Frequent Contributor
  • **
  • Posts: 565
  • Country: eu
  • Minimalist
Re: RFC: 1-Wire PWM dimmer/motor controller for 12V vehicle systems
« Reply #92 on: April 16, 2017, 09:34:19 pm »
In the vein of "oh god this is such a pile of hacks": How about using a simple 555 circuit on the power side to digitize the CS voltage, pass it thru an opto, then filter it?

Alternatively, any way to get the BAEwhatever to do serial comms of any kind? I'd personally be tempted to drop a $0.50 MCU on the power side, then do isolated comms to that. And yes, I'd be happy to supply those if you want; I've got a tube of PIC12F1501s that I don't particularly like, that can be pre-programmed with the incredibly simple program needed.
Many thanks, that's very kind of you. But going down either of these routes (linear opto, opamp, pre opto ADC, or even adding a second MCU) just seems a bridge too far to me. There has to be some limit to this madness, and I think we're dangerously close to the point where paying someone to write a Modbus driver for Domoticz is more sensible. Maybe it has already been passed.
 

Offline ovnr

  • Frequent Contributor
  • **
  • Posts: 658
  • Country: no
  • Lurker
Re: RFC: 1-Wire PWM dimmer/motor controller for 12V vehicle systems
« Reply #93 on: April 16, 2017, 10:04:34 pm »
There has to be some limit to this madness, and I think we're dangerously close to the point where paying someone to write a Modbus driver for Domoticz is more sensible. Maybe it has already been passed.

Nooooo. That can't possibly be.
 
The following users thanked this post: Lomax

Offline LomaxTopic starter

  • Frequent Contributor
  • **
  • Posts: 565
  • Country: eu
  • Minimalist
Re: RFC: 1-Wire PWM dimmer/motor controller for 12V vehicle systems
« Reply #94 on: April 16, 2017, 10:42:22 pm »
There has to be some limit to this madness, and I think we're dangerously close to the point where paying someone to write a Modbus driver for Domoticz is more sensible. Maybe it has already been passed.

Nooooo. That can't possibly be.

Well I know you think it has :) But you're not looking at this from quite the same angle as I am.
 

Offline LomaxTopic starter

  • Frequent Contributor
  • **
  • Posts: 565
  • Country: eu
  • Minimalist
Re: RFC: 1-Wire PWM dimmer/motor controller for 12V vehicle systems
« Reply #95 on: April 20, 2017, 12:08:09 pm »
We are over-thinking this

@Ian.M It may be that you're just fed up with this discussion - I wouldn't blame you if that's the case - but I suspect you may have missed my response to your last post?
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12853
Re: RFC: 1-Wire PWM dimmer/motor controller for 12V vehicle systems
« Reply #96 on: April 20, 2017, 12:38:37 pm »
Didn't miss it, just didn't have anything to add.  It would work subject to the constraint that there must *NEVER* be more than 2.7V difference between the power and digital grounds. However as you have guarantee that constraint is met without clamping you haven't shown - no comment.

I'd still prefer something with an OPAMP differential amplifier entirely powered by the 5V side, designed to allow an operating common mode range of several volts without affecting the desired 0V-5V signal, and with its inputs protected against damage due to ground offsets up to double the maximum possible battery voltage to allow for transients due to wiring inductance and possible loose connections of the power wiring.

You are going to a lot of work to add current sensing you didn't originally have.  Beware of feeping creaturism.
 
The following users thanked this post: Lomax

Offline LomaxTopic starter

  • Frequent Contributor
  • **
  • Posts: 565
  • Country: eu
  • Minimalist
Re: RFC: 1-Wire PWM dimmer/motor controller for 12V vehicle systems
« Reply #97 on: April 20, 2017, 01:00:44 pm »
Didn't miss it, just didn't have anything to add.
Fair enough!

However as you have guarantee that constraint is met without clamping you haven't shown - no comment.
I'm sorry, but I'm struggling to decipher this - are you saying I could/should clamp the GNDD offset with a diode somehow?

I'd still prefer something with an OPAMP differential amplifier entirely powered by the 5V side, designed to allow an operating common mode range of several volts without affecting the desired 0V-5V signal, and with its inputs protected against damage due to ground offsets up to double the maximum possible battery voltage to allow for transients due to wiring inductance and possible loose connections of the power wiring.
I hear that. Thanks.

You are going to a lot of work to add current sensing you didn't originally have.  Beware of feeping creaturism.
It's either current monitoring or supply end voltage stabilisation. Current monitoring will make it easier to ensure equal brightness in a chain of lights.
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12853
Re: RFC: 1-Wire PWM dimmer/motor controller for 12V vehicle systems
« Reply #98 on: April 20, 2017, 01:18:47 pm »
However as you have guarantee that constraint is met without clamping you haven't shown - no comment.
I'm sorry, but I'm struggling to decipher this - are you saying I could/should clamp the GNDD offset with a diode somehow?
I'm saying, if you don't have anything to prevent that constraint being exceeded, all your lamp control boards will go bang the first time you get a bad connection on the power ground.   OTOH, if you do clamp the grounds together (maybe via a string of antiparallel diodes to allow say +/-2V offset)  you reduce noise immunity, and if the power ground comes loose at the feed end, you probably end up melting your data ground wire as it tries to handle the ground return current from ten lamps.

I'm afraid we are back into increasing complexity.  You *could* use a NPN current mirror referenced to power ground, to drive another PNP current mirror referenced to +5V, with a Schottky diode between them to protect both if the power ground goes above the 5V rail to transfer the CS current to the logic side, but at best that's three more discrete semiconductors ( diode + two dual transistors) and it doesn't offer anywhere near the 'isolation' of an OPAMP with 100K input resistors.
 

Offline LomaxTopic starter

  • Frequent Contributor
  • **
  • Posts: 565
  • Country: eu
  • Minimalist
Re: RFC: 1-Wire PWM dimmer/motor controller for 12V vehicle systems
« Reply #99 on: April 20, 2017, 03:57:35 pm »
Thanks. I am now looking at Node Red as a possible replacement for Domoticz. It appears to have good Modbus support, but I need to do some more research before I know if this is a viable option. I would also need to find/write some kind of bootloader and Modbus implementation for a suitable (Atmel) MCU.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf