You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

Reply
 
Thread Tools Display Modes
Old November 14th, 2020, 11:04 PM   #1
rupej
Member
United States

rupej is offline
 
Join Date: Sep 2014
Location: NC
Posts: 815
PID process simulator for Studio/Logix 5000?

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!
  Reply With Quote
Old November 15th, 2020, 12:31 AM   #2
Peter Nachtwey
Member
United States

Peter Nachtwey is offline
 
Peter Nachtwey's Avatar
 
Join Date: Apr 2002
Location: Vancouver, WA, US
Posts: 7,259
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.
__________________
"Living is easy with eyes closed, misunderstanding all you see...." Strawberry Fields Forever, John Lennon
  Reply With Quote
Old November 15th, 2020, 06:06 PM   #3
Peter Nachtwey
Member
United States

Peter Nachtwey is offline
 
Peter Nachtwey's Avatar
 
Join Date: Apr 2002
Location: Vancouver, WA, US
Posts: 7,259
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.
__________________
"Living is easy with eyes closed, misunderstanding all you see...." Strawberry Fields Forever, John Lennon
  Reply With Quote
Old November 15th, 2020, 07:08 PM   #4
drbitboy
Lifetime Supporting Member
United States

drbitboy is offline
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 1,626
https://github.com/drbitboy/pressure...a_fan_velocity


That contains a simulator written using AdvancedHMI. It is not analog but it is an example of simulating an analog process; the PLC will not know the difference.
  Reply With Quote
Old November 15th, 2020, 10:08 PM   #5
Peter Nachtwey
Member
United States

Peter Nachtwey is offline
 
Peter Nachtwey's Avatar
 
Join Date: Apr 2002
Location: Vancouver, WA, US
Posts: 7,259
Quote:
Originally Posted by drbitboy View Post
https://github.com/drbitboy/pressure...a_fan_velocity


That contains a simulator written using AdvancedHMI. It is not analog but it is an example of simulating an analog process; the PLC will not know the difference.

I want the hardware. The software is trivial.

I have simulators for integrating, non integrating, single pole, two pole, two complex poles and more.


The AdvancedHMI software is just software.
__________________
"Living is easy with eyes closed, misunderstanding all you see...." Strawberry Fields Forever, John Lennon
  Reply With Quote
Old November 15th, 2020, 10:09 PM   #6
_Dock_
Member
United States

_Dock_ is offline
 
Join Date: Sep 2015
Location: KY
Posts: 351
Quote:
Originally Posted by Peter Nachtwey View Post
I want the hardware. The software is trivial.

I have simulators for integrating, non integrating, single pole, two pole, two complex poles and more.


The AdvancedHMI software is just software.
He wasn’t talking to you.
  Reply With Quote
Old November 15th, 2020, 11:20 PM   #7
Holmux
Lifetime Supporting Member
Denmark

Holmux is offline
 
Join Date: Oct 2013
Location: Aalborg
Posts: 218
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
  Reply With Quote
Old November 16th, 2020, 03:54 AM   #8
Peter Nachtwey
Member
United States

Peter Nachtwey is offline
 
Peter Nachtwey's Avatar
 
Join Date: Apr 2002
Location: Vancouver, WA, US
Posts: 7,259
That is irrelevant

Quote:
Originally Posted by _Dock_ View Post
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.
__________________
"Living is easy with eyes closed, misunderstanding all you see...." Strawberry Fields Forever, John Lennon
  Reply With Quote
Old November 16th, 2020, 04:12 AM   #9
JesperMP
Lifetime Supporting Member + Moderator
Denmark

JesperMP is offline
 
JesperMP's Avatar
 
Join Date: Feb 2003
Location: Copenhagen.
Posts: 14,484
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.
__________________
Jesper
See my profile interests for Q&A
  Reply With Quote
Old November 16th, 2020, 11:02 AM   #10
drbitboy
Lifetime Supporting Member
United States

drbitboy is offline
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 1,626
Quote:
Originally Posted by rupej View Post
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.
  Reply With Quote
Old November 16th, 2020, 11:47 AM   #11
Peter Nachtwey
Member
United States

Peter Nachtwey is offline
 
Peter Nachtwey's Avatar
 
Join Date: Apr 2002
Location: Vancouver, WA, US
Posts: 7,259
Quote:
Originally Posted by drbitboy View Post
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.
__________________
"Living is easy with eyes closed, misunderstanding all you see...." Strawberry Fields Forever, John Lennon
  Reply With Quote
Old November 16th, 2020, 12:08 PM   #12
drbitboy
Lifetime Supporting Member
United States

drbitboy is offline
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 1,626
Quote:
Originally Posted by Peter Nachtwey View Post
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.
  Reply With Quote
Old November 16th, 2020, 12:27 PM   #13
cardosocea
Member
United Kingdom

cardosocea is offline
 
Join Date: Nov 2016
Location: Fields of corn
Posts: 1,695
Quote:
Originally Posted by Peter Nachtwey View Post
I am thinking of using a Raspberry Pi that cost less than $200 with 16bit DACs and ADCs.
What OS would you run this on?
  Reply With Quote
Old November 16th, 2020, 01:38 PM   #14
geniusintraining
Lifetime Supporting Member + Moderator
United States

geniusintraining is offline
 
geniusintraining's Avatar
 
Join Date: Jun 2005
Location: SC
Posts: 7,253
Quote:
Originally Posted by Peter Nachtwey View Post
I want the hardware.
May be not what you are looking for Peter but I make and sell a PID trainer

https://www.plccable.com/miniature-m...al-derivative/ and Tim made a series of videos with it https://www.youtube.com/watch?v=8Yv-aBEZFrc
__________________
www.PLCCable.com PLC Communication Cables, PLC Trainers, MicroLogix, ControlLogix, Siemens, Allen Bradley and more...OEM and aftermarket supplies... Aftermarket 1784-U2DHP Allen Bradley USB to DH+, new USB to 485 modbus
  Reply With Quote
Old November 16th, 2020, 03:18 PM   #15
Peter Nachtwey
Member
United States

Peter Nachtwey is offline
 
Peter Nachtwey's Avatar
 
Join Date: Apr 2002
Location: Vancouver, WA, US
Posts: 7,259
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.



Quote:
Originally Posted by cardosocea View Post
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...-raspberry-pi/


raspberry PI 16 bit ADC DAC


https://www.walmart.com/ip/Raspberry...%208gb&veh=sem
__________________
"Living is easy with eyes closed, misunderstanding all you see...." Strawberry Fields Forever, John Lennon
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
PID Control Action Mode in RSLOGIX 5000 plcnovel LIVE PLC Questions And Answers 16 November 6th, 2020 01:22 AM
Quick comparison of PID, PIDE, and PI instructions in RSLogix5000 ... Ron Beaufort LIVE PLC Questions And Answers 14 June 7th, 2018 02:24 PM
Pid rslogix 5000 industrial 951 LIVE PLC Questions And Answers 6 July 10th, 2014 10:48 AM
Wierd Issue with PID on Compact Lgx 5000 vgiesbrecht LIVE PLC Questions And Answers 3 March 23rd, 2008 07:33 PM
RSLogix 5000 V15 Features Samneggs LIVE PLC Questions And Answers 18 April 20th, 2006 06:45 PM


All times are GMT -5. The time now is 08:32 AM.


.