Sign in to follow this  
Followers 0
lostcontrol

Efficiency - ST vs Ladder

3 posts in this topic

I have been wondering for some time, what is the most efficient to code, both in terms of memory usage & code execution. I have created 2x similar functions in both Ladder & ST to test this, and at first glance, ladder is the most efficient for memory usage. I am yet to test in a PLC to see which executes faster. My thoughts are that ST would of been the best at both, but it appears that this is not the case.

Share this post


Link to post
Share on other sites
In my opinion, I would consider efficiency in a different manner. Not from a memory usage concern, but from an efficiency of programming view. I tend to try to use structured text only for complex mathematical calculations (complex in the number of steps, not neccisarily the functions used). It would be a real pain to use structured text for boolean operations for which ladder logic was specifically designed. All that being said, I went ahead and did a quick, simple and limited test of a ST FB vs a ladder FB. I made a FB of each type that converted celcius to fahrenheit and then made 5 instances of each in separate programs. The FBs were set to execute all the time. Using a CJ2H-CPU64-EIP and looking at scan time of the program, the differences were negligable. These were the results: Mean: 0.34 ms Max: 0.42 ms Min: 0.14 ms The above numbers were taken after a minute or so of operation. What was a little surprising was the memory views of the 2 separate programs: What I found to be odd was that the ST FB (top picture) used less FB memory (898 bytes), but the user memory required for 5 instances of the FB was slightly larger (925 steps) than the ladder version. So, I guess that my conclusion here is that the memory used by each method is nearly the same and I would make my decision on what type of programming you are doing. If you are doing all calculations, use Structured Text, if you are doing boolean programming, use ladder. If it is a mix, do ladder, it is easier to do math in ladder than it is to do boolean logic in Structured text. That is my 2 cents. Have a good one.

Share this post


Link to post
Share on other sites
Same as Sparky, I find structured text much easier and quicker for tricky maths, especially when you have lots of floating point calculations. It's also better for fault finding as you can view each stage on one screen instead of scrolling through lots of rungs. It's especially nice to use in function blocks. Once the code is written and working you can just use it and forget about it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0