+ Post New Thread
Results 1 to 5 of 5
  1. #1
    Member level 3
    Points: 944, Level: 6

    Join Date
    Aug 2012
    Posts
    66
    Helped
    1 / 1
    Points
    944
    Level
    6

    how to display milliampere using pic c code

    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

    •   AltAdvertisment

        
       

  2. #2
    Advanced Member level 4
    Points: 7,943, Level: 21
    Achievements:
    7 years registered
    paulfjujo's Avatar
    Join Date
    Jun 2008
    Location
    France 01120
    Posts
    1,299
    Helped
    263 / 263
    Points
    7,943
    Level
    21

    Re: how to display milliampere using pic c code

    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 ?



    •   AltAdvertisment

        
       

  3. #3
    Full Member level 4
    Points: 1,802, Level: 9

    Join Date
    Aug 2014
    Location
    Buenos Aires, Argentina
    Posts
    214
    Helped
    38 / 38
    Points
    1,802
    Level
    9

    Re: how to display milliampere using pic c code

    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).



    •   AltAdvertisment

        
       

  4. #4
    Member level 3
    Points: 944, Level: 6

    Join Date
    Aug 2012
    Posts
    66
    Helped
    1 / 1
    Points
    944
    Level
    6

    Re: how to display milliampere using pic c code

    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



  5. #5
    Full Member level 4
    Points: 1,802, Level: 9

    Join Date
    Aug 2014
    Location
    Buenos Aires, Argentina
    Posts
    214
    Helped
    38 / 38
    Points
    1,802
    Level
    9

    Re: how to display milliampere using pic c code

    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.



--[[ ]]--