OhmMeter (Resistance Meter) PIC24, DsPIC33 and DsPIC30 (16bit PIC microcontoller) Code + Proteus Simulation

This post is all about how to build a digital OhmMeter (Resistance meter) to measure resistance of different unknown resistors. This design measures resistance from 1Ω to 1MΩ with an accuracy of ±5% approximately. You may download code and Proteus Simulation from the download section at the bottom of this post. I am using MPLAB X IDE, C30 Compiler and Proteus Simulation on v8.0. This code is written in C Language and will work on PIC24, DsPIC33 and DsPIC30 (16bit microcontroller) by slightly changing the code.

In this post I supposed that you know following things if not then please go through following posts before proceeding with this.

Proteus Simulation:

            In the following figure 1. I used a fix resistor (R3 = 10kΩ) that is pull-up by Vcc (5 volts) and the resistor whose value we have to find is attached to other end of R3 and the second terminal of resistor is grounded. This creates a potential divider and we can measure the value of resistor by using potential divider formula. Rest of the circuit is same as explained in my previous post of LCD. The Potential divider output is given to ADC channel zero on AN0.

Figure 1. Circuit Proteus

In the following figure 2. When I change value of the resistor at channel 0, microcontroller displays the measured value of resistance in Ohm, kOhm and MOhm. When the value is beyond the range of this design it displays a message “Too large”. For instance by the help of animation I tried to show different resistance values for different resistors placed at a position of R4.

Figure 2. Circuit Proteus simulation


In the following figure 3. This is main function in which I first initialize LCD, then I configure ADC with Channel 0. And a loop which only calls a function named DisplayResistance() which is responsible for displaying measured resistance value on LCD.

Figure 3. Main Function.

In the following figure 4. We have DisplayResistance() which has a string that is printed directly and a variables named “R3” and “Vcc” whose value is fixed for this design as 10kΩ and 5.0 volts respectively’(you may change them according to your requirement). “VoltageOuput” is potential divider value with the formula “voltageoutput = (R3/ (R3 + R4)) * Vcc”. Rearranging this formula for value of R4 you will get the following formula:

With R4 replacing “ResistanceMeasured” in code.

Figure 4. DisplayResistance function.

Now at this stage we measured the value of unknown resistance and now we have to display this on LCD for this I wrote a function that will display the value of resistance and return an unsigned char for displaying Units on LCD eg for MegaOhm resistance it will return 2 and for KiloOhm it will return 1 etc.

Reading Suggestions:


You can download Code (MPLAB X IDE and C30 compiler) and Proteus (v8) Simulation Click here

For all topics Click here.

That’s all for this post hope you will learn please comment if you have any questions.


All the text and graphics contained on this blog belongs to owner except otherwise mentioned. Other parties' trademarks and service marks that may be referred to herein are the property of their respective owners. Reproducing or distributing text and graphics on your own site is strictly not allowed without proper linking to original content and before publishing that you should ask for permission. 
© Copyright 2013 IbrahimLabs. All rights reserved.

Popular posts from this blog

Defining code regions in MPLAB X IDE

Digital AC voltmeter Schematic + Code + Proteus Simulation

Graphical LCD interfacing with PIC16F877 Code + Schematic + Proteus Simulation