Programming Question

@Parky, thanks a lot for your observation. I think sending the same setpoint again to the Arduino will give same result, and will therefore not mitigate the error. So there will have to be adjustment of the setpoint by the PLC in other to compensate for the error.

@drbitboy @parky do you think there's a way for me to make the PLC act as a deadband without PID logic in the PLC?




Yes.


But I would still go with PID as it is is straightforward and easy to code. Easier in e.g. Structured Text, perhaps, but not overly difficult with adds, subtracts, multiplies and divides in ladder. Using a CV-incrementing algorithm and clamping the output will automatically provide anti-windup reset.

I may have an example someplace that my brother wrote, including deadband, if you are interested.
 
@drbitboy, thanks for sharing the document; I'm trying to figure out the logic. However, I noticed that it employs PID for the PLC. I'd appreciate it if you could show me another way to use ladder logic that isn't based on PID.

But here's a thought: what do you think about having logic in the PLC that allows you to manually joggle the motor clockwise or anticlockwise?
 
@drbitboy, thanks for sharing the document; I'm trying to figure out the logic. However, I noticed that it employs PID for the PLC. I'd appreciate it if you could show me another way to use ladder logic that isn't based on PID.


It does not employ a PID instruction, it is not based on a PID instruction.


It implements the PID algorithm to minimize the error between the measured flow value and the setpoint flow value, which would be an effective way to assign a value to the valve position passed to the Arduino for this process.
 
It's common requirement to be able to do that via HMI, or Panel mounted controls or even through code if the process so requires.


Of course it's possible and common, I wasn't saying it was not.

But the only function OP has mentioned for PLC is telling Arduino motor (valve) position setpoint, and it sounded like this was an alternative control scheme. So unless this is a class assignment, why bother with the PLC if the only task is to jog motor (valve) position?
 
Of course it's possible and common, I wasn't saying it was not.

But the only function OP has mentioned for PLC is telling Arduino motor (valve) position setpoint, and it sounded like this was an alternative control scheme. So unless this is a class assignment, why bother with the PLC if the only task is to jog motor (valve) position?
I will think of an excuse why I misunderstood that and will be right back :D
 
I think you mis-understand the function of a PID, it's primary functions is to reach it's set point as quickly as possible without much overshoot (some like it without any), maintain that set-point, if there is a disturbance then it will react to correct it to maintain the control as close as possible to the set-point. The PID is not working correctly if it cannot reach the required value, the reasons are the PID algorithm is not doing it's job, the controlling components i.e. motor/valve or what ever is not capable of reaching set-point.
here is a scenario, You give the PID a set-point of 100, it reaches 94, in practice the PID will ramp up the output to 100%, if it fails to reach 100 then your hardware is not up to the job, for example a pump driven by an inverter is set for 0-60hz and your PID output gives 0-10v the inverter is set to 0-60hz for the 0-10v you require a flow of 100 galls per minute, the PID will ramp to 100% but can only achieve 94, therefore increasing the set-point will not do anything. I strongly suggest you look at the motor / PID as there must be something wrong. First of all, it appears you are simulating this well at least as far as HMI etc. have you actually got a physical motor and flow/speed with feedback ?.

Here is the manual for using the PID instructions:
https://dl.mitsubishielectric.com/dl/fa/document/manual/plc/sh080040/sh080040s.pdf

These are the functions
PID control data setting S(P).PIDINIT PIDINIT(P)
PID operation S(P).PIDCONT PIDCONT(P)
PID control status monitor  PID57(P)
Specified loop No. operation stop S(P).PIDSTOP PIDSTOP(P)
Specified loop No. operation start S(P).PIDRUN PIDRUN(P)
Specified loop No. parameter change S(P).PIDPRMW PIDPRMW(P)
Note: the PID function uses something like 30 + memory areas i.e. "D" words & "M" bits, not all need to be set only initially to set up the modes & parameters.
This is quite complex & not for the faint hearted.
 
It seems you are determined to do something that is not practical, so here is some logic that will do the following:
If the operator changes the set point but it is not equal to or greater than the original set point +- 5% then it will not change, it will also put the HMI set point variable back to the original.
how it works.
If the HMI set point is changed it is compared with the last valid change & if > or < the last set point it then calculates the original set points with a plus or minus 5%, then compares the new set point with those limits & if equal to or greater it copies the new set point to the last (the last set point is the one you send to the PID), if not it copies the last set point back to the HMI set point so it reverts back to it's original (this makes sense or your original would be lost).
No idea how you are sending the set point to the PID but I have included a bit that is set on a successful change that resets after a time, you could do what ever you need to here.
See code attached.
Caveats: Initially, the last set point will be 0 probably as would the HMI set point, so it will need an initial change to set it up, also, if for some reason you do actually need a smaller change than 5% then you would have to set the set point outside the 5% first then back so for example if the set point was at 100.0 and you really wanted 102.5, then it will not change but setting it to 105.1 or 94.5 then back to 102.5 it will change.
 
Thanks for you reply @drbitboy.

The system is to control the flow through a motorized valve, and there will be a feedback for the motor position, and the flow rate. The feedback is to both the PLC and the Arduino, the Arduino uses the feedback to calculate the CV using the PID algorithm. While the PLC basically supervises the whole system, getting the setpoint from the HMI, sends it to the Arduino, does the comparing of the feedback to the set point, and if its within tolerable range the PLC updates the status via indicator on the HMI(green), and if not the PLC resend the setpoint to the Arduino and also updates the HMI indicator(red).

I believe I can do more with the PLC, and I am open to suggestions on how to improve its functionality.

This is my second project using PLC, and I might not be accurate with my use of words or expression. Kindly permit me, and suggest the best way to go with it. Thanks.

^^we figured this out, but thanks for confirming.
Nothing personal here, but, whenever I hear Arduino, my first question is: What did your professors tell you was so differentially wonderful and operational positive about an Arduino, versus integrating whatever you're trying to do, in the PLC to begin with (as others have gravitated towards here).
No doubt, if you want a wireless interface to a USB stick, the A. is a good method.
But, in this example; PID; the PLC already does that.
...
OK, if at this point, the A. will be the answer, perhaps a bit of future-casting is in order. What happens 10 years from now, when the thing needs to be modified? The original designer and programmer will be long gone, and the developement environment that made the A. what it was will be impossible to replicate. MEANWHILE, in PLC-land, the PLC is still sold as a unit, the software remains supported, and anyone with systems-level knowledge can hop on and figure it out.
...
No flames, please....just asking for a friend.
:)
 

Similar Topics

I'm been deciphering a program for a press here. I've gotten most of it deciphered using the manual to understand the instructions (first mitsu...
Replies
11
Views
274
Hello. Was just curious, if it is possible to load an image from an SD card on to a Compactlogix PLC that came straight out of the box brand new...
Replies
4
Views
539
Hi All, Looking for advice on programming MicroLogix 1400 with RSLogix500. Basically, I have a client who requested I make a "simple" program...
Replies
19
Views
3,199
How do you code it to when you push a button attached to X001, it turns on Y001. Then, the next time you push the button attached to X001 it...
Replies
4
Views
1,606
I am just finishing up my project, which was my first experience with PLCs. I thank everyone that has helped me work through the RIO and analog...
Replies
11
Views
2,964
Back
Top Bottom