Commit b890f73f authored by Patrick's avatar Patrick

updated the adc calculations to use the full range

parent bcb1b26f
......@@ -167,7 +167,7 @@ float red_peg::volts(t_SensorData data_record)
float red_peg::mA(t_SensorData data_record)
{
if (data_record.the_sensor == MA4_20) {
return float( data_record.the_reading * 20.48 / 32787.0 );
return float( data_record.the_reading * 20.48 / 32767.0 );
} else {
return -1.0;
}
......@@ -182,10 +182,10 @@ float red_peg::level(t_SensorData data_record, double max_level)
float red_peg::level(t_SensorData data_record, float max_level)
{
if (data_record.the_sensor == MA4_20) {
long zero_reading = 6515L;
long zero_reading = 6553L;
// subtract the
long reading = long(data_record.the_reading) - 6515L;
float level = float(reading) * ( max_level / (26212.0));
long reading = long(data_record.the_reading) - zero_reading;
float level = float(reading) * ( max_level / (26214.0));
return level;
} else {
return -max_level;
......@@ -201,10 +201,10 @@ long red_peg::level(t_SensorData data_record, int max_level)
long red_peg::level(t_SensorData data_record, long max_level)
{
if (data_record.the_sensor == MA4_20) {
long zero_reading = 6515L;
long zero_reading = 6553L;
// subtract the
long reading = long(data_record.the_reading) - 6515L;
long level = map(reading, 0, 26212, 0, max_level);
long reading = long(data_record.the_reading) - zero_reading;
long level = map(reading, 0, 26214L, 0, max_level);
return level;
} else {
return -max_level;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment