Creative voltage divider/ladder.....opinions?
I've been working on a 6 volt solar charge controller. I'm using a Stamp to control when the batteries charge.
I didn't want to add an ADC to the circuit, so I came up with this voltage divider/ladder. The voltage is designed to trigger logic levels on the pins of which they are connected. The input levels are set to around a little over 6.3 volts and a little over 7 volts.
Any opinions?
Also, do I need to add a resistor to the I/O pins?
J Long
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
James L
Partner/Designer
Lil Brother SMT Assembly Services
Please note: Due to economic conditions the light at the end of the tunnel will be turned off until further notice. Thanks for your understanding.
I didn't want to add an ADC to the circuit, so I came up with this voltage divider/ladder. The voltage is designed to trigger logic levels on the pins of which they are connected. The input levels are set to around a little over 6.3 volts and a little over 7 volts.
Any opinions?
Also, do I need to add a resistor to the I/O pins?
J Long
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
James L
Partner/Designer
Lil Brother SMT Assembly Services
Please note: Due to economic conditions the light at the end of the tunnel will be turned off until further notice. Thanks for your understanding.
Comments
You run a single input divider into the comparator with the other input tied to an RC network driven from an output. Software discharges the cap and then proceeds to charge it while measuring how long it takes before the output of the comparator switches. This method is a lot more precise than trying to use logic inputs as "comparators".
*Peter*
You only showed part of your circuit, so it's not possible to give you a definitive thumbs-up. It's always a bit dicey feeding an analog signal directly into a digital circuit and calling that an A/D converter. With slowly-changing voltages, you will probably get some oscillation/instability. But even if you don't, the main thing is that you need to make absolutely sure that your 6 and 7 volts stay far away from your Stamp. All you care about is the input pin's 1.4 volt transition range, so your VD just has to scale the 6/7 volts down to 1.4 volts.
An better way IMHO would be to use a cheap LM 339 quad comparator as a poor man's A/D converter. Add a feedback resistor to add hysteresis (damping) and you're done pretty quickly.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
The circuit clearly shows 187K series input resistors PLUS the resistors to ground to form the voltage divider. Putting extra resistors in series with the pins is absolutely totally redundant don't you think? It's true what you say about the instability and any comparator type system normally needs some positive feedback for hysteresis. However the simple comparator needs resistors for voltage dividers and resistors for reference, so that you need at least 2 for the input plus 3 for the reference ladder. The STAMP I think has weak pullups as the comparator outputs are open-collector so you don't need any extra there.
My thinking is do away with trying to set these two fixed voltages with fixed value resistors (no trimmers!!) and let software figure it out. An 8-pin LM393 comparator or even an LM358 opamp along with 3 fixed (but not critical value) resistors plus the capacitor will do the trick and much better besides.
*Peter*
Ok....so I may go with an opamp or a comparator......the question is.....how would that circuit look?
I'm going to try and keep much of the part SMT......to keep the end board small.
The stamp and board to wire connectors (plus a display header) will be the only through hole parts.
The rest of the schematic is mostly just a chipfet, diode, and resistors for power control.
James L
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
James L
Partner/Designer
Lil Brother SMT Assembly Services
Please note: Due to economic conditions the light at the end of the tunnel will be turned off until further notice. Thanks for your understanding.
The circuit is very simple and the values are nominal. You can change the RC values to suit as and the divider is just to give you a 0 to 10V range using standard values. An LM358 will probably work because even though the output is about 1.5V below the supply you also have some pullup on the STAMP. Software is a simple discharge, wait, turn on the output and count and wait till the input goes low then take the value of that count. The RC ramp is non-linear but I guess you just specify the trip-points so you won't have to do any conversions.
*Peter*
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
With a slight alteration to your circuit you could change it into a VCO (Voltage Controlled Oscillator). My concern is that using the COUNT function, you don't have as much resolution as you would with RCTIME. Compare 1ms with COUNT to 2us with RCTIME. With a VCO configuration you gain some of that resolution back by measuring several pulses as a combined effort rather than relying on the amount of time required for a single pulse rise after you discharge.
(You could also do this with RCTIME)
This will bring back memories for some of you...
www.hth.com/losa/ ... See entry number 35 "Simple Battery Check using the BS2-IC"
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Ahhhh....yeeeeaaaahhh......even better.
I'll revise for RC time.
Thanks Beau
James L
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
James L
Partner/Designer
Lil Brother SMT Assembly Services
Please note: Due to economic conditions the light at the end of the tunnel will be turned off until further notice. Thanks for your understanding.
I figure that is probably good enough. I am going to couple that with a 681K 1% resistor.
I figure that will get me close enough to do RC time without a bunch of other components. Total cost......about $0.40 (enough to do it 10 times). I guess I have to get some other stuff....to justify the shipping.
(I already have 470 ohm resistors on a 4000 count reel.......SMT assembly and all)
EDIT: just to be able to use the design for 12 volts.....I increased the capacitor value to 50v. Price and size of the capacitor did go up......but still pretty easy to build the circuit for it.
J Long
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
James L
Partner/Designer
Lil Brother SMT Assembly Services
Please note: Due to economic conditions the light at the end of the tunnel will be turned off until further notice. Thanks for your understanding.
Post Edited (James Long) : 9/11/2009 5:45:03 AM GMT
Hi Erco,
Please don't mind my manner, even mild forum posts can sound a bit harsh at times although we are just a bunch of guys with a common interest and trying to be helpful and not at all intending offense. If I need to qualify a technical point then I will. It's not a personal thing, it's about the technical point, and I don't mind being challenged about it either, it's not personal. There's nothing to lose here as when it comes to laying our cards on the table no one loses, it's a forum, everyone wins. I'm always aware of how others who might not be in the know would interpret it, so therefore the qualification of certain technical points is really for these ones, not us guys who already know.
As you know the project and homework boards could have ANYTHING connected to them as they are prototyping boards. It's usually a bit safer to design current limit resistors in the I/O lines in these instances for a variety of reasons being:
1) Maximum short circuit current is within spec of I/O pin
2) Very useful for driving LEDs as you don't need an extra resistor
3) Accidental connections to "slightly" higher voltages should protect the pin but might not prevent damage or mis-operation if connected to say 12V.
4) Less support calls to Parallax staff
These reasons don't make it a standard or necessary practice either.
Unlike the general-purpose prototyping boards it sounds like James has built the STAMP into his own board and since he has such large value resistors there already there would be absolutely no need for additional resistors. Accidents happen but a purpose built unit has known constraints versus the "anything goes" with prototypes which I am sure Parallax are well aware of and try to factor in as best they can.
@Beau - The values were only nominal and dependent upon what can be achieved with the remaining resources on the STAMP. The VCO is a good idea and probably suits the STAMP a bit more but I've never really used the STAMP myself to know. On the Prop the RC would simply be a counter driven DAC providing a DC accurate ADC, but then again the VCO might me better. Can't help thinking that a little I2C ADC might have been less fuss! (but less fun).
*Peter*
Hi James,
That capacitor will never go above the supply volts of the opamp which can't go above what the STAMP can handle, so it's 5V. A 6.3V or 10V cap is more than ample and I'm thinking that if you have to have a really stable cap then maybe you should just an ADC [noparse]:)[/noparse] I have used a cheap 8-pin PIC12F675 as a 10-bit ADC that just keeps spitting out on one I/O pin the data in a suitable form. Might be an idea, just use 2 resistors as your voltage divider into one of the inputs.
*Peter*
I decided to go with a different method using RC time.
I used a little routine found here: www.emesystems.com/BS2rct.htm#B_voltage
I think this will serve good enough for what I'm trying to accomplish.
James L
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
James L
Partner/Designer
Lil Brother SMT Assembly Services
Please note: Due to economic conditions the light at the end of the tunnel will be turned off until further notice. Thanks for your understanding.
Fair enough, I've done rough ones like this in the past too but it doesn't get away from the fact that it's still relying upon the uncertain logic switching threshold but for your purposes should be good enough. I noticed the website had some reference to multiple switches on an RC network. I know I came up with this idea over 10 years ago or more as I used it to simplify the wiring in vending machines and I even released a Microchip style appnote with this technique (except I was using an AVR).
*Peter*
Peter,
I agree, the system will need to have some manual calibration, and even then, it will vary some with temperature. The system is for my father, and just needs to be somewhat reliable, and can switch off solar cells to prevent over charging, and then switch on when the batteries are getting low. We are not logging battery information nor using it to display voltage.
I would definitely go with a different method if needing more precision. I do appreciate the ideas you presented......it is nice to have different options.
James L
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
James L
Partner/Designer
Lil Brother SMT Assembly Services
Please note: Due to economic conditions the light at the end of the tunnel will be turned off until further notice. Thanks for your understanding.