- LinuxCNC
- General LinuxCNC Questions
- Need a bit of help with a Raspberry PI 4 GPIO Glass scales control loop
Need a bit of help with a Raspberry PI 4 GPIO Glass scales control loop
- PCW
- Offline
- Moderator
- Posts: 17950
- Thank you received: 4817
what do you want to do in velocity mode? Usually axes are in position mode and spindle in velocity mode.
If you close the position loop on LinuxCNC
(which is required if LinuxCNC is using the encoders
as a position feedback source) You must use velocity
mode on the step generators
Please Log in or Create an account to join the conversation.
- chris@cnc
- Offline
- Platinum Member
- Posts: 529
- Thank you received: 139
And what is now not right? Feedback seems working.
Please Log in or Create an account to join the conversation.
- yagias
- Offline
- Junior Member
- Posts: 21
- Thank you received: 0
@ Chris
Haaah . Not much.
At this point i seem to have feedback working with your help!
Now i “just” need to add the PID component in the loop.
But all the examples i’ve read so far are examples running in velocity mode.
If I’m reading the PID documentation right then command and feedback are in position units but the output is in velocity and i have little idea how to use that.
@ Aciera
Jup. Read that. Tried it out including doing “quite a few” configuration changes but i didn’t manage to get the basic configuration working.
Please Log in or Create an account to join the conversation.
- yagias
- Offline
- Junior Member
- Posts: 21
- Thank you received: 0
“I see you have the position command directly to stepgen. To engage feedback the position command has to go via the pid component so it can adjust for the position deviation.”
Please Log in or Create an account to join the conversation.
- PCW
- Offline
- Moderator
- Posts: 17950
- Thank you received: 4817
You can also work in position mode. I tried both and found the velocity mode worked better.
The other change needed is to set FF0=1 instead of FF1=1 for position mode if I remember right.
Yes, you can run in position mode but its quite sub-optimal as you are now depending on the Stepgen-maxvel
and stepgen-maxaccel to not make instantaneous steps in position, rather than making scaled velocity corrections
to meet the target position at the next servo thread incocation
Please Log in or Create an account to join the conversation.
- Aciera
- Offline
- Administrator
- Posts: 4006
- Thank you received: 1730
We're getting feedback but PID is not correcting the output.
It's somewhat difficult to help if you don't show your current hal file.
Have a look at Hakan's hal section and see how you could adjust that to your system. He's using a mesa card so the pin names are different but it should still give you an idea how connect the pins.
[edit]
Stepgen information:
linuxcnc.org/docs/html/man/man9/stepgen.9.html
Please Log in or Create an account to join the conversation.
- yagias
- Offline
- Junior Member
- Posts: 21
- Thank you received: 0
Latest attached HAL file is the current functioning configuration.
forum.linuxcnc.org/media/kunena/attachme...-2021-02-21-1149.hal
Yes. I'm looking at Hakans configuration file.
Have been pretty much since he posted
Please Log in or Create an account to join the conversation.
- Aciera
- Offline
- Administrator
- Posts: 4006
- Thank you received: 1730
Next you would look at how Hakan has connected his encoder pins to the pid pins.
Your pins are these:
linuxcnc.org/docs/html/man/man9/encoder.9.html
And his code is this:
net z-index-enable <=> pid.z.index-enable
net z-enable => pid.z.enable
net z-pos-cmd => pid.z.command
net z-vel-cmd => pid.z.command-deriv
net z-pos-fb => pid.z.feedback
net z-output => pid.z.output
# ---closedloop stepper signals---
net z-pos-cmd <= joint.2.motor-pos-cmd
net z-vel-cmd <= joint.2.vel-cmd
net z-output <= hm2_7i76e.0.stepgen.02.velocity-cmd
net z-pos-fb <= hm2_7i76e.0.encoder.02.position
net z-pos-fb => joint.2.motor-pos-fb
net z-enable <= joint.2.amp-enable-out
net z-enable => hm2_7i76e.0.stepgen.02.enable
net z-vel-fb <= hm2_7i76e.0.encoder.02.velocity
net z-vel-fb => pid.z.feedback-deriv
So start with one axis and replace the hm2...stepgen.. stuff and the hm2..encoder.. stuff with the corresponding stepgen and encoder in your config.
Give it a try and if you have a problem show us what you did and what is not working.
Please Log in or Create an account to join the conversation.
- yagias
- Offline
- Junior Member
- Posts: 21
- Thank you received: 0
I'll get back to you when i reach the next stage of enlightenment.
@ Aciera
"Well, after all the explanations so far the one thing I would have expected to see is your stepgens configured to velocity mode."
I can't help but interpret that as an assumption of lack of participation or effort from my side when i ask you for help.
What can i say.
There's a difference between reading documentation and comprehending.
Believe me... it's not a lack of effort or hours spent from my side.
Please Log in or Create an account to join the conversation.
- Mike_Eitel
- Offline
- Platinum Member
- Posts: 1125
- Thank you received: 184
On some place I even see decoder signals connected to debounce??
Have you ever run a simple config without glas scale? With pid for the steppers.
Then having glas scales included, showing more or less same values as commanded positions. So you know all fits together.
And than try to close the loop for one?
Mike
Please Log in or Create an account to join the conversation.
- LinuxCNC
- General LinuxCNC Questions
- Need a bit of help with a Raspberry PI 4 GPIO Glass scales control loop