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

More
5 years 8 months ago #199445 by yagias
Hello
This being my first post and the fact that I’m yet another newbie at Linuxcnc i do hope you’ll bear with me.
The scenario is as follows.
- Sieg X2 mini mill converted with ballscrews etc.
- Raspberry Pi 4 running direct using hal_pi_gpio
- 5 micron glass scales are mounted. (well one of them is)

I have the basic setup working e.g. X,Y,Z movement and i have the first glass scale encoder feeding back into Linuxcnc with correct scaling Encoder.0 . (as well as a rotary encoder controlling feed override in gmoccapy Encoder.1)

Now… I spent days trying to figure out how to implement the PID control loop between the X axis and the glass scale with no success. It may very well be me but as i said i cannot for the life of me figure it out and am in need of a bit of help.
If one of you experienced guys could point out to me what i need to add to hal and ini and what components to connect to what I’d be downright happy :) .
__________________________________________________________________________________
Having gone over quite a few forum posts regarding the raspberry pi I’ll go ahead and answer a couple of questions right away.
Yes I know it’ll be slow (step and encoder read speed). But it’s fast enough for my purposes.
This is a small not very rigid machine and reading the glass scales keeps up just fine at the maximum speed I’m ever going to run it at.

Yes I’m aware that this would likely be easier if I just bought a Mesa card.
So much so that i went ahead and bought one. I did however get caught up in this Raspberry thing where I’d really like to see it run without it. And i can’t help but feel i’m really close.

Best
/Yagias

File Attachment:

File Name: my-mill.ini
File Size:2.22 KB

File Attachment:

File Name: my-mill.hal
File Size:5.45 KB

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

More
5 years 8 months ago #199461 by Henk
Is the pi GPIO actually fast enough to count a glass scale, even at 5um? I have no idea, just wondering.

Anyway. I'm no expert on step and for setups but it seems that your Stepgens are currently running in position control mode. For closed loop with feedback from a linear scale you need the Stepgens set up in velocity control mode and the pid to do the position control.

Alternatively, you can just use the linear scale to monitor the position and signal if there are indications of lost steps...

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

More
5 years 8 months ago - 5 years 8 months ago #199463 by PCW

Henk wrote: Is the pi GPIO actually fast enough to count a glass scale, even at 5um? I have no idea, just wondering.

Anyway. I'm no expert on step and for setups but it seems that your Stepgens are currently running in position control mode. For closed loop with feedback from a linear scale you need the Stepgens set up in velocity control mode and the pid to do the position control.

Alternatively, you can just use the linear scale to monitor the position and signal if there are indications of lost steps...


Right, for closed loop step/dir with encoder feedback at a minimum you need:
Stepgens set into velocity mode
PIDs position command and position feedback connected to motion and encoder positions respectively
PID output connected to stepgen velocity command
Last edit: 5 years 8 months ago by PCW.

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

More
5 years 8 months ago - 5 years 8 months ago #199464 by yagias
Hi Henrik

Thank you for you’r reply.

I was in doubt as I’ve read posts stating exactly what you’re saying about having to run velocity mode in order to “close the loop” but on the other hand i also read a post from Andy where he suggest to run it in position mode.

Personally i have no idea so i’ll go with whatever works even if that means changing everything 

Regarding counting speed. At this point I’ve had it up to 1,2 Meters a minute which if my math is right equates to 8 Khz without losing counts and i won’t be running anything near that when cutting anyways so for the purpose it’s perfectly fine.

(On a side note the driver implementation of the hal_pi_gpio seems to be the biggest issue. From what I’ve found the raw read capability is actually quite high. 8Khz OS default but in the Mhz. range if a bit of hacking is involved.)
Last edit: 5 years 8 months ago by yagias.

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

More
5 years 8 months ago #199465 by yagias
Thank’s PCW

Seems I’ll be changing to velocity before I’ll be doing anything else :)
I’ll get back to you.

BTW: What a fabulous forum! Near instant feedback.
Thank you both.

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

More
5 years 8 months ago #199549 by yagias
So… The frustrations are rising on my end.

Spent yet another day with nothing to show for it. And to make matters worse my vacation is coming to an end.

Now apologize if i break a forum rule that i’m unaware of but here goes.

In the interest of moving forwards i’m wondering if anyone here will take on the task of producing a working closed loop X axis with the PID section and feedback from the encoder from the configuration files i attached earlier? (Yes I’ll do the testing and the PID tuning on my end)

I’ll pay you a hundred USD over Paypal if we get this working.
(Not subject to resulting accuracy or speed)

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

Time to create page: 0.297 seconds
Powered by Kunena Forum