LinuxCNC S-Curve Accelerations
- TheRoslyak
- Offline
- Elite Member
Less
More
- Posts: 238
- Thank you received: 37
07 Jun 2021 12:32 #211417
by TheRoslyak
Replied by TheRoslyak on topic LinuxCNC S-Curve Accelerations
Hi.
Is it possible to simple import this module in linuxcnc?
It need me for this topic forum.linuxcnc.org/27-driver-boards/4274...-with-stm32-or-esp32
Or can you say another way: How to smooth velocity?
Is it possible to simple import this module in linuxcnc?
It need me for this topic forum.linuxcnc.org/27-driver-boards/4274...-with-stm32-or-esp32
Or can you say another way: How to smooth velocity?
Please Log in or Create an account to join the conversation.
10 Jun 2021 20:20 - 10 Jun 2021 20:27 #211728
by chris@cnc
Replied by chris@cnc on topic LinuxCNC S-Curve Accelerations
I try to find an easier way and stumbled over Sigmoid function. My Idea is to build s-curve gain and multiply to current acceleration. This function get back good result but i am not able to scale the timer. If its possible to define this function with timers could we bend anything to S curve.
What do you thing about this way?
What do you thing about this way?
Warning: Spoiler!
component scurve " ";
description
"""
/******* Description *****************
HAL componet to put out scurve gain
Input scurve timecycle
Output scuve
********* Compile **************
halcompile --compile scurve.comp
sudo halcompile --install scurve.comp
Halfile load :
loadrt scruve
addf scurve.0 servo-thread
setp scurve.0.time
setp scurve.0.in
*/
""";
author "Chris@cnc";
license "GPL";
// Input pins
pin in float stime=10; //this value has to setp command.
pin in bit in=0;
// Output pins
pin out float out;
pin out float counter;
pin out float multi;
pin out float totalnsec;
function _;
;;
#include "rtapi_math.h"
FUNCTION(_) {
//double totalnsec;
if(in && counter <= stime) {
totalnsec += fperiod;
counter += totalnsec * 0.1;
out = 1 / ( 1+exp(-counter));
}
else {
out = 0;
counter = -10;
totalnsec = 0;
}
}
Last edit: 10 Jun 2021 20:27 by chris@cnc.
Please Log in or Create an account to join the conversation.
- TheRoslyak
- Offline
- Elite Member
Less
More
- Posts: 238
- Thank you received: 37
12 Jun 2021 14:06 #211870
by TheRoslyak
Replied by TheRoslyak on topic LinuxCNC S-Curve Accelerations
Hi arvidb,
Can you share how you imported S-Curve Accelerations?
Looking at scope you did it.
Can you share how you imported S-Curve Accelerations?
Looking at scope you did it.
Please Log in or Create an account to join the conversation.
12 Jun 2021 17:41 - 12 Jun 2021 17:42 #211876
by arvidb
Replied by arvidb on topic LinuxCNC S-Curve Accelerations
Hi TheRoslyak,
What you see on the scope is just the simplest case of jerk-limited motion: from stationary to stationary with a constant velocity part in between. There are much trickier cases that must work too for the code to be usable.
My code isn't finished yet. Since my last post I've fixed the bug I found during testing with the MPG (and another one), but there is still one corner case that I have to implement, and then integrate the resulting library with the LinuxCNC build system. I've had precious little "leftover energy" to spend on hobby programming lately, but the project is still moving forward, albeit *very* slowly at present.
What you see on the scope is just the simplest case of jerk-limited motion: from stationary to stationary with a constant velocity part in between. There are much trickier cases that must work too for the code to be usable.
My code isn't finished yet. Since my last post I've fixed the bug I found during testing with the MPG (and another one), but there is still one corner case that I have to implement, and then integrate the resulting library with the LinuxCNC build system. I've had precious little "leftover energy" to spend on hobby programming lately, but the project is still moving forward, albeit *very* slowly at present.
Last edit: 12 Jun 2021 17:42 by arvidb.
Please Log in or Create an account to join the conversation.
12 Jun 2021 21:16 #211893
by automata
Replied by automata on topic LinuxCNC S-Curve Accelerations
Hi arvidb,
Nice work with the jerk limited motion.
I am very much interested in helping out and have decent experience in the linuxcnc codebase. ( I coded the original switch kins module to switch between multiple kinematics).
It you share your current branch which looks in good form, the community can move together to solve this long standing missing feature from one of the most flexible and open cnc software.
- automata
Nice work with the jerk limited motion.
I am very much interested in helping out and have decent experience in the linuxcnc codebase. ( I coded the original switch kins module to switch between multiple kinematics).
It you share your current branch which looks in good form, the community can move together to solve this long standing missing feature from one of the most flexible and open cnc software.
- automata
Please Log in or Create an account to join the conversation.
13 Jun 2021 06:16 #211917
by chris@cnc
Replied by chris@cnc on topic LinuxCNC S-Curve Accelerations
hello arvidb hello automata, i would also help as far as i can. My approach would be a 2nd acceleration time in the ini that defines the curve. So we can easily decide whether linear or in s-curve. And the curve defines, for example, the sigmoid function. Some servo manufacturers go this route and it works very well. I have no idea how to start this. what do you think of this idea?
Christian
Christian
Please Log in or Create an account to join the conversation.
13 Jun 2021 06:51 #211919
by arvidb
Did you download and compile/run the code that I've already published ? If not, that's a good place to start (for anyone who wants to help).
Replied by arvidb on topic LinuxCNC S-Curve Accelerations
Thanks!Hi arvidb,
Nice work with the jerk limited motion.
I am very much interested in helping out and have decent experience in the linuxcnc codebase.
Did you download and compile/run the code that I've already published ? If not, that's a good place to start (for anyone who wants to help).
Please Log in or Create an account to join the conversation.
13 Jun 2021 07:06 #211921
by arvidb
Replied by arvidb on topic LinuxCNC S-Curve Accelerations
Another step forward: I managed to implement that missing corner case yesterday. Here's an oscilloscope plot showing MPG jogging, where jerk limited planning might have its biggest impact:
A bit more interesting than the last plot, don't you think?
There are still a few known bugs in the code, but it's nearing a state where testing might soon become meaningful!
A bit more interesting than the last plot, don't you think?
There are still a few known bugs in the code, but it's nearing a state where testing might soon become meaningful!
Attachments:
Please Log in or Create an account to join the conversation.
13 Jun 2021 08:46 - 13 Jun 2021 08:50 #211925
by arvidb
I think a great way to start would be to make your algorithm move a specified distance. Looking at your plot above, your algorithm moves from v = 0.0 to v = 1.0. Add a deceleration stage (from v = 1.0 to v = 0.0) and then scale peak velocity so that your algorithm ends up moving any distance that you specify as an input.
Then check that your peak velocity doesn't violate any "max velocity" (also specified as an input). If it does, insert a constant velocity segment.
Then make it work with initial velocity not zero.
And so on...
Replied by arvidb on topic LinuxCNC S-Curve Accelerations
Hi Christian!hello arvidb hello automata, i would also help as far as i can. My approach would be a 2nd acceleration time in the ini that defines the curve. So we can easily decide whether linear or in s-curve. And the curve defines, for example, the sigmoid function. Some servo manufacturers go this route and it works very well. I have no idea how to start this. what do you think of this idea?
Christian
I think a great way to start would be to make your algorithm move a specified distance. Looking at your plot above, your algorithm moves from v = 0.0 to v = 1.0. Add a deceleration stage (from v = 1.0 to v = 0.0) and then scale peak velocity so that your algorithm ends up moving any distance that you specify as an input.
Then check that your peak velocity doesn't violate any "max velocity" (also specified as an input). If it does, insert a constant velocity segment.
Then make it work with initial velocity not zero.
And so on...
Last edit: 13 Jun 2021 08:50 by arvidb.
The following user(s) said Thank You: chris@cnc
Please Log in or Create an account to join the conversation.
13 Jun 2021 17:29 #211954
by chris@cnc
You're right. It's a good idea to climb down the hill. But i can't do it.I can't do two calculations in a row. I can now control the length of the curve using a pin. My programming skills are not enough. I should leave it to people who know what they're doing. Try and error no longer leads to the goal.
Maybe someone else can make something of it. I can not...
Replied by chris@cnc on topic LinuxCNC S-Curve Accelerations
Hi arvidb,. Add a deceleration stage (from v = 1.0 to v = 0.0) and then scale peak velocity so that your algorithm ends up moving any distance that you specify as an input.
You're right. It's a good idea to climb down the hill. But i can't do it.I can't do two calculations in a row. I can now control the length of the curve using a pin. My programming skills are not enough. I should leave it to people who know what they're doing. Try and error no longer leads to the goal.
Maybe someone else can make something of it. I can not...
Warning: Spoiler!
component scurve " ";
description
"""
/******* Description *****************
HAL componet to put out scurve gain
Input scurve timecycle
Output scurve
********* Compile **************
halcompile --compile scurve.comp
sudo halcompile --install scurve.comp
Halfile load :
loadrt scurve
addf scurve.0 servo-thread
setp scurve.0.scurve
setp scurve.0.in
*/
""";
license "GPL";
// Input pins
pin in float scurve=1; //Scurve length
pin in bit in=0;
// Output pins
pin out float out;
pin out float totalnsec;
//Global Variable
variable float counter=-10;
variable int stime=10;
function _;
;;
#include "rtapi_math.h"
FUNCTION(_) {
if(in && counter <= stime) {
totalnsec += fperiod;
counter += totalnsec * scurve;
out = 1 / ( 1+exp(-counter));
}
else {
out = 0;
counter = -10;
totalnsec = 0;
}
}
Please Log in or Create an account to join the conversation.
Time to create page: 0.185 seconds