EtherCAT servo as main spindle

  • Hexagon
  • Away
  • New Member
  • New Member
More
30 Nov 2025 18:22 #339516 by Hexagon
EtherCAT servo as main spindle was created by Hexagon
Hello, everyone. I have a problem configuring a servo from StepperOnline: A6-1000EC. My goal is to control this servo via the python api. It should be possible to position it between 0 and 360° as well as rotation with different speeds.

My first attempt was to configure the servo as an angular axis. Then I wrote a simple python program to control the axis via JOG_INCREMENT and JOG_CONTINOUS. For absolute positioning I switch to MDI mode and send my target position. This works totally fine, but I can't run gcode with this solution, because I can't turn the servo continuous in one direction.

So I tried setting up this as a spindle instead. At first I changed my xml so I can process target-velocity and control-mode. Then I used a mux2 to change the control-mode depending on the use of M3/M4/M5 or M19. This works fine and my frequency drive changes between mode8 and mode9. The spindle control with M3/M4/M5 also works fine, but when I enter a command like M19 R180 Q2 P0 the servo drive throws a fault. When the target position is near the actual position this works, so I assume it is some sort of following error. My bigger problem is, that the actual position of the motor after using M3 for some time is very large, cause it is not restricted to one revolution. Is there a way to change that? At my first attempt using it as an axis I used wrapped_rotary, but that only affected the display, not the actual value.

Does anyone know what I could do, or if there is a better way for the use of an servo as position and continuous motion?

Many thanks in advance

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

More
30 Nov 2025 22:33 #339534 by Hakan
Replied by Hakan on topic EtherCAT servo as main spindle
This may be relevant forum.linuxcnc.org/38-general-linuxcnc-q...ove-only-following-e
Start from the end where the final setup is.
The following user(s) said Thank You: Hexagon

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

  • Hexagon
  • Away
  • New Member
  • New Member
More
01 Dec 2025 18:15 #339599 by Hexagon
Replied by Hexagon on topic EtherCAT servo as main spindle
Thank you Hakan.

This was very helpful. With your cia402pv and the files from aDm1N, I managed to get the servo running with GCode Commands both for rotation and positioning.

Here are the things I had to change in the hal-file:
- net c-mode-request and2.3.in0 -> spindle-ok-for-c
- net spindle-speed-normal spindle.0.speed-out mux2.0.in0 -> spindle.0.speed-out-rps
- and of corse some names and scale values

Now to my problem:
As long as I only use G0 and G1, the servo positions correct (example: C0 is at 12 o'clock). Then I let it run with M3 S1000 and after a while I stop it using M5. Now the servo stops at its position. In my optinion it should move to 12 o'clock, if I use G0 C0. But nothing happens. If I type G0 C90, it moves 1/4 revolution. So it looks like if the stopping of the servo sets somehow the zero position? 
Attachments:

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

More
01 Dec 2025 18:43 #339600 by Hakan
Replied by Hakan on topic EtherCAT servo as main spindle
I don't have such a setup so it is very difficult to say.
But it sounds like the current position is lost, and when you go back to csp mode the current position is set to zero no matter how the spindle actually is rotated.
aDm1N had something about tracking position didn't he? Did you try that?

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

  • Hexagon
  • Away
  • New Member
  • New Member
More
02 Dec 2025 14:27 #339640 by Hexagon
Replied by Hexagon on topic EtherCAT servo as main spindle
Yes I use his code for tracking the positon.

It also seems like if I tested the pv mode not long enough, because if I let the servo run with for example 600rpm, it throws a joint0 following error after some time. Is this even possible in pv mode? I thought this is only a velocity command without feedback loop?

I also changed the code back to spindle.0.speed-out instead of spindle.0.speed-out-rps (of course with a scale change), but the behaviour is exactly the same.

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

More
02 Dec 2025 14:52 - 02 Dec 2025 15:01 #339641 by Hakan
Replied by Hakan on topic EtherCAT servo as main spindle
There might be something in the cia402pv code.
The original cia402 component didn't allow mode switching, it took the first csp_mode value at startup.
I need to at least go over that part to make sure mode switching works.
But I doubt that's the reason.

Start using the debugging tools. Halshow and maybe halscope to follow the values over time
to find out the reason for the following error.
Last edit: 02 Dec 2025 15:01 by Hakan.

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

  • Hexagon
  • Away
  • New Member
  • New Member
More
04 Dec 2025 15:34 #339733 by Hexagon
Replied by Hexagon on topic EtherCAT servo as main spindle
The problem in spindle mode is, that the cia402 pos-fb is mapped to joint motor-pos-fb, but joint motor-pos-cmd is fixed. So joint f-error increases over time. Now I'm not sure how to solve this problem, cause I can't manipulate joint motor-pos-cmd. One way would be to freeze joint motor pos-fb, this way there is no f-error and track the movement to set an offset. But I can't figure out how to solve this, without writing to joint motor-pos-cmd.

The following error should also be a problem for aDm1N. But I assume it is less important, cause he only has 8000inc/rev, where I have 131072inc/rev, so the error adds up much slower. This would also explain FERROR = 1000000 in his ini.

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

More
04 Dec 2025 16:08 #339734 by Aciera
Replied by Aciera on topic EtherCAT servo as main spindle
I'm not familiar with ethercat but the somewhat 'established' strategy when switching between spindle and rotary is to use a hal component to freeze the encoder position feedback when switching to spindle mode and reposition the spindle using M19 before switching back to rotary mode and reconnecting the encoder signal.

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

More
04 Dec 2025 16:38 #339735 by Hakan
Replied by Hakan on topic EtherCAT servo as main spindle
I thought ADm1N solved this with the c_pos_sync component?

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

  • Hexagon
  • Away
  • New Member
  • New Member
More
04 Dec 2025 17:11 #339736 by Hexagon
Replied by Hexagon on topic EtherCAT servo as main spindle
The sync component only calculates the c-pos-sync.0.pos_cmd_out, but has no effect to the joint.0.motor-pos-cmd.

It takes joint.0.motor-pos-cmd as c-pos-sync.0.pos-cmd-in and joint.0.motor-pos-fb as c-pos-sync.0.pos-fb_in. The calculated delta is called offset. So in spindle mode cmd_out = fb_in, but cmd_in is fixed. That results in the following joint error.

FUNCTION(_) {
    if (!c_mode_active) {
        offset = pos_fb_in - pos_cmd_in;
        pos_cmd_out = pos_fb_in;
    } else {
        pos_cmd_out = pos_cmd_in + offset;
    }
}

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

Time to create page: 0.111 seconds
Powered by Kunena Forum