Novice Questions

This thread is to discuss basic questions for the novice user.

I’ll start with:

In the power up chart, for each chart a start chart command is required. What are the advantages or disadvantages of going through the start chart commands once or continuing to loop through the commands? I’ve noticed that when the start chart is scanned once the status bits go back to not running. Whereas when looped through the status variable indicates the charts are running…

Thanks,

Andy

A powerup chart looping through “startchart” commands will have no effect if the chart is already running and will waste system resources. This may actually cause you some problems if any of your charts are suspended or stopped on purpose by your strategy.

As for the status bits, only cycling thru the powerup chart once should have no effect on the status bits for other charts. If the chart is running, the status bit will indicate that. If your status bits are showing not running when only cycling through the powerup chart once, then perhaps your other charts do not have loops and are only running once? I think that is what you are saying is happening? But not entirely sure.

It is also possible you are not seeing the status bits change because the chart you have started has not gotten a time slice yet and hasn’t had an opportunity to start. If you were to add even a very brief delay to your startup chart before you check the status bits, you would likely find they indicate that the chart(s) have started, having gotten timeslice(s) when you made the delay call.

I checked the status bit that you define when you program a start chart command and if I go through the power up chart once all status’ show 0; if I loop the power up chart all status’ indicate -5. In debug mode you can see all the charts are running. Plus the program works. I’ll try the delay in the power up chart will show the status and see if that works. I also could try a ischartrunning? command indicates the charts are running.

Thanks for the replies,

Andy

StartChart Status Codes:

0 = success
-5 = failure

Andy, if you need to worry about the Status Code of StartChart or CallChart, that is a symptom of something wrong in the logic.

There are 2 types of charts:

  1. Those that do some operations and then finish
  2. Those that, after doing the operations, start over and never finish (let me call them [I]“cyclic”[/I]).

The cyclic charts need (and must) only be started once. They will keep running for ever. On the other hand, the first ones, the non-cyclic charts, will need to be called (or started) over and over.

When planning a strategy you usually divide the whole problem into independent tasks. One task will be dedicated to scan I/O, other task will control alarms, other will communicate with some external program or device …
For each of these tasks, you just need to build a cyclic chart (which will eventually call some other simpler non-cyclic charts).

The job of the Powerup chart limits then to start the cyclic charts (i.e. the independent tasks). Therefore Powerup should not be cyclic.

This is a sample OptoScript code of a typical Powerup chart in my projects (paradoxically I rarely use OptoScript in Powerup)


CallChart(Initialization); // this one is not cyclic but I want it to be finished before starting anything else.
StartChart(Task1);
StartChart(Task2);
StartChart(Task3);
 

This way you have your logic cleanly divided and almost self-explained by the code. Also you can always tell whether your strategy has finished the start-up process (as soon as Powerup goes to stopped status).

Hi All,

Thank you for the replies. I’m not having and trouble with my program, rather I didn’t understand how the chart status bit functions.

If I understand now, when I cycle or loop through the power up charts I receive a -5 as the charts are already running and can’t be “started”. Is that how you all see it?

I don’t use chart status in my program, I just wanted to understand how it functions in case I ever wanted to use it.

Thanks,

Andy

Hi Andy,

Thanks for starting this excellent thread! Good questions & answers. I am adding this topic, which I’ll call: “Flowchart Flow” to my list of topics we could cover better with our various training tools.

To answer your question about the -5: yes, you would get that error coming back if you tried to start a chart that was already running. For example, if you tried to start the Powerup chart from within the Powerup chart, you’d get a -5 for the status code returned.

There’s one important point I’d like to emphasize, especially given the mention above “cyclic charts”: in these charts that loop, ALWAYS add a Delay command. We talk about this in the training classes here at Opto 22 in Temecula, and Ben always puts this in his examples and reminds people any chance he can get. It may just be the most important concept for the “novice” strategy developer.

At first, this idea of adding a delay to make your strategy run faster overall, might seem counter-intuitive. Someone else mentioned, earlier in this discussion, the concept of a “time slice” and other charts getting a chance to run. Keep in mind that there’s only one CPU in your PAC, so all these charts that run “at once” are sharing the CPU’s time.

To use an analogy of a mom driving some kids somewhere–the chart with no delay is like the kid in the back seat asking: “Are we there yet? Are we there yet?” over and over. You want him to maybe ask you every 20 minutes max. Likewise, in your strategy, if you have looping/cyclical chart that perhaps checks: “Is it too hot yet?” over and over, faster than makes sense, then the CPU doesn’t have as much time to do all the other things it should be doing and can appear slow or sluggish overall.

Meanwhile, the mom (or dad) driving has a PID running in their head to keep their speed below the limit, where the “Input” is the current speed, “Output” is foot on gas, and the PID “algorithm” might be…??? Maybe I took this analogy too far. :slight_smile:

In any case, keep those good questions and answers coming!

Speaking of Novice Questions, and learning… I’d like to ask all of you:
[INDENT]1) What were some of the must[B] difficult concepts [/B]you came across while learning about and how to use Opto 22 products?

  1. What kinds of [B]learning tools [/B]do you prefer? (Videos, animated demos, sample code, discussions like this, free Product Support, white papers, in-person classes?)

  2. What [B]topics [/B]would you like to see more learning tools address (videos, etc.)?
    [/INDENT]Thanks and write on!
    -Mary

Hi Mary,

Thanks for the explanation. I don’t use time delays in my charts. I haven’t noticed any real problems yet, but will start using delays due to the excellent explanation.

I use PID loops to run large kilns. They have large response delays that require derivative tuning. Through trial and error at 4 am with a deadline looming, I was able to get a PID to work. I still don’t know why I should use one type of PID over another. I guess that might be the most difficult thing I’ve run into, even though I was able to get a working controller(s).

An online video “PID for Non-Physicists” might be good.

I was also wondering if there is any way to put the tuning window into my PAC Display. I love the way it functions as opposed to the historian. I’m able to review my firings in real time scrolling and zooming with ease. This requires that I open and leave running PAC Control every time I run the kiln. The new control will be going to someone less familiar with the ways of a PAC controller. So I thought it would be great to integrate the Loop View window into the PAC Display.

Any ideas?

Andy


Hi Andy
If you have the latest version of PAC Display there is an object button in the toolbox that will allow you to ‘insert’ a PID loop tuning object into your HMI. it will allow for auto/man control, PID tuning and setting of scan rates, FF values etc… It is very similar to the PID viewer in PAC Control. The only thing i don’t believe it does is the scrolling (and zooming?) of the x/y axis.
On the topic of pid loops (this could be another thread altogether) are the values there anything like what you ended up with for your tuning? I ask because we have had a lot of trouble tuning our heating/cooling systems with the new PAC system, same issue with slow response times. Generally with HVAC a PI tuning solution is enough ‘maths’ to keep a loop controlled. We are finding that we are ending up with tiny PI values as opposed to the figures we are used to using mistic PID loops (i understand the algorithms are different) and are not real happy with the response. just wondering what values you had and how your control responds. i agree with your video concept, maybe a video on HVAC (or slow response) tuning??

Nick

Hi Nick & Andy,

Thanks again for the good questions and answers, and suggestions for content! Nick’s right, the topic of PIDs could be a whole other thread, and you’ve certainly gotten far beyond “novice” on this one.

However, in case you haven’t seen these two PID videos, you might want to check these out:

Kelly’s short (approx 6 minutes) intro video
Ben’s archived webinar (almost 1 hour) on PIDs

I’m guessing Nick & Andy are familiar with the basics Kelly introduces in that first video. In the second video, Ben gets into detail about the different algorithms and some real-world experience thrown in. I’d be interested in hearing your thoughts on those.

Thanks & write on!
Mary

p.s.

In Kelly’s PID Loop video, she mentions the Learning Center PID OptoTutorial which may also be of interest. The pdf that goes with it includes many of the concepts Ben talks about during his PID Loop webinar. Even if you don’t have a Learning Center, the doc might be good if you’re looking for something to read next time you’re up awake at 4am! Form 1641

Hi Mary
Thanks heaps for the links to the video’s. I will check them both out.

Nick

Hi Nick,

Thanks for the hint on the PID Loop tuning object. I couldn’t find it in my Pac Display 9.0F. Are you using Pro?
I’m running a 4’ x 8’ kiln, ~40 KW. There is a lag time from the peak power input, to the peak temperature response of 3 minutes. That’s how I ended up with a 360 seconds of derivative. (I guess seconds are the units for D) Why it is negative I don’t know. I figured it out by trial and error. I did notice that the help files describe the different algorithms. Velocity B is like Mistic it says. I have no experience with Opto22 PID’s other than the kiln. The kiln’s insulting values change dramatically with temperature so I change tuning parameters with Script at various temperatures. I do get a swing at those changes but put them where they won’t affect product. Maybe one of the other algorithms would work better? The gain numbers are smaller than I would expect, but then what do I know. The kiln controls great with very little overshoot and good quarter wave dampening. Here are one set of parameters:

SetPidGain(Heat_PID_Top, -0.05);
SetPidTuneDerivative(Heat_PID_Top, -360);
SetPidTuneIntegral(Heat_PID_Top, 1);

Mary,

Thanks for the links to the videos. I’ll watch them.

Andy

Hi Andy,

On the PID’s (I too wonder if we should not move this into its own forum topic), I’m not sure if you ever get the chance to tune the kiln without product being in it… but, with such a long dead loop time (the time between when you change the output and when you see a change in temperature (the input)) you really need to look at your scan rate.

The scan rate time is how often the PID formula is done. The default is once a second. In your case, this would be far too quick. What will be happening is that the PID formula will be getting ‘wound up’ expecting to see a change in temerature each time it does the math. In your case, it will not happen for 180 times (that’s once a second for three minutes), then after the calculation runs for about 180 times, it finally sees a little creep on the input.

You never mention what your scan loop time is set at, but its a really really important parameter. Its just as important as P, I and D as it sets how often those parameters get a say in the output.

If you can, you need to do a ‘step function response’. That is, set up a trend (or two or three with different time spans so you can be sure to catch this (Note, this is really easy to do in PAC Control debug because you can have a few of the graphical tuners open for the same PID loop, each set to a different time span). Then, set the output to a steady state. Once the temperature settles, move the output ~40% and watch the temperature change and wait for it to steady.
The time between when you changed the output and when the input began to change, that’s your dead loop time. You can then set your scan rate to be around 2-3 times faster than this.

As for setting different PID values depending on where you are in your process, that’s fine. Its a typical procedure for the exact situation you mention. I have used it myself a few times where I used to work (a hospital).

As for the different algorithms, don’t worry about changing it. They are there simply as a convenience for users coming from other systems. They all do the PID function. Its not like one loop type is for temperature, another for flow another for pressure and you have to select the right type. That’s not it at all. We just put a range in for those users are used to tuning and using a given formula.
My advice is stick to the one you are using, you are getting to know it. We only ever used the one loop type at the hospital and we had hundreds and hundreds of loops all controlling vastly different processes.

Keep the questions coming, its a great thread for old and new users alike.

Ben.

Hi Andy,

Re:

An online video “PID for Non-Physicists” might be good.

Just in case you haven’t seen these two videos on PIDs, here’s a link to Kelly showing how it’s done in PAC Control: [B]PAC Control PID intro[/B]

and here’s an archived webinar w/Ben that gets into more detail. Sometimes our webinars are tricky to find on the website, so I hope you’ll check out other recordings on this page too: [B]Ben’s PID Webinar[/B]

Hope that helps!
-OptoMary

Hi Mary,

Good job on the video.

Thanks,

Andy

One other PID tool I’m not sure I mentioned before is our “PID Tutorial” which is a very helpful document, but you can also download the otg file to experiment on your own–designed for the [URL=“http://www.opto22.com/site/pr_details.aspx?cid=1&item=SNAP-PACLC”]SNAP PAC Learning Center but could be used w/a SNAP-PAC-R1 too.

For more info on PIDs, all in one handy place: click here.

Hi Everyone,

My program generates alarms from calculations and analog inputs. I’ve worked out a way in OptoScript to have a set point, wait for a time delay, then set and latch the alarm. The alarm is cleared when the value goes below set point [U][B]and [/B][/U]an acknowledge button from the OptoDisplay alarm manager is poked. In ladder logic this is fairly straight forward. However, I’m not a programmer and although I have it working, I feel like I’m using a sledgehammer to create the code. Note that I also used the sledgehammer on my forehead while developing the code as well!

I would like to know how other people would handle the problem. Maybe with only a ball-peen hammer.

Thanks in advance.

Andy