Programming Question

THIMMY01

Member
Join Date
Aug 2021
Location
Huddersfield
Posts
37
I'm currently working on a project in which I'm using a PLC as a supervisory system to monitor an Arduino uno that's controlling a process with a PID algorithm. I'm looking for advice on how to construct the ladder logic. I completed the conversion from integer to floating-point, as well as the supervisory part of determining whether the feedback is within the tolerance range of the feedback. Can you tell me what to tell the PLC if the condition is met or not? Also, how can I make the PLC programming more robust by requiring meaningful actions to be performed?
 
More information is needed, for example what PLC manufacturer, how is the Arduino talking to the PLC is it coms or via an analogue what do you mean by condition met is it set point or what. The more information you give us will mean receiving replies that will help you, what you have asked is like saying how long is a piece of string.
 
No idea why you are using an Arduino, why not the PLC doing it all, or why not do the compare in the Arduino & just send the bits/words to the PLC, what is the PLC going to do with this information, is it just an alarm how do you display this information on what.
 
I agree with @parky and others: please describe the process in more detail: overall process description (level/temperature/pressure/whatever controls, safety aspects, etc.); what are the inputs; what are the outputs; what changes in the inputs should cause what changes in the outputs.
 
So I'm using the Mitsubishi Q series, with gx works 2 and ladder logic. I'm using Arduino to gain hands-on experience with how the PLC interacts with the Arduino. For the HMI interface, the project will be simulated on the PLC using GT designer. The set point will be provided by the HMI between 0 and 144, and the PLC will convert the feedback and compare it to the setpoint. If the feedback is within +/-5 percent of the setpoint tolerance, the motor remains in the same position; otherwise, the PLC resends the setpoint to the Arduino to adjust the motor as needed.

I am open to suggestions for additional features to make the process more robust, such as the use of a light beacon.
 
So I'm using the Mitsubishi Q series, with gx works 2 and ladder logic. I'm using Arduino to gain hands-on experience with how the PLC interacts with the Arduino. For the HMI interface, the project will be simulated on the PLC using GT designer. The set point will be provided by the HMI between 0 and 144, and the PLC will convert the feedback and compare it to the setpoint. If the feedback is within +/-5 percent of the setpoint tolerance, the motor remains in the same position; otherwise, the PLC resends the setpoint to the Arduino to adjust the motor as needed.

I am open to suggestions for additional features to make the process more robust, such as the use of a light beacon.

Thank you.


Please allow me to restate that back to you, slightly re-ordered, how I hear it:

  • The HMI provides a setpoint value, between 0 and 144, to the PLC from HMI
    • I assume this is initiated by a human
  • The PLC reads a feedback value
    • I assume the value is read from the Arduino
    • I assume the Arduino calculates the value based on the most recent setpoint previously sent to the Arduino
      • The Arduino implements a PID, and where the process is I am not sure
        • although it sounds like something is being simulated on the PLC
          • so perhaps the "feedback" value is actually the PID's CV, i.e. output, value from the Arduino,
          • which begs the question, how does the PV get to the PID on the Arduino?
  • The PLC converts the feedback value
    • I assume to the same offset and units as the HMI-provided setpoint value.
    • I suppose there could also be other processing e.g. moving average or median filtering.
  • The PLC compares the converted feedback value to the HMI-provided setpoint value
    • If the converted feedback value is within 5% of the HMI-provided setpoint value, do nothing
      • You actually wrote "within 5% of the setpoint tolerance"
        • I assume that was a typo and the 5% is tolerance, but please correct that assumption if needed; perhaps you "within 5% of range of the setpoint" i.e. within setpoint value ± 7.2.
    • If the converted feedback value is not within 5% of the HMI-provided setpoint value, send the HMI-provided setpoint value to the Arduino
If all or most of those assumptions are correct, and my simulation/PLC/Arduino/PID confusion can be resolved, then the PLC is acting as a kind of deadband front-end to the PID.

- drbitboy, DMD (added that signature for @PN ;))
 
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.
 
  • What does the CV output of the Arduino's PID control?
    • I would assume it is somehow controlling the motor position and/or valve position (e.g. 0% is valve closed, 100% is valve fully opened).
  • What is the nature of the setpoint value provided to the PLC by the HMI?
    • I would assume it is the desired flow rate.
  • What is the nature of the setpoint value provided to the Arduino by the PLC?
    • I would assume it is the desired motor (valve) position.
  • Which element compares the flow feedback to the flow setpoint?
    • I would assume it is the PLC
  • Which element compares the motor (valve) position feedback to the motor (valve) position setpoint?
    • I would assume it is the Arduino
All of those assumptions are to suggest that

  1. the PLC performs deadband control, i.e. minimizes the difference (error), between the measured flow feedback and the flow setpoint, by sending a motor (valve) position setpoint to the Arduino, and
  2. the Arduino PID is a valve positioner, which minimizes the error between the measured motor (valve) position feedback (PV) and the motor (valve) position setpoint, by changing its CV that is sent to the motor/servo/motor-positioning-system.
Am I close yet?

- drbitboy, DMD
 
Last edited:
You have a PID in the Arduino, why not send the set point A PID is made for that job, how do you know what set point to send to the Arduino, so for example you have a set point on the HMI, this say is 150, the feedback from the Arduino is 130 what do you send to the Arduino ? this will upset the PID as it should be controlling it's output to the motor ?. You sending a newer set point of say 140 will then tell the PID to increase it's output quite dramatically, this probably means your PID is not working correctly does not seem right to me or am I reading your post wrong.
 
@drbitboy, You are accurate with your interpretation. That's exactly how the system should be. Any hint on how the ladder logic should be? And what suggestions or advice can you give to make a better project?

I'm not sure I understand what you mean @parky, but the setpoint is given through the HMI, to the PLC and then to the Arduino. The Arduino does the output calculation (CV) to adjust the motor as needed, then the feedback is given to both the Arduino and the PLC.

Before the setpoint can be changed, the system should not be on a run mode.
 
Quote : So I'm using the Mitsubishi Q series, with gx works 2 and ladder logic. I'm using Arduino to gain hands-on experience with how the PLC interacts with the Arduino. For the HMI interface, the project will be simulated on the PLC using GT designer. The set point will be provided by the HMI between 0 and 144, and the PLC will convert the feedback and compare it to the setpoint. If the feedback is within +/-5 percent of the setpoint tolerance, the motor remains in the same position; otherwise, the PLC resends the setpoint to the Arduino to adjust the motor as needed.

Quote: I'm not sure I understand what you mean @parky, but the setpoint is given through the HMI, to the PLC and then to the Arduino. The Arduino does the output calculation (CV) to adjust the motor as needed, then the feedback is given to both the Arduino and the PLC.

Your descriptions do not make sense
On one hand you are saying if it is out of spec by 5% the PLC re-sends the setpoint surely The Arduino already has it, unless you are changing the set point ?

Again the above statement is that it already has sent the SP & the Arduino adjusts the CV to control the motor, why would you re-send the set point unless you change the set point for example set point is 130 this is sent to the Arduino, set point is changed by operator say 140 but the PLC only sends this set-point if it is outside of the original SP by 5%.
If this is what you mean then I get what you mean but what is the point of not changing if within 5 % of the last set point ? perhaps to stop the operator tweaking the set point for some reason.
So if this is what you want you need to do an on change bit of logic
so assume you start from scratch then you compare two registers with the current set point with the last set point if greater or less than the last set point + or - 5% then send it, if not do not send, the problems are:
At first go assume that the PLC has the set point and the last stored was zero then it sends the set point and then copies the set point into the last, fine however, then the HMI will display the updated set point but this is not what it is running at and will only change if a new set point is input that is greater or less than the original plus or minus 5%.
You could update the HMI back to the original, here it gets messy.
Perhaps if my assumption is right then you explain it a lot beter exactly what you are trying to acheive.
 
@drbitboy, You are accurate with your interpretation. That's exactly how the system should be. Any hint on how the ladder logic should be? And what suggestions or advice can you give to make a better project?

I'm not sure I understand what you mean @parky, but the setpoint is given through the HMI, to the PLC and then to the Arduino. The Arduino does the output calculation (CV) to adjust the motor as needed, then the feedback is given to both the Arduino and the PLC.

Before the setpoint can be changed, the system should not be on a run mode.




Does the PLC have a PID instruction? Does that PID instruction include a deadband for error (PV-SP or SP-PV)?


If the PLC has a PID instruction with a deadband, then the ladder logic is essentially one rung long; the rest will handle the communication with the uno and any start/stop/run/etc. logic.

If the PLC does not have a PID instruction, then I would build one in ladder; it's not very complex.
 
@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?
 

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
286
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
545
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,214
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,611
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,967
Back
Top Bottom