Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encoder velocity calculation #50

Closed
Peter-van-Tol opened this issue Sep 24, 2023 Discussed in #49 · 5 comments · Fixed by #51
Closed

Encoder velocity calculation #50

Peter-van-Tol opened this issue Sep 24, 2023 Discussed in #49 · 5 comments · Fixed by #51
Labels
bug Something isn't working

Comments

@Peter-van-Tol
Copy link
Owner

Discussed in #49

Originally posted by OJthe123 September 22, 2023
Hi.
I mentioned this in another question, but it was not the main topic.

I have to multiply the encoder velocity output pin by 8 to get the right value.
Is this a bug, or do I set something wrong?

from my hal....

loadrt mult2 names=spindle-rpm-scale
addf spindle-rpm-scale	servo-thread
setp [LITEXCNC](NAME).encoder.00.position-scale 10000
setp [LITEXCNC](NAME).encoder.00.x4-mode 1
setp spindle-rpm-scale.in0 8
net spindle-rpm spindle-rpm-scale.in1 [LITEXCNC](NAME).encoder.00.velocity
net spindle-vel-fb-rps         =>  spindle.0.speed-in	spindle-rpm-scale.out #[LITEXCNC](NAME).encoder.00.velocity

when I use the encoder.00.velocity pin directly the speed is wrong

@Peter-van-Tol Peter-van-Tol added the bug Something isn't working label Sep 25, 2023
@OJthe123
Copy link

now Linuxcnc won't start at all....

error.txt

@Peter-van-Tol
Copy link
Owner Author

Sorry about the error. Too tired to spot the error in the buffer => sizeOf was giving the size of the array in bytes not the number of items in the buffer. Wasn't thinking clear yesterday evening (got some sleep deprivation from volunteering work). Tested now on my rig and LinuxCNC starts.

@OJthe123
Copy link

Great!
It works on the RPi4 again.
Tomorrow I am going to test it on the lathe 😄

@OJthe123
Copy link

Tested it successfully on my lathe 👍
Encoder velocity now matches with the commanded speed

@Peter-van-Tol
Copy link
Owner Author

Thanks for testing. Will merge it to main and will add it to the coming release.

@Peter-van-Tol Peter-van-Tol linked a pull request Sep 27, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants