Skip to content

Commit d50f63d

Browse files
authored
Merge pull request #909 from chille/multimeter
Multimeter: Added modes for resistance, capacitance, continuity and diode test
2 parents 3388cbe + 04ef11e commit d50f63d

File tree

4 files changed

+57
-9
lines changed

4 files changed

+57
-9
lines changed

scopehal/Multimeter.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ Unit Multimeter::GetMeterUnit()
5757
case Multimeter::AC_CURRENT:
5858
return Unit(Unit::UNIT_AMPS);
5959

60+
case Multimeter::RESISTANCE:
61+
case Multimeter::CONTINUITY:
62+
return Unit(Unit::UNIT_OHMS);
63+
64+
case Multimeter::CAPACITANCE:
65+
return Unit(Unit::UNIT_FARADS);
66+
67+
case Multimeter::DIODE:
6068
case Multimeter::DC_VOLTAGE:
6169
case Multimeter::DC_RMS_AMPLITUDE:
6270
case Multimeter::AC_RMS_AMPLITUDE:
@@ -79,6 +87,14 @@ Unit Multimeter::GetSecondaryMeterUnit()
7987
case Multimeter::AC_CURRENT:
8088
return Unit(Unit::UNIT_AMPS);
8189

90+
case Multimeter::RESISTANCE:
91+
case Multimeter::CONTINUITY:
92+
return Unit(Unit::UNIT_OHMS);
93+
94+
case Multimeter::CAPACITANCE:
95+
return Unit(Unit::UNIT_FARADS);
96+
97+
case Multimeter::DIODE:
8298
case Multimeter::DC_VOLTAGE:
8399
case Multimeter::DC_RMS_AMPLITUDE:
84100
case Multimeter::AC_RMS_AMPLITUDE:
@@ -108,6 +124,14 @@ string Multimeter::ModeToText(MeasurementTypes type)
108124
return "DC RMS Amplitude";
109125
case Multimeter::AC_RMS_AMPLITUDE:
110126
return "AC RMS Amplitude";
127+
case Multimeter::RESISTANCE:
128+
return "Resistance";
129+
case Multimeter::CAPACITANCE:
130+
return "Capacitance";
131+
case Multimeter::CONTINUITY:
132+
return "Continuity";
133+
case Multimeter::DIODE:
134+
return "Diode";
111135

112136
default:
113137
return "";
@@ -133,6 +157,14 @@ Multimeter::MeasurementTypes Multimeter::TextToMode(const string& mode)
133157
return Multimeter::DC_RMS_AMPLITUDE;
134158
else if(mode == "AC RMS Amplitude")
135159
return Multimeter::AC_RMS_AMPLITUDE;
160+
else if(mode == "Resistance")
161+
return Multimeter::RESISTANCE;
162+
else if(mode == "Capacitance")
163+
return Multimeter::CAPACITANCE;
164+
else if(mode == "Continuity")
165+
return Multimeter::CONTINUITY;
166+
else if(mode == "Diode")
167+
return Multimeter::DIODE;
136168

137169
//invalid / unknown
138170
return Multimeter::DC_VOLTAGE;

scopehal/Multimeter.h

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,20 @@ class Multimeter : public virtual Instrument
4545

4646
enum MeasurementTypes
4747
{
48-
NONE = 0x00,
49-
50-
DC_VOLTAGE = 0x01,
51-
DC_RMS_AMPLITUDE = 0x02,
52-
AC_RMS_AMPLITUDE = 0x04,
53-
FREQUENCY = 0x08,
54-
DC_CURRENT = 0x10,
55-
AC_CURRENT = 0x20,
56-
TEMPERATURE = 0x40
48+
NONE = 0x000,
49+
50+
DC_VOLTAGE = 0x001,
51+
DC_RMS_AMPLITUDE = 0x002,
52+
AC_RMS_AMPLITUDE = 0x004,
53+
FREQUENCY = 0x008,
54+
DC_CURRENT = 0x010,
55+
AC_CURRENT = 0x020,
56+
TEMPERATURE = 0x040,
57+
RESISTANCE = 0x080,
58+
CAPACITANCE = 0x100,
59+
CONTINUITY = 0x200,
60+
DIODE = 0x400
61+
5762

5863
//TODO: other types
5964
};

scopehal/Unit.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ Unit::Unit(const string& rhs)
112112
m_type = UNIT_W_M2;
113113
else if(rhs == "μA")
114114
m_type = UNIT_MICROAMPS;
115+
else if(rhs == "F")
116+
m_type = UNIT_FARADS;
115117
else
116118
LogWarning("Unrecognized unit \"%s\"\n", rhs.c_str());
117119
}
@@ -213,6 +215,9 @@ string Unit::ToString() const
213215
case UNIT_W_M2:
214216
return "W/m²";
215217

218+
case UNIT_FARADS:
219+
return "F";
220+
216221
default:
217222
return "unknown";
218223
}
@@ -491,6 +496,10 @@ void Unit::GetUnitSuffix(UnitType type, double num, double& scaleFactor, string&
491496
suffix = "RPM";
492497
break;
493498

499+
case UNIT_FARADS:
500+
suffix = "F";
501+
break;
502+
494503
//Angular degrees do not use SI prefixes
495504
case UNIT_DEGREES:
496505
suffix = "°";

scopehal/Unit.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ class Unit
102102

103103
UNIT_MICROAMPS, //Another hack for current in the X axis
104104

105+
UNIT_FARADS, //Capacitance in farads
106+
105107
//TODO: more here
106108
};
107109

0 commit comments

Comments
 (0)