Introduction: Digital Multimeter Shield for Arduino

This instructable describes a shield, which converts "Arduino" board in a digital multimeter (DMM).


The shield can be inserted on "Arduino" UNO und Duemilanove boards. It can work in three modes:

  • standalone - the measurement data can be seen at the character or graphical LCM
  • connected - the measurement data can be read on the PC screen using the "Arduino" IDE "Serial monitor"
  • combined - the data can be observed on both devices

The second mode does not require the presence of LCM, what makes the shield very cheap.

The "Arduino" based DMM has the following functions:

  • voltmeter with 3 ranges : 0-10V; 0-30V; 0-100V
  • amperemeter - it has a range 0-500mA
  • ohmmeter with 2 ranhes : 0-1KOhm, 0-250KOhm
  • diode, LED, connectivity checker
  • LED functionality tester
  • NPN BJT Beta meter

Step 1: DMM "Arduino" V/s Standard Digital Multimeter

The following movie shows how the "Arduino" based DMM works in comparison with non-professional standard DMM

Step 2: WARNINGS

I thought to add these warnings at the end, where the conclusions should be, but I have changed my mind because of the importance of this step. Before starting the copying of the design and doing some measurements the following things should be kept always in attention.

Dangerous voltages could appear at the shield nodes, connections and parts. As the shield is designed in the presented implementation, it can be used for measuring of voltages until 100 V. These voltages are dangerous for the life!!!. Even voltages close to 30 V in some cases can cause death. For this reason, all requirements concerning the work with high voltages must be met:

You should use only insulated leads. You should avoid touching of the shield parts (especially the banana socket for voltage measurements and the input resistor). You should keep your table clean - no metal parts or instruments shall be placed close to the shield because they can create short circuit between the shield parts. You should not touch any of the banana sockets and plugs during high voltage measurements. (The banana socket for the voltage measurement is not insulated in any way and touching it during operation can have deadly results!!!).

I would like to thank the user "granz" (see the comments), who reminded us about the following: When using the "Arduino" based DMM connected to the computer, you should be aware of that the ground potentials of the DMM is the same as the ground potential of you PC, and you should measure voltages and currents of device or unit, which have the same ground potential. In other case you risk to damage both - you computer and your device. If you are not sure, what the ground potential of your device is - then it is recommended to use the "Arduino" based DMM in standalone mode - supplied by battery pack or isolated DC/DC converter.

.....

Step 3: The Design Work

The main idea of the project was to create a shild for "Arduino", which can be used for voltage and current measurements. The shield had to be relatively precise ~ 1% and to be able to display the measured data on the liquid crystal display.
Starting the design, I decided to keep the circuit as simple and cheap as possible. During the design phase, I have found that I can implement some additional useful functions without big efforts and investments. Because I have used dual opamp chip and one of the embedded amplifiers was used for the ampere meter, I was looking for a way, how I could use the second one. I decided to design with its use a voltage to current converter, which further could be used for other functions : resistance measurements, diode/LED functionality checks, NPN Transistor gain measurements. This required some additional parts, but have added more functionality to the board.
Although the main two functions could be done very precise (especially with final software trimming), the additional functions have some lack of accuracy. The error in some cases can reach ~10%. The reason for that will be explained further. Keep reading :-).
There are some simple solutions, which can drastically improve also this accuracy, but they require some additional parts and are matter of possible feature project.
The schematics and the PCB board layout are presented on the pictures.

Remarks on the schematic:

  1. On the schematic you can see two opamp instances - they both represent only one chip, but with different packages. On the PCB both instances are placed one over other. In the reality only one chip shall be soldered. This approach makes the PCB more universal - different type of packages are supported simultaneously.
  2. The same design technique is used also for the transistor. It can be PMOS or PNP BJT, and it can have different packages.
  3. This chain is optional. The devices can be omitted. When using PMOS transistor, the LED could indicate if some device is connected for measurement : high intensity - the load is missing, low intensity - the load is connected. When using PNP BJT for the VIC (Voltage to Current Converter), it is difficult to see a change in the intensity of the LED. The advantages/ disadvantage of using PMOS or PNP will be discussed further.


The "Eagle" design files are attached to the project and are available for download and free use.

The Gerber files prepared for PCBway(fab with very cheap and high quality production) are also available for download.

Step 4: Explanation : How This Shield Works...

The schematic may look quite complicated. For that reason I will try to explain how the different functions work, separating the circuit in sub-blocks, simplifying them and showing how the calculations were done.

Let's start with the voltmeter. On the picture, its simplified schematic can be seen. Three voltage dividers ( for the three ranges) can be alternatively formed by use of switches controlled by the "Arduino" board. Only one switch is closed during the voltage measurement. As switches I use NMOS enhancement mode switching transistors from the type BSS123. They have typical Ron around 6-10 Ohms, which does not influence a lot the accuracy for the ranges 0-10V, 0-30V. For the range 0-100V, their Ron is taken into account, when calculating the voltage divider ratio.
The Zener diode is used to clamp the Vmeas potential ( the voltage applied to the analog input A0 of the "Arduino") at 5.6V and to protect the Atmel chip. Its clamping value is taken with the presumption, that the board will be supplied with 5V source. This Zener diode must be very carefully chosen. I took one of ten measured. It must satisfy two criteria:

  1. The clamping voltage must be not higher than 5.6V
  2. The current flowing through the diode in reverse connection, when 5V are applied on it must be close to 0. If significant current flows, this will affect the measurement accuracy and will introduce some non linearity. The diode, which I soldered was passing only 1uA.

Step 5: How the Current Is Measured...

     You can see how the current is measured on the presented schematic diagram.
     The measured current is passed through 1 OhM resistance to the ground. Amplifier, which  output is connected with the "Arduino" analog input A1 is amplifying the voltage drop over the resistor with gain 10.
     To prevent damages, when higher then desired current is applied at the ampere meter, I have put a resettable PTC for 500mA.
     
 

Step 6: How the Resistance Is Measured....

     A reference voltage with respect the positive supply range is created by the use of the Zener diode (2V). The generated in this way voltage reference is applied to the input of voltage to current converter realized by the opamp and the PNP BJT (PMOS) transistor, at which emitter (source) terminal, adjustable and commutable  resistors are connected. The voltage over these resistors is identical with the voltage over the Zener diode. The "Arduino" board controls, which of both switches will be closed, defining in this way through which of both resistors will flow current. Thus two possible current values are possible: 10uA, 2.5mA. These currents can be adjusted very preciously. The generated so current is passed through the measured device (resistor, diode, LED, transistor) and the voltage drop appeared over the device under test (DUT) is applied to the analog pin A2 of the "Arduino" board.
     For the VIC (voltage to current converter) can be used as well PMOS or PNP bipolar devices.
     At the first try I was using PMOS NDT2955 device. (I had one available, and decided to use it). The opamap used was LM358. 
Making some tests, I have found that some measured data is not stable. I found that oscillation appeared. The VIC was not stable.
The reason for that was: The maximal capacitive load, which the LM358 can drive is less than 50pF (without resistive isolation).
The gate capacitance of the used PMOS was 600pF, which was making the whole circuit unstable. Then, I have changed the transistor with PNP BJT (Bipolar Junction Transistor) 2n3906, and the circuit was stabilized.
    In other words: the type of the opamp and transistor of the VIC must be carefully chosen. The LM358 is not the best choice - it has stability problems with high capacitive loads, it has sensible offset and the output swing is not the best. If more precision is required better to be chosen an R2R (rail to rail) input/output opamp with JFET/CMOS (low input current) inputs, with low offset. 
The higher offset in my case would be useful "feature", because further, in the software tuning part, I would like to show, how this offset can be corrected by the use of the software.
Using the PMOS transistor, will allow us to use the "load/no load" function of the Ohmmeter, but could create stability problems.
Using PNP BJT has the  advantage that the circuit is stable. 
In both cases, independently, which type devices are used (OK..mostly for the PMOS), they create small accuracy problems.
    The reason for lower accuracy is the limited output resistance of both devices. What is this meaning:
Lets take the resistor range 1000 Ohm. In this case, reference current of 2.5mA are passed through the resistor, and the generated voltage is applied to the ADC input of the Atmega chip. The resistor value, which we want to measure can vary between 0 Ohm and 1000 Ohm. The voltage Vmeas in this way also varies between 0V and 2.5V. The Vce (Vds) : Collector-emitter/ Drain-source voltage varies between 0.5V-3V.  The variation of the mentioned voltage affects directly the collector-emitter / drain-source flowing  current, what finally results in worse accuracy. The described phenomena can be better understood looking on the typical NPN BJT transfer characteristics presented on the picture.
This effect can be in some limits corrected by the software, but if some non linearity  effects are available, the correction becomes very difficult.

   

Step 7: How the Beta Is Measured....

    The current, which generation was explained in the previous step is passed through different devices : resistors, diodes, LED's, Schottky diodes...etc. The generated voltage drop over the corresponding device is measured. This voltage can serve as information obout the functioning of the device. For example, the Vf  (the voltage drop over the device, when connected in forward direction) can vary for:
     diodes                                                           -  0.4V- 0.8V
     Schottky diodes                                           -  0.1V-0.5V
     LED   (depend on the color)                      - 1.1V-3.5V...etc.
For this check, the current of 10uA is used.
If the current 2.5mA is passed though the mentioned devices, these voltages become higher. The LED's start to glow. This is way to test securely the functionality of LED diodes. (The white ones could not glow - sometimes they require over 3V).
     The current with value 10uA is used also for the NPN BJT Beta (Hfe) measurement . The circuit and the corresponding calculation for this can be seen on the picture   
           
     

Step 8: The Parts List (BOM)

  Part                                      Value /Name                Package

C1                                           100nF                                C0805       
C2                                           100nF                                C0805       
C21                                            10u                        085CS_1AR   
D1                                   Zener 5.1V                              DO34Z7      
D2                                      Zener 2V                              DO34Z7      
D3                                      Zener 2V                              DO34Z7              
F1               MF-MSMF050-2 500mA-                                 L1812 
                   resettable PTC
IC1/U1                                   LM358                                   SO08   0r
                                              LM358                               SOIC08
IC11                        74LVC1G14DBV                              SOT23-5 
U2               SN74LVC2G66_DCT_8                                    DCT8        
LED1                     GREEN SMD LED                  CHIPLED_0805
LED2                         RED SMD LED                  CHIPLED_0805
Q1                                       BSS123                                SOT23                 
Q2                                       BSS123                                SOT23       
Q3                                       BSS123                                SOT23       
Q4/T1                                   2N3906                                  TO92    Or
                                          NDT2955                              SOT223    
R1                                        10K 1W                             0207/10     
R2                                                 10                                R0805       
R3                                               510                                R0805       
R4                                               10K                                R0805       
R5                                                 2K                                R0805       
R6                                               1K1                                R0805       
R7                                               510                                R0805       
R8                      10K   (trimmer pot.)                          RTRIM64W    
R9                                      1 1W 1%                              0207/10     
R10                                           1.5K                                 R0805       
R11                                            12K                                 R0805       
R12                                           1.5K                                  R0805       
R13                                             300                                 R0805       
R14                                             300                                 R0805       
R15                                             300                                 R0805       
R16                    250K  (trimmer pot.)                          RTRIM64W    
R17                    1000  (trimmer pot.)                          RTRIM64W    
R18                                            10K                                  R0805       
S1                                  microswitch                            B3F-10XX    
S2                                  microswitch                            B3F-10XX    
     
U$1    Banana connector socket   4mm    
U$2    Banana connector socket   4mm    
U$3    Banana connector socket   4mm    
U$4      16x2 LCM (Character liquid crystal display module)  . Very cheap (2.25 USD) at ebay.   Not needed if you want to use only the serial monitor mode.   
       
Header connectors - male and female 
DUT      IN GND e c b e                        1X06
JANALOG  6x1F-H8.5-L14.5mm            1X06        
JANALOG1 POWER                             1X06        
JHIGH    10x1F-H8.5-L14.5mm              1X10        
JLOW     8x1F-H8.5-L14.5mm               1X08

Step 9: PCB's...

   The PCB's were ordered in the fab and after two weeks they came.

Step 10: Soldering...

     All the parts were soldered. I have decided to solder female header for LCM. On the LCD module, I have soldered pin headers. In this way I can simply attach and detach the display when needed or to use it for other projects  :-).
    When was possible, I tried to chose the most precise parts, from those available at home.

Step 11: Some Explanation About the PCB

On the pictures can be seen how the tested devices (resistors, diodes, Schottky diodes, LEDS are inserted)

Step 12: Let's Start the Tests

    As first step I wanted to test the LCD connection and control correctness. For that purpose I used the well known "Hello world" example available in the "LiquidCrystal" library with small modifications.
   My LCM has different connections, as described in the example. The reason for that is - I wanted to have the "Arduino" digital pin #2 free, because I wanted to use the interrupt attached to this pin for other purposes.
     The pin connections are the following:

   LCM 1602                  Arduino

D4                                         6
D5                                         5
D6                                         4
D7                                         3
E                                          11
RS                                       12
RW - connected to ground

     Additionally, I have connected the display back-light  LED "K" pin to the "Arduino" digital pin 10. I wanted to be able to fade the back-light and to create some effects  ( "Overflow") .
     The modified "Hello world" sketch is attached.

Step 13: Functions Definition

     The next step was to defined the all functional modes. I have counted 9 of them. They are shown on the picture. 
     Now the idea was to test the functional mode selection. I wanted that all the modes roll one after the other in one direction, by pressing the switch called "MODE". There are two switches on the shield board - the first duplicates the reset button of "Arduino", the second one is the "MODE" switch. As mentioned before, this switch is connected with pin #2 of the "Arduino" board. To this pin is attached the hardware INT0. Using the interupt, I have implemented debouncing of the switch. The debouncing and the menu state machine was tested with the attached sketch.

Step 14: The DMM Software

After successful finishing of the previous tests, the main working DMM software was written.
The code is attached in the *.ZIP file.
I will explain only some main functions, the other simply repeat them:

The function for voltmeter (range 0-100V) :

void V_100() {
digitalWrite(v100, HIGH);
lcd.clear();
lcd.print("V-meter V=<100V");
Serial.println("* Voltmeter mode - Range 0 - 100 V *");
lcd.setCursor(0, 1);
voltage_meas();
}


prints some messages on the screen and calls the function voltage_meas() :

void voltage_meas() {
acc_value = 0;
for (int i=0; i <= 15; i++){
curr_value = analogRead(A0);
acc_value = acc_value + curr_value;
}
curr_value = int(acc_value/16);
if (curr_value == 1023) {
meas_overflow(); }
else {
switch (MODE) {
case 1:
disp_res = ( curr_value*supply*20)/1024*coeff_v100 ;
break;
case 2:
disp_res = ( curr_value*supply*6)/1024*coeff_v30;
break;
case 3:
disp_res = ( curr_value*supply*2)/1024*coeff_v10;
break; }
lcd.print(" V = ");
lcd.print(disp_res, 2);
lcd.print(" V");
Serial.print("* V = ");
Serial.print(disp_res, 2);
Serial.println(" V");
delay(250);
}
}


, which take 16 consecutive samples and
averages them. If the result is less than 1023, it converts the ADC word to corresponding voltage value and displays it on the screen. During this calculation, some trimming factors are added. First of them is the measured preliminary supply voltage (it is used as reference for the AD conversion), the second one tries to correct the devices mismatch. It is close to 1.00, but in some cases can differ few percents. This coefficient is determined empirically during the tuning phase. Explanation will follow.
If the result after the averaging of the 16 samples is 1023 the "meas_overflow" is called.

void meas_overflow() {
lcd.setCursor(0, 1);
lcd.print(" OVERFLOW!!! ");
Serial.println("* OVERFLOW!!! *");
lcd.setCursor(0, 1);
for (int i=0; i <= 101; i++){
analogWrite(back_light, brightness);
brightness = brightness + fadeAmount;
if (brightness == 255) {
fadeAmount = -fadeAmount ;
}
delay(15);
}
}


In this procedure the back-light is faded and a warning is displayed.



On the pictures can be seen the functioning DMM in different modes and functions.

P.S. Thanks to jfrontone, we have found a possible problem in the code.

It is in the button_pressed() procedure.

if the increment MODE=MODE++; does not work (sometimes this depends on the microcontroller chip or on the IDE version), you can write either MODE=++MODE; or MODE=MODE+1; . Until now no-one has reported about such problem in the "for" control structure - for example for (int i=0; i <= 101; i++)...

Step 15: Software Tuning of the Accuracy (part 1)

    Let's as first step to trim the voltmeter.
I will show how to do this for the range 0-10V. The other ranges are trimmed in the same way. 
To trim the accuracy for a given range the best approach is to chose trimming reference voltage, as close as possible to the upper limit of the range. Once trimmed for this voltage is assumed that, because of the linearity of the voltage divider and the AD conversion , the whole range is covered with the same accuracy. To trim the voltmeter for the range 0-10V I have taken new 9V battery.
As first step I have measured the power supply voltage at the "Arduino" board supply header. In my case it was 4.91V.
This voltage serves as reference for the ADC of the Atmega chip. It is included in the formula for the conversion of the taken ADC reading to voltage value:
                  disp_res = ( curr_value*supply*2)/1024*coeff_v10;

, where :
        disp_res  - is the voltage value displayed on the screen;
        curr_value - is the averaged digital reading;
        supply - is the measured power supply voltage ;
        coeff_v10 - is the software trimming coefficient 
     The next step is to measure the battery voltage by the standard DMM and to write the value.
     After that we measure the same battery with the "Arduino" based DMM. Based on both measurements we calculate the trimming coefficient   coeff_v10 as quotient resulting of the division of the first measurement result by the second measurement result.  In my case I have measured the battery with the standard DMM to be 9.51V. Measured by the "Arduino" DMM it was 9.34V.
The correction coefficient was calculated as:
     coeff_v10 = 9.51/9.34 = 1.018
The resulting value is assigned to the coeff_v10 in the code.
After recompiling and loading the code it is seen that after the trimming the "Arduino" DMM shows the target value.
I would recommend that this coefficient is calculated for few voltages measured with the same range settings and the final value entered in the code is the averaged of all calculated.


Step 16: Software Tuning of the Accuracy (part 2)

Let us trim the ampere meter.
The voltmeter trimming was easy - the error was caused only by the spread of the resistor values in the voltage dividers.
In the ampere meter the sources of errors are mainly:

  • the resistor spread of R1 (see the picture in step 4). Its value is 1 Ohm, and the exact value of the used device is difficult to be measured precisely
  • the voltage gain of the opamp - caused mainly by the resistors R2 and R3 values spread
  • The offset of the opamp Voffset. As mentioned before LM358 is not the best choice for this project ( I had one available and I have used it. That is the reason why the PCB supports also the SO08 package - not often used in our time). In the datasheet of the chip can be seen that the offset can be 7 mV. With our current to voltage transfer solution, this can introduce a constant current error of 7mA. It can happen that no current is passing, but the ampere meter shows 7mA, and vice versa : a current of 7 mA can flow and the device can show 0 mA.

All these errors must be cleaned up by the software.
As first step we have to determine the exact value of the R1 resistor. For that purpose I used a constant current generator.
I have applied 189.9 mA input current and I have measured 186.7 mV on the resistor R1. Its value is calculated to be 0.98315 Ohm. This number will be used also as correction coefficient.
Now remain two other parameter, which must be calculated / measured : the real voltage gain of the opamp and its offset voltage.
To determine them we need to make two separate measurements at two different currents. The measurements are : we fix the current by the current generator and we measure it once with the standard DMM and once with "Arduino" based DMM. The voltage on R1 is also measured during this procedure. Here are the results which I had :
Applied current Measured current Voltage over R1
(standard DMM) "Arduino" DMM (standard DMM)
[mA] [mA] [mV]

189.9 186 186.7
73.1 71.9 71.7

The opamp offset voltage is added to the voltage drop over R1, and the resulting potential is amplified 10 (corrected with the gain error coefficient) and finally converted by the ADC.
This process can be modeled with the following equation:
( VR1+Voffset)*coeff_A_gain=Imeas;
where:
VR1 - is the voltage over R1;
Voffset - the input opamp offset voltage;
coeff_A_gain - gain error coefficient, in this case has unit of Siemens [S];
Imeas - measured by the "Arduino" DMM current

Based on this equation and the measured data, replacing Voffsetwith "x" andcoeff_A_gain with "y" a system of two equations and two unknown variables can be written:

(186.7 + x ) * y = 186
(71.7 + x ) * y = 71.9

186.7y + xy =186
71.7 y + xy = 71.9 ; extracting from the first the second equation

115y=114.1
y = 0.992174 - the gain error caused by the resistor value spread of the gain defining resistors R2,R3

X = 0.767 mV - the input offset of the opamp (not so bad...)

The final code for the ampere meter now would have the following definitions:

float coeff_A_gain = 0.992174;
float coeff_A_res = 0.98315;
float opamp_offset = 0.000767;


The calculation of the current can be done with the following equation:
disp_res = (((curr_value*supply )/1024 - 10*opamp_offset)/coeff_A_gain)/coeff_A_res*100;

(see the step 14 for additional information)

Step 17: Trimming the Ohmmeter

How to trim the ohmmeter I will show for the range 1000 Ohm. The same approach is used for the other range.

Before applying the software trimming some additional measurement must be done.

  1. The voltage drop over the Zener diode D2.
  2. To have stable current I have changed the following row in the main program ( loop () ) : digitalWrite(curr_mode, LOW------------------->HIGH); - in this way I can keep the current stable and to measure it during the welcome procedure. The current flowing from the PNP/PMOS collector/drain terminal to ground should be measured (picture 1)
  3. The same current is measured again but with serial connected resistance of 1KOhm (the max for the range) - picture 2. The voltage over the resistor should be measured too.

I have measured 2.5 mA in the first and 2.48 mA in the second measurements. My resistor was 997 Ohm.

Now we need to process the sampled data. To be able to make this we need to calculate also the Vce/Vds - the voltage drop over the transistor for bot cases.

This voltage - for simplicity I will write Vce is calculated using the following formula:

Vce = Vsupply - Vzener - Vr, where

Vsupply is the measured supply voltage of the "Arduino" board;

Vzener - the voltage drop over D2 (measured at step 1 above);

Vr - the voltage over the resistor - measured at step 3. For the first case is 0 V.

The calculated Vce and the corresponding currents are filled in excel file.(picture 3). Graph is done, and trendline corresponding to the date is shown (straight line). The equation of the trendline is displayed - it will be used for the calculations.

In my case Ir = Ice = 0.0081*Vce+2.4773 - using this formula we can calculate always the current Ice flowing through the measured resistor and also function of the voltage over the resistor, which is sampled by the ADC. Here is taken the presumption, that the dependence Ice of Vce is linear, what is commonly true.

Finally we calculate the resistance using the Ohm formula:

R = Vr / Ir

here is how the modified code looks like:

.......

float V_zener = 2.16;
float Vr = 0;

float Vce = 0;

float Ice = 0;

float coeff_v100 = 1.01;

float coeff_v30 = 1.011;

float coeff_v10 = 1.018;

float coeff_A_gain = 0.992174;

float coeff_A_res = 0.98315;

float opamp_offset = 0.000767;

volatile unsigned long last_millis = 0;

void R_1000() {
digitalWrite(curr_mode, HIGH);

delay(20);

lcd.clear();

lcd.print("Ohmmeter R=<1000");

Serial.println("* Ohmmeter mode - Range 0 - 1000 Ohm *");

lcd.setCursor(0, 1);

acc_value = 0;

for (int i=0; i <= 15; i++)

{ curr_value = analogRead(A2);

acc_value = acc_value + curr_value; }

curr_value = int(acc_value/16);

if (curr_value >= 513) { meas_overflow(); }

else { Vr = ( curr_value*supply )/1024;

Vce = supply - V_zener - Vr; Ice = 0.0081*Vce + 2.4773;

disp_res = Vr / Ice * 1000;

lcd.print(" R = ");

lcd.print(disp_res, 1);

lcd.print(" Ohm");

Serial.print("* R = ");

Serial.print(disp_res, 1);

Serial.println(" Ohm");

delay(250); }

}



As conclusion:

The presented multimeter is designed in the simplest way, trying to embed as much functions as possible. This approach brings some undesired features - the input resistance is very low, the accuracy in comparison with the standard fabric DMM is lower. The reasons for that are :

the matching of the discrete elements (mainly resistors);

not enough accuracy of the microcontroller ADC - it is 10 bit, but allows error of 3-4 LSB;

the digital noise affecting the analog measurements;

not well fixed supply voltage (it can vary when the DMM is connected to different computers), which serves as voltage reference for the ADC converter;

...etc.

Despite all disadvantages, in this work was shown, how using software tricks, the accuracy of such device can be drastically increased - starting with multiple ADC readings, their averaging and all additional software trimming. I think that similar project would be interesting for students willing to get deep inside the data measuring and processing theory. It can be used also as DMM replacement for home electronic projects, which do net require more complicated measurement tools.


Thank you for the attention!

Comments

author
Milen (author)2017-08-31

Hi,

You can - but you have to merge both procedures (for voltage and current measurements) in one and to display both values.

author
diazfth (author)Milen2017-09-02

Hi Milen, thanks for the reply

I've tried it but the voltage value remains zero. Only current value is displayed on serial monitor.

This my simplified circuit on my project. thankyou

Capture.PNG
author
Milen (author)diazfth2017-09-02

HI,
as I see on your circuit, the resistor R1 I connected from both sides to Arduino GND - that means it is shorted. No voltage drop exist over it.
That is the reason your voltage is always zero.
Re-arrange the circuit - I would suggest to put R1 from the left side of R3.You will have some small voltage measurement error, but you can cancel it by the software. Also the current should affected by the additional voltage divider R6,R7...but this can be also corrected.

author
diazfth (author)Milen2017-09-02

Oh okay, Now I know the main problem. is my circuit correct now? (which figure 1 or figure 2 is correct?)

one more question, how to get rid that error? please give me more explanation and example. thank you sir

Capture.PNGCapture1.PNG
author
Milen (author)diazfth2017-09-02

Hi,

The right one could work. I would remove R2 if possible.

Practically this measurement is not fully identical with the 4 probe measurement. There the main idea is to pass some known current and to measure the voltage drop, here the current is defined by your resistors and the applied voltage.

If you remove the R2 than you can measure precisely the voltage as

Vin = (R6+R7)/R7*Vmeas, where Vin is the battery voltage (input voltage), Vmeas is the sampled voltage.

The current sourced by the battery can be estimated as Imeas+Vin/(R6+R7),

where Imeas is the measured current and Vin is the calculated voltage(see above).

If R2 is your load and you can not omit it, then the formulas will change.

R2 must be known and have to be inserted in the calculations.

What is the tool that you use for drawing the circuit?

Do you use some spice simulator?

I would suggest you to simulate the circuit before building it.In this way you can observe all voltage and currents and to see their behavior.

here is a nice free spice simulator, which you could use , in the case you do not have one : http://www.linear.com/solutions/ltspice

author
diazfth (author)Milen2017-09-02

Hi, thanks for the reply.

in my project, I have some circuit that can make a constant current. I use cascode BJT Current Mirror with sink configuration ( I use NPN Transistor to make it). I can remove R2 because the load is on R1. And yes, the right ciruit is not identical with 4 probe measurement.

I use proteus for drawing that circuit.

I will download the software you give to me. and I will make some simulation on it.

I will use your equation and try to simulate it. I will contact you if i get some problem again. Thankyou very much sir.
author
diazfth (author)diazfth2017-09-02

one thing I forgot to say, I will use my circuit for measuring high voltage with four probe method like this

four-pt-schematic.gif
author
diazfth (author)2017-08-30

Hi Milen,

can I measure current and voltage at the same time?

author
eduman (author)2017-06-15

Hi,

Can we measure AC voltage?

Thank you..

author
Milen (author)eduman2017-06-15

Hi,

In the state it is now - no.

hardware or software changes must be implemented.

Software - you could make FFT and find the signal amplitude

Hardware - the voltage must be rectified, filtered and measured as DC - further calculations must be done to receive the RMS value.

author
DummyD (author)2017-05-13

hi sir, im new to arduino and i want learn more how did you make this multimeter powered by arduino...especially the ammeter part and if you have the spare time could you teach? any help will be appreciated

author
Milen (author)DummyD2017-05-14

Hi,

Practically all amperemeters work in similar way - the current which must be measured is passed through small resistor. It creates a voltage drop over the resistor, and this voltage drop is measured by the embedded in the multimeter voltmeter. Further a calculation of the current is done : known are the resistor value and the voltage drop over the resistor and according the Ohm's law I=V/R.
In my case I use the same approach - the measured current is passed through 1 Ohm resistor. After that I use amplifier by 10 - I multiply the voltage drop over the resistor 10 times. For that purpose an operational amplifier in noninverting configuration is used (the input resistance of this configuration is practically infinity).
So a current of 500 mA flowing through 1 Ohm resistor creates 0.5V voltage drop x10 = 5V(as big as the supply voltage of the arduino and as its reference voltage used .for the analog to digital conversion.). Amplifying the voltage drop over the resistors makes the resolution of the measured voltage 10 times better.
As you know the arduino main chip has embedded 10 bit ADC.
The amplified voltage is measured by it - using the AnalogRead() command. I measure it 16 times. Then I sum all these results and divide the sum by 16. In this way I receive some average value, what improves the accuracy of the measurement - removes the noise in some degree and improves the resolution. This value is still digital word (big from 0 to 1023). And finally I calculate the real current:
the digital word I divide by 1024 - this gives the ratio measured voltage divided by reference voltage. After that the division is multiplied by the reference voltage (in our case the ATMEGA328 supply voltage) and we have the needed measured voltage. We divide it by 10 to cancel the amplification, and divide it by 1 Ohm (in my case - it can be also different value - depends on the resistor used) and we have finally the needed current.

author
DummyD (author)Milen2017-05-15

thanks for the fast response sir..Im getting the gist of it but im a little bit confused so ill ask a question again if you may, and correct me if im wrong.. Basically on what i understand you use your voltmeter ckt to read the voltage drop across the 1 ohm resistor and amplify that voltage using the LM358 opamp to get a higher value for a better resolution for arduino...

So my question sir regarding to the amperemeter, what is real the input for the amperemeter ckt. It is the voltage or current? voltage used to supply the LM358 opamp? and lastly im not really good at reading schematics sir and i have a favor to ask can you please give me the schematic you used just for the amperemeter and the code...and i apologize for being demanding but i need your knowledge to help me understand all of this..

thank you in advanced sir and any help is much more appreciated :)

author
Milen (author)DummyD2017-05-15

Hi,

The input for the amperemeter is current, but there is a current to voltage conversion inside the DMM - The current passing through 1 Ohm resistor creates voltage drop. And practically what the DMM does is measuring this voltage, but not the actual current. You can see the schematics of the amperemeter at step 5. Because the voltage is measured (which is product of the current passing through 1 Ohm resistor), there is not a big difference between the voltmeter and the amperemeter in the code.

Only the calculations of the results, which shall be shown on the screen are different. The units also.

The procedure performing current measurement is A_500() - you can scroll the code and find it easy.

author
DummyD (author)Milen2017-05-15

thanks again for your help sir.. but according to the schematics on step 5 the positive supply and negative supply of the opamp are not connected, and how much voltage did you use to supply the LM358 supply? and how did you use the amperemeter to measure current did you connect it in series like normal multimeter??

i hope for your response and thank you in advanced:)

author
Milen (author)DummyD2017-05-15

The opamp is supplied by the common supply (5V). Its ground is the common ground. The amperemeter is used in series as usual amperemeter. Please read step to for more precise explanation.

author
DummyD (author)Milen2017-05-17

sir sorry but im still having some trouble understanding the amperemeter..you said the input for the amperemeter is current but how did you produce current?? and the arduino only reads voltage correct me if im wrong...further help is aprreciated sir

author
Milen (author)DummyD2017-05-17

Hi,

I did not produce current. It is flowing by itself. Imagine a wire through which a current is flowing. We cut the wire and put the ampermeeter between two cut parts. That means - we short again both pieces but through 1Ohm resistor. (we suppose it does not effect the current value). The current flows again. But it creates a voltage drop over the 1Ohm resistors. That is what we measure.

author
DummyD (author)Milen2017-05-17

i get it now sir and thank you for answering my questions :) (Y)

author
DummyD (author)DummyD2017-05-20

hi sir

i just want to verify one more thing, does the DMM measure the voltage,resistance and current at the same time??

author
Milen (author)DummyD2017-05-21

If you apply all current, voltage and resistance simultaneously - you can measure each of them switching by the main menu.

author
DummyD (author)2017-05-15

thanks for the fast response sir..Im getting the gist of it but im a little bit confused so ill ask a question again if you may, and correct me if im wrong.. Basically on what i understand you use your voltmeter ckt to read the voltage drop across the 1 ohm resistor and amplify that voltage using the LM358 opamp to get a higher value for a better resolution for arduino...

So my question sir regarding to the amperemeter, what is real the input for the amperemeter ckt. It is the voltage or current? voltage used to supply the LM358 opamp? and lastly im not really good at reading schematics sir and i have a favor to ask can you please give me the schematic you used just for the amperemeter and the code...and i apologize for being demanding but i need your knowledge to help me understand all of this..

thank you in advanced sir and any help is much more appreciated :)

author
Milen (author)2017-02-22

Sorry,

I did a mistake.

None of the listed chips will work as input voltage protection for the DMM if connected as shown in their datasheets.

Problems:

1) They must be supplied by the common DMM supply - not by the input voltage, because it could drop even to 0V and the current is limired.

2) If only NMOS or PMOS switch used - it will cut some part of the input voltages

when PMOS used - it will pass only the voltage (rough said) >2.5V, if NMOS only used it will pass voltages <2.5V.

So called transmission gate must be used ( parallel connection of NMOS and PMOS) switches controlled by the signals with opposite polarity.

That means - at the output of (let's say) NCP346 additional inverter must be connected and it has to control an NMOS switch connected in parallel with the PMOS switch controlled directly by the "OUT" terminal of the chip.

So.... the circuit becomes more and more complicated :-)

author
ArezkiL (author)Milen2017-02-22

ah i see, thanks for prevention and explanation, can i use a varistor instead to avoid this complicated circuit and im afraid i can't find this ics either ?

author
Milen (author)ArezkiL2017-02-22

The varistors are for high voltages.
In all cases the simplest solution is to use some 5.6V zenner diode.

author
ArezkiL (author)Milen2017-02-23

that's right i ll keep searching, there must be the right diode out here.

sorry i took to much of your time and really appreciate your help thanks!

Regards

Arezki

author
Milen (author)2017-02-22

Hi,

I took a look on the datasheets.

The serial diode is optional.

You can use NCP346 without it and without problems.

author
Milen (author)2017-02-20

Hi ArezkiL

As I remember I bought 50 pcs 5.6V zenner diodes and I have chosen one of them having the smallest reverse current at 5V.

There are also another possibilities to protect the input against HV.

There exist special overvoltage protection circuits containing MOS switch with very low Ron, which observe the input voltage and if it becomes higher then desired interrupt the connection. All depends on that how much you want to complicate the device :-)

Examples of such circuits:

NCP346, STBP112,NUS3046MN...and a lot of others.

You can use 5% resistors, The introduced error you have to correct further by the software trimming.

Regards

Milen

author
ArezkiL (author)Milen2017-02-21

i ve read about NCP346 it says that it requires external schottky diode to prevent reverse current, Is it necessary?

are all commercial multimeters operating this way or there are other circuit diagrams ?

author
Milen (author)ArezkiL2017-02-21

May be NCP346 is not the most suitable circuit for a voltmeter.
It has to have only low Ron switch. Check the others.
The serial diode would effect the correctness of the measurement because of the voltage drop on it.

Normally each multimeter should have some protection on the input.
The protection which I use is the simplest and may be most used.
As common the DMM devices use dedicated chips (ASIC) and I suppose the protection is embedded directly inside them - in all cases it has to based on some voltage clamping circuit, or circuit similar to mentioned before chips.

author
ArezkiL (author)Milen2017-02-22

i will check the others.

thanks a lot!

author
ArezkiL (author)Milen2017-02-21

thank you so much! yes i want to complicate it but im not an expert therfore i can't change it or add other compononents on my own so i have to follow a schema and your advices thanks for help again ^ ^

author
ArezkiL (author)2017-02-20

Hi Milen,

thanks for this great project!

sorry for the late comment i would ask you if i can remplace zener diode of the voltmeter with other protection components because i couldn't find a low current leakage one ? and about resistors can i use 5% tolerance resistors ?

author
CharleneD16 (author)2016-12-20

Dear Milen,

Can you suggest any alternative for 74LVC1G14DBV and SN74LVC2G66? I would prefer it to be thru-hole instead of SMD.

author
Milen (author)CharleneD162016-12-20

Hi CharleneD16 ,

You can replace the chip with a pair of PMOS transistprs (like BSS84 :
http://www.nxp.com/documents/data_sheet/BSS84.pdf) Exactly this is SND, but you can find similar in through-hole package. There should not be any difference in the performance.
The transistors should be connected in the following way:
sources - supply
gates - first to the input of the inverter, second at the its output
drains - to the trimmer potentiometers

Regards
Milen

author
CharleneD16 (author)Milen2016-12-20

Thanks a lot! This project is really awesome. Thank you for sharing.

author
CharleneD16 (author)CharleneD162017-02-10

What is the maximum current and the maximum frequency that can be feed to the analog pin of an Arduino Nano? Can I substitute the resettable PTC fuse to a glass fuse instead?

author
Milen (author)CharleneD162017-02-12

Hi,

you can not feed current inside the analog pin. You can apply only voltage - not more than the supply voltage+0.5V.

The maximum frequency is determined by the max sample rate:

76.9kSPS of the ATMEGA328 ADC and the Nyquist requirement ----> around 38,5 kHz.

You can put a fuse from the type that you like, but its max current must be proper chosen

author
CharleneD16 (author)Milen2017-02-12

Hi Milen,
Thank you for your reply. I just want to ask about the maximum current rating that the fuse for ammeter can be?

author
Milen (author)CharleneD162017-02-12

Hi,

as designed it measures 500 mA max current - that should be the fuse rating. If you want to measure higher current ´then you have to change also the resistor. You could add also input for higher currents with different resistor and can use also different arduino analog input.

author
ChumpolW (author)2016-08-17

Dear Milen

You did a great job ! I have a project that need to use arduino as multimeter. Could you help me something? If i just want to use Arduino for measuring Current, Voltage, and Temperature and send the data to PLC, I don't need to show in LCD, but send to PLC.
What is the code should i use in Arduino program ? If Arduino's TX pin connect to TTL to RS232 converter.

author
Milen (author)ChumpolW2016-08-17

Thanks,
I think - you have to decide which type of communication you want to use : SPI or I2C and depending on this to define the used pins and libraries. From the code you can remove then the LCD and serial monitor part.

author
ChumpolW (author)Milen2016-08-24

Dear Milen,
Thank you for your replied and sorry for my late respond. I read about SPI and I2C as you recommended, So i chose I2C be my answer because I have to measure in real-time and yes I2C has more speed than SPI. I have a design for my Arduino measuring Voltage and Temperature as this in attached picture. Will it work ? I will use TX port for sending data to "TTL to RS232" and then to PLC.

Untitled-1.png
author
Milen (author)ChumpolW2016-08-24

Hi,

Check the connections of the voltage sensor - seems that the sig and supply pins are swapped. Is it not possible to supply this sensor with 5V arduino supply?

Do not forget pull-up resistors needed for the I2C communication. I suppose that also the rx TTL pin shall be connected - some return data is send also during the communication.

regards

Milen

author
ChumpolW (author)Milen2016-08-24

Dear Milen,
Thank you very much ! But i'm not sure about the code. If i connected IR Temp and Voltage Sensor(swapped it already) with Arduino, Should i write the code like "DigitalRead(A1, Voltage) and DigitalRead(SDA or SCL, Temp)" like this ?
I know about doing code to show in LCD, But I don't know about sending/receiving data from TX/RX pin. Could you give me some hint ?
Sorry for bothering you a lot.

author
Milen (author)ChumpolW2016-08-24

Hi .

Please write the type of both sensors. For the temperature sensor I suppose you have to serch the proper arduino library. The voltage sensor seems to me to have an analog output (check if true). In this case you have simply to use AnalogRead(A0). Check what should be the output voltage if you supply the sensor with 9V battery (as on the picture). If it is higher than 5V - an error will occur - you have to insert proper resistor voltage divider at the output of the voltage sensor and the analog arduino pin.

author
WisarUK (author)2016-07-08

Great project! What are the dimensions of the PCB? I am going to order one but need the size and I can't read the Eagle files.

Thanks,

Will

author
Milen (author)WisarUK2016-07-08

Hi Will,

The PCB size is 92.1 x 53.6 mm. Good luck.

Regards
milen

author
WisarUK (author)Milen2016-07-09

Thanks for the fast reply. My idea is to piggyback your electronics with a Pi Zero and have the Pi deliver a GUI front end. Ideally I want to get the Eagle board into Fritzing and hope I can find a conversion tool as I don't want to learn Eagle!

Will

author
nituj (author)2016-06-22

Hello Milen,Ray,

I am interested to make PCB for this design. If its possible may any of you share the Gerber files? I am going with PCBway.

Thanks

About This Instructable

124,069views

385favorites

Bio: Thank you all for following me.
More by Milen:DIY Oscilloscope Kit - Assembling and Troubleshooting GuideParty stroboscope done by recycled partsArduino controlled power supply source
Add instructable to: