Slider (scale) to change stepper acceleration

More
09 Oct 2024 18:44 #311666 by Leintz2
Hello!
I'm wondering is it possible to change stepper motors ACCELERATION value in real time with the pyVCP scale (SLIDER) component.
Yes  I can change MAX_ACCDLERATION value in INI file but rebooting is not very good solution.
Any HAL code example will be welcomed also.

This solution will help to remove (decrease) mechanical vibration from big router type laser cutter.

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

More
09 Oct 2024 19:51 - 10 Oct 2024 18:35 #311673 by Todd Zuercher
Replied by Todd Zuercher on topic Slider (scale) to change stepper acceleration
You can change them without restarting Linuxcnc but not necessarily in real time (ie durring the exicution of a G-code file.)

For example I made a custom M100 code that would change all of the acceleration settings for each of my axis on a cnc router. The command was M100Pn with n=the new acceleration setting. I had the code for the M100 command written so that if the Pn was omitted then it would reset the accleration settings back to thier original default settings.  Or you can use a hal command to setp the value of  the pin "ini.N.max_acceleration".

The M-code worked reasonably well for me, but I'm not sure I would trust it to actually make those changes on the fly during the execution of a program.  It might work perfectly, or it could give an unpredictable delayed reaction, or it might not effect the change until execution of the G-code file ends.  I only used it as an MDI command between running programs.

If you try to use this M code be sure to edit it to change the default acceleration setting to one that is appropriate for your machine (This one was set to 6in/sec^2)

 

File Attachment:

File Name: M100_2024-10-10.txt
File Size:1 KB
Attachments:
Last edit: 10 Oct 2024 18:35 by Todd Zuercher. Reason: Updated corrected M100 file

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

More
09 Oct 2024 19:59 #311674 by Todd Zuercher
Replied by Todd Zuercher on topic Slider (scale) to change stepper acceleration
I'm not sure that changing the accelerations via a slider in real time will work. The problem is that the trajectory planner must recalculate the accelerations for a file, and locks those settings durring execution. (I think a loaded g-code file might need to be reloaded or reprocessed before execution after changing the acceleration settings.)

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

More
10 Oct 2024 04:27 #311696 by Aciera
INI hal pin values can be changed in gcode during execution but require a queuebuster command (eg M66 E0 L0) to be updated.

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

More
10 Oct 2024 14:29 #311730 by Leintz2
Replied by Leintz2 on topic Slider (scale) to change stepper acceleration
Thank you very much!
It works very well...need yo add only USER_M_PATH =... to INI file and give full permission to execute the M100 file.
You are right, this is not real time... and after entering M100 code all breakout board output jumps a little....but i do not care...it solves my problem :)

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

More
10 Oct 2024 17:34 #311756 by Leintz2
Replied by Leintz2 on topic Slider (scale) to change stepper acceleration
M100 Pxx command works and Hal meter show me the same acceleration value in ini.0.max_acceleration pin...but no changes in motor acceleration...any comments?

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

More
10 Oct 2024 18:26 - 10 Oct 2024 18:27 #311758 by Todd Zuercher
Replied by Todd Zuercher on topic Slider (scale) to change stepper acceleration
Interesting. I have to be honest with you, I set this up a long time ago, and the machines that were using it were (and still are) running Linuxcnc version 2.7.

I just experrimented a bit in a virtual machine and it appears that in the version of Master that I have installed there. if both a max acceleration for the joint and a max acceleration for an axis letter are specified, the max acceleration for the axis letter overrides the joint max acceleration. This seems like a bug to me, I would think that the expected behavior should be that the lowest max acceleration should be the one obeyed if both are specified. Changing the M code to this should work.
#M100
#!/bin/bash
#changes the max acceleration for each axis to P=

test=$(echo "0 > $1" | bc -q )

if [ $test = 1 ]
then
accel=6
echo "Acceleration set to default of 6 in/sec^2"
else
accel=$1
echo "Acceleration set to $accel in/sec^2"
fi
halcmd setp ini.0.max_acceleration $accel
halcmd setp ini.1.max_acceleration $accel
halcmd setp ini.2.max_acceleration $accel
halcmd setp ini.x.max_acceleration $accel
halcmd setp ini.y.max_acceleration $accel
halcmd setp ini.z.max_acceleration $accel
exit 0
Last edit: 10 Oct 2024 18:27 by Todd Zuercher.

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

More
10 Oct 2024 18:47 #311762 by Todd Zuercher
Replied by Todd Zuercher on topic Slider (scale) to change stepper acceleration
A little more experimentation shows that the joint max acceleration is only obeyed in joint mode (such as when homing), and the axis acceleration is what is obeyed in world mode. So both are required.

This behavior works fine in a Cartesian machine, but might give very broken results for a non Cartesian machine (such as a robot arm.) But I haven't really played with one of those.
The following user(s) said Thank You: tommylight

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

More
11 Oct 2024 15:59 #311816 by Leintz2
Replied by Leintz2 on topic Slider (scale) to change stepper acceleration
Hi again!
Final results:
yes, this code is correct:

halcmd setp ini.0.max_acceleration $accel
halcmd setp ini.x.max_acceleration $accel

M100 Pxx codes works well....it contains keyboard arrow/pendant/program acceleration overrides
so...i wrote small part to pyVCP as well

Thank you all! (specially to Todd)
Attachments:
The following user(s) said Thank You: tommylight

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

Time to create page: 0.065 seconds
Powered by Kunena Forum