News:

  • August 20, 2026, 10:16:23 AM

Login with username, password and session length

Author Topic: PID Wholesale Parameter Copying  (Read 45540 times)

Mike Nash

  • Hero Member
  • *****
  • Posts: 652
PID Wholesale Parameter Copying
« on: October 20, 2017, 10:34:02 AM »
Is there a simple, quick way to initially copy PID_01's element values to PID_02 thru PID-40?

MEMCOPY would require 39 instances which is not simple or quick.
COPY doesn't want to allow me to do just the elements I want 39 times.
Memory View doesn't allow the structures at all.

I realize this is not something I would want to do normally as the loops will most likely not tune the same. But initially, I thought it would be a reasonable starting point.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3843
    • Host Engineering
Re: PID Wholesale Parameter Copying
« Reply #1 on: October 20, 2017, 10:41:46 AM »
Rather than create the PIDs as heap-items, make a block of 40 PIDs (say MyPID).

Now you have MyPID0..MyPID39.

Then just do
FOR V0 1 to 40
MEMCOPY MyPID0 to MyPID[V0]
NEXT

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3843
    • Host Engineering
Re: PID Wholesale Parameter Copying
« Reply #2 on: October 20, 2017, 10:43:52 AM »
And use Nicknames on your MyPID elements for good "tag" names  ;)

Tie ChillerXYZ nickname to MyPID5, HeaterABC to MyPID39
then just use

ChillerXYZ.PV

HeaterABC.SP

in your instructions, data views, etc.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3843
    • Host Engineering
Re: PID Wholesale Parameter Copying
« Reply #3 on: October 20, 2017, 10:45:24 AM »
Or use the new COPY instruction, which could have 39 rows of heap-item copies.

Mike Nash

  • Hero Member
  • *****
  • Posts: 652
Re: PID Wholesale Parameter Copying
« Reply #4 on: October 20, 2017, 10:53:41 AM »
Thanks!

I had convinced myself I couldn't do the PIDs as an array structure  :-[ without actually checking.

I also don't know that I will want to keep the names as PID_01, etc., which is why I didn't look last night. And of course you answered this also as I was typing!

The problem for me with the COPY, was all that typing in could be done just as well in the PID elements themselves. I was just trying to stuff values initially to get a starting point.

At this stage, I was more wondering what the impact was going to be on scan time for so many loops. I am seeing about 5-6 mS adder for all 40. (This H2 already has code in it I have been playing with so the 40 add'l PIDs took the scan from 1.7 to 7 mS.

To be fair, I have been programming AB stuff the last couple weeks and the transition back and forth at times confuses me. (Like, what really happens in AB land when I keep hitting F8 to accept?)

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3843
    • Host Engineering
Re: PID Wholesale Parameter Copying
« Reply #5 on: October 20, 2017, 10:57:51 AM »
At this stage, I was more wondering what the impact was going to be on scan time for so many loops. I am seeing about 5-6 mS adder for all 40. (This H2 already has code in it I have been playing with so the 40 add'l PIDs took the scan from 1.7 to 7 mS.

You realize with Do-more you have COMPLETE CONTROL of that if you stick the FOR/NEXT loop in a TASK and use the task's .TimeSlice field (MICROseconds) to adjust the "bump" per scan.  Just use the task's .Done bit to know when it gets done (might take 2, 3, 4 scans).

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3626
  • Darth Ladder
Re: PID Wholesale Parameter Copying
« Reply #6 on: October 20, 2017, 11:22:23 AM »
No, I think he's talking about the scam tine impact of actually running 40 loops.  Even so, if they're process loops, time slicing should still be fine (or even a 7ms scan time).
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3843
    • Host Engineering
Re: PID Wholesale Parameter Copying
« Reply #7 on: October 20, 2017, 11:27:38 AM »
No, I think he's talking about the scam tine impact of actually running 40 loops.  Even so, if they're process loops, time slicing should still be fine (or even a 7ms scan time).

Oops.  My bad.

PID is a time-based instruction, so it needs to run every scan (so it can track time).  Hence, trying to utilize yielding would NOT work as desired.  :-\

Mike Nash

  • Hero Member
  • *****
  • Posts: 652
Re: PID Wholesale Parameter Copying
« Reply #8 on: October 20, 2017, 11:49:52 AM »
On the yielding, yes I have used that feature previously.

Yes on the PID "loops" impact being reasonable. Hopefully I won't need 40, but over 30 for sure.

And I did stick a PID in a TASK just to see if it would work. It didn't mind (no warnings) as long as the ENTASK was continuous at 0 mS. I get warnings with the other choices. I'm going to just put them in a Program.

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3626
  • Darth Ladder
Re: PID Wholesale Parameter Copying
« Reply #9 on: October 20, 2017, 11:55:58 AM »
That whole timing by totalling scan times still seems weird to me.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6172
  • Yes Pinky, Do-more will control the world!
Re: PID Wholesale Parameter Copying
« Reply #10 on: October 20, 2017, 12:04:48 PM »
That whole timing by totalling scan times still seems weird to me.

There's a reason it's called an "accumulator".
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3626
  • Darth Ladder
Re: PID Wholesale Parameter Copying
« Reply #11 on: October 20, 2017, 05:28:39 PM »
PID is a time-based instruction, so it needs to run every scan (so it can track time).  Hence, trying to utilize yielding would NOT work as desired.  :-\

I think the best way to write a PID, and what I do when I write one, is to have it be aware of its time base, whether as an input parameter, or by automagically checking the elapsed time since the previous execution.  Proportional doesn't care anyway, but integral and derivative can then just use that time in their calcs.  Then, if you have an application for which evaluating the PID every 30 seconds is often enough, knock yourself out.  You're not required to scan it 100000 times more often than required by the process.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6172
  • Yes Pinky, Do-more will control the world!
Re: PID Wholesale Parameter Copying
« Reply #12 on: October 20, 2017, 06:29:51 PM »
That's exactly how it runs internally. It needs to run every scan to check time, just like you are proposing.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3626
  • Darth Ladder
Re: PID Wholesale Parameter Copying
« Reply #13 on: October 20, 2017, 06:33:19 PM »
That's not what I meant to suggest, but OK.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6172
  • Yes Pinky, Do-more will control the world!
Re: PID Wholesale Parameter Copying
« Reply #14 on: October 20, 2017, 06:39:24 PM »
You said to evaluate the loop at an interval that fit the application. How are you planning to specify that internal and test whether it has passed? A timer and a comparison. That is exactly what the SampleTime parameter is and exactly what happens internally.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO