tld70 wrote: Now I didn't understand.
I thought hm2_5i20.1.encoder.00.velocity is the Speed ( rpm) this is OK
I set the hm2_5i20.1.encoder.00.scale to -66.6667
Do I think wrong?
What I have to set?
My Motor does max 7100 rpm amd have a encoder with 1024 pulse
It is usual to set the spindle encoder scale so that 1 revolution = +1 on the encoder.position.
If you set it this way then encoder.velocity is in revolutions per second.
You then need an external scale signal to calculate an rpm value, if you need one.
I think this way is better, as you get an exact calculation of spindle position. with two values of X.66667 in the calculations you have a slight imprecision, so the tap pitch will be not exactly right.
I also think that for a 1024 slot encoder (4096 counts?) your scale should have been 68.2666666666666 anyway.
I think you should set encoder.scale to 4096 and then check that encoder.position increments exactly 1.000 for a single turn of the spindle.
You can then use the scale component to produce the rpm value (which isn't used by LinuxCNC)
Then connect the encoder.00.position pin directly to the motion.spindle-revs pin.
The name is ambiguous. motion.spindle-revs means "spindle revolutions" not "spindle revolutions per minute". It is meant to be a continuous count of spindle revolutions.
This might explain something which has been puzzling me. In your G-code the K value is tiny.