Tuesday, July 11, 2017

Microcontroller Current Meter : Simple 3A DC Current Meter Using PIC for PowerSupply

This project is in the series of different small projects i did for new learner in mircrocontroller stuff.
In this project i am using PIC16F1459 mcu for no particular reason , any MCU can be used to implement this project. all you need an ADC and Few GPIO to drive LED display .  I am using internal 10 bit ADC of PIC16F1459 MCU .

Though 10bit resolution is quite low , with 3 Amps rage we can only get resolution of about 2.92 mA per bit. I would love to have a least 1mA per bit or better , but for that either we need to limit our range to 1A or have more than 10bit ADC. To get higher bit in ADC require either external ADC chip or use an MCU with has 12 or 14bit ADC.

i just wanted to keep this project simple and low cost . so i am okey with 2.92mA per bit.

Good thing about PIC16F1459 is , that this part has on chip reference , which we can use with our ADC to increase accuracy and stability .

Internal reference can be set to 1.024 or 2.048 or 4.096 volts.  i am setting to 2.048V.



Schematic 




Current Sens Register and Current Sens amplifier 

As microcontroller can accept analog signal upto its reference only , we have chosen reference to be 2.048v. so maximum signal which can be feed into MCU ADC is 2.048V.

we have to chose our reference register in such as way that maximum voltage drop across register is within range of our current sens amplifier , we are using MAX4080T , which has gain of 20 , and Full-Scale Sense Voltage of maximum 250mV.

i have chosen current sens register of 0.030 ohms or 30mOhms , which will give us 30mV / Amp. and after current sens amplifier multiplication of 20 , it will be 600mV /Amp.

if you want to modify this current meter to higher or lower current you need to change current sensor register accordingly.

How to chose current sens register

Three this are really important choosing current sensor register.
1. Value of  sens Register.
2. Wattage of sens  Register. (how much power it can take)
3. Long term stability.

1. Value of the current sens register is always a trade of between how much burden voltage you can have and how big drop signal you want to produce . Bigger the drop easy to measure but big burden voltage . a nice current sens amplifier can save you from choosing high value. because they can amplify signal.

2. Wattage of the register is trade of between size of the register  and how much power it can dissipate. chose double the maximum power you are expecting through.

3. Long term stability is very important as , this will directly affect your results. if value of register is little off you can calibrate this in software but if value keep on changing too much with temperature or age , this is going to be an issue


How to current sens Amplifier. 

I am using MAX4080 chip as current sens amplifier , what is part does it just multiply voltage across current sens register of your choice , by factor of your choice .  This part  comes in 3 different variants , factor of 5 , 20 and 60.  i am using MAX4080T which is 20 times gain.

so if current sens register has voltage drop of 60mV , i will get 1.2V output from the amplifier.

Current sens Amplifier gain is really useful to keep current sens register value as low as possible.
Low value of current sens make burden voltage of the current meter low , and power dissipation also low. by this you can have smaller in size and lower wattage current sens register.


Hardware 



i am using my lab power supply to feed exact 1.5A current into meter though my Agilent U1272A. it shows almost bang-on  value , as this meter has resolution of +/-3mA + 1 last digit , it is good enough the purpose of a home made lab power supply or any other project




Firmware and Source code. 

firmware source and schematic PDF available at https://github.com/circuitvalley/Meters/tree/master/PIC_Current_Meter_3A

i am using xc8 compiler to compile this project .


Firmware has two timer setup. one timer to setup display , another timer to sample adc values at a fixed sample rate .
Fixed sample rate is really important as it helps getting stable values.
Finally there is 128 point average applied and updated to display.

1 comment: