Need a bit of help with a Raspberry PI 4 GPIO Glass scales control loop

More
21 Feb 2021 14:21 #199616 by PCW

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
The following user(s) said Thank You: chris@cnc

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

More
21 Feb 2021 14:44 #199619 by chris@cnc
Okay understood,
And what is now not right? Feedback seems working.

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

More
21 Feb 2021 14:47 #199621 by yagias
LOL. I've been writing responses but you guys are a lot faster than i am.

@ 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.

More
21 Feb 2021 14:49 #199622 by yagias
We're getting feedback but PID is not correcting the output. And according to Hakan.
“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.

More
21 Feb 2021 15:05 #199623 by PCW

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.

More
21 Feb 2021 15:19 - 21 Feb 2021 15:21 #199624 by Aciera

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
Last edit: 21 Feb 2021 15:21 by Aciera.

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

More
21 Feb 2021 15:24 #199625 by yagias
@ Aciera
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.

More
21 Feb 2021 15:52 #199629 by Aciera
Well, after all the explanations so far the one thing I would have expected to see is your stepgens configured to velocity mode.

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.

More
21 Feb 2021 16:13 #199634 by yagias
Thank you for your effort guys. You especially Chris!
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.

More
21 Feb 2021 17:05 #199638 by Mike_Eitel
Sorry to chime in as I do, but I think your hal is very mixed up. And I do not understand it....
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.

Time to create page: 0.111 seconds
Powered by Kunena Forum