Beruflich Dokumente
Kultur Dokumente
workshop
living
food
play
outside
Table of Contents
Make a Mini Arduino programmable 4 channel DC-DVM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Step 5: Calibration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
http://www.instructables.com/id/Make-a-Mini-Arduino-programmable-4-channel-DC-DVM/
Image Notes
1. Resistors:
4 x 1meg ( brown, black, green)
4 x 100k (brown, black, yellow)
Image Notes
http://www.instructables.com/id/Make-a-Mini-Arduino-programmable-4-channel-DC-DVM/
1. solderless breadboard
2. TFT LCD Color display
3. Jumper wires
4. Arduino uno
Image Notes
1. Sainsmart Arduino Nano Clone
http://www.instructables.com/id/Make-a-Mini-Arduino-programmable-4-channel-DC-DVM/
http://www.instructables.com/id/Make-a-Mini-Arduino-programmable-4-channel-DC-DVM/
void loop()
{
V1= analogRead(0);
Serial.print(" Voltage @ pin A0 ");
Serial.println((((V1*VREF) / 1023)) * Dv1, 2);
}
// -----------------Sketch End----------------------------Let's review what's happening;
The Atmega controller used for the Arduino contains an on-board 6 channel analog-to-digital (A/D) converter. The converter has 10 bit resolution, which returns an integer
from 0 to 1023 (210 =1024, 0 counts, so it's 1023 steps) for the value of 0 to 5 volts.
We want to convert the A/D returned value to the actual voltage that we are measuring.
We need to multiply the result by 5 and divide by 1023 to adjust the value returned by the 10 bit A/D Converter.
We are also dividing the voltage by 11 with the voltage divider, so the voltage we are measuring ( and we want to see on the display), has to be multiplied by 11 to
compensate for the division.
We do that with the followimg formula:
Vout=((Vin*(5/1023))*11).
the code for this is:
Serial.println((((V1*VREF) / 1023)) * Dv1, 2);
We multiply by 5(VREF)and divide by 1023 to convert the A/D output into a scale between O and 5,then we multiply by 11(Dv1) to compensate for the voltage divider .
The reason we are using variables for the divider and voltage values, is that these values will change when we calibrate the DVM. The "2" at the end of the formula
defines how many digits to show after the decimal.
If you got the program to load correctly, open the serial monitor by clicking on the magnifying icon in the upper righthand corner of the arduino IDE, you should see data
flowing. Using a jumper wire, try connecting the free leg of the 1Meg resistor to the GND Pin first and then to the 5V pin . You should see the reading change from 0 to 5v.
Now we just have to repeat what we did for the first channel three more times to have a 4 channel DVM, but before we do that, let's connect our TFT COLOR LCD
DISPLAY to the Arduino. You will need 7 jumper wires to do this:
Connect the following with the jumpers
TFT LCD. Arduino
VCC 5V
GND Gnd
SCL 13
SDA 11
CS 10
RS/DC 9
RES 8
Note:
Unlike my other instructables, we will be using the high speed SPI Interface to drive the display so the jumper wiring is different. Again, check out the pictures to guide
you if your not sure how to wire it up.
You will need to install two libraries to use the display:
Adafruit_GFX .h The Core graphics library
Adafruit_ST7735 .h The Hardware-specific library
Download the libraries and copy them to the Arduino library folder.
Copy and paste the sketch below to the Arduino IDE. The sketch DVM code is the same, but with the addition of code to display the voltage on A0 on the LCD Display.
Compile and Upload the sketch to the Arduino.
// -----------------Sketch Start----------------------------/*----------------------------------------------------------Program: TFTLCDDVM
Description: DC voltmeter with voltage displayed
on Color TFT LCD to 2 decimal places
Hardware: Arduino NANO with voltage divider on A0.
TFT LCD connected
Software: Developed using Arduino 1.0.3 software
Date: 10 March 2014
Author: johnag
--------------------------------------------------------------*/
http://www.instructables.com/id/Make-a-Mini-Arduino-programmable-4-channel-DC-DVM/
#define sclk 13
#define mosi 11
#define cs 10
#define dc 9
#define rst 8 // reset
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <SPI.h>
Adafruit_ST7735 tft = Adafruit_ST7735(cs, dc, rst);
// voltage divider calibration value
#define Dv1 11
// ADC reference voltage
#define VREF 5
float V1 = {0.00};
void setup()
{
Serial.begin(9600);
tft.initR(INITR_BLACKTAB); // initialize a ST7735S chip, black tab
tft.fillScreen(ST7735_BLACK); // clear screen
tft.setTextColor(ST7735_WHITE);
tft.setTextSize(1);
tft.setCursor(10,0);
tft.println(" DC voltmeter DVM");
tft.setTextColor(ST7735_RED);
tft.setCursor(0,140);
tft.println(" Caution max voltage 55vdc");
}
void loop()
{
V1= analogRead(0);
tft.drawLine(0, 20, tft.width()-1, 20, ST7735_WHITE);
tft.drawLine(0, 130, tft.width()-1, 130, ST7735_WHITE);
tft.setTextColor(ST7735_YELLOW,ST7735_BLACK);
tft.setTextSize(2);
// voltage 1 (pin A0)
// voltage is multiplied by the resistor network
// division factor to calculate the actual voltage
tft.setCursor(45, 40);
tft.println(" V1 ");
tft.setTextSize(1);
tft.println(" Voltage @ pin A0 ");
tft.setCursor(20, 80);
tft.setTextSize(2);
Serial.print(" Voltage @ pin A0 ");
Serial.println((((V1*VREF) / 1023)) * Dv1, 2);
tft.print((((V1*VREF) / 1023)) * Dv1, 2);
tft.print(" Vdc ");
}
//---------------Sketch End----------------------------------------
Image Notes
1. 100K Resistor
2. 1 Meg Resistor
http://www.instructables.com/id/Make-a-Mini-Arduino-programmable-4-channel-DC-DVM/
3. Resistor junction
4. Jumper going from junction to Arduino A0 Pin
5. Jumper from 100k Leg to Arduino GND
6. Jumper used as voltage test probe
Image Notes
1. Arduino IDE
2. Serial monitor window displaying voltage at Analog pin A0
3. Serial monitor Icon click to activate
Image Notes
1. Arduino with 3 voltage dividers
Image Notes
1. VCC Pin to 5v
2. GND pin to GND
3. SCL to Arduino pin 13
4. SDA to Arduino pin 11
5. RS/DC to Arduino pin 9
6. RES to Arduino pin 8
7. CS to Arduino pin 10
Image Notes
1. PINS for display
2. Measuring only 1 voltage at pin A0
3. Jumper from resistor junction connected to Arduino pin A0
4. Voltage Divider
http://www.instructables.com/id/Make-a-Mini-Arduino-programmable-4-channel-DC-DVM/
float V1 = {0.0};
float V2 = {0.0};
void setup()
{
tft.initR(INITR_BLACKTAB); // initialize a ST7735S chip, black tab
tft.fillScreen(ST7735_BLACK); // clear screen
tft.setTextColor(ST7735_WHITE);
tft.setTextSize(1);
tft.setCursor(5,0);
tft.println("2 channel voltmeter");
tft.setTextColor(ST7735_RED);
tft.setCursor(0,140);
tft.println(" Caution max voltage 55vdc");
}
void loop()
{
V1= analogRead(A0);
V2= analogRead(A1);
tft.drawLine(0, 20, tft.width()-1, 20, ST7735_WHITE);
tft.drawLine(0, 130, tft.width()-1, 130, ST7735_WHITE);
tft.setTextColor(ST7735_YELLOW,ST7735_BLACK);
// voltage 1 (pin A0)
tft.setCursor(5, 40);
tft.setTextSize(1);
tft.println(" Voltage @ pin A0 ");
tft.setTextSize(2);
tft.setCursor(10, 50);
tft.print("V1 ");
tft.print((((V1*VREF) / 1023)) * Dv1, 1);
tft.print("V ");
// voltage 2 (pin A1)
tft.setCursor(5, 70);
tft.setTextSize(1);
tft.println(" Voltage @ pin A1 ");
tft.setTextSize(2);
tft.setTextColor(ST7735_GREEN,ST7735_BLACK);
tft.setCursor(10, 80);
tft.print("V2 ");
tft.print((((V2*VREF) / 1023))* Dv2, 1);
tft.print("V ");
}
//---------------------------2channel DVM END------------------
http://www.instructables.com/id/Make-a-Mini-Arduino-programmable-4-channel-DC-DVM/
Image Notes
1. Display from Arduino UNO running sketch for 2 channel DVM
2. Display from Arduino Nano running sketch for 1 channel DVM
3. Arduino UNO
Image Notes
1. Arduino UNO running 4 channel DVM Sketch
Image Notes
1. Close up shot of display
Step 5: Calibration
To calibrate the DVM, you will need a multimeter and a power supply with a stable regulated output. You can use the Arduinos 5 volt and 3.3 v as reference voltages, but
you do need a multimeter as there is a tolerance so voltage outputs may vary from Arduino to Arduino.
Steps for calibration:
1. Measure the voltage at the 5v pin in the Arduino with your multimeter, and use that number in the code as the VREF value. for example, if you measured 5.0v
then the line in the sketch that defines VREF should be #define VREF 5.0.
2. On your voltage divider circuit, plug the free leg on the 1meg resistor to the 5v pin of your Arduino, and measure the voltage across the entire voltage divider and
then the voltage across the 100 k resistor. (first from GND to the 5v then from GND to the resistor junction point, across the 100k resistor). Now divide the two
voltages, for examle, I got 5.0 for the voltage from GND to 5v and 0.46v for the voltage across the 100k resistor so I divide 5 by 0.46: 5/0.46=10.869
3. Place that value in the Dv1 definition line: #define Dv1 10.869.
4. Upload the sketch and see if the reading on your display matches the reading on your multimeter.
5. Repeat the steps for all the voltage dividers and change the values accordingly.
http://www.instructables.com/id/Make-a-Mini-Arduino-programmable-4-channel-DC-DVM/
Image Notes
1. Multimeter test probe lead
2. Multimete COM test probe lead
3. Voltage divider circuit
4. Vatiable voltage power supply made with a LM317 voltage regulator.
5. Jumpers going to power supply
6. Jumpers going to Arduino GND and 5v Pins
7. Arduino DVM
Image Notes
1. Meter reading at 11.22 volts
(coming from variable power supply)
2. Same voltage on display
Image Notes
1. ATX Power supply converted to Workbench Power supply
2. RS Multimeter
3. Arduino DVM
4. Variable voltage regulator using LM317
Image Notes
1. !0 K Pot used to vary Voltage from voltage regulator
2. Aligator clip test probe from DMM
3. Aligator clip test probe from DMM
4. Aligator clip test probe from DMM
5. Arduino DVM
http://www.instructables.com/id/Make-a-Mini-Arduino-programmable-4-channel-DC-DVM/
http://www.instructables.com/id/Make-a-Mini-Arduino-programmable-4-channel-DC-DVM/
{
// take a number of analog samples and add them up
while (Scount < NUMSAMP) {
sum += analogRead(A0); // read and add the samples
Scount++; //increment the sample count
delay(10); //Wait 10 mS before reading next sample
}
AVvolts = ((float)sum / (float)NUMSAMP * VREF ) / 1023; // calculate average voltage
// Display the calculated Average voltage
tft.setTextColor(ST7735_YELLOW,ST7735_BLACK);
tft.setTextSize(2);
tft.setCursor(45, 50);
tft.println(" V1 ");
tft.setCursor(10, 80);
tft.setTextSize(2);
tft.print(AVvolts * Dv1);
tft.println(" Vdc ");
Scount = 0;
sum = 0;
}
// -----------------Sketch End-----------------------------
http://www.instructables.com/id/Make-a-Mini-Arduino-programmable-4-channel-DC-DVM/
http://www.instructables.com/id/Make-a-Mini-Arduino-programmable-4-channel-DC-DVM/
Author:
--------------------------------------------------------------*/
#define sclk 13
#define mosi 11
#define cs 10
#define dc 9
#define rst 8 // reset
#include // Core graphics library
#include // Hardware-specific library
#include
Adafruit_ST7735 tft = Adafruit_ST7735(cs, dc, rst);
// number of analog samples to take per reading, per channel
#define NSAMP 100 // number of samples to take befor displaying
// voltage divider calibration values
#define Dv1 11.00
#define Dv2 11.001
#define Dv3 11.00
#define Dv4 10.985
// ADC reference voltage / calibration value
#define VREF 5.00
int sum[4] = {0}; // sums of samples taken
unsigned char Scount = 0; // current sample number
float AVvolts[4] = {0.0}; // calculated voltages
char cnt1 = 0; // used in 'for' loops
void setup()
{
tft.initR(INITR_BLACKTAB); // initialize a ST7735S chip, black tab
tft.fillScreen(ST7735_BLACK); // clear screen
tft.setTextColor(ST7735_WHITE);
tft.drawRoundRect(2, 20, 120, 110, 5,ST7735_WHITE);
tft.setTextSize(1);
tft.setCursor(5,0);
tft.println("4 channel voltmeter");
tft.setTextColor(0XFF00);
tft.setCursor(0,140);
tft.println(" Caution max voltage 55vdc");
}
void loop()
{
// take a number of analog samples and add them up
while (Scount < NSAMP) {
// sample each channel A0 to A3
for (cnt1 = 0; cnt1 < 4; cnt1++) {
sum[cnt1] += analogRead(A0 + cnt1);
}
Scount++;
delay(10);
}
// calculate the voltage for each channel
for (cnt1 = 0; cnt1 < 4; cnt1++) {
AVvolts[cnt1] = ((float)sum[cnt1] / (float)NSAMP * VREF) / 1024.0;
}
// display voltages on TFT LCC Display
// voltage 1 - V1(pin A0
tft.setTextColor(ST7735_YELLOW,ST7735_BLACK); // set color for V1
tft.setTextSize(2);
tft.setCursor(15, 40);
tft.print("V1 ");
tft.print(AVvolts[0] * Dv1, 1);
tft.print("V ");
// voltage 2 - V2(pin A1)
tft.setTextColor(ST7735_GREEN,ST7735_BLACK);// set color for V2
tft.setCursor(15, 60);
tft.print("V2 ");
tft.print(AVvolts[1] * Dv2, 1);
tft.print("V ");
// voltge 3 - V3(pin A2)
tft.setTextColor(ST7735_CYAN,ST7735_BLACK);// set color for V3
tft.setCursor(15, 80);
tft.print("V3 ");
tft.print(AVvolts[2] * Dv3, 1);
tft.print("V ");
// voltage 4 - V4(pin A3)
tft.setTextColor(ST7735_WHITE,ST7735_BLACK);// set color for V4
tft.setCursor(15, 100);
tft.print("V4 ");
tft.print(AVvolts[3] * Dv4, 2);
tft.print("V ");
http://www.instructables.com/id/Make-a-Mini-Arduino-programmable-4-channel-DC-DVM/
http://www.instructables.com/id/Make-a-Mini-Arduino-programmable-4-channel-DC-DVM/
http://www.instructables.com/id/Make-a-Mini-Arduino-programmable-4-channel-DC-DVM/
Mini Arduino
environment
monitor **
UPDATE Added RTC ***
by johnag
Your Image on
an Arduino! TFT LCD Screen
Guide by
Qtechknow
Mini Arduino
Portable EEG Brain Wave
Monitor + by
johnag
Mini Arduino
Multi Function
Controller w/
LCD Display by
johnag
How to use
2.4inch TFT
LCD SPFD5408
with arduino
MEGA 2560 by
zhungu
Arduino TFT
Forecast
Weather Station
with ESP8266
by tufantas
http://www.instructables.com/id/Make-a-Mini-Arduino-programmable-4-channel-DC-DVM/
Advertisements
Comments
http://www.instructables.com/id/Make-a-Mini-Arduino-programmable-4-channel-DC-DVM/