improve calibration offset resolution and range

range: -0.32V to +0.32V
steps: by 0.01V
This commit is contained in:
ole00 2024-03-17 17:54:28 +00:00
parent a559e10612
commit 460d0f2caa
2 changed files with 10 additions and 10 deletions

View File

@ -2994,9 +2994,9 @@ void loop() {
// small differences in analog ref which is ~3.3 V derived from LDO.
case COMMAND_CALIBRATION_OFFSET: {
int8_t offset = line[1] - '0';
if (offset >=0 && offset <= 9) {
//0:-0.2V 1:-0.15V 2: -0.1V 3: -0.05V 4: 0V 5: 0.05V 6: 0.1V 7: 0.15V 8: 0.20V 9:0.25V
calOffset = (offset - 4) * 5;
if (offset >=0 && offset <= 64) {
//0:-0.32V 1:-0.31V 2: -0.30V ... 32:0V 33:0.01V 34: 0.02V ... 64:0.32V
calOffset = offset - 32;
Serial.print(F("Using cal offset: "));
Serial.println(calOffset);
} else {

View File

@ -276,13 +276,13 @@ static int8_t checkArgs(int argc, char** argv) {
} else if (strcmp("-co", param) == 0) {
i++;
calOffset = atoi(argv[i]);
if (calOffset < -20 || calOffset > 25) {
printf("Calibration offset out of range (-20..25 inclusive).\n");
if (calOffset < -32 || calOffset > 32) {
printf("Calibration offset out of range (-32..32 inclusive).\n");
}
if (calOffset < -20) {
calOffset = -20;
} else if (calOffset > 25) {
calOffset = 25;
if (calOffset < -32) {
calOffset = -32;
} else if (calOffset > 32) {
calOffset = 32;
}
}
else if (param[0] != '-') {
@ -988,7 +988,7 @@ static char operationTestVpp(void) {
static char operationCalibrateVpp(void) {
char result;
char cmd [8] = {0};
char val = (char)('0' + (calOffset + 20) / 5);
char val = (char)('0' + (calOffset + 32));
if (openSerial() != 0) {
return -1;