Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] Help needed with automatic 12V/24V detection using PIC16F µC

Status
Not open for further replies.

richardlaishram

Member level 4
Joined
Jan 6, 2013
Messages
77
Helped
6
Reputation
12
Reaction score
6
Trophy points
1,298
Location
Planet Earth
Activity points
1,804
I have to design a circuit which needs to automatically switch between 12V and 24V inputs, basically a battery level indicator using PIC16F716A µC. Let's say the range of 12V is 8V(Low)-14V(High) and that of 24V is 20V(Low)-26V(High). If I use a common voltage divider for both inputs with maximum output level up to 5V, I'm hoping to be able to differentiate the battery input.
Pseudocode:
Code:
if(voltage < 15)
{
     display 12V battery detected && indicate battery Level
}
if(voltage < 28 && voltage > 18)
{
     display 24V battery detected && indicate battery level
}
Please suggest me if I can continue with this or is there any better way to acomplish this. Also If I want to add 48V input what can be done?

Thanks in advance.
 

You can have common voltage divider only if one source is connected to the voltage divider at a time.
At the later stages I'm planning to include for 48V battery also. How can I achieve this like the one used in multimeter. I'm using a multimeter which automatically switches the range of voltage 0V-5V, 5V-24V, 24V-48V and so on while measuring.
Apart from detecting the type of battery, I also want to measure the voltage accurately (two decimals if possible) which I think will be hard if I use the same voltage divider circuit.
 
Last edited:

As jayanth said you need to convert input voltages in range of micro controller 0-5v for say range of 0 to 48 v using either voltage devider or some other method and detect this voltage using micro controller....

Good luck

Milind
 

If I've to design a voltage divider which will give an output in the range 0V-5V for a 48V input, the voltage divider output for a 12V input will be very low (nearly zero). Like I said, I want to measure the voltage, so with the 10-bit ADC of PIC16F microcontrollers, I think it'll be hard to achieve up to two decimal accuracy for each range i.e. 0V-12V, 12V-24V and 24V-48V. Please guide me if my speculation is wrong. Thanks.
 

If u have inbuilt adc then detect DC voltage detect battery along with its lower & higher voltage level using same resistor network which is mentioned above
 

Hi.....

With 10 bit resolution you will get 1024 reading for now let say you map 48 volts to let say 1000 count of ADC you will get 20 ADC count resolution per volt I think it is very good resolution to detect the range of the voltages that you are taking.....you even have design op amp circuit to give 8v to 48v mapping from 0 to 5V will give you even more range of approximately 1000/40 is 25 count...... if you don't want to go to this circuit you need to have relay or switch based intelligent circuit to give you potential divider for respective ranges...... I mean you can design 3 different potential divider and switch them using relays will also possible..... but require more components .....

Good Luck
 

Thanks Milind, I'll go with a single voltage divider. Vout = Vin*{R1/(R1+R2)} so if I go for R1:R2 :: 11:1, then the divider output will be 6V = 0.5V and 48V = 4V
Last time I used 8-bit ADC, so I was calculating the resolution according to that, that's a terrible mistake but now I'm clear. My bad :(
 

In a fluke meter schematic for the auto ranging they use something like a 4066 chip controlled by the micro to switch resistors in and out to make it more actually I did upload a schematic here sometime ago do a search for fluke 39&40 you should find it I can't find the copy I had on my computer otherwise I would of up loaded it here.
You can use 3 pins of the PIC to control the 4066
 

one thing I will like to suggest you is that choose proper value of resistors for potential divider circuit.....as In case of ADC require some sampling current too and also ADC pin resistance based on chip that you are using comes parallel to R2 if you are taking voltage samples across R2 ...... other wise use an op amp buffer combination such that potential divider circuit will not get loaded because of the Micro-controller ......

Good Luck

Milind
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top