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.

how to display milliampere using pic c code

Status
Not open for further replies.

engineer khan

Member level 3
Member level 3
Joined
Aug 31, 2012
Messages
66
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Visit site
Activity points
1,833
I m using PIC18F and c18 compiler I wish to make milliampere meter but in coding i have a problem please guide me how to write code for getting value of current in milliampere 0-5v is applied on RA3 chanel3
 

hello,

Give more details..

what is your full scale of milliamp for 5V on RA3 ADC input ?

with ADC 10 bits => you will get 1024 pts for the full scale...

How do you display the result ?
UART -> RS232 -> terminal
or on LCD 2x16 car
or ?
 

Hello.

You should use a small value resistor (not above 1 ohm) where a current could flow through. It will generate a potential difference between its terminals, but that's not referenced to GND. To do that you can use a differential opamp between the resistor terminals. Then, the output can be connected to the ADC input.

The count you will have to make is a well known one: I=V/R. The voltage is measured by the ADC, and the R is a known value determined by you (1 ohm or less).

If you measure 1V over the 1 ohm resistor, a 1A current should be flowing through the resistor.

Make the VREF+ value useful for your application; don't rise 'R' value because it will generate changes in the measured circuit (since current is measured in series, the resistance can affect the circuit correct working).
 

the input to controller that is to be measured is 0-12v and i wnna display result on hyperterminal, the circuit u duided me about if u pleas post that will be too helpful for me thanks
 

Hello.

So as I can understand you already have the measurement circuit which outputs a voltage from 0 to 12V in the whole measurement range.

Well, those 12V will burn or damage your PIC ADC, since it supports voltages from 0 to 5V. You could use a resistive voltage divider with two resistors (Use Ohm law to calculate it or look for a calculator applet).

You can calculate your system accuracy with the sensor measurement range and its output voltages. Take into account that you divide the voltage so it will be worse.

Then, with the A/D conversion you calculate the current. I think that the output voltage is directly proportional to the measured current. Once you get the count your PIC will have to do to convert a voltage value digitally converted from 0 to 1024 to a "mA" value, the only thing left to do is sending that measurement to your PC so it can display it on the screen.

You have to use a level converter like MAX232 or similar (you can also use transistors...) to interface PC with PIC, in case of using RS-232. You have to configure how you are going to transmit data (ASCII, decimal, binary, hex, etc) both in HyperTerminal and in your PIC.

Good luck with that, just ask if you have any doubt.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top