From 65ee789d92ab6d9d75600f44eb5d55d8c300c616 Mon Sep 17 00:00:00 2001 From: BarbourSmith Date: Thu, 18 Oct 2018 10:44:02 -0700 Subject: [PATCH] Revert "Beam tilt correction" --- cnc_ctrl_v1/Kinematics.cpp | 18 ++++++++---------- cnc_ctrl_v1/Kinematics.h | 7 +++---- cnc_ctrl_v1/Report.cpp | 9 +-------- cnc_ctrl_v1/Settings.cpp | 8 -------- cnc_ctrl_v1/Settings.h | 3 +-- 5 files changed, 13 insertions(+), 32 deletions(-) diff --git a/cnc_ctrl_v1/Kinematics.cpp b/cnc_ctrl_v1/Kinematics.cpp index e027b855..4e2d99b6 100644 --- a/cnc_ctrl_v1/Kinematics.cpp +++ b/cnc_ctrl_v1/Kinematics.cpp @@ -56,11 +56,9 @@ void Kinematics::recomputeGeometry(){ halfWidth = sysSettings.machineWidth / 2.0; halfHeight = sysSettings.machineHeight / 2.0; + _xCordOfMotor = sysSettings.distBetweenMotors/2; + _yCordOfMotor = halfHeight + sysSettings.motorOffsetY; - leftMotorX = cos(sysSettings.topBeamTilt*DEG_TO_RAD)*sysSettings.distBetweenMotors/-2.0; - leftMotorY = sin(sysSettings.topBeamTilt*DEG_TO_RAD)*sysSettings.distBetweenMotors/-2.0 + (sysSettings.motorOffsetY+sysSettings.machineHeight/2.0); - rightMotorX = cos(sysSettings.topBeamTilt*DEG_TO_RAD)*sysSettings.distBetweenMotors+leftMotorX; - rightMotorY = sin(sysSettings.topBeamTilt*DEG_TO_RAD)*sysSettings.distBetweenMotors/2.0 + (sysSettings.motorOffsetY+sysSettings.machineHeight/2.0); } void Kinematics::inverse(float xTarget,float yTarget, float* aChainLength, float* bChainLength){ @@ -210,20 +208,20 @@ void Kinematics::triangularInverse(float xTarget,float yTarget, float* aChainLe float Chain2AroundSprocket = 0; //Calculate motor axes length to the bit - float Motor1Distance = sqrt(pow((leftMotorX - xTarget),2)+pow((leftMotorY - yTarget),2)); - float Motor2Distance = sqrt(pow((rightMotorX - xTarget),2)+pow((rightMotorY - yTarget),2)); + float Motor1Distance = sqrt(pow((-1*_xCordOfMotor - xTarget),2)+pow((_yCordOfMotor - yTarget),2)); + float Motor2Distance = sqrt(pow((_xCordOfMotor - xTarget),2)+pow((_yCordOfMotor - yTarget),2)); //Calculate the chain angles from horizontal, based on if the chain connects to the sled from the top or bottom of the sprocket if(sysSettings.chainOverSprocket == 1){ - Chain1Angle = asin((leftMotorY - yTarget)/Motor1Distance) + asin(RleftChainTolerance/Motor1Distance); - Chain2Angle = asin((rightMotorY - yTarget)/Motor2Distance) + asin(RrightChainTolerance/Motor2Distance); + Chain1Angle = asin((_yCordOfMotor - yTarget)/Motor1Distance) + asin(RleftChainTolerance/Motor1Distance); + Chain2Angle = asin((_yCordOfMotor - yTarget)/Motor2Distance) + asin(RrightChainTolerance/Motor2Distance); Chain1AroundSprocket = RleftChainTolerance * Chain1Angle; Chain2AroundSprocket = RrightChainTolerance * Chain2Angle; } else{ - Chain1Angle = asin((leftMotorY - yTarget)/Motor1Distance) - asin(RleftChainTolerance/Motor1Distance); - Chain2Angle = asin((rightMotorY - yTarget)/Motor2Distance) - asin(RrightChainTolerance/Motor2Distance); + Chain1Angle = asin((_yCordOfMotor - yTarget)/Motor1Distance) - asin(RleftChainTolerance/Motor1Distance); + Chain2Angle = asin((_yCordOfMotor - yTarget)/Motor2Distance) - asin(RrightChainTolerance/Motor2Distance); Chain1AroundSprocket = RleftChainTolerance * (3.14159 - Chain1Angle); Chain2AroundSprocket = RrightChainTolerance * (3.14159 - Chain2Angle); diff --git a/cnc_ctrl_v1/Kinematics.h b/cnc_ctrl_v1/Kinematics.h index 81822082..01b6379b 100644 --- a/cnc_ctrl_v1/Kinematics.h +++ b/cnc_ctrl_v1/Kinematics.h @@ -40,11 +40,8 @@ float R = 10.1; //sprocket radius float RleftChainTolerance = 10.1; // Left sprocket radius including chain tolerance float RrightChainTolerance = 10.1; // Right sprocket radius including chain tolerance + - float leftMotorX = -1800.0; - float leftMotorY = -1200.0; - float rightMotorX = 1800.0; - float rightMotorY = -1200.0; float halfWidth; //Half the machine width float halfHeight; //Half the machine height @@ -57,6 +54,8 @@ //target router bit coordinates. float x = 0; float y = 0; + float _xCordOfMotor; + float _yCordOfMotor; //utility variables boolean Mirror; diff --git a/cnc_ctrl_v1/Report.cpp b/cnc_ctrl_v1/Report.cpp index c50c5381..f6b87d83 100644 --- a/cnc_ctrl_v1/Report.cpp +++ b/cnc_ctrl_v1/Report.cpp @@ -182,7 +182,6 @@ void reportMaslowSettings() { Serial.print(F("$40=")); Serial.println(sysSettings.distPerRotLeftChainTolerance, 8); Serial.print(F("$41=")); Serial.println(sysSettings.distPerRotRightChainTolerance, 8); Serial.print(F("$42=")); Serial.println(sysSettings.positionErrorLimit, 8); - Serial.print(F("$43=")); Serial.println(sysSettings.topBeamTilt, 8); #else Serial.print(F("$0=")); Serial.print(sysSettings.machineWidth); @@ -227,13 +226,7 @@ void reportMaslowSettings() { Serial.print(F(" (PWM frequency value 1=39,000Hz, 2=4,100Hz, 3=490Hz)\r\n$40=")); Serial.print(sysSettings.distPerRotLeftChainTolerance, 8); Serial.print(F(" (distance / rotation, including chain tolerance, left chain, mm)\r\n$41=")); Serial.print(sysSettings.distPerRotRightChainTolerance, 8); Serial.print(F(" (distance / rotation, including chain tolerance, right chain, mm)\r\n$42=")); Serial.print(sysSettings.positionErrorLimit, 8); - Serial.print(F(" (position error alarm limit, mm\r\n$43=)")); Serial.print(sysSettings.topBeamTilt, 8); - Serial.print(F(" (top beam tilt, degrees)\r\n")); - Serial.print(F(" (right chain tolerance, degrees)\r\n")); Serial.print(kinematics.leftMotorX,8); - Serial.print(F(" (left Motor X, mm)\r\n")); Serial.print(kinematics.leftMotorY,8); - Serial.print(F(" (left Motor Y, mm)\r\n")); Serial.print(kinematics.rightMotorX,8); - Serial.print(F(" (right Motor X, mm)\r\n")); Serial.print(kinematics.rightMotorY,8); - Serial.print(F(" (right Motor Y, mm)\r\n")); + Serial.print(F(" (position error alarm limit, mm)")); Serial.println(); #endif } diff --git a/cnc_ctrl_v1/Settings.cpp b/cnc_ctrl_v1/Settings.cpp index c76a81ec..e7fd6ff4 100644 --- a/cnc_ctrl_v1/Settings.cpp +++ b/cnc_ctrl_v1/Settings.cpp @@ -105,7 +105,6 @@ void settingsReset() { sysSettings.distPerRotLeftChainTolerance = 63.5; // float distPerRotLeftChainTolerance; sysSettings.distPerRotRightChainTolerance = 63.5; // float distPerRotRightChainTolerance; sysSettings.positionErrorLimit = 2.0; // float positionErrorLimit; - sysSettings.topBeamTilt = 0.0; sysSettings.eepromValidData = EEPROMVALIDDATA; // byte eepromValidData; } @@ -232,15 +231,12 @@ byte settingsStoreGlobalSetting(const byte& parameter,const float& value){ break; case 1: sysSettings.machineHeight = value; - kinematics.recomputeGeometry(); break; case 2: sysSettings.distBetweenMotors = value; - kinematics.recomputeGeometry(); break; case 3: sysSettings.motorOffsetY = value; - kinematics.recomputeGeometry(); break; case 4: sysSettings.sledWidth = value; @@ -414,10 +410,6 @@ byte settingsStoreGlobalSetting(const byte& parameter,const float& value){ case 42: sysSettings.positionErrorLimit = value; break; - case 43: - sysSettings.topBeamTilt = value; - kinematics.recomputeGeometry(); - break; default: return(STATUS_INVALID_STATEMENT); } diff --git a/cnc_ctrl_v1/Settings.h b/cnc_ctrl_v1/Settings.h index 807b2cba..dd028e35 100644 --- a/cnc_ctrl_v1/Settings.h +++ b/cnc_ctrl_v1/Settings.h @@ -20,7 +20,7 @@ Copyright 2014-2017 Bar Smith*/ #ifndef settings_h #define settings_h -#define SETTINGSVERSION 5 // The current version of settings, if this doesn't +#define SETTINGSVERSION 4 // The current version of settings, if this doesn't // match what is in EEPROM then settings on // machine are reset to defaults #define EEPROMVALIDDATA 56 // This is just a random byte value that is used @@ -81,7 +81,6 @@ typedef struct { // I think this is about ~128 bytes in size if I counted corre float distPerRotLeftChainTolerance; float distPerRotRightChainTolerance; float positionErrorLimit; - float topBeamTilt; byte eepromValidData; // This should always be last, that way if an error // happens in writing, it will not be written and we } settings_t; // will know to reset the settings