Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 23 additions & 15 deletions scopehal/OwonXDMMultimeter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ OwonXDMMultimeter::OwonXDMMultimeter(SCPITransport* transport)

// Set speed to high
m_transport->SendCommandQueued("RATE F");

// Rate limit to 65 Hz (which is the highest measurement supported by the metter)
m_transport->EnableRateLimiting(chrono::milliseconds(1000/65));
}

OwonXDMMultimeter::~OwonXDMMultimeter()
Expand Down Expand Up @@ -115,10 +118,10 @@ bool OwonXDMMultimeter::GetMeterAutoRange()
void OwonXDMMultimeter::SetMeterAutoRange(bool enable)
{
if(enable)
m_transport->SendCommandQueued("AUTO");
m_transport->SendCommandImmediate("AUTO");
else
{
m_transport->SendCommandQueued("RANGE 1");
m_transport->SendCommandImmediate("RANGE 1");
}
}

Expand All @@ -143,6 +146,9 @@ double OwonXDMMultimeter::GetMeterValue()
LogWarning("Failed to read value: got '%s'\n",value.c_str());
continue;
}
else if(value == "1E+9") // Overload
return std::numeric_limits<double>::max();

istringstream os(value);
double result;
os >> result;
Expand All @@ -165,7 +171,9 @@ double OwonXDMMultimeter::GetSecondaryMeterValue()
// No secondary reading at this point
return 0;
}
if(value.empty()||(value.find("NON")!=std::string::npos))
else if(value == "1E+9")
return std::numeric_limits<double>::max(); // Overload
if(value.empty())
{
LogWarning("Failed to read value: got '%s'\n",value.c_str());
continue;
Expand Down Expand Up @@ -259,43 +267,43 @@ void OwonXDMMultimeter::SetMeterMode(Multimeter::MeasurementTypes type)
switch(type)
{
case DC_VOLTAGE:
m_transport->SendCommandQueued("CONF:VOLT:DC");
m_transport->SendCommandImmediate("CONF:VOLT:DC");
break;

case AC_RMS_AMPLITUDE:
m_transport->SendCommandQueued("CONF:VOLT:AC");
m_transport->SendCommandImmediate("CONF:VOLT:AC");
break;

case DC_CURRENT:
m_transport->SendCommandQueued("CONF:CURR:DC");
m_transport->SendCommandImmediate("CONF:CURR:DC");
break;

case AC_CURRENT:
m_transport->SendCommandQueued("CONF:CURR:AC");
m_transport->SendCommandImmediate("CONF:CURR:AC");
break;

case RESISTANCE:
m_transport->SendCommandQueued("CONF:RES");
m_transport->SendCommandImmediate("CONF:RES");
break;

case CAPACITANCE:
m_transport->SendCommandQueued("CONF:CAP");
m_transport->SendCommandImmediate("CONF:CAP");
break;

case FREQUENCY:
m_transport->SendCommandQueued("CONF:FREQ");
m_transport->SendCommandImmediate("CONF:FREQ");
break;

case DIODE:
m_transport->SendCommandQueued("CONF:DIOD");
m_transport->SendCommandImmediate("CONF:DIOD");
break;

case CONTINUITY:
m_transport->SendCommandQueued("CONF:CONT");
m_transport->SendCommandImmediate("CONF:CONT");
break;

case TEMPERATURE:
m_transport->SendCommandQueued("CONF:TEMP");
m_transport->SendCommandImmediate("CONF:TEMP");
break;

//whatever it is, not supported
Expand All @@ -313,11 +321,11 @@ void OwonXDMMultimeter::SetSecondaryMeterMode(Multimeter::MeasurementTypes type)
switch(type)
{
case FREQUENCY:
m_transport->SendCommandQueued("FUNC2 \"FREQ\"");
m_transport->SendCommandImmediate("FUNC2 \"FREQ\"");
break;

case NONE:
m_transport->SendCommandQueued("FUNC2 \"NONe\"");
m_transport->SendCommandImmediate("FUNC2 \"NONe\"");
break;

//not supported
Expand Down
8 changes: 8 additions & 0 deletions scopehal/Unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,10 @@ void Unit::GetUnitSuffix(UnitType type, double num, double& scaleFactor, string&
*/
string Unit::PrettyPrint(double value, int sigfigs, bool useDisplayLocale) const
{
// Special handling for overload value
if(value >= std::numeric_limits<double>::max())
return UNIT_OVERLOAD_LABEL;

if(useDisplayLocale)
SetPrintingLocale();

Expand Down Expand Up @@ -981,6 +985,10 @@ string Unit::PrettyPrintRange(double pixelMin, double pixelMax, double rangeMin,
*/
double Unit::ParseString(const string& str, bool useDisplayLocale)
{
// Special handling for overload value
if(str == UNIT_OVERLOAD_LABEL)
return std::numeric_limits<double>::max();

if(useDisplayLocale)
SetPrintingLocale();

Expand Down
2 changes: 2 additions & 0 deletions scopehal/Unit.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@

#endif

#define UNIT_OVERLOAD_LABEL "Overload"

/**
@brief A unit of measurement, plus conversion to pretty-printed output

Expand Down