Understanding the Device Simulator Functions

Hi all,

I'm attempting to understand the OPC UA device simulator a little more as I want to simulate a basic device (a limit switch), only, having read through the description of each Function, and, the available Parameters, I'm struggling to understand what each of the Parameters mean for the 'realistic' function.

In my defense, I'm pretty new to the world of OPC/Logic controllers, and, reading through the explanations for each of the associated parameters seems to suggest that they were written with a degree of assumed knowledge.

Being a resourceful type however, I attempted to load up the Generic Device Simulator, which, according to this post here (ok, ok, yeah, it's a 7.9 article...I just can't find the 8.1 equivalent) should contain some examples of it's implementation.

The problem I have with this though is that it suggests the simulator should be representing the Function with the following timings and parameters:

If implemented according to this schema, I assume that this would have given me a fantastic opportunity to better understand this for myself.

However, when I loaded up the simulator, and, proceeded to edit the program, I was presented with the following parameter settings:

I'm not sure I can connect what the article is suggesting with these settings.

Am I correct in thinking that this isn't how it should be configured based upon the settings illustrated in the article, or, am I misunderstanding something here?

Can someone maybe assist me with a more verbose explanation behind each of the parameters used with this function, and, maybe, update the 8.1.x Ignition User Manual website with this information too?

I mean, I suppose i could search the Interwebz for an explanation. However, I couldn't ever be sure that what the internet suggests could be the meaning would tie up exactly with how Inductive Automation have realised/implemented this within Ignition...it being somewhat of its own ecosystem after all.

Many thanks in advance for anything anyone can provide!

The old simulators were deprecated (for a variety of reasons) and their functional purpose absorbed into the new "programmable device simulator"; if you choose a specific program for the new sim it acts in a slightly special way to simulate the legacy devices; I would recommend not doing that if you're just trying to explore things for learning purposes.

The new simulator is documented here:

1 Like

Hi PGriffith,

Thanks, however, I'm aware of this link.

My problem is that having read it, as explained, I'm still at a loss as to how the Realistic Function works.

As I explained, the description of its Properties is not at all sufficient for me to get a good read on what it's actually doing.

That is when I broke out the included Device sims to see if I could potentially better understanding how what was documented for the Generic sim was being realised within the simulator available to me in 8.1.

Although I'm still uncertain as to why I shouldn't use them, my thought was that at least it would allow me to work out what I was missing from the descriptions assigned to each of the properties for the realistic function.

In fact, the lack of understanding with regards to the description is what is preventing me from going deeper into the programmable aspect of the simulator myself.

Is there a chance someone has the knowledge to expand on a simple read-back of the word used to as a the place holder for the function's property:

I'm sure that these words mean something to some, however, I do not have the baseline knowledge and therefore do not understand. Also, I have no understanding of the three letter acronym PID other than, say, maybe, process ID. However, how such a thing would relate back to the function placeholder name, I haven't a clue.

Many thanks once again.

"PID" is "Proportional-Integral-Derivative", an extremely common feedback control strategy in real world process applications. Google it.

2 Likes

When you first start looking into process control you'll run into two different types of control loops, Open Loops and Closed Loops. The difference is that Closed loops take "part" of the measure the output and feed it back into the loop, this is known as "feedback".

In PID this feedback term is used to calculate the error. The two other terms you need to know to get a general understanding of PID are the "Set Point" (target) and the "Process Value or Variable" (actual). The error is the difference in these two. So you end up with a control loop that looks something like this:

For instance you might have a Pressure control valve (the controller) controlling the pressure in a tank (the system), and there is a Pressure transmitter (Measuring element) on the tank which is reading the pressure (Process Value).

So, the sum of the error and the set point is fed into the controller which drives the system, the process value is then measured and fed back into the system. This happens continuously until a steady state is reached.

There is some complicated math that goes on, but generally this interaction is mashed together into what is called the systems "Transfer Function", and what we are really interested in is at the beginning of this loop in the "comparator".

Essentially what the PID is attempting to answer is this question:
"Given a set point what output should I send to the controller to move the process value to the set point?". The controller here can be many different things from a Pressure control valve to a VFD.

The most basic equation for a PID looks something like this:

Output = Kp * e(t) + Ki * Σe(t) + Kd * Δe(t) / Δt

So the Proportional Gain (Kp) is how much the instantaneous error is accounted for in the output. In other words, the output is directly proportional to the error. The goal being that the error is driven to zero.

The Integral Gain (Ki) is how much the sum of the error over time (the integral) is accounted for in the output. So over time the output will increase (or decrease) according to the integral gain in order to drive the sum of the error to zero.

The Derivative Gain (Kd is how much the rate of change of the error (the derivative) is accounted for in the output. So over time the output will increase (or decrease) according to the derivative gain in order to drive the rate of change of the error to zero.

There are reasons that these gains are used or not in different scenarios. For instance the derivative term tends to make the system susceptible to noise and so is often avoided. When a particular gain is not used then it is standard to drop that letter from the acronym so you might see things like: PI controller, Proportional Controller, PD Controller.

It's a very large topic with a whole bunch of applications, but if you're going to venturing into the world of control systems it's one that you will want to get versed in.

3 Likes

<pedant mode="true">

No, closed loops measure the process to use in the math to produce an error signal, which allows the controller to adjust for varying conditions. The measurement is the feedback. The setpoint must use the same units and scaling for the math to work.

Open loops simply compute an output, via some model of the process, from the setpoint (no error signal) and blindly assume it works. No feedback at all.

Closed loops may also use a model in the controller for better performance.

</pedant>

5 Likes

Yeah, I was trying to keep it “simple” and got in my own way.

Thanks

ahaa, being a newbie to electro-mechanical (or other non electro-mechanical) process design/analysis this was not at all immediately obvious.

Cheers for the heads up, I will now endeavour to read up on the subject.

1 Like

Although I sorta kinda followed, this, I had to run it through a GPT to translate somewhat.

A good example it came up with was a cruise control system for a car.

It would monitor the final speed to understand how short it is of the target speed. The further away the higher the correction factor would be.

It would at the same time keep a record of the number of speed readings taken along with how far away (plus or minus) the reading currently is, and therefore the distance from the set point (i.e. zero error) it is since the point it was engaged to understand the overall situation and the correction factor which should be applied as a result to smooth out any potential for a jumpy response.

Again at the same time, the system works out the number and size of changes being applied (the rate of change) and works out whether it may be applying too much of a or too many change(s), or, on the flip side, whether it's applying too few.

All these factors combine to even out the rate and amount of change to hopefully result in smooth/optimal transitions as the system 'fights' to maintain an equilibrium (i.e. the target speed).

So, that all said, how is the simulation working if the factors are set and we're not supplying a real life value stream (feedback loop of the speed of an actual car, pressure reading on an actual valve etc.etc.) into the function?

That's a too optimistic idea of what a controller does.

A PID controller applies three simple factors to produce a control output:

  • Error × Proportional factor. Set throttle linearly based on speed error. No memory of past action.

  • (Time summation of Error) × Integral factor. Ramp throttle based on speed error. This is the primary memory of past action.

  • (Changes in Error) × Derivative factor. Bump the throttle up or down to handle relatively sudden speed changes. This is a tweak to avoid overshooting, using memory of past measurement, not memory of actions.

FWIW, my engineering education devoted an entire semester course to "Feedback Control Systems". Don't be discouraged if it doesn't "click" immediately. It is worth noting that PID control is an attempt to mimic what humans naturally do with eye-hand coordination when manually controlling some physical process. Or in the case of a car, eye-foot control of the throttle pedal.

3 Likes

Don't make the mistake of thinking the device simulator is Serious Software.

It was a cheeky under-spec'd hack that somebody whipped up because training needed more ways to have OPC values that change in various ways during their classes.

4 Likes

oh yeah, i get it...I just wanted to better understand what it is this particular function is actually doing...something that, although thanks to the responses here I'm starting to get more of a handle on (although, the more I read the more i realise I'm still very much in the tundra towards to the base of the foothills), it still isn't exactly clear to me what it is doing.

So, we appear to have values for the desired outcome and the control rate to temper the over/undershoots, but, I'm still somewhat at a loss as to how it generates the numbers representing the 'result' or output.

I see that typically for example, the set point is 100 by default, yet, when we fire up a test device and watch what it's outputting, I see values of 140+ appearing.

Given that, its difficult to understand what exactly the logic is driving the output of the function.

It is not just running the math for the PID algorithm, but pretending to be a real process controlled by such and algorithm, with random noise and disruptions. Because it is a simulator.

1 Like

Yep, quite literally just random noise is added while updating.

                double noise = random.nextGaussian() * 0.8; // gaussian distribution with standard deviation of 0.8

                currentValue = currentValue + update + noise;

                if (random.nextDouble() < changeTargetProbability) {
                    // gaussian distribution with standard deviation of 50
                    setValue(new DataValue(new Variant(currentValue + (random.nextGaussian() * 50))));
                } else {
                    setValue(new DataValue(new Variant(currentValue)));
                }
2 Likes