-
Notifications
You must be signed in to change notification settings - Fork 91
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
Conversation
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
Fixed some typos and syntax errors.
Hope you enjoyed your trip! :)
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.
So no one accidentally tries to use a real HAAS routine on it? yeah i see it. |
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) { |
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.
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.
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.
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?
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.
I am starting to believe that this PR should be deferred until I get an overdue settings revision done. This so that I do not run into issues later on. I'll look into this in the next few days.
planner.c
Outdated
@@ -348,9 +348,28 @@ static inline float limit_acceleration_by_axis_maximum (float *unit_vec) | |||
if (unit_vec[--idx] != 0.0f) // Avoid divide by zero. | |||
limit_value = min(limit_value, fabsf(settings.axis[idx].acceleration / unit_vec[idx])); | |||
} while(idx); | |||
#if ENABLE_ACCELERATION_PROFILES | |||
limit_value *= lookupprofile(gc_state.modal.activeaccelprofile); |
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.
The profile factor should be passed from gcode.c in the plan_block_t structure. And set it in the plan_data_init() too, perhaps to 1.0?
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.
I rewrote it so it uses the plan_block_t structure and plan_data_init() function.
How it should now work is the machine initializes with active profile 1 - 1.0 factor. in gcode.c (including reset handling)
plan_data_init() looks up the current factor with the lookupfactor() function.
plan_block_t now has storage for the current_factor and gets it from pl_data->current_factor to calucalte adjusted acceleration limits via limit_value *= block->acceleration_factor;
hope i didnt mess that up too badly
settings.h
Outdated
@@ -714,6 +718,9 @@ typedef struct { | |||
float steps_per_mm; | |||
float max_rate; | |||
float acceleration; | |||
#if ENABLE_JERK_ACCELERATION | |||
float jerk; | |||
#endif |
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.
This is another potential problem we have to be aware of, the area reserved for global settings may overflow when many axes are configured. I have already switched to claim settings storage for a second PWM spindle from above the area reseved for the core. Perhaps the jerk settings should as well? I'll have to think about that. See nvs.h.
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.
I have just commited a version with updated settings structures and that adds a permanent field for jerk. I have also reserved ten new axis settings for the core, jerk beeing the first assigned.
If you can update your PR against this version then I will be able to merge it without risking issues with the settings.
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.
Currently at work, will take a look and push latest revision tomorrow night or maybe wednesday!
Thanks for all the work! :)
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.
resolved the conflicts. :)
…ction to plan_data_init, renamed lookup fuction and adjusted the acceleration limit functions to new structure
Is this nearly ready for merge now? |
Cleaned up out of sync functions. Most likely a remnant from resolving the merge conflict.
The out of sync file might have been from cleaning up the merge conflicts, my apologes. So apart from physical testing i guess it's ready? edit: just wait a sec, found another issue |
Okay, seems to be looking good now on my end. Edit: G187 implementation is currently having 2 issues. It throws an error36 after the "ok" when changing p-values and the controller crashes when issuing any movements with it enabled. It's late now and i will continue debugging later. |
planner.c
Outdated
@@ -339,7 +339,7 @@ inline static float plan_compute_profile_parameters (plan_block_t *block, float | |||
return nominal_speed; | |||
} | |||
|
|||
static inline float limit_acceleration_by_axis_maximum (float *unit_vec) | |||
static inline float limit_acceleration_by_axis_maximum (float *unit_vec,) | |||
{ |
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.
Stray comma?
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.
Yep, removed.
settings.h
Outdated
@@ -712,7 +712,9 @@ typedef struct { | |||
float dual_axis_offset; | |||
float homing_seek_rate; | |||
float homing_feed_rate; | |||
#if ENABLE_JERK_ACCELERATION |
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.
Remove this #if/#endif, it will trigger a settings reset when enabling/disabling jerk.
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.
Done.
Also fixed the G187 Unused P Value error. The crash on motion command still persists. :/ Edit: Found the issue for the crashes. The plan_data_init() doesnt initialize it.
it stays at 0 and the debug print doesnt get called either. |
No crashes for me, but then I have modified your code a bit, in gcode.c: Simplified this a bit, the FAIL macro is a
Copying the factor to plan_data passed to the planner is missing in your code:
|
…e!) added the line for initilizing the acceleration_factor, renamed acceleration_profiles variable to acceleration_factor to match the rest of the code
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! :)