You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fel0021(triggered ps3000 scope) currently fails to run, even though the selected range 0.05 (50 mV in the flowgraph) is valid.
The reason seems to be that floating-point comparison should better not be done with ==, since already minimal discrepancies (for whatever reason) lead to a mismatch.
Edit: Problem is, that partly double and partly float is used to store the "range", which leads to conversion errors. Using the same type in all places fixes the problem.
Though a much more failsafe way would be the usage of an enum, like e.g. done for coupling (check for coupling_t).
Here the currently used code which throws an expetion, when "0.05" is passed due to floating point comparison:
static PS3000A_RANGE
convert_to_ps3000a_range(float range)
{
if (range == 0.01)
return PS3000A_10MV;
else if (range == 0.02)
return PS3000A_20MV;
else if (range == 0.05)
return PS3000A_50MV;
else if (range == 0.1)
return PS3000A_100MV;
else if (range == 0.2)
return PS3000A_200MV;
else if (range == 0.5)
return PS3000A_500MV;
else if (range == 1.0)
return PS3000A_1V;
else if (range == 2.0)
return PS3000A_2V;
else if (range == 5.0)
return PS3000A_5V;
else if (range == 10.0)
return PS3000A_10V;
else if (range == 20.0)
return PS3000A_20V;
else if (range == 50.0)
return PS3000A_50V;
else
{
std::ostringstream message;
message << "Exception in " << __FILE__ << ":" << __LINE__ << ": Range value not supported: " << range;
throw std::runtime_error(message.str());
}
}
The text was updated successfully, but these errors were encountered:
fel0021(triggered ps3000 scope) currently fails to run, even though the selected range
0.05
(50 mV in the flowgraph) is valid.The reason seems to be that floating-point comparison should better not be done with
==
, since already minimal discrepancies (for whatever reason) lead to a mismatch.Edit: Problem is, that partly double and partly float is used to store the "range", which leads to conversion errors. Using the same type in all places fixes the problem.
Though a much more failsafe way would be the usage of an enum, like e.g. done for coupling (check for coupling_t).
Here the currently used code which throws an expetion, when "0.05" is passed due to floating point comparison:
The text was updated successfully, but these errors were encountered: