Skip to content
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

Pull Request #1 broke delta/motion-ctl calcs (XYZ_STEPS=~2666.67, should be ~83) #2

Open
FlyingLotus1983 opened this issue Feb 1, 2015 · 2 comments

Comments

@FlyingLotus1983
Copy link

Initially seen by Douglas last week, confirmed by me yesterday night. Causes the machine to move too many steps, causing errors and other bad things. Backing out the change results in normal movements, but doesn't fix the scaling issue that pull request #1 set out to fix.

@FlyingLotus1983
Copy link
Author

Suggested change by Douglas Pearless, via dev-group mailing list, 2/1/2015:

Hi Team,

I have ported part of the code to run under Xcode on my mac and I can confirm the results:

// default settings
#define BELT_THICKNESS 1.49  // thickest part of belt
#define TOOTH_DEPTH 0.74     // thinnest part of the belt
#define TOOTH_SPACING 2.0   // 2mm for GT2 belts

// recalculate circumference to take into account tooth thickness, as this adds to the radius of the pulley
#define BIG_PULLEY_CIRCUM BIG_PULLEY_TEETH*TOOTH_SPACING + (BELT_THICKNESS - TOOTH_DEPTH)*6.283185
#define SMALL_PULLEY_CIRCUM SMALL_PULLEY_TEETH * TOOTH_SPACING

#define XYZ_FULL_STEPS_PER_ROTATION 200.0
#define XYZ_MICROSTEPS 16.0
#define SMALL_PULLEY_TEETH 16.0
#define BIG_PULLEY_TEETH 150.0
//#define PULLEY_REDUCTION BIG_PULLEY_TEETH/SMALL_PULLEY_TEETH
#define PULLEY_REDUCTION BIG_PULLEY_CIRCUM/SMALL_PULLEY_CIRCUM
#define xstr(s) str(s)
#define str(s) #s
#define XYZ_STEPS (XYZ_FULL_STEPS_PER_ROTATION*XYZ_MICROSTEPS*PULLEY_REDUCTION)/360.0

#include <iostream>

int main(int argc, const char * argv[]) {
    // insert code here...
    //std::cout << "Hello, World!\n";
    float result = XYZ_STEPS;
    printf ("result %F", result);
    return 0;
}

result 2666.668213

Program ended with exit code: 0

The issue is two fold:
(1) the order of mathematical precedence in the line that calculates the BIG_PULLEY_CIRCUM
(2) the small pulley circumference calculation is missing the 2xPI (the *6.283185 )

I have highlighted the changes in pink

// default settings
#define BELT_THICKNESS 1.49  // thickest part of belt
#define TOOTH_DEPTH 0.74     // thinnest part of the belt
#define TOOTH_SPACING 2.0   // 2mm for GT2 belts

// recalculate circumference to take into account tooth thickness, as this adds to the radius of the pulley
#define BIG_PULLEY_CIRCUM (BIG_PULLEY_TEETH*TOOTH_SPACING + (BELT_THICKNESS - TOOTH_DEPTH))*6.283185
#define SMALL_PULLEY_CIRCUM SMALL_PULLEY_TEETH * TOOTH_SPACING *6.283185

#define XYZ_FULL_STEPS_PER_ROTATION 200.0
#define XYZ_MICROSTEPS 16.0
#define SMALL_PULLEY_TEETH 16.0
#define BIG_PULLEY_TEETH 150.0
#define PULLEY_REDUCTION BIG_PULLEY_TEETH/SMALL_PULLEY_TEETH
#define xstr(s) str(s)
#define str(s) #s
#define XYZ_STEPS (XYZ_FULL_STEPS_PER_ROTATION*XYZ_MICROSTEPS*PULLEY_REDUCTION)/360.0

#include <iostream>

int main(int argc, const char * argv[]) {
    // insert code here...
    //std::cout << "Hello, World!\n";
    float result = XYZ_STEPS;
    printf ("result %F", result);
    return 0;
}

result 83.333336

Program ended with exit code: 0

So that explains why we had the issue :-)

Therefore, either changing the two lines as I did, or Neil’s solution will work.

Cheers

Douglas

Igor-Rast added a commit to Igor-Rast/printipi that referenced this issue Feb 2, 2015
@AlessioMorale
Copy link

this is still wrong:

#define BIG_PULLEY_CIRCUM (BIG_PULLEY_TEETH*TOOTH_SPACING + (BELT_THICKNESS - TOOTH_DEPTH))*6.283185
#define SMALL_PULLEY_CIRCUM SMALL_PULLEY_TEETH * TOOTH_SPACING *6.283185

it should really be:

#define BIG_PULLEY_CIRCUM (BIG_PULLEY_TEETH*TOOTH_SPACING + (BELT_THICKNESS - TOOTH_DEPTH) * 6.283185)
#define SMALL_PULLEY_CIRCUM SMALL_PULLEY_TEETH * TOOTH_SPACING

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants