Skip to content

Instantly share code, notes, and snippets.

@arthurwolf
Created December 2, 2014 23:47
Show Gist options
  • Save arthurwolf/0629c705c9758fa679ee to your computer and use it in GitHub Desktop.
Save arthurwolf/0629c705c9758fa679ee to your computer and use it in GitHub Desktop.
Changes needed for much more rational accel :
Essentially, all accel happens in stepticker, and the modules tell it what to do.
Note : once this is all done, experimenting with per-step accel is trivially easy ( the hardest part being changing planner to set accelerate_until and decelerate_after to be expressed in ticks instead of steps, which is not too hard, but has to be done )
Changes to steppermotor : 
* Instead of getting distance ( once ) and speed updates ( on a regular basis ), it gets distance + initial speed + accel + accelerate_until + decelerate_after ( once ) and stores them
* On accel tick call from stepticker, update speed ( speed += accel_change ), checks if we are at a point where the accel ramp needs to change, and if so, modify accel_change
Note : to try to limit the number of ifs, we don't test both for if(current_step = accelerate_until) and if(current_step = decelerate_after) but we check for if(current_steps = next_ramp_change), and then change next_ramp_change as needed when a ramp change happens
Note : the accel update handles in steptickers need either to get passed the current step of the fastest axis ( which is what accelerate_until and decelerate_after compare against ), or we need to modify planner to express those in term of ticks instead of steps, and then just compare them with the current tick
Changes to stepticker : 
* On accel tick ( which it now calls, convenient ), it calls the accel tick handler in each steppermotor ( could set a update_accel flag and then just call tick normally and have a if there, whatever is less expensive )
That's is .. I think ?
Changes to stepper : 
* Removing all the speed change stuff, obviously
* Just pass along the right parameters to steppermotor->move when setting them up.
Changes to extruder : 
* Remove a shitton of crap
* Pass the right parameters to steppermotor->move when setting them up
Note : accelerate_until and decelerate_after are the same as the block's
But acceleration must be computed ( much like the current speed updates are calculated, proportional to the block's speed )
Additional note :
If we want to turn accelerate_until and decelerate_after from being expressed in steps ( of the fastest axis ) to being expressed in ticks, we need to change this : 
https://github.com/Smoothieware/Smoothieware/blob/edge/src/modules/robot/Block.cpp#L110
needs to convert the speeds from steps/s to ticks/s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment