“Lesson 9--Microduino "DIY Multimeter"”的版本间的差异

来自Microduino Wikipedia
跳转至: 导航搜索
第4行: 第4行:
 
|
 
|
 
==Objective==
 
==Objective==
We have introduced the reading (0-1024) of the analog port before. Now, we will use the analog port of microduino to make a multimeter with the range of 0-5 V.
+
Previously, we introduced analogRead() and its return values of 0~1024. In this lesson, we will use the analog port of [[Microduino-Core]] to make a multimeter with the range of 0-5 V.
  
'''Notice: The circuit design of the experiment has no relatively complicated protection circuit. So please don't use more than two AA batteries and don't use the circuit to measure the lithium battery or other power supply!!'''
+
'''Important: The design of the experiment does not have an effective protection circuit. Please don't use more than two AA batteries and don't use the circuit to measure a lithium battery or any other power supply!'''
  
 
==Equipment==
 
==Equipment==
第12行: 第12行:
 
*'''[[Microduino-FT232R]]'''
 
*'''[[Microduino-FT232R]]'''
 
*Other hardware equipment
 
*Other hardware equipment
**Breadboard Jumper            one box    
+
**1x AA Battery
**Breadboard               one piece 
+
**1x Box of breadboard jumper wires    
**1kΩ resistor       one
+
**1x Breadboard                
**USB Data cable               one
+
**1x 1kΩ resistor        
 +
**1x USB Data cable      
  
 
[[File:lesson9All.jpg|600px|center|thumb]]
 
[[File:lesson9All.jpg|600px|center|thumb]]
  
==Experimental schematic==
+
==Experiment Schematic==
 
[[File:less0n9-schematic.jpg|center|600px|thumb]]
 
[[File:less0n9-schematic.jpg|center|600px|thumb]]
The purpose of using 1K resistor is that in the case of measuring end vacant, the GND reference guide to measure port, and avoid vacant interfaces interference.
 
  
 
==Program==
 
==Program==
第28行: 第28行:
 
void setup()
 
void setup()
 
{
 
{
   Serial.begin(115200);    //Set baud rate 9600
+
   Serial.begin(9600);    //Set baud rate 9600
 
}
 
}
 
void loop()
 
void loop()
第34行: 第34行:
 
   
 
   
 
   int V1 = analogRead(A0);                     
 
   int V1 = analogRead(A0);                     
// Read the voltage date form A0 and stores in V1, the voltage range is 0-5v and return value is 0-1024.  
+
// Read the voltage data from A0 and store it in variable V1. The voltage range is 0-5V and returns values 0-1024.  
 
   float vol = V1*(5.0 / 1023.0);               
 
   float vol = V1*(5.0 / 1023.0);               
//Convert the V1 to actual voltage value and stores in vol
+
//Convert the V1 to the voltage value and store it in vol
 
   if (vol == temp)                             
 
   if (vol == temp)                             
 
//Use to filter duplicate data, Only the voltage value and the last isn't same then output the value.
 
//Use to filter duplicate data, Only the voltage value and the last isn't same then output the value.
第51行: 第51行:
 
}
 
}
 
</source>
 
</source>
We don't use the function map() to the conversion, you can try it by yourself.
+
We didn't use the map() function in this example, but you can try it yourself!
  
 
==Result==
 
==Result==
When the measured voltage changed, refresh the date every 1s. If there is a gap between two voltage value, this is normal.
+
When the measured voltage changes, refresh the data every second. It is normal if there is a difference between two measurements of the same battery. This is because this is still simply a low accuracy test. If you need a high accuracy test, you can take a look at:
Because this is a low accuracy test. If you need a high accuracy test, please refer to:
 
 
http://www.hacktronics.com/Tutorials/arduino-current-sensor.html
 
http://www.hacktronics.com/Tutorials/arduino-current-sensor.html
  
 
[[File:lesson9Result.jpg|600px|center|thumb]]
 
[[File:lesson9Result.jpg|600px|center|thumb]]
 
==Video==
 
==Video==
 +
https://www.youtube.com/watch?v=bhaj_QhRE-Q
 
|}
 
|}
 
https://www.youtube.com/watch?v=bhaj_QhRE-Q
 

2015年7月15日 (三) 07:43的版本

Language English

Objective

Previously, we introduced analogRead() and its return values of 0~1024. In this lesson, we will use the analog port of Microduino-Core to make a multimeter with the range of 0-5 V.

Important: The design of the experiment does not have an effective protection circuit. Please don't use more than two AA batteries and don't use the circuit to measure a lithium battery or any other power supply!

Equipment

Lesson9All.jpg

Experiment Schematic

Less0n9-schematic.jpg

Program

float temp;   // Define a float variable temp to save data.
void setup()
{
  Serial.begin(9600);     //Set baud rate 9600
}
void loop()
{
 
  int V1 = analogRead(A0);                    
// Read the voltage data from A0 and store it in variable V1. The voltage range is 0-5V and returns values 0-1024. 
  float vol = V1*(5.0 / 1023.0);               
//Convert the V1 to the voltage value and store it in vol
  if (vol == temp)                             
//Use to filter duplicate data, Only the voltage value and the last isn't same then output the value.
  {
    temp = vol;                               //Compared, then store in temp variable "temp"
  }
  else
  { 
    Serial.print(vol);                       //Serial output voltage, nowrap  
    Serial.println(" V");                    //Serial output character "V", and wrap
    temp = vol;
    delay(1000);                           //Wait for 1s, use to refresh the data
  }
}

We didn't use the map() function in this example, but you can try it yourself!

Result

When the measured voltage changes, refresh the data every second. It is normal if there is a difference between two measurements of the same battery. This is because this is still simply a low accuracy test. If you need a high accuracy test, you can take a look at: http://www.hacktronics.com/Tutorials/arduino-current-sensor.html

Lesson9Result.jpg

Video

https://www.youtube.com/watch?v=bhaj_QhRE-Q