orient spindle with ethercat EL5101
- laurentl38
- Offline
- Junior Member
-
Less
More
- Posts: 32
- Thank you received: 1
04 Sep 2025 12:02 #334397
by laurentl38
Replied by laurentl38 on topic orient spindle with ethercat EL5101
I took the PID solution and modified the code a little. I initialized spindle-index-enable to 1 when starting Lcnc.
I also used ABS on spindle-Pos-fb-abs.
The spindle is positioned, but only in certain cases:
- When starting Lcnc, if I've never rotated the spindle at speed and the angular displacement is small (less than 20 degrees).
- If I rotate the spindle first and then try to orient it, almost every time, it will start at maximum speed, without orientation.
- If I rotate the spindle first, and then reposition it slightly by hand with my index finger, I can orient it, but always with small successive angular displacements.
It's progressing little by little, but from my point of view, it's more tinkering than mastery...
I also used ABS on spindle-Pos-fb-abs.
The spindle is positioned, but only in certain cases:
- When starting Lcnc, if I've never rotated the spindle at speed and the angular displacement is small (less than 20 degrees).
- If I rotate the spindle first and then try to orient it, almost every time, it will start at maximum speed, without orientation.
- If I rotate the spindle first, and then reposition it slightly by hand with my index finger, I can orient it, but always with small successive angular displacements.
It's progressing little by little, but from my point of view, it's more tinkering than mastery...
Attachments:
Please Log in or Create an account to join the conversation.
- Hakan
- Away
- Platinum Member
-
Less
More
- Posts: 921
- Thank you received: 324
04 Sep 2025 16:07 #334410
by Hakan
Replied by Hakan on topic orient spindle with ethercat EL5101
Try a small value for FF1 so it starts to rotate. Then add P so it stops.
Please Log in or Create an account to join the conversation.
- laurentl38
- Offline
- Junior Member
-
Less
More
- Posts: 32
- Thank you received: 1
05 Sep 2025 19:27 #334508
by laurentl38
Replied by laurentl38 on topic orient spindle with ethercat EL5101
I'm going to run some tests this weekend.
To be honest, I'm having trouble understanding the purpose of the FF0, FF1, and FF2 terms. Are these offsets of the PID terms?
To be honest, I'm having trouble understanding the purpose of the FF0, FF1, and FF2 terms. Are these offsets of the PID terms?
Please Log in or Create an account to join the conversation.
- PCW
-
- Online
- Moderator
-
Less
More
- Posts: 17313
- Thank you received: 5037
05 Sep 2025 20:36 - 05 Sep 2025 20:37 #334515
by PCW
Replied by PCW on topic orient spindle with ethercat EL5101
FF0,FF1,FF2 are feed forward terms
FF0 adds a proportion of the PID command to the PID output
FF1 adds a proportion of the PID commands first derivative to the PID output
FF2 adds a proportion of the PID commands second derivative to the PID output
For a simple example imagine a spindle control PID loop
This would have a PID loop with velocity command and velocity output.
Setting FF0 to 1 means that at a say commanded RPM of 3000, means
that the PID output would be 3000 without any correction from the PID error
term. You can think of the FF terms as a way of centering the operating
point of the PID loop around the current state (rather than having
feedback have to do all the heavy lifting)
FF0 adds a proportion of the PID command to the PID output
FF1 adds a proportion of the PID commands first derivative to the PID output
FF2 adds a proportion of the PID commands second derivative to the PID output
For a simple example imagine a spindle control PID loop
This would have a PID loop with velocity command and velocity output.
Setting FF0 to 1 means that at a say commanded RPM of 3000, means
that the PID output would be 3000 without any correction from the PID error
term. You can think of the FF terms as a way of centering the operating
point of the PID loop around the current state (rather than having
feedback have to do all the heavy lifting)
Last edit: 05 Sep 2025 20:37 by PCW. Reason: typo
Please Log in or Create an account to join the conversation.
- Hakan
- Away
- Platinum Member
-
Less
More
- Posts: 921
- Thank you received: 324
06 Sep 2025 08:51 #334539
by Hakan
Replied by Hakan on topic orient spindle with ethercat EL5101
When I think of it, it may not work very well with FF1 in this situation.
I guess orient just gives a position, without any ramping up and down.
Not like a motion profile with acceleration up and down.
My new bet is to set all FFs to zero and slowly increase P.
I guess orient just gives a position, without any ramping up and down.
Not like a motion profile with acceleration up and down.
My new bet is to set all FFs to zero and slowly increase P.
Please Log in or Create an account to join the conversation.
- laurentl38
- Offline
- Junior Member
-
Less
More
- Posts: 32
- Thank you received: 1
06 Oct 2025 08:32 #335906
by laurentl38
Replied by laurentl38 on topic orient spindle with ethercat EL5101
hello,
I've spent hours playing with the PID values and still have the same problem...
In the meantime, I've made progress on other points on the machine to take my mind off things.
If I move the spindle to 45 degrees, then 145, 245, and 345, no problem; it positions itself correctly at the value. However, if I move it from 45 to 245, the spindle goes to maximum speed without stopping...
But since yesterday, I've had an interesting lead. When this doesn't work, I realized that the spindle command becomes negative (LCNC, probably choosing the shortest path, by wanting to rotate the spindle in the opposite direction).
And that's the problem: the spindle doesn't change direction, so the PID drifts...
To confirm my idea, I made the same movements, but imposed the rotation direction with an M19 Rx P1.
And then, if I move the spindle from 45 to 145 degrees or from 45 to 345, there's no longer a problem; it positions itself every time.
I've probably found the cause, but how to resolve it, I don't know.
Do I have an error in my HAL or am I missing a line?
Do you have any leads?
I've spent hours playing with the PID values and still have the same problem...
In the meantime, I've made progress on other points on the machine to take my mind off things.
If I move the spindle to 45 degrees, then 145, 245, and 345, no problem; it positions itself correctly at the value. However, if I move it from 45 to 245, the spindle goes to maximum speed without stopping...
But since yesterday, I've had an interesting lead. When this doesn't work, I realized that the spindle command becomes negative (LCNC, probably choosing the shortest path, by wanting to rotate the spindle in the opposite direction).
And that's the problem: the spindle doesn't change direction, so the PID drifts...
To confirm my idea, I made the same movements, but imposed the rotation direction with an M19 Rx P1.
And then, if I move the spindle from 45 to 145 degrees or from 45 to 345, there's no longer a problem; it positions itself every time.
I've probably found the cause, but how to resolve it, I don't know.
Do I have an error in my HAL or am I missing a line?
Do you have any leads?
Please Log in or Create an account to join the conversation.
- laurentl38
- Offline
- Junior Member
-
Less
More
- Posts: 32
- Thank you received: 1
07 Oct 2025 07:24 #335977
by laurentl38
Replied by laurentl38 on topic orient spindle with ethercat EL5101
Well, I just found another mistake.
My spindle driver only has two pins: forward and reverse; it doesn't have an enable pin.
And I had wired spindle.0.on to the driver's forward pin instead of spindle.0.forward.
The good news is that the PID speed still works fine.
The bad news is that the orientation doesn't move at all anymore, nothing...
My spindle driver only has two pins: forward and reverse; it doesn't have an enable pin.
And I had wired spindle.0.on to the driver's forward pin instead of spindle.0.forward.
The good news is that the PID speed still works fine.
The bad news is that the orientation doesn't move at all anymore, nothing...
Attachments:
Please Log in or Create an account to join the conversation.
- laurentl38
- Offline
- Junior Member
-
Less
More
- Posts: 32
- Thank you received: 1
07 Oct 2025 17:23 #336038
by laurentl38
Replied by laurentl38 on topic orient spindle with ethercat EL5101
Victory!! I finally have something working.
The spindle orients normally (all that's left is to set the orientation PID values correctly...) in both directions, without using the M19's P1 or P2 prefixes.
I added an ABS for the analog control voltage of the driver command and
net spindle-fwdd abs.spindle.is-positive => lcec.0.D3.dout-0
net spindle-revv abs.spindle.is-negative => lcec.0.D3.dout-1
It was hard and laborious, but anyway... the rest will seem almost easy to me
The spindle orients normally (all that's left is to set the orientation PID values correctly...) in both directions, without using the M19's P1 or P2 prefixes.
I added an ABS for the analog control voltage of the driver command and
net spindle-fwdd abs.spindle.is-positive => lcec.0.D3.dout-0
net spindle-revv abs.spindle.is-negative => lcec.0.D3.dout-1
It was hard and laborious, but anyway... the rest will seem almost easy to me

The following user(s) said Thank You: tommylight
Please Log in or Create an account to join the conversation.
Time to create page: 0.087 seconds