X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fdmm%2Fut71x.c;h=9a7d2eab93b0776bd56e1a75fcaf9fea86887cb1;hb=45fcaf2ccad796b4bc4434d81b1d0e23f11a8eae;hp=23f72c2d9012d6e3975efdcb899bb72cd6359906;hpb=d9251a2c9f1ca4380c27240ccca90c9f9ed46d3f;p=libsigrok.git diff --git a/src/dmm/ut71x.c b/src/dmm/ut71x.c index 23f72c2d..9a7d2eab 100644 --- a/src/dmm/ut71x.c +++ b/src/dmm/ut71x.c @@ -14,8 +14,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * along with this program; if not, see . */ /* @@ -45,7 +44,7 @@ static const int exponents[16][8] = { { 0, -4, -3, -2, -1, 0, 0, 0 }, /* DC V */ { 0, -4, -3, -2, -1, 0, 0, 0 }, /* AC V */ { -5, 0, 0, 0, 0, 0, 0, 0 }, /* DC mV */ - { 0, -1, 0, 1, 2, 3, 4, 0 }, /* Resistance */ + { 0, -2, -1, 0, 1, 2, 3, 0 }, /* Resistance */ { 0, -12, -11, -10, -9, -8, -7, -6 }, /* Capacitance */ { -1, 0, 0, 0, 0, 0, 0, 0 }, /* Temp (C) */ { -8, -7, 0, 0, 0, 0, 0, 0 }, /* uA */ @@ -82,9 +81,21 @@ static int parse_value(const uint8_t *buf, struct ut71x_info *info, float *resul buf[0], buf[1], buf[2], buf[3], buf[4]); return SR_ERR; } + for (i = 0, intval = 0; i < num_digits; i++) intval = 10 * intval + (buf[i] - '0'); + /* + * For measurements that only have 4000 instead of 40000 counts + * (resistance, continuity) we have to use an additional factor of 10. + * + * This seems to vary between DMMs. E.g. the Voltcraft VC920 and VC940 + * have 4000 counts for resistance, whereas the Tenma 72-9380A, + * 72-7730 and 72-7732 have 40000 counts for resistance. + */ + if (num_digits == 4) + intval *= 10; + /* Apply sign. */ intval *= info->is_sign ? -1 : 1; @@ -117,7 +128,7 @@ static int parse_range(const uint8_t *buf, float *floatval, int *exponent) /* Apply respective exponent (mode-dependent) on the value. */ *floatval *= powf(10, *exponent); - sr_dbg("Applying exponent %d, new value is %f.", *exponent, *floatval); + sr_dbg("Applying exponent %d, new value is %g.", *exponent, *floatval); return SR_OK; }