LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Multi-axis PID Loop

Solved!
Go to solution

Hey y'all, I was wondering if there was a way to make multiple PID loops without using the Array method in the PID VI.  My issue is that I have 2 axes that I thought I'd try to control with a PID loop.  I was going to take turns, first moving the X axis, then I'd use a different loop for the y axis.  However, I don't think it'll work with the array, as both axes use the same processing parameter and setpoint, and since it's only actually moving/correcting 1 axes half the time, I feel like the Integral will get polluted with bad data, or at the very least data that wasn't actually directly changed.  So is there any way to make 2 completely separate PID loops that don't need to be run at the same time, since each axis will have a different affect on the processing parameter?  Just for completeness, the processing parameter is the difference between 4 diodes that are equidistant from each other, and it's trying to center the light between all 4 of them

0 Kudos
Message 1 of 11
(1,281 Views)

Hi Ethan,

 


@EthanHenry wrote:

So is there any way to make 2 completely separate PID loops that don't need to be run at the same time, since each axis will have a different affect on the processing parameter?


Yes.

Just implement it as described: two completely separate PID loops…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 11
(1,275 Views)

But the PID VI uses shift registers. I'd like to be able to just use the already built PID VI, but if that's not possible I guess I could always write my own.  Just didn't want to have to reinvent the wheel if at all possible

0 Kudos
Message 3 of 11
(1,270 Views)

actually, now that I'm thinking about it, I don't think that's the best way to go about it, as if they both share the same processing parameter and setpoint, then I'm just going to have 2 loops that are the exact same, which isn't what I want.  Instead, I could make each loops processing parameter the difference of 2 diodes + difference of the other 2 diodes.  The groups of these diodes would be the 2 that change when that axis moved.  then I'll have 2 different loops each trying to correct and, hopefully, drive all the differences to 0

0 Kudos
Message 4 of 11
(1,258 Views)
Solution
Accepted by topic author EthanHenry

Hi Ethan,

 


@EthanHenry wrote:

But the PID VI uses shift registers. I'd like to be able to just use the already built PID VI, but if that's not possible I guess I could always write my own. Just didn't want to have to reinvent the wheel if at all possible


Each PID will have it's own internal shift registers - but what's the matter when you place them in their own independent loops???

 


@EthanHenry wrote:

as if they both share the same processing parameter and setpoint, then I'm just going to have 2 loops that are the exact same, which isn't what I want.  Instead, I could make each loops processing parameter the difference of 2 diodes + difference of the other 2 diodes.  The groups of these diodes would be the 2 that change when that axis moved.  then I'll have 2 different loops each trying to correct and, hopefully, drive all the differences to 0


How can you drive two independent motors, moving independent axes, using the very same set of setpoints and process values???

 

Each axis should have their own set of process value, motor (driver) and PID gains…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 11
(1,243 Views)

The shipping PID VI is configured as preallocated clone reentrant execution. According to Differences Between Reentrant, Template, and Dynamic VIs

If the Preallocated clone reentrant execution option is selected, each caller is given its own private data space (and clone). If there are 20 calls to the VI, 20 clones will be created and added to the pool when the calling VI begins.

 

-------------------------------------------------------
Control Lead | Intelline Inc
Message 6 of 11
(1,241 Views)

"How can you drive two independent motors, moving independent axes, using the very same set of setpoints and process values???" That was kind of my question haha.  I haven't set it up, but I'm having some difficulties figuring out how to make it work, or even if a PID loop will work for this kind of problem.  The problem for me, at least now, is what to make the 2 separate processing parameters, and it probably has to do with which diodes change when an axis is moved

 

"Each PID will have it's own internal shift registers - but what's the matter when you place them in their own independent loops???" Whoops, sems I had a bit of a brain fart about preallocated reentrant clones.  If I don't use the same processing parameters, which is obvious now, than using the same loop should be fine.  I think I was going about PID loops all wrong, thinking of them as something I had to take a more active part in.  Thanks,  I'll see what I can do!

0 Kudos
Message 7 of 11
(1,236 Views)

ah a bit of a brain fart, whoops.  I'm too used to passing around objects or identifiers, forgot about the shift register single iteration for loop method.  Thanks!

0 Kudos
Message 8 of 11
(1,234 Views)

Hi Ethan,

 


@EthanHenry wrote:

I'm too used to passing around objects or identifiers, forgot about the shift register single iteration for loop method. 


Where does that "single iteration FOR loop" apply here?

(Unless you talk about the inner implementation of the PID functions…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 11
(1,094 Views)

Yeah that’s what I was talking about, the VI uses a for loop with a single iteration and shift registers to store data

0 Kudos
Message 10 of 11
(1,091 Views)