Implementation of Ohmmeter using ZKit51
Resistance is the reluctance or a kind of friction in a carrier which
opposes the flow of current through it. The resistance of an element
is measurable and it is represented by an unit known as
Ohm
. Ohmmeter is a device used to measure the electrical
resistance. This project shows how to construct a simple ohmmeter
using 8051 microcontroller.
Theory & Design
The resistance of an element can be measured by building a voltage divider circuit with a known input voltage (`V_i`), a known resistor value (`R_k`), and the unknown resistor (`R_u`), as shown in the figure below. By measuring the output voltage (`V_u`), it is possible to determine the value of unknown resistance.
The output voltage `V_u` is given by, the voltage divider equation.
`V_u=V_i*R_u/(R_u+R_k)`,
The equation is rearranged to obtain the unknown resistance `R_u`.
`R_u=V_u*R_k/(V_iV_u)`,
From the above derivation, we find that the unknown resistance is measured with the known resistance `R_k` , input voltage `V_i` and the voltage `V_u` across the unknown resistor. Since `R_k` and `V_i` is known already, only the `V_u` has to be measured. In our design of a digital ohmmeter using ZKit51, we use an ADC to measure the voltage `V_u` in the above circuit, to calculate the resistance `R_u` using the above formula in software.
The range of resistance to be measured will vary based on the known resistor used in the circuit.
Known resistor 
Measurement range 
10 ohms 
< 30 ohm 
10 kilo ohm 
31 ohm  41 kilo ohm 
1 mega ohm 
18 kilo ohm  4 mega ohm 
What you need

ZKit51 Motherboad

FRC 10 cable

Resistors  10K  2 nos
Hardware

Build the voltage divider circuit as shown in the diagram.

Connect voltage divider circuit to ZKit51 ADC module to measure the voltage across unknown resistor.

Connect ZKit51 ADC module with ZKit51motherboard using FRC connector.

Calculation of the unknown resistor value will be done in software part.
Software
The code for resistance measurement using ZDev library is given below,

/static/code/zkit51ohmmeter.c[Download the source code]

/static/code/zkit51ohmmeter.ihx[Download the hex file for 8051]
#include <board.h>
#include <stdio.h>
#include <adc.h>
#include <lcd.h>
#include <delay.h>
#define KNOWN_RESISTANCE 10000
/* Input volt=5.1, adjusted for nonfloating point value manipulation. */
#define INPUT_VOLTAGE 5070
/* Calculate unknown resistance from measured voltage. */
uint32_t resistance_value(uint8_t digi_volt, uint32_t res, uint16_t vin)
{
uint32_t resistance;
uint16_t analog_volt;
analog_volt = (digi_volt * 16);
resistance =
((analog_volt * (res / 1000)) / ((vin  analog_volt) / 10));
return (resistance * 100L);
}
int main()
{
uint8_t volt;
uint32_t resistance;
uint8_t prev_value = 0;
board_init();
board_stdout(LCD_STDOUT);
lcd_init();
adc_init();
adc_enable(2);
delay_init();
while (1) {
volt = adc_read8(2);
if (volt == prev_value)
continue;
prev_value = volt;
resistance = resistance_value(volt, KNOWN_RESISTANCE, INPUT_VOLTAGE);
lcd_clear();
printf("%ld ohms", resistance);
mdelay(1000);
}
}