Add LENGTH_OFFSET and REACHED_TOLERANCE options
Add feature and config option #define TARGET_LENGTH_OFFSET that makes it possible to set a distance that gets added to the target length, thus preventing falling short on the actual length when spools rotates back slightly after stop. Also move reached tolerance to config.
This commit is contained in:
parent
592351c265
commit
8f5b33c554
@ -55,6 +55,9 @@ extern "C" {
|
||||
|
||||
|
||||
|
||||
//=============================
|
||||
//======= configuration =======
|
||||
//=============================
|
||||
//--------------------------
|
||||
//----- display config -----
|
||||
//--------------------------
|
||||
@ -79,11 +82,20 @@ extern "C" {
|
||||
//--------------------------
|
||||
//------ calibration -------
|
||||
//--------------------------
|
||||
//use encoder test for calibration and calculate STEPS_PER_METER
|
||||
//#define ENCODER_TEST //show encoder count instead of converted meters
|
||||
//enable mode encoder test for calibration
|
||||
//if defined, displays always show length and steps instead of the normal messages
|
||||
//#define ENCODER_TEST
|
||||
|
||||
//steps per meter
|
||||
#define STEPS_PER_METER 2127 //roll-v3-gummi-86.6mm - d=89.8mm
|
||||
//#define MEASURING_ROLL_DIAMETER 86.6 //roll v3 large
|
||||
//#define PI 3.14159265358979323846
|
||||
|
||||
//millimetres added to target length
|
||||
//to ensure that length does not fall short when spool slightly rotates back after stop
|
||||
#define TARGET_LENGTH_OFFSET 20
|
||||
|
||||
//millimetres lengthNow can be below lengthTarget to still stay in target_reached state
|
||||
#define TARGET_REACHED_TOLERANCE 5
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -43,7 +43,7 @@ QueueHandle_t encoder_queue = NULL; //encoder event queue
|
||||
rotary_encoder_state_t encoderState;
|
||||
|
||||
int lengthNow = 0; //length measured in mm
|
||||
int lengthTarget = 3000; //target length in mm
|
||||
int lengthTarget = 5000; //default target length in mm
|
||||
int lengthRemaining = 0; //(target - now) length needed for reaching the target
|
||||
int potiRead = 0; //voltage read from adc
|
||||
uint32_t timestamp_motorStarted = 0; //timestamp winding started
|
||||
@ -312,7 +312,7 @@ void task_control(void *pvParameter)
|
||||
//--------- control ---------
|
||||
//---------------------------
|
||||
//calculate length difference
|
||||
lengthRemaining = lengthTarget - lengthNow;
|
||||
lengthRemaining = lengthTarget - lengthNow + TARGET_LENGTH_OFFSET;
|
||||
|
||||
//--- statemachine ---
|
||||
switch (controlState) {
|
||||
@ -349,7 +349,7 @@ void task_control(void *pvParameter)
|
||||
case systemState_t::TARGET_REACHED:
|
||||
vfd_setState(false);
|
||||
//switch to counting state when no longer at or above target length
|
||||
if ( lengthRemaining > 10 ) { //FIXME: require reset switch to be able to restart? or evaluate a tolerance here?
|
||||
if ( lengthNow < lengthTarget - TARGET_REACHED_TOLERANCE ) {
|
||||
changeState(systemState_t::COUNTING);
|
||||
}
|
||||
//switch initiate countdown to auto-cut
|
||||
|
Loading…
x
Reference in New Issue
Block a user