Skip to content

SIM: negative spindle speed with simulated encoder #4582

Description

@rmu75

User "DauntlessA" (who it seems didn't file an issue) reported on QtPyVcp channel:

I came across this issue again in spindle_sim.hal, where the spindle speed becomes negative at or above 12500rpm, is this something that can be fixed in the base install?
It causes the spindle-at-speed signal to stay low, so when trying to run a program the simulated machine will dwell forever waiting for the spindle to reach the requested speed.


# assume 120 ppr = 480 counts/rev for the spindle

setp sim_encoder_0.ppr 2
# ^^^ used to be 12 which works up to 12499rpm, 2 works up to 74999rpm (with a 100000ns base-thread)

# iocontrol output is in rpm, but sim-encoder speed is rps
setp sim_encoder_0.scale 60
# scale encoder output to read in revolutions
#(that way thread pitches can be straightforward,
#  a 20 tpi thread would multiply the encoder output
#  by 1/20, etc)

setp encoder_0.position-scale 8
# ^^^ Used to be 48, 8 works up to just 74999rpm (with a 100000ns base-thread)

As the sim_encoder would only be used in a simulated machine config, it there a reason such a high sampling frequency needs to be used?

If sim_encoder_0.ppr and encoder_0.position-scale are both halved from their original values of 12 and 48 respectively, the issue occurs at double the spindle speed compared to before (at or above 25000rpm) and so on for additional values.

I've personally set the values for sim_encoder_0.ppr and encoder_0.position-scale to 2 and 8 respectively, so the issue doesn't occur until at or above 75000rpm, which will likely cover almost all machines.

(This is all for a base thread of 100000ns, the trigger values are all proportional to the base frequency)

and

It seems that this issue is also present in gmoccapy...

Because their hal logic is different, the negative spindle velocity and position when at or exceeding 12500rpm isn't displayed. But the spindle-at-speed issue is still present.

Found a post here:
https://www.forum.linuxcnc.org/38-general-linuxcnc-questions/58764-can-t-sim-programs-with-spindle-speed-over-12500rpm

The BASE_PERIOD in the sim config is too low for that spindle speed so the sim_encoder component cannot calculate the speed correctly.

I would definitely call this a bug, the fact that the default sampling frequency causes an issue with the default base_period if the spindle speed ≥12500rpm (and lots of people including me have programs to run on high speed spindles which exceed that)

I'm just trying to think of a justification for such a high sampling frequency in a sim, all I can think of is that this code in gmoccapy predates high speed spindles so it wasn't seen as an issue at the time?

If it is worth keeping unchanged then the other options could be a note in spindle_sim.hal or logic to detect the issue and display a warning message?

forum topic:

https://www.forum.linuxcnc.org/38-general-linuxcnc-questions/58764-can-t-sim-programs-with-spindle-speed-over-12500rpm#349793

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions