Basic PLC question that challenges the best:

Kalabdel, I do agree with you that having access to the PLC code is a requirement, and that it should be written such that anyone with suitable expertise in the system being controlled can follow.

There was a similar thread a few weeks ago about this.

I think some members here who build specialist machines, or things which they make dozens or hundreds of each year believe that the HMI should provide all diagnostics. Yes maybe, if but there will always be some situation the original designer didn't think of. Or a hardware issue that needs resolving. For example i had to get another integrator in to change IO allocation for a flow switch on a little Siemens S7-300 because the input went bad. The HMI might have been able to show me the status, but i don't know many machine builders that let me programmatically swap IO. German machine, local agent here isn't a PLC guy, would have had to ship out something from the factory overseas, machine down for 6 weeks. Not an option. Now there's time to get a replacement card and restore everything to how it was.

And for a big facility with thousands of IO, having full diagnostics on each IO point via SCADA is something you only get at the DCS level. Access to the code is the poor mans DCS grade diags.

I think Steve Bailey was more taking a dig at the fact that it's very easy to criticize others when you're not in their shoes. Yeah I've seen some terrible code, but I've also had to write some pretty nasty stuff to get something up and running again, and then the client never fronts up with the money to fix it properly... now you come along and say "geez, look at this **** code that Saffa wrote!" Without knowing the context.

Not defending poor design and poor programming, but it's not always black and white who should get the blame for it...
 
The original problem wasn't that hard.
What language is best depends on what you are trying to do. Also, different manufacturers provide different debugging facilities.
For motion control we use a form of SFC or state machine and ST. For discrete digital control LD and FBD are fine.
We provide debugging tools that are superior to any PLC I have seen or seen posted on this forum.


Before I came to Delta I worked for a OEM that made projects that were too complicated for the average mill electrician to get into. All debugging was done using the HMI. It was more than sufficient since there were wait conditions for every step and time outs. If an error message appeared it was a mechanical or electrical problem.


I don't think I have seen near as much terrible code as terrible mechanical/hydraulic designs. I can remember one case there the programmer was way over his head and couldn't get the job done even with a trip to Delta to get help. Sometimes the trigonometry and motion planning is way too much. The forum can see how this could be after the recent thread about computing the formulas for a seven segment motion.
 
Here is the behavior coded in a language similar enough to ST that the ST version would be almost exactly the same.

@swedeleaner: educate me as to how this is somehow so much better that I should become a language bigot.

Code:
      logical function not a challenge(input_1,scan_ms)
      implicitnone
      logical input_1
      real scan_ms
      real accum_input_ms / 0.0 /
      real output_on_ms / -1.0 /
      integer accum_pulses / 0 /
      save
      if (input_1) then
        accum_input_ms = accum_input_ms + scan_ms
      else
        if (accum_input_ms.ge.40.0 .and. accum_input_ms.le.60.0) then
          accum_pulses = accum_pulses + 1
        endif
        accum_input_ms = 0.0
      endif
      if (accum_pulses.eq.4) then
        accum_pulses = 0
        output_on_ms = 75.0
      endif
      not a challenge = output_on_ms.ge.0.0
      if (not a challenge) output_on_ms = output_on_ms - scan_ms
      return
      end
And here is what it looks like in a Real Programmer™ language ;):
Code:
int not_a_challenge(int input_1, float scan_ms) {
int rtn;
static float accum_input_ms;
static float output_on_ms = -1.0;
static int accum_pulses;
  accum_input_ms += input_1 ? scan_ms : -accum_input_ms;
  accum_pulses += !input_1 && accum_input_ms >= 40.0 && accum_input_ms <= 60.0 ? 1 : 0;
  if (accum_pulses==4) {
    accum_pulses = 0;
    output_on_ms = 75.0;
  }
  rtn = output_on_ms >= 0.0;
  if (rtn) output_on_ms -= scan_ms;
  return rtn;
}
 
Last edited:
Here is the behavior coded in a language similar enough to ST that the ST version would be almost exactly the same.

@swedeleaner: educate me as to how this is somehow so much better that I should become a language bigot.

I think you already are a language bigot by defending the use of LAD. Sorry, not sorry pal.(y)

I for one use FBD for the most part, ST or IL for some operations and SFC when sequencing becomes crucial for getting things right.

I’ve never seen the need for LAD in any of my programing tasks, so you educate me. And that was my point earlier on, when is LAD superior...
 
I think you already are a language bigot by defending the use of LAD. Sorry, not sorry pal.(y)


I thought you posted that you were done trolling ;).

There is only one person (and it ain't me) posting on this thread with the claim that any one language is superior or inferior to another, and denigrating others for using it.

By any objective metric, all the languages are (assumed) Turing complete, so none are superior. That leaves subjective, and application- and site-specific, metrics, so declaring any language superior or inferior is declaring oneself normative, which is a natural human tendency, but also the height of ... well, many things, and finally something we should grow out of with wisdom.

To everyone else: I know, DNFTT.
 
Last edited:
I’ve never seen the need for LAD in any of my programing tasks, so you educate me. And that was my point earlier on, when is LAD superior...

I'll educate you... because the customer says so! That doesn't make it superior, nor inferior. Educate yourself on why ladder exists in the first place. That reason is still why it's used today. There is nothing wrong with using it, nor is there anything wrong with the language you choose. Go away!!
 
If you had read my posts you would have known I´ve already granted it a place in the hall of fame. I merely asked for when it´s favorable/superior to other languages in this (or previous) decade. But all you guys do is getting angry and scream "EVERYBODY WINS, stop being a dick, read up fool"
 
it's neither superior nor inferior, in this or any other decade. i really don't understand how one could say it is either.


What is this obsession with ladder logic anyway?

I get that IL translates well to LAD, but really can’t see the point of ladder in 2020?


Are you claiming that does not infer it is inferior now?
 
Last edited:
Mitsubishi made good compromise. There are four ways of making program:
1. Ladder with command "ST in Ladder", where you can "wrap" Structure Text in Ladder output box.
2. FBD/LD where you can mix both Ladder and Function Block Diagram in almost every way you like.
3. SFC, but with option to make transitions by directly connecting FBD/LD line output.
4. ST.
After using all that options I ended making almost all programs with FBD or ST. Before I was using extensively Ladder or ST.
If you write programs where maintenance are technicians write in LD.
If you write programs where maintenance are engineers write in FBD.
If you write programs where maintenance are IT guys write in ST.
There few situations where SFC is useful.
Never write in IL.
 
I thought you posted that you were done trolling ;).

There is only one person (and it ain't me) posting on this thread with the claim that any one language is superior or inferior to another, and denigrating others for using it.

By any objective metric, all the languages are (assumed) Turing complete, so none are superior. That leaves subjective, and application- and site-specific, metrics, so declaring any language superior or inferior is declaring oneself normative, which is a natural human tendency, but also the height of ... well, many things, and finally something we should grow out of with wisdom.

To everyone else: I know, DNFTT.

You posted a claimed comparable example of ST...with 50% more LOC than needed to get the logic across. And the troll is...?
 
You posted a claimed comparable example of ST...with 50% more LOC than needed to get the logic across. And the troll is...?

That was only ST-ish, feel free to post a better approach; the point is whether that is somehow superior to ladder. I would only claim it's basically the same.
 
If you had read my posts you would have known I´ve already granted it a place in the hall of fame. I merely asked for when it´s favorable/superior to other languages in this (or previous) decade. But all you guys do is getting angry and scream "EVERYBODY WINS, stop being a dick, read up fool"
I have better things to do than read your nonsense. I would love to see some of your work. I bet it is laughable. I could be wrong, but most people like you that bark high and mighty stuff usually churn out garbage.
 
That was only ST-ish, feel free to post a better approach; the point is whether that is somehow superior to ladder. I would only claim it's basically the same.

I’m more talking about all of the variable declarations and such at the top while the LAD was allowed to reference global variable registers.

Sure...it’s all equal for small/trivial examples. Everything is fast for small n too...

I’m not sure it helps to point out that they’re all Turing complete. There are plenty of esoteric languages that are Turing compete. Are you evaluating those for your next project? Or are those other “subjective” metrics more meaningful than you let on?
 

Similar Topics

What ladder logic is required to have an HMI button that gives output when you push it then removes that output when you push it again? For...
Replies
9
Views
3,804
I will apologize in advance for this question. In a PLC scan I understand the inputs are read, then the PLC carries out a scan out the logic and...
Replies
11
Views
4,091
:banghead: I am a newbie trying PSIM and am facing difficulty with a counter in the Batch program. I observe that there is significance in the...
Replies
2
Views
2,165
Hello Everyone, I am brand new to PLC's (learned they even existed 3 days ago) and have gone through the tutorial on this site. I am a little...
Replies
4
Views
5,203
Please,: Explain the meaning of Scan cycle in a PLC when it is running a program?
Replies
2
Views
3,199
Back
Top Bottom