-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Chain Wrap Direction #382
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6cd58fc
Add Chain Wrap Direction
reecej aa803a6
Move variable definition outside if statement
reecej a788020
Call systemReset if value changes
reecej 9cef7ac
Make systemReset public
reecej 86f65d2
Store new chainOverSprocket to EEPROM
reecej f9b2ae5
Load settings before setting up axes
reecej File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -199,14 +199,32 @@ void Kinematics::triangularInverse(float xTarget,float yTarget, float* aChainLe | |
|
||
//Confirm that the coordinates are on the wood | ||
_verifyValidTarget(&xTarget, &yTarget); | ||
|
||
|
||
//Set up variables | ||
float Chain1Angle = 0; | ||
float Chain2Angle = 0; | ||
float Chain1AroundSprocket = 0; | ||
float Chain2AroundSprocket = 0; | ||
|
||
//Calculate motor axes length to the bit | ||
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 | ||
float Chain1Angle = 3.14159 - acos(R/Motor1Distance) - acos((_yCordOfMotor - yTarget)/Motor1Distance); | ||
float Chain2Angle = 3.14159 - acos(R/Motor2Distance) - acos((_yCordOfMotor - yTarget)/Motor2Distance); | ||
//Calculate the chain angles from horizontal, based on if the chain connects to the sled from the top or bottom of the sprocket | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is so cleanly done. Excellent! I was worried this would require all types of changes throughout the code 👍 👍 |
||
if(sysSettings.chainOverSprocket == 1){ | ||
Chain1Angle = asin((_yCordOfMotor - yTarget)/Motor1Distance) + asin(R/Motor1Distance); | ||
Chain2Angle = asin((_yCordOfMotor - yTarget)/Motor2Distance) + asin(R/Motor2Distance); | ||
|
||
Chain1AroundSprocket = R * Chain1Angle; | ||
Chain2AroundSprocket = R * Chain2Angle; | ||
} | ||
else{ | ||
Chain1Angle = asin((_yCordOfMotor - yTarget)/Motor1Distance) - asin(R/Motor1Distance); | ||
Chain2Angle = asin((_yCordOfMotor - yTarget)/Motor2Distance) - asin(R/Motor2Distance); | ||
|
||
Chain1AroundSprocket = R * (3.14159 - Chain1Angle); | ||
Chain2AroundSprocket = R * (3.14159 - Chain2Angle); | ||
} | ||
|
||
//Calculate the straight chain length from the sprocket to the bit | ||
float Chain1Straight = sqrt(pow(Motor1Distance,2)-pow(R,2)); | ||
|
@@ -217,8 +235,8 @@ void Kinematics::triangularInverse(float xTarget,float yTarget, float* aChainLe | |
Chain2Straight *= (1 + ((sysSettings.chainSagCorrection / 1000000000000) * pow(cos(Chain2Angle),2) * pow(Chain2Straight,2) * pow((tan(Chain1Angle) * cos(Chain2Angle)) + sin(Chain2Angle),2))); | ||
|
||
//Calculate total chain lengths accounting for sprocket geometry and chain sag | ||
float Chain1 = (R * Chain1Angle) + Chain1Straight; | ||
float Chain2 = (R * Chain2Angle) + Chain2Straight; | ||
float Chain1 = Chain1AroundSprocket + Chain1Straight; | ||
float Chain2 = Chain2AroundSprocket + Chain2Straight; | ||
|
||
//Subtract of the virtual length which is added to the chain by the rotation mechanism | ||
Chain1 = Chain1 - sysSettings.rotationDiskRadius; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️