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

Jerk Acceleration Settings and HAAS G187 Acceleration Profiles #593

Open
wants to merge 46 commits into
base: master
Choose a base branch
from

Conversation

Dietz0r
Copy link

@Dietz0r Dietz0r commented Sep 29, 2024

This adds code to implement 3rd order accleration settings over the acceleration ticks of the stepper loop.

With the default settings of 100 acceleration ticks it will update the acceleration values according to the jerk setting with each 10ms block that gets fed into the stepper loop.
If a CPU is strong enough to run 1000 acceleration ticks that would net a 1ms Jerk Stepper Loop but 100 or 200 ticks work fine.
Tested on 2 independent machines with help from @EmpyreanCNC

Known Issue:
The machine moves a bit erratically/stuttery when getting fed jog commands from either a pendant or the IOSender interface, i think this has to do with how those conitinous jog commands are fed to the controller but i wasnt able to veryify or fix the issue on my end. Normal G-Code file execution works as expected. I hope you might have more insight into why this problem arises.

Also added support for HAAS style G187 acceleration profiles currently set to 20%, 40% 60% 80% and 100% of the max settings to allow for fine control during toolpathes and improved surface finishes.
Gets called as G187 P1 for 100% speed roughing to G187 P5 for 20% slow finishing.

Hope this helps! :)

Dietz0r and others added 30 commits October 30, 2023 11:37
First experimental checkin for constant jerk motions
First experimental checkin for constant jerk motions
First experimental checkin for constant jerk motions
missing semicolon
bugfixing float variables
DEFAULT_X_JERK capitalization
static char added for axis_jerk
@Dietz0r
Copy link
Author

Dietz0r commented Oct 18, 2024

No questions, annotations, comments or change requests? =(

@terjeio
Copy link
Contributor

terjeio commented Oct 19, 2024

I'll get to this when I am back home early next month since I do not have access to a machine where I am now.

@terjeio
Copy link
Contributor

terjeio commented Oct 30, 2024

FYI I'll be back home in a week...

From the Haas documentation:

G187 will be canceled whenever [RESET] is pressed, M30 or M02 is executed, the end of program is reached, or [EMERGENCY STOP] is pressed.

This means that there should be a setting for the default P value? And cancellation implemented?

gcode.c Outdated Show resolved Hide resolved
settings.h Outdated
@@ -1064,6 +1071,11 @@ bool settings_read_coord_data(coord_system_id_t id, float (*coord_data)[N_AXIS])
// Temporarily override acceleration, if 0 restore to configured setting value
bool settings_override_acceleration (uint8_t axis, float acceleration);

#if ENABLE_ACCELERATION_PROFILES
extern uint8_t ActiveAccelProfile;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO ActiveAccelProfile should be added to gc_state and passed to the planner via pl_block instead. Set the default in gc_init() and restore it in the M2/M30 handling code.

Copy link
Author

@Dietz0r Dietz0r Oct 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would something like this work?
this in gc_init() to initialize the state:
gc_init
and call back it in the limit function in planner.c like this:
planner c

and then set and reset the gc_state.modal.activeaccelprofile to whatever profile is currently needed with the g187 function? And then also add the m2/m30/reset handling, of course.

@Dietz0r
Copy link
Author

Dietz0r commented Oct 30, 2024

FYI I'll be back home in a week...

Hope you enjoyed your trip! :)

This means that there should be a setting for the default P value? And cancellation implemented?

I think the most reliable thing would be to have the default value be 100%, so the settings that are set on the axis and be modified from there with the profiles. Saves a setting slot and if you really want to just run at 80% max it's trivial to just add G187 P4 at the start of any code.

The cancellation is a good point! didnt think of that! Will look at it and add it.

This should be !gc_block.words.p to check if a value has been supplied. IMO also check gc_block.words.e, if supplied (true) error out since it is not supported?

So no one accidentally tries to use a real HAAS routine on it? yeah i see it.

settings.c Outdated Show resolved Hide resolved
settings.c Outdated
ActiveAccelProfile = 1; // Initialize machine with 100% Profile

//Acceleration Profiles for G187 P[x] in percent of maximum machine acceleration.
float LookupProfile(uint8_t Profile) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to planner.c as static inlined?
and the return value is either 0 or 1 since you assign the value to Profile before returning it? Use return lookup(profile); instead?
BTW I do not use camel cased or upper case names in the core.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving it to planner.c as static inlined would make it very hard to find if you wanted to have other profiles instead of the generic placeholder 20% ones.

I shied away from making it yet another list of $ settings because it would likely mean a whole slew of settings for however much profiles you wanted. having the lookuptable in settings.c makes it findable though.

maybe move it to the driver my_machine.h because it is a compile time setting?

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.

3 participants