Fix ENCODER_TEST, Calibrate length measurement
config: - calibrate length measurement control: - Fix ENCODER_TEST - syntax error - Add beep at 0.5m
This commit is contained in:
parent
1dd8388769
commit
9dfca6f6c3
@ -108,16 +108,18 @@
|
|||||||
//enable mode encoder test for calibration (determine ENCODER_STEPS_PER_METER)
|
//enable mode encoder test for calibration (determine ENCODER_STEPS_PER_METER)
|
||||||
//if defined, displays always show length and steps instead of the normal messages
|
//if defined, displays always show length and steps instead of the normal messages
|
||||||
//#define ENCODER_TEST
|
//#define ENCODER_TEST
|
||||||
|
//TODO: add way to calibrate without flashing -> enter calibration mode with certain button sequence, enter steps-per-meter with poti, store in nvs
|
||||||
|
|
||||||
//steps per meter
|
//steps per meter
|
||||||
//this value is determined experimentally while ENCODER_TEST is enabled
|
//this value is determined experimentally while ENCODER_TEST is enabled
|
||||||
#define ENCODER_STEPS_PER_METER 2127 //roll-v3-gummi-86.6mm - d=89.8mm
|
//#define ENCODER_STEPS_PER_METER 2127 //until 2024.03.13 roll-v3-gummi-86.6mm - d=89.8mm
|
||||||
|
#define ENCODER_STEPS_PER_METER 2118 //2024.03.13 roll-v3-gummi measured 86.5mm
|
||||||
|
|
||||||
//millimetres added to target length
|
//millimeters added to target length
|
||||||
//to ensure that length does not fall short when spool slightly rotates back after stop
|
//to ensure that length does not fall short when spool slightly rotates back after stop
|
||||||
#define TARGET_LENGTH_OFFSET 0
|
#define TARGET_LENGTH_OFFSET 0
|
||||||
|
|
||||||
//millimetres lengthNow can be below lengthTarget to still stay in target_reached state
|
//millimeters lengthNow can be below lengthTarget to still stay in target_reached state
|
||||||
#define TARGET_REACHED_TOLERANCE 5
|
#define TARGET_REACHED_TOLERANCE 5
|
||||||
|
|
||||||
|
|
||||||
|
@ -446,17 +446,21 @@ void task_control(void *pvParameter)
|
|||||||
displayTop.handle();
|
displayTop.handle();
|
||||||
displayBot.handle();
|
displayBot.handle();
|
||||||
//-- show encoder steps on display1 ---
|
//-- show encoder steps on display1 ---
|
||||||
sprintf(buf_disp1, "EN %05d", encoder_getSteps); //count
|
sprintf(buf_disp1, "EN %05d", encoder_getSteps()); //count
|
||||||
displayTop.showString(buf_disp1);
|
displayTop.showString(buf_disp1);
|
||||||
//--- show converted distance on display2 ---
|
//--- show converted distance on display2 ---
|
||||||
sprintf(buf_disp2, "Met %5.3f", (float)lengthNow/1000); //m
|
sprintf(buf_disp2, "Met %5.3f", (float)lengthNow/1000); //m
|
||||||
displayBot.showString(buf_disp2);
|
displayBot.showString(buf_disp2);
|
||||||
//--- beep every 1m ---
|
//--- beep every 0.5m ---
|
||||||
//note: only works precicely in forward/positive direction
|
//note: only works precisely in forward/positive direction, in reverse it it beeps by tolerance too early
|
||||||
if (lengthNow % 1000 < 50) { //with tolerance in case of missed exact value
|
static int lengthBeeped = 0;
|
||||||
if (fabs(lengthNow - lengthBeeped) >= 900) { //dont beep multiple times at same meter
|
if (lengthNow % 500 < 50) { //with tolerance in case of missed exact value
|
||||||
//TODO: add case for reverse direction. currently beeps 0.1 too early
|
if (fabs(lengthNow - lengthBeeped) >= 400) { //dont beep multiple times at same distance
|
||||||
buzzer.beep(1, 400, 100 );
|
//TODO: add case for reverse direction. currently beeps 50mm too early
|
||||||
|
if (lengthNow % 1000 < 50) // 1m beep
|
||||||
|
buzzer.beep(1, 400, 100);
|
||||||
|
else // 0.5m beep
|
||||||
|
buzzer.beep(1, 200, 100);
|
||||||
lengthBeeped = lengthNow;
|
lengthBeeped = lengthNow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
|
|
||||||
|
// task that repeatedly checks supply voltage (12V) and saves certain values to nvs in case of it drops below a certain threshold (power off detected)
|
||||||
void task_shutDownDetection(void *pvParameter);
|
void task_shutDownDetection(void *pvParameter);
|
||||||
|
|
||||||
// read last axis position in steps from nvs
|
// read last axis position in steps from nvs
|
||||||
|
Loading…
x
Reference in New Issue
Block a user