# Easiest way to build a voltage sensor?

Discussion in 'The Projects Forum' started by rudyauction8, Mar 21, 2014.

1. ### rudyauction8 Thread Starter Member

Jan 27, 2012
252
2
Need something that can switch a relay on or trigger a microcontroller at around 22-27v (adjustable if possible) and switch it off around 30v, and it needs to be accurate to +-1v on the high range or adjustable to get that accuracy. What's the easiest way to do this? It will be used to switch a small generator on a scooter to automatically charge the battery while riding. I'd prefer to avoid expensive solar/windmill charge controllers and will switch the generator manually if possible, just looking to see if there's a somewhat simple circuit capable of doing the job.

EDIT: Just thought of something, if I string enough diodes together (5 volt zener to 25v and normal rectifiers the rest of the way) would that be enough to trigger a power transistor with a pull down, or will the current slowly increase over a large voltage range or something? I could add and remove diodes as needed to adjust the voltage needed to turn on the generator. I've never tried using diodes this way so I have no idea how they'd behave.

Last edited: Mar 21, 2014
2. ### MrChips Moderator

Oct 2, 2009
14,505
4,271
You can use a voltage divider to reduce the voltage by a factor of 10 so now you are monitoring voltages from 0-3V.

Then use two analog comparators that are set with reference at 2.5V and 3.0V respectively.

3. ### ericgibbs AAC Fanatic!

Jan 29, 2010
3,325
591
Morning MrC,
A 10:1 resistive divider will not give an output of 0-3V.

Eric

EDIT:
The OP is monitoring 27V thru 30V

EDIT2:
My apologies, I misread the OP's question.
I will now go outside and beat myself with a stick!

Last edited: Mar 21, 2014
#12 likes this.
4. ### Dodgydave AAC Fanatic!

Jun 22, 2012
6,476
1,024
Use an op amp Window Comparator, scale the voltage down using a resistive divider as suggested earlier, set your trigger point altering the values of R1,R2,R3, choose an op amp to suit your needs.

5. ### rudyauction8 Thread Starter Member

Jan 27, 2012
252
2
Thanks guys, I'll look into those. I have a few microcontrollers with analog to digital converters, could I use a voltage divider with one of them so I can program the exact switching points?

6. ### Alec_t AAC Fanatic!

Sep 17, 2013
7,097
1,478
What is the battery voltage?
Will you be using the battery to power the relay (or whatever) circuit?

Edit:
Assuming a 12V battery powering the circuit you could make a window comparator from a '555 IC, like this

• ###### 555_WindowComparator.gif
File size:
23.5 KB
Views:
33
Last edited: Mar 22, 2014
#12 likes this.
7. ### rudyauction8 Thread Starter Member

Jan 27, 2012
252
2
The circuit will preferably run off the 36v source and a 5v regulator. I'm having trouble with the generator now so I may not be building the circuit, I'll know soon.

8. ### #12 Expert

Nov 30, 2010
17,889
9,297
The LM555 has a supply limit of 18 volts, so using a regulator to supply it would be a good thing, but you will have to change some resistor values if you are going to use Alec's circuit with a 5 volt supply. While you're at it, be sure to consider that a generator can throw some nasty voltage spikes. Protect your regulator from these.

As for zeners to the base of a transistor, a transistor (base to emitter) is affected by temperature change and might make this design change where it switches too much to be reliable in this position. Besides, one transistor would only make one switching point. The 555 chip seems the excellent choice for this job. And thanks to Alec. I usually forget that a 555 can be used for a window comparator.

• ###### LM555.PDF
File size:
236.1 KB
Views:
12
Last edited: Mar 22, 2014
9. ### rudyauction8 Thread Starter Member

Jan 27, 2012
252
2
Just realized the window comparator won't quite work. The low range where the output is low should actually switch on, the middle range where it's high shouldn't switch (stay where it is), and the high range where it's low again should switch off. It's close but not perfect. With the window comparator when the battery is really low, the generator will switch off, and when the batteries are near full, the generator will cut off and the voltage will drop quickly, causing it to start again in just seconds.

10. ### rudyauction8 Thread Starter Member

Jan 27, 2012
252
2
Here's a graph I made in paint to show what I need done. I think I fixed the generator today, or at least have it close, so the project is back on.

File size:
16 KB
Views:
17
11. ### Alec_t AAC Fanatic!

Sep 17, 2013
7,097
1,478
I don't think so. The voltage won't drop more than a couple of volts (?), and the window comparator has a larger hysteresis so shouldn't respond to that drop.

Last edited: Mar 23, 2014
12. ### rudyauction8 Thread Starter Member

Jan 27, 2012
252
2

Under the load of the scooter motors (15 amps on 3x old 12ah sla batteries in series), the voltage could likely drop 2/3 of the way to the low trigger voltage in under a minute. I'll have to test this to find out exactly how much it drops.

13. ### burger2227 Member

Feb 3, 2014
194
25
How do you calculate the high and low voltage value components needed on the 555?
Is there a reference somewhere?

14. ### #12 Expert

Nov 30, 2010
17,889
9,297
No. It's pure brain work. You have to know the chip intimately to do this kind of off-label design.

15. ### burger2227 Member

Feb 3, 2014
194
25
Well I'll take it to dinner, but I'll have to draw a line somewhere!

#12 likes this.
16. ### Alec_t AAC Fanatic!

Sep 17, 2013
7,097
1,478
3 x 12V sla batteries in series are going to need >41V to charge them. Can your genny provide that?

17. ### rudyauction8 Thread Starter Member

Jan 27, 2012
252
2
Currently it's maxing at ~50v at redline, and charging fine. I'm just using a switch and would like to automate it in the near future. I'm going to build a new generator soon that will provide the same ~50v but 5x the current (current one only gives 5a at 36v) so it'll easily keep up with the 350w motor on the scooter, and only need to run 1/4 of the time. I have the motor and parts, just need to wait for a free day to put it all together.

18. ### MrChips Moderator

Oct 2, 2009
14,505
4,271
I would not charge three 12V batteries in series. You will get unbalanced charging and risk over charging one or more batteries.

Edit: Oops, sorry, I just reread your posts. I now see that the generator is on a scooter.
I think you need to do some energy calculations first to determine how much energy will be required to recharge your batteries.

Last edited: Mar 24, 2014
19. ### rudyauction8 Thread Starter Member

Jan 27, 2012
252
2
The way the scooter comes from the factory charges all 3 in series, however I use my computerized chargers to individually charge each battery every night so balancing shouldn't be a problem.

20. ### MrChips Moderator

Oct 2, 2009
14,505
4,271
I hope you are not hoping to create an over-unity scooter.