# Online Feedrate Override

**URL:** <http://discourse.heig-vd.ch/t/online-feedrate-override/335>\
**Category:** OpenCN Framework\
**Created:** [June 22, 2022, 9:26am UTC](http://discourse.heig-vd.ch/t/online-feedrate-override/335 "2022-06-22T09:26:24Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![yakunix](http://discourse.heig-vd.ch/letter_avatar_proxy/v4/letter/y/bb73d2/32.png) [@yakunix](http://discourse.heig-vd.ch/u/yakunix)\
**Post date:** [June 22, 2022, 9:26am UTC](http://discourse.heig-vd.ch/t/online-feedrate-override/335/1 "2022-06-22T09:26:24Z")

</div>

Does the planning algorithm support online change of the feedrate? For example, the user can enlarge of lower the maximum feedrate at runtime. The optimization should re-run to respect the new feedrate constraint.

---

<div class="post-metadata">

**Author:** ![Raoul](http://discourse.heig-vd.ch/user_avatar/discourse.heig-vd.ch/raoul/32/21_2.png) [@Raoul](http://discourse.heig-vd.ch/u/Raoul)\
**Post date:** [June 27, 2022, 2:37pm UTC](http://discourse.heig-vd.ch/t/online-feedrate-override/335/2 "2022-06-27T14:37:57Z")

</div>

Yes, OpenCN supports online change of the feedrate, often called by CNC manufacturers “Override”.

The Override is acting at the “resampling” phase **after** the feedrate optimization.  
It’s simply a scale factor on the time axis.  
Therefore, it not only changes the maximum feedrate, but also the acceleration and jerk limits.  
Everything is slowed down or speeded up.

At the moment being, the resampling takes place in the user space, and there is a FIFO buffer of setpoint values between user and kernel space.

This buffer induces a loss of reactivity when changing the feedrate.

We decided as a low priority task to move the resampling in the kernel space in order to avoid the time lag created by the FIFO buffer.

---

<div class="post-metadata">

**Author:** ![yakunix](http://discourse.heig-vd.ch/letter_avatar_proxy/v4/letter/y/bb73d2/32.png) [@yakunix](http://discourse.heig-vd.ch/u/yakunix)\
**Post date:** [June 29, 2022, 1:42am UTC](http://discourse.heig-vd.ch/t/online-feedrate-override/335/3 "2022-06-29T01:42:11Z")

</div>

Hi Raoul, Do you mean the following resampling function:  
`function state = ResampleNoCtx(state, Bl, Curv) `  
But I didn’t see a time scaling factor in the input interface.

---

<div class="post-metadata">

**Author:** ![hugoGrallLucas](http://discourse.heig-vd.ch/letter_avatar_proxy/v4/letter/h/6f9a4e/32.png) [@hugoGrallLucas](http://discourse.heig-vd.ch/u/hugoGrallLucas)\
**Post date:** [June 29, 2022, 11:27am UTC](http://discourse.heig-vd.ch/t/online-feedrate-override/335/4 "2022-06-29T11:27:58Z")

</div>

Hi Yakunix,

There are two ways to change the feedrate in our algorithm:

- The federate is passed directly in our curvStruct. This value is then used to define the matrix of constraints of the optimization problem ( Have a look to the function `buildConstr` in [FeedratePlanning\_LP](https://gitlab.com/mecatronyx/opencnc/opencn-matlab/-/blob/27-PR2-transitions-5-axes/common/c_planner_v5/FeedratePlanning_LP.m)) )
- In the C++ implementation, we used a parameter called Override that can be changed from the user GUI. This parameter will directly rescale the time step used during the resampling. A smaller value of time step will reduce the federate. Note, the rate used to send the commands to the drive remains the same. ( See Class LowPass` ` : [feedopt.cpp](https://gitlab.com/mecatronyx/opencnc/opencn/-/blob/master/agency/usr/target/components/feedopt/feedopt.cpp) ) This code isn’t present in opencn-matlab, it is native C/C++ code.

I hope this will help you,

Best

---

<div class="post-metadata">

**Author:** ![yakunix](http://discourse.heig-vd.ch/letter_avatar_proxy/v4/letter/y/bb73d2/32.png) [@yakunix](http://discourse.heig-vd.ch/u/yakunix)\
**Post date:** [June 29, 2022, 12:58pm UTC](http://discourse.heig-vd.ch/t/online-feedrate-override/335/5 "2022-06-29T12:58:00Z")

</div>

I see. So a low pass filter is used to smoothly change the sampling period. Should the velocity and acceleration also be scaled when doing the evaluation? Or we just use the position command without vel/acc send to the servor?

---

<div class="post-metadata">

**Author:** ![Raoul](http://discourse.heig-vd.ch/user_avatar/discourse.heig-vd.ch/raoul/32/21_2.png) [@Raoul](http://discourse.heig-vd.ch/u/Raoul)\
**Post date:** [June 29, 2022, 1:13pm UTC](http://discourse.heig-vd.ch/t/online-feedrate-override/335/6 "2022-06-29T13:13:15Z")

</div>

Only position setpoint values are sent via EtherCAT to the drives.  
This is the EtherCAT standard (CSP mode).

The drives recovers from the received position data the velocity and acceleration for feedforward purposes

---

<div class="post-metadata">

**Author:** ![hugoGrallLucas](http://discourse.heig-vd.ch/letter_avatar_proxy/v4/letter/h/6f9a4e/32.png) [@hugoGrallLucas](http://discourse.heig-vd.ch/u/hugoGrallLucas)\
**Post date:** [June 29, 2022, 2:27pm UTC](http://discourse.heig-vd.ch/t/online-feedrate-override/335/7 "2022-06-29T14:27:09Z")

</div>

Hi,  
Adding a scaling to the time step used during the resampling changes the equation (7) from the publication [openCN](https://discourse.heig-vd.ch/uploads/short-url/dMAnqwXH900zyGbGiPk3tht3Xej.pdf) :  
 ![rescaling_factor](http://discourse.heig-vd.ch/uploads/default/original/1X/21abbc9517fb10e9ff18964f0f3bc19e4b0009f5.png)

If the LP optimization leaded to a feasible solution, both velocity and acceleration constraints are ensured to be satisfied for given time step ( scaling = 1 ).

In the particular case where s is smaller than 1 but bigger than 0 ( =\> a lower feedrate than before we will be optained ), both velocity and acceleration should remain bellow the constraints used during the optimization since we have :

![vel_acc_wrt_u](http://discourse.heig-vd.ch/uploads/default/original/1X/71231a163e03afe2f8fe7321477b7caf8f669117.png)

If the scaling factor is bigger than 1, the resulting trajectory might violate the constraints.

To resume, I think the time scaling used during resampling rescales both speed and acceleration even if only the position is sent to the drive.

best,

---

<div class="post-metadata">

**Author:** ![Raoul](http://discourse.heig-vd.ch/user_avatar/discourse.heig-vd.ch/raoul/32/21_2.png) [@Raoul](http://discourse.heig-vd.ch/u/Raoul)\
**Post date:** [June 29, 2022, 3:16pm UTC](http://discourse.heig-vd.ch/t/online-feedrate-override/335/8 "2022-06-29T15:16:06Z")

</div>

If Override = 0.5, the max velocity is diveded by 2, the max acceleration is divided by 4, and the max jerk is divided by 8.

This is simply a consequence of the time scaling.

---

<div class="post-metadata">

**Author:** ![yakunix](http://discourse.heig-vd.ch/letter_avatar_proxy/v4/letter/y/bb73d2/32.png) [@yakunix](http://discourse.heig-vd.ch/u/yakunix)\
**Post date:** [June 30, 2022, 3:49am UTC](http://discourse.heig-vd.ch/t/online-feedrate-override/335/9 "2022-06-30T03:49:32Z")

</div>

In the function [ResampleNoCtx](https://gitlab.com/mecatronyx/opencnc/opencn-matlab/-/blob/master/common/c_planner_v5/ResampleNoCtx.m), there is a remaining time estimation:

 ![image](http://discourse.heig-vd.ch/uploads/default/original/1X/dd4901ed0388f1694423579cc637705915d14e8a.png)

If the dt is changed online, will the Trest still be valid?

For example if scaling = 0.5, the remaining time should be 2 \* Trest?

---

<div class="post-metadata">

**Author:** ![Raoul](http://discourse.heig-vd.ch/user_avatar/discourse.heig-vd.ch/raoul/32/21_2.png) [@Raoul](http://discourse.heig-vd.ch/u/Raoul)\
**Post date:** [June 30, 2022, 7:22am UTC](http://discourse.heig-vd.ch/t/online-feedrate-override/335/10 "2022-06-30T07:22:18Z")

</div>

dear yakunix,

Thanks for your comment.  
I will have a look into this next week.

It’s the end of semester here and I’m extremely busy with exams and corrections 🙂

---

<div class="post-metadata">

**Author:** ![yakunix](http://discourse.heig-vd.ch/letter_avatar_proxy/v4/letter/y/bb73d2/32.png) [@yakunix](http://discourse.heig-vd.ch/u/yakunix)\
**Post date:** [June 30, 2022, 7:57am UTC](http://discourse.heig-vd.ch/t/online-feedrate-override/335/11 "2022-06-30T07:57:58Z")

</div>

Thanks Raoul. Take your time! 🙂
