LinuxCNC S-Curve Accelerations

More
29 Mar 2023 21:05 #267861 by rodw
Replied by rodw on topic LinuxCNC S-Curve Accelerations

[...]
So the rule is for every call to malloc, you must also have a corresponding call to free BEFORE you exit the same procedure or you are setting yourself up for failure and you will spend days chasing random code errors due to memory overflow...

Hope that helps.
I'm sorry to say that, but that is not sound programming advice. Freeing dynamically allocated memory before exiting the procedure where you allocated it completely defeats the purpose of dynamic memory allocations.


Agreed and updated. Sorry about that. It still does not absolve the programmer from carefully managing memory alocation to avoid memory leaks.
The following user(s) said Thank You: Grotius, Darium

Please Log in or Create an account to join the conversation.

More
29 Mar 2023 23:44 - 29 Mar 2023 23:56 #267874 by Grotius
Hi guys,

I managed to get a scurve motion running in lcnc tp.c

So this is the first video ever representing a scurve motion profile running in lcnc axis.

It is running, but code in tp.c is far from where it must be. This are the first step on the lcnc moon for me.

video of scurve in lcnc

Don't expect gold from the video for now. It's just showing it works.

Thanks to Andy who asked to integrate the scurve into lcnc, supporters like TommyLight. Coders like Rod,
conversations with rmu and others, comments of Mr Garret.
And all others who contributed.

To be continued.




 
Last edit: 29 Mar 2023 23:56 by Grotius.
The following user(s) said Thank You: rodw, wellingtoncsouza, scotta, Darium

Please Log in or Create an account to join the conversation.

More
30 Mar 2023 00:17 #267878 by rodw
Replied by rodw on topic LinuxCNC S-Curve Accelerations
Very cool. make sure you free your memory somehow or someone like me who leaves his machine on 24/7 will be complaining months later that it had a melt down and spoiled a job!

I'm not sure of the objective but if it was to create values in an array where the length varies, perhaps a linked list might be more appropriate.
The following user(s) said Thank You: Grotius, Darium

Please Log in or Create an account to join the conversation.

More
30 Mar 2023 07:16 #267890 by zz912
Hi Grotius and others,

excited to read this thread. Unfortunately I don't understand half the stuff, but I'm looking forward to LinuxCNC having S-Curve Accelerations.

I wish you a lot of success, may the work be successful.
The following user(s) said Thank You: grijalvap, Grotius, Darium

Please Log in or Create an account to join the conversation.

More
04 Apr 2023 19:42 #268286 by Grotius
Hi,

I don't understand half the stuff,
Me too.

github_video_link

github sc_tp.c source

A little update.

Along the road we reached a new stone. Not a milestone yet.

The traject 9 axis interpolating value is just from 0 to 1. Previously it was for each gcode line 0 to 1. But now
changed for the whole traject from 0 to 1.

The reason is the scurve velocity transition when using short segments. Ok this sounds very confusing, but it
eliminates velocity transitions with acceleration=0.

It can now benefit from velocity transitions up to 2* max acceleration, without any split cycle.

In the video the traject interpolation from 0-1 can be seen. 
The only optimization that is done and can be seen is the scurve acc, dcc periods for g1,g2,g3.
You can spot the velocity transition at the linuxcnc letters. It can not be done any better.

Ok. This also show's the scurve is functional.
I had many problems with staying withing the linuxcnc cycle time. Now the interpolation + the scurve calculations are
time ok.

I have much to do, and to clean up. But the code is done with a little help of chat ai, and extern c++.



















 
The following user(s) said Thank You: tommylight, bkt, rodw, zz912, Darium

Please Log in or Create an account to join the conversation.

More
06 Apr 2023 11:22 #268414 by Grotius
Hi,

Update:
1. Cleaned up unused files and code.
  • The sc_tp.c component is now ~800 lines of code.
2. It's using the ruckig scurve library. I made a gui example to test this lib fast outside lcnc : ruckig_gui
  • The sc_engine library is for now to heavy for lcnc servo-thread, that's the reason i switched to ruckig.
3. In the sc_tp component there is now a state machine that controls the program flow. 4. It can do a program run, do vm interupts, pause, resume.
Todo:
1. It's not very difficult now to add motion reverse. And motion reverse is not limited to just one line.
2. Add adaptive feed.
3. Add more path rules, now only path rule is difference between g0 and g1,2,3 moves.
4. Create a proper program exec method without first having to set some parameters at startup.
5. How to run big programs with ~30.000 gcode lines. When is lcnc given new gcode lines?
6. And a few more.

Questions:
1. Where in lcnc's source code, during startup, is the interpreter given the coordinates to the gremlin screen?
  • I want to be able to load a custom opengl screen with these values.

sc_tp.c source
The following user(s) said Thank You: tommylight, wellingtoncsouza, zz912, Darium, mehdidadash, gotu0000

Please Log in or Create an account to join the conversation.

More
06 Apr 2023 19:57 #268453 by Grotius
Hi,

For today, a nice day with some progress.

In the video you can see i am playing with the :
  • adaptive feed
  • velocity overide
  • max velocity
The planner is capable of going back until start of gcode file is reached.

In the gremlin screen, the dtg for xyz are present, also current velocity is present.

The change in adaptive feed, has to react a little faster, i will change that in the code.

inline_github_video

Question :
Where can i retrieve the current adaptive feed value? Is it just one motion.c hal pin?
I don't like to open a new nml channel for this. For now it can be set with a parameter pin.

 
The following user(s) said Thank You: tommylight, bkt, wellingtoncsouza, endian, MichalHK, Darium, mehdidadash

Please Log in or Create an account to join the conversation.

More
06 Apr 2023 21:56 #268458 by rmu
Replied by rmu on topic LinuxCNC S-Curve Accelerations
Is it going around corners at full speed?

Please Log in or Create an account to join the conversation.

More
15 Apr 2023 17:50 #269136 by zz912
Hi Grotius,

I wanted to ask if this S-curve project is your private project? Or if you plan to release it to the official LCNC Branch?

If I understood correctly, someone else tried the S-curve first and didn't make it to the end. Then you created a HAL component that allowed you to do S-curve movements and now you're making your own interpreter. It is so?

If you are making a new intepreter and at the same time if you plan to release it, I would like to ask you that your new intepreter allows you to use the python command self.execute("G1 X20 Y20 f50") after the "yield INTERP_EXECUTE_FINISH" command. Namely, to be able to use the command "yield INTERP_EXECUTE_FINISH" several times during Remap, not just once.

forum.linuxcnc.org/38-general-linuxcnc-q...xecute-finish#268975

  • Code following a yield may not recursively call the interpreter, like with self.execute("<mdi command>"). This is an architectural restriction of the interpreter and is not fixable without a major redesign.


I understand that no one will probably do this modification in the current Interpreter, but it was a shame to repeat this mistake in the new Interpreter.
 

Please Log in or Create an account to join the conversation.

More
14 Sep 2023 13:24 - 17 Sep 2023 14:08 #280742 by Beef
Replied by Beef on topic LinuxCNC S-Curve Accelerations
I've read through the entire post history here and it's really impressive both the quality of contribution from the community and also the tenacity of Grotius in solving this problem.

--- Edit

It's taken me a couple of days but I've gotten it to compile and I'm working through getting it up and running to test it out. I have a step-by-step guide that I've been keeping along the way to help me understand how it works, and we'll see if I can refactor this a bit to be easier for others to follow along and more easily improve this in the near future.
Last edit: 17 Sep 2023 14:08 by Beef.

Please Log in or Create an account to join the conversation.

Time to create page: 0.386 seconds
Powered by Kunena Forum