PID process simulator for Studio/Logix 5000?

rupej

Member
Join Date
Sep 2014
Location
NC
Posts
964
Does anyone know of any sample code for an analog process simulator? I'm looking to test out some PID tuning methods but would rather have the PLC simulate the feedback rather than waste the customer's product for my experiments. ;)


Thanks a bunch!
 
Just curious. Are there any Arduino or Raspberry PI boards with good analog inputs and outputs? Digital outputs would work too for simulating SCR on/off control



I think it would be better to have an external device that the PLC can control.


I can write a small python script to simulate a SOPDT system easily since I already have that part done.


The advantage this would have is that would work for any PLC.
 
You guys are not helping much with finding a CHEAP hardware solution.
I would like to find a cheap hardware solution with good 16 bit ADC and 16 bit DAC.

The reason I am interested in this is because one of my guys bought a cheap board but the ADC and DAC were too noise and didn't have enough resolution to be useful. This person ended up using one of our motion controllers.
Many years ago I did a gotomeeting about temperature control but only two people showed up. I used our motion controller because I can simulated a SOPDT, do the closed loop temperature control and graph it all in real time.
 
When I need to test something, I will use a PLC in the other end as well.

My suggestion is to find a used PLC and write a program that will match your needs.

There are so many bennifit in having your own test rig :)
 
That is irrelevant

He wasn’t talking to you.
Smart a$$.
You should be listening.

If everyone wants to re-invent the wheel the go ahead. There are raspberry pi boards with python. The raspberry pi board will become obsolete but the python code won't. I also wouldn't want to waste my time writing code that works for just a few pieces of hardware.
Long ago I wrote a temperature simulator to simulate Ron Beaufort's "hot rod" system. That was back in 2004. It is in the downloads/misc section
It was OK for back then but it should be deleted now as the SLC500 and ML1500 are obsolete. PLC hardware becomes obsolete. So does the ladder that was used.
 
Why not simulate in the PLC ?
I do that for all my PLC programs, and I find it handy to have everything in one software package instead of having to juggle multiple softwares let alone hardware.

I do realise that I dont simulate the hardware, and I therefore dont catch an addressing error, but it is a trivial problem that is immediately identified at the mandatory I/O test.
Some colleagues of mine are using Siemens Simit hardware, they have to have a guy maintain the simulation code alone.
 
Does anyone know of any sample code for an analog process simulator? I'm looking to test out some PID tuning methods but would rather have the PLC simulate the feedback rather than waste the customer's product for my experiments. ;)


Thanks a bunch!




For the OP (rupej)


What process are you trying to simulate in the PLC?


My brother did this, but the simulation was a simple time exponential e.g.


PV = oldCV*(1-k) + newCV*k + noise



where k was in the range (0:1) e.g. 0.8.


Not very realistic of course, but it demonstrated what was needed i.e. that enabling a deadband in the PID reduced noise and provided better control when there is noise in the PV signal. I can dig it up and post it if the OP (rupej) is interested.

Another PLC-based simulation is here, but I have no idea why I wrote that.


For PeterN requesting hardware


I remember seeing a YouTube of a system that was a force balance: a fan applying force to a paddle by blowing on it vs. gravity applied to the paddle on its shaft: the balance determined the angle of the paddles shaft; the angle was the PV; the fan speed was the CV.
 
PV = oldCV*(1-k) + newCV*k + noise
Yes, what are you trying to simulate?
That has only one time constant or pole which is simulated by k.
There is no dead time, no bias, no system or open loop gain.
What about time?



This is how it is done

Code:
def difeq(t, y, k, t0, t1, c, dt):
    """ generate estimated SOPDT solution
        y[0] = process value
        y[1] = rate of change of the process value"""
    _u = control_interp.interp(t-dt)    # offset CO for dead time
    _dy2dt = (-(t0+t1)*y[1]-y[0]+k*_u+c)/(t0*t1)    # SOPDT dif Eq
    return np.array([y[1], _dy2dt])     # return PV' and PV''

This simulates a SOPDT system.
k is the open loop gain or degrees/% control output

t0 and t1 are time constants to make the simulation second order.
c is the bias or ambient temperature in this case. When the control output goes to 0 the temperature goes down to ambient temperature, not zero.
dt is the dead time.
_dy2dt needs to be integrated to get the next process variable or temperature.


This function would need to be modified depending on the type of system that is being simulated but it is easy to do in python.



@Jesper, I gave a list of reasons why not do it in the PLC. I can add more reasons.
It is easier to modify the simulator.
The hardware is cheaper than a PLC. I am thinking of using a Raspberry Pi that cost less than $200 with 16bit DACs and ADCs.
The simulation can run much faster with control over time.
 
Yes, what are you trying to simulate?
That has only one time constant or pole which is simulated by k.
There is no dead time, no bias, no system or open loop gain.
What about time?



This is how it is done ...


Yes, I know how it is done, but my PLC does not use Python.



I said it was a simple time exponential, which you repeated using different terms. That describes many processes adequately (IFF the fidelity requirements are loose enough). I did not provide details because they would be left as an exercise for the OP. Of course time is important, but again the details are part of the implementation: it may be accurate enough to assume constant average scan time and use exp(ln(0.8/1000)) to get 80% movement per 1s for a 1ms mean scan time, but that would probably not work with a 32-bit float. And of course calculating random noise is brings its own cargo of problems. But it's all solvable.
 
I think I have found an 8 GB Raspberry PI 4 and an analog board that will cost around 100. Obviously this doesn't cover the cost of a keyboard and monitor but most of us have that stuff laying around.



What OS would you run this on?
Raspberry PIs normally run a Raspberry PI version of linux.
https://realpython.com/python-raspberry-pi/
https://www.circuitbasics.com/how-to-write-and-run-a-python-program-on-the-raspberry-pi/


raspberry PI 16 bit ADC DAC


https://www.walmart.com/ip/Raspberr...5_10000006727&wl14=raspberry pi 4 8gb&veh=sem
 

Similar Topics

Hi all, I'm working on a wastewater plant with oxidation ditch aerators. The aerators are on VFDs and the operators want the dissolved oxygen in...
Replies
45
Views
17,411
Hi, Have problem with getting PID to work. Have been using 4x different programmers on siemens, not one could make PID to work as I want. Problem...
Replies
6
Views
1,717
I am currently trying to implement a process control of the temperature of water going down a drain after it has gone through 2 radiators. I have...
Replies
6
Views
1,937
I'm not really experienced with PID so I need some help. I have a 300l insulated pasteurizer with heat exchanger on the inner side wall and the...
Replies
6
Views
2,697
Hi, I have a basic query about how PLC handles out of range process parameter. I have a control valve which is modulated to maintain its...
Replies
4
Views
2,047
Back
Top Bottom