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.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


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

PLC training tools sale

Reply
 
Thread Tools Display Modes
Old April 17th, 2017, 09:17 PM   #16
MitsM83
Member
United States

MitsM83 is offline
 
MitsM83's Avatar
 
Join Date: Jan 2017
Location: Indianapolis
Posts: 64
ST or Ladder?

We got a machine a while back that is mainly ST. I go to that area to help recover her when she breaks down. Maintenance over there hates ST and will probably string up the engineer if they ever find him! Actually just heard they are quoting having it rewritten.

And trust me, when they can not figure something out or open it and cant tell WTF they are looking at...Its the wingineer who is stupid not them! haha.

Oh and in my opinion for next loops and program control have their place. Not in every stinkin program you write but they do have their place.
__________________
01001000 01101111 01101110 01100100 01100001

Last edited by MitsM83; April 17th, 2017 at 09:21 PM.
  Reply With Quote
Old April 17th, 2017, 09:39 PM   #17
Paully's5.0
Lifetime Supporting Member
United States

Paully's5.0 is offline
 
Join Date: Jan 2006
Location: WI
Posts: 1,865
Quote:
Originally Posted by Phrog30 View Post
If I want to create a loop in ladder I will use a jmp/lbl. So, let me guess, looping is bad practice?
The argument will be made that using a jmp/lbl combo which results in jumping backwards in logic using isn't desirable. I know there have been discussions about that topic on the forum. I don't use jmp/lbl enough to make a good argument one way or another. Jumping to skip a bunch of logic that doesn't need to be processed is understandable. Personally if I'm doing any looping in ladder it's with a for loop instruction and a dedicated sub-routine simply for clarity.

It's not too often I use any loops in logic, especially with AOIs. If I do require a loop, then I am defaulting to ST code because I'm probably manipulating data rather than looping through "control" logic.

I do see loops used for device control which is a dated technique given the rise of AOIs.
__________________
"Comments should be like a mini-skirt... long enough to cover the essentials but short enough to keep your interest." - Uptown47
  Reply With Quote
Old April 17th, 2017, 10:00 PM   #18
Peter Nachtwey
Member
United States

Peter Nachtwey is offline
 
Peter Nachtwey's Avatar
 
Join Date: Apr 2002
Location: Vancouver, WA, US
Posts: 6,469
Quote:
Originally Posted by SoftwareJanitor View Post
So just for the fun of it, I re-wrote a couple of ladder programs here in "C" just to see what they'd look like, and it turned out to be a thousand IF statements with some embedded PIDs and Timers (an oddball-looking program, I'd say).
Boolean math doesn't require IF THEN ELSE

C:=A AND B;

IF THEN is only required if there is a need to do more than just change a coil.

The advantage of ladder is that you can see visually what is active and what isn't.
__________________
"Living is easy with eyes closed, misunderstanding all you see...." Strawberry Fields Forever, John Lennon
  Reply With Quote
Old April 18th, 2017, 01:19 AM   #19
Epy
Lifetime Supporting Member
United States

Epy is offline
 
Epy's Avatar
 
Join Date: Jul 2012
Location: Allen-Bradley Valley
Posts: 284
Quote:
Originally Posted by Phrog30 View Post
Not that you will care, but not much I agree with in your post. So using lbl/jmp is not good practice? That's ridiculous. Intentionally making a program complicated to prevent tinkering is even more stupid. You don't want tinkering, try a password.
Didn't say that lbl/jmp was bad practice, or to make a program more complicated. Strawman much?

Setup your arrays so that the last item is the newest. Then a single COP can shift the array. Elegant and efficient.

Use the best tool for the job. If you can make something cleaner in ST that others won't understand, too bad for them. I'm not going to write inefficient code for the sake of others. That's what comments are for, to explain how you did something. If someone can't understand, then they don't belong doing what they're doing.
__________________
Quote:
Originally Posted by ganutenator View Post
customers:
I don't know how to do it so it must be easy
  Reply With Quote
Old April 18th, 2017, 08:07 AM   #20
Phrog30
Member
United States

Phrog30 is offline
 
Join Date: Dec 2006
Location: Montgomery, Alabama
Posts: 257
Quote:
Originally Posted by Epy View Post
Didn't say that lbl/jmp was bad practice, or to make a program more complicated. Strawman much?

Setup your arrays so that the last item is the newest. Then a single COP can shift the array. Elegant and efficient.

Use the best tool for the job. If you can make something cleaner in ST that others won't understand, too bad for them. I'm not going to write inefficient code for the sake of others. That's what comments are for, to explain how you did something. If someone can't understand, then they don't belong doing what they're doing.
Oh, so you didn't say, "You don't want to make it easy for people to tinker in your program in the first place." I guess that means different things.
  Reply With Quote
Old April 18th, 2017, 08:10 AM   #21
Phrog30
Member
United States

Phrog30 is offline
 
Join Date: Dec 2006
Location: Montgomery, Alabama
Posts: 257
Quote:
Originally Posted by Paully's5.0 View Post
The argument will be made that using a jmp/lbl combo which results in jumping backwards in logic using isn't desirable. I know there have been discussions about that topic on the forum. I don't use jmp/lbl enough to make a good argument one way or another. Jumping to skip a bunch of logic that doesn't need to be processed is understandable. Personally if I'm doing any looping in ladder it's with a for loop instruction and a dedicated sub-routine simply for clarity.

It's not too often I use any loops in logic, especially with AOIs. If I do require a loop, then I am defaulting to ST code because I'm probably manipulating data rather than looping through "control" logic.

I do see loops used for device control which is a dated technique given the rise of AOIs.
I guess I should have indicated that my question about loops was rhetorical. Asking about best practice in this forum and you will get 100 responses, all different... the majority of which are not correct, or realistic. Thanks for the response though.
  Reply With Quote
Old April 18th, 2017, 08:11 AM   #22
proof
Member
United States

proof is offline
 
Join Date: Jan 2014
Location: Illinois
Posts: 113
Quote:
Originally Posted by SoftwareJanitor View Post
With this upcoming project, since I am really a "C"/"C++" programmer and *not* a PLC/Ladder programmer, I would like to use Structured Text for my logic.
You have just made another big assumption, but unfortunately incorrect assumption. The format of the instructions, Ladder, structure text, function blocks, and etc, are not different languages, but are different ways of displaying the same logic. Some may have some instructions (like PIDE) that are not available the other formats, but this is not important for this discussion.

** Changing to a format that looks like "C" does not change the PLC into a "C" type operation. **

The thought process for programming a PLC is more like writing code for AWK or sed than C. Broadly generalizing, In C programs the logic typically executes 'once through', with some sections repeating with loops. In PLC code ALL of the logic is re-run continuously. In C programs, the logic performs a calculation, and its function is done. The function may get repeated again, but the logic is "complete" when the subroutine returns. In PLCs, the function of the code continues through multiple executions of the same code. For instance, in even a simple function of starting a motor, one pass through the code uses a start input to latch logic to turn on an output and start a timer. Subsequent passes through the same code does a different function of checking to see of the motor shows faults, or checks to see if the motor should stop.

The different PLC formats make it easier to follow different types of code. Structured text is nice for displaying formulas. Function blocks are nice for showing relations within the logic. Ladder shows the logic most directly to how is executes, and many of us find it the easiest to follow and troubleshoot problems due to unusual input conditions.
  Reply With Quote
Old April 18th, 2017, 08:26 AM   #23
geniusintraining
Lifetime Supporting Member + Moderator
United States

geniusintraining is offline
 
geniusintraining's Avatar
 
Join Date: Jun 2005
Location: SC
Posts: 4,787
Quote:
Originally Posted by Phrog30 View Post
... Asking about best practice in this forum and you will get 100 responses....
That is true if only 50 people reply (2 per)
__________________
www.PLCCable.com PLC Communication Cables, PLC Trainers, Fluke Meters, MicroLogix, ControlLogix, Siemens, Allen Bradley and more... all your automation needs... ((NEW)) After Market 1784-U2DHP Allen Bradley USB to DH+ and Gateways
  Reply With Quote
Old April 18th, 2017, 09:01 AM   #24
mk42
Member
United States

mk42 is online now
 
Join Date: Jun 2013
Location: MI
Posts: 1,347
Quote:
Originally Posted by proof View Post
The thought process for programming a PLC is more like writing code for AWK or sed than C. Broadly generalizing, In C programs the logic typically executes 'once through', with some sections repeating with loops. In PLC code ALL of the logic is re-run continuously. In C programs, the logic performs a calculation, and its function is done. The function may get repeated again, but the logic is "complete" when the subroutine returns. In PLCs, the function of the code continues through multiple executions of the same code. For instance, in even a simple function of starting a motor, one pass through the code uses a start input to latch logic to turn on an output and start a timer. Subsequent passes through the same code does a different function of checking to see of the motor shows faults, or checks to see if the motor should stop.
It's not really that different.

Each program/routine/AOI/FC/FB executes to completion, just like it would in the C world. The main difference is that the main task/OB starts over from the beginning once it is done, whereas the C programmer would have to manually do that if he wanted his program to run forever.
  Reply With Quote
Old April 18th, 2017, 09:08 AM   #25
mk42
Member
United States

mk42 is online now
 
Join Date: Jun 2013
Location: MI
Posts: 1,347
Quote:
Originally Posted by Peter Nachtwey View Post
Boolean math doesn't require IF THEN ELSE

C:=A AND B;

IF THEN is only required if there is a need to do more than just change a coil.

The advantage of ladder is that you can see visually what is active and what isn't.
Peter, you are a shining light in the darkness. The rest of us are bickering about personal preferences, and you're trying to get us back on topic with solidly useful info.
  Reply With Quote
Old April 18th, 2017, 09:15 AM   #26
dmargineau
Lifetime Supporting Member
United States

dmargineau is offline
 
dmargineau's Avatar
 
Join Date: Dec 2011
Location: Midwest
Posts: 2,153
Quote:
Originally Posted by proof View Post
YThe format of the instructions, Ladder, structure text, function blocks, and etc, are not different languages, but are different ways of displaying the same logic.
Actually, LAD, FBD, ST, STL etc. are different programming languages and, as any language (spoken or written) they are conveying information/commands from the user to the operating system of the automation controller.

There are rules, mnemonics and syntax that apply to each language and each operating system of any CPU controller require different logic commands in order to achieve the intended functionality.

Last edited by dmargineau; April 18th, 2017 at 09:20 AM.
  Reply With Quote
Old April 18th, 2017, 10:08 AM   #27
daba
Lifetime Supporting Member + Moderator
United Kingdom

daba is offline
 
daba's Avatar
 
Join Date: Jul 2004
Location: uk
Posts: 3,812
Quote:
Originally Posted by Phrog30 View Post
If I want to create a loop in ladder I will use a jmp/lbl. So, let me guess, looping is bad practice?
Try FOR and BRK - it is more "structured" - your code that is executed repeatedly is containerised into its own subroutine file. The same can be said for code that you want JMP'd over (skipped), put it into a new subroutine and conditionally JSR it, it will have exactly the same effect.

One of the problems with JMPs and LBLs is that it imposes a restriction on placement of new code. To the unwary, adding a few rungs of code into the ladder could be sitting it in aplace that is skipped by a JMP/LBL, or executed many times in a "looping" JMP backwards
__________________
___________________________
ControlLogix & SLC Training
a-b train ltd.
abtrain@tiscali.co.uk
www.abtrain.co.uk
tel: 07506 73 9999
nil illegitimi carborundem


  Reply With Quote
Old April 18th, 2017, 10:15 AM   #28
Epy
Lifetime Supporting Member
United States

Epy is offline
 
Epy's Avatar
 
Join Date: Jul 2012
Location: Allen-Bradley Valley
Posts: 284
Quote:
Originally Posted by Phrog30 View Post
Oh, so you didn't say, "You don't want to make it easy for people to tinker in your program in the first place." I guess that means different things.
Yes, not making it easy to tinker /= intentionally making it difficult
__________________
Quote:
Originally Posted by ganutenator View Post
customers:
I don't know how to do it so it must be easy
  Reply With Quote
Old April 18th, 2017, 10:36 AM   #29
Mara
Member
Finland

Mara is offline
 
Join Date: Jan 2017
Location: Finland
Posts: 15
Quote:
Originally Posted by Peter Nachtwey View Post
the advantage of ladder is that you can see visually what is active and what isn't.
I am not sure about other PLC's but a i am using Beckhoff with TwinCat 3 and i can see active variables in ST. Same thing with with FBD. I can't see any advantages in Ladder. Of course this is just my opinion but i feel that Ladder is very unclear.

Last edited by Mara; April 18th, 2017 at 10:38 AM.
  Reply With Quote
Old April 18th, 2017, 10:52 AM   #30
daba
Lifetime Supporting Member + Moderator
United Kingdom

daba is offline
 
daba's Avatar
 
Join Date: Jul 2004
Location: uk
Posts: 3,812
Quote:
Originally Posted by Mara View Post
I am not sure about other PLC's but a i am using Beckhoff with TwinCat 3 and i can see active variables in ST. Same thing with with FBD. I can't see any advantages in Ladder. Of course this is just my opinion but i feel that Ladder is very unclear.
Really ? Is that why it has become one of the most popular, if not the most popular PLC language since the 1960's.

As a visual representation of the running program, it suits the widest audience, from seasoned programmers to low-skilled maintenance techs....
__________________
___________________________
ControlLogix & SLC Training
a-b train ltd.
abtrain@tiscali.co.uk
www.abtrain.co.uk
tel: 07506 73 9999
nil illegitimi carborundem


  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
Which programming method is better - ladder logic or structured text sinha_nsit LIVE PLC Questions And Answers 32 February 29th, 2016 11:47 AM
RS Logix Structured Text JasonWade LIVE PLC Questions And Answers 22 July 28th, 2014 04:19 PM
why use structured text and function block over Ladder spidermonkey LIVE PLC Questions And Answers 46 January 8th, 2013 10:02 AM
Structured Text on a PLC-5 antjon1 LIVE PLC Questions And Answers 6 March 30th, 2006 01:05 PM
Documentation on Structured Text cmulder LIVE PLC Questions And Answers 13 June 11th, 2003 10:10 AM


All times are GMT -5. The time now is 08:42 PM.


.