-
Notifications
You must be signed in to change notification settings - Fork 4
/
mv2adc.m
22 lines (18 loc) · 1.04 KB
/
mv2adc.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
function values = mv2adc(values, voltageRange, maxValue)
% MV2ADC Converts millivolt values to Analogue to Digital Converter count values.
% mv2adc(values, voltageRange, maxValue) returns Analogue to Digital
% Converter count values corresponding to the voltage range selected.
%
% values - the values in millivolts, (scalar, vector or matrix).
% voltageRange - the voltage range used for the channel (positive, non-zero integer scalar value, in millivolts).
% maxValue - the maximum ADC value corresponding to the resolution for the device (positive, non-zero integer scalar value).
%
% Copyright: © 2012 - 2015 Pico Technology Ltd. All rights reserved.
%
% See also adc2mv.
validateattributes(values, {'numeric'}, {'real', 'finite', 'nonnan'});
validateattributes(voltageRange, {'numeric'}, {'scalar', 'integer', 'positive'});
validateattributes(maxValue, {'numeric'}, {'scalar', 'integer', 'positive'});
% Convert value
values = int32((int32(values) * double(maxValue)) / voltageRange);
end