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

Change Encoder Steps to Float - Conflicts Fixed #344

Merged
merged 3 commits into from
Dec 15, 2017

Conversation

krkeegan
Copy link
Collaborator

Fixed the conflicts in @reecej PR #343.

The encoderSteps and zEncoderSteps variables were changed from int to float, and the changeEncoderResolution function updated accordingly.

I also removed the conversion of distance into a whole number of encoder steps. I don't know how much this is really doing for us. Plus after the fact, I realize I made that code much more complicated than necessary. We can always add this concept back in if it is necessary.

I still have not had the chance to test to see if this fixes all of the float->int errors, but it certianly looks like it does.

reecej and others added 3 commits December 14, 2017 20:12
The encoderSteps and zEncoderSteps variables were changed from int to float, and the changeEncoderResolution function updated accordingly.
I don't know how important this the whole number of encoder steps
really is.  It would be more of an issue if we used the KI term in
the PID calculations.  We can always add back later if we think it
actually contributes something important.

Also changed the default values of a few related variables, the
defaults are never used, but it should help future programers if
the defaults at least make some sense.
@BarbourSmith
Copy link
Member

Great! I will merge this as soon as you guys say it's good to go!

@reecej
Copy link
Contributor

reecej commented Dec 15, 2017

Thanks for getting this sorted @krkeegan.

One note. I see that the _mmPerRotation is statically calculated. I have seen the sprocket radius entered into other parts of the code as 10.2, whereas it seemed to be calculated as 10.1 here. Do you know which is the correct value?

@davidelang
Copy link
Contributor

davidelang commented Dec 15, 2017 via email

@krkeegan
Copy link
Collaborator Author

I think _mmPerRotation is part of the settings sent from GC and I think that is just a fixed number entered by the user. The value I changed is only a initialized value which can't ever be used, I thought it would just help programmers in the future if they had a default value of its size.

I do see that in kinematics there is a sprocket radius hardcoded in there. That should become a variable at some point.

@davidelang
Copy link
Contributor

davidelang commented Dec 15, 2017 via email

@reecej
Copy link
Contributor

reecej commented Dec 15, 2017

Good point @davidelang, and calculating it based on a 10 tooth sprocket with a 0.25" pitch on 25 chain, the radius is 10.1mm, just as @krkeegan had. I agree that calculating based on chain pitch and number of sprocket teeth is the more reliable method, but that would be another PR. Also note that the value of 10.2 using in the kinematics formulas is wrong then.

@davidelang
Copy link
Contributor

davidelang commented Dec 15, 2017 via email

@reecej
Copy link
Contributor

reecej commented Dec 15, 2017

If so, do we want to correct that value as well in this release? Several aspects of this code would make a machine calibration useful in the code now versus the previous release (updated motor encoder steps per revolution, updated triangular kinematics), and an updated sprocket radius would be similar as well. It might be useful to push that through and then strongly recommend users perform a calibration after upgrading to account for all changes.

@davidelang
Copy link
Contributor

davidelang commented Dec 15, 2017 via email

@madgrizzle
Copy link
Contributor

Isn't _mmPerRotation already calculated as you say? numberofteeth*chainPitch?

In system.cpp, the following appears:

if (gearTeeth != -1 and chainPitch != -1){
float distPerRot = gearTeeth*chainPitch;
leftAxis.changePitch(distPerRot);
rightAxis.changePitch(distPerRot);
zAxis.changePitch(zDistPerRot);
}

in axis.cpp, that calls:

void Axis::changePitch(const float& newPitch){
...
_mmPerRotation = newPitch;
}

You can calculate R from that (_mmPerRotation/(2*Pi)). I would just throw that calc into the changePitch routine.

@reecej
Copy link
Contributor

reecej commented Dec 15, 2017

As pointed out, it looks like the _mmPerRotation is calculated as gearTeeth*chainPitch, which is what we want. From what I can see, the value R used in the current quadilateral and triangular kinematics is statically set to 10.2, which is not correct for the configuration of 25 chain and a 10 tooth sprocket.

The difference of 10.1 vs 10.2 for the R value would only make a 1% difference on the length of chain wrapping around the sprocket, but 0.2-0.3mm error in chain length is possible. It is a simple fix, and I would recommend we either update it now to the 10.1 value or set it to be calculated similar to _mmPerRotation.

@blurfl
Copy link
Collaborator

blurfl commented Dec 15, 2017

Better to calculate it, as that will permit folks to use non-standard sprockets.

@reecej
Copy link
Contributor

reecej commented Dec 15, 2017

How would you want to do that? Include CNC_Functions.h in Kinematics.h and define R = (gearTeeth x chainPitch)/(2 x 3.14159)?

@davidelang
Copy link
Contributor

davidelang commented Dec 15, 2017 via email

@madgrizzle
Copy link
Contributor

It should be part of the updateMotorSettings routine (or subroutine called in it, such as changePitch)

@BarbourSmith
Copy link
Member

BarbourSmith commented Dec 15, 2017

#345 updates the default radius to EDIT: 10.1
#346 sets the radius to a value computed from the chain pitch and number of sprocket teeth exactly as @reecej and @madgrizzle recommended

@krkeegan
Copy link
Collaborator Author

Those look like the solve the concerns raised.

@reecej
Copy link
Contributor

reecej commented Dec 15, 2017

I agree. That will also apply the needed changes for the updated triangular kinematics as well, which now incorporate the sprocket radius.

@BarbourSmith
Copy link
Member

Great! I'm going to merge this whole batch of pull requests then 👍 👍 😀

Great collaboration everyone!

@BarbourSmith BarbourSmith merged commit f08b1c4 into MaslowCNC:master Dec 15, 2017
@reecej
Copy link
Contributor

reecej commented Dec 15, 2017

Are similar changes need in the GC simulator to keep them in sync? I believe GC has R defined statically as 10.2.

@BarbourSmith
Copy link
Member

Yes, this same issue will be present in the simulator. Great reminder!

@davidelang
Copy link
Contributor

davidelang commented Dec 15, 2017 via email

@krkeegan krkeegan deleted the FloatEncoderSteps branch January 17, 2018 22:29
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

Successfully merging this pull request may close these issues.

6 participants