Anyone Bored?

arkansascontrols

Lifetime Supporting Member
Join Date
Jan 2008
Location
Arkansas
Posts
112
Believe it or not I've nearly got this thing completed, but I have two remaining functions that I've still yet to complete. I only had a little while to test on the CPU today, but I've got an issue with a function that has got me stumped and was hoping for a little help.

The function is 7 full pages long so I won't burden you with the entire thing, unless you're a masochist and ask for it. So here's the pertinent code and the area where things are breaking.

L #NumElements;
begn: T #LoopCounter;

//MUCH CODE HERE that is working fine;

L #LoopCounter;
LOOP begn;

If I monitor the routine, everything works well up to the end of the loop where the routine seems to stick and the value of the Loop counter never decrements. I've tried the T #LoopCounter before the label and after the label. I've tried manually decrementing the Loopcounter value prior to the LOOP begn; statement and it resulted in CPU STOP. I have several other routines that loop but not with a LOOP statement, In my other routines I've just manually incremented the loopcounter and then checked for a valid range and executed a JC back to the label, but I thought I would try to implement this as it presented some challenges in the code due to the reverse action of the loop and I thought it would be a good learning experience. I can't test my function beyond the loop statment but I'm fairly certain I can make it work as I want.

So I'm not asking anyone to troubleshoot 7 pages of code, I can make this work, I'd just like to make the LOOP statement work without resorting to my tried and true method.

Thanks in advance.

Eric
 
Your posted code is correct for the LOOP instruction.

Have you single stepped the program to verify it's operation, or are you just monitoring the program ?
When monitoring a loop it is very difficult to really "see" what is going on. If the routine is "sticking" then the program will time out with a cycle time error.
Is this an FC or FB. Is the LoopCounter a temp ?

One method I use is to add another network after the one contaning the loop, and then L LoopCounter and monitor. The accumulator will be loaded with 1 after the program comes out of the loop.
 
Last edited:
Simon,

No I have not single stepped through, I would love to do that, however I think my Step7 software is buggy, Whether online or off, in monitor mode or out of monitor mode, all items on the debug menu are unavailable, But I also can't use the "Reference Data" application in Step7 and a few other little quirky things, so I'm kind of stuck having to work with what I've got. I have 3 laptops with Step7 and all of them do the same thing. I'm pretty sure I need to install SP2, I'm running 4.54 SP1 on HP Notebooks, and I've gotten a little feedback from our Support Group in the States saying they 'THINK' there might be some compatability issues with this series of notebooks and SP1

The network below this network containing the loop never shows any data in monitor mode, nor do any of the subsequent networks in the routine.

I'll try adding a load loopcounter in the next network tomorrow and see what happens with that.

This is an FC by the way. and the Loopcounter is a TEMP.
 
Actually I was beginning to wonder if I had exceed the max jump distance. The online documentation says 32767 words of program code. But does that refer to the amount of physical memory space that the code occupies or actual typed words of code. The way the documentation reads I interpret that as the latter, in which case I'm good, jumping less than 3000 words, if it's the former, I'm not sure how I'd even calculate it.

The maximum jump distance is -32768 or +32767 words of program code. The actual maximum number of statements you can jump over depends on the mix of the statements used in your program (one-, two-, or three word statements).

It's not a huge distance, but there is quite a bit of code there.
 
Post the source code and I'll have a look tomorrow.

(I've never encountered the jump limit - I would guess you could never save the block if the jump was too big)

Just tried (for the first time) a German herb based drink called Jagermeister - cheers!
 
Last edited:
Jager?

Jager..? Eck... Getting popular all over I suppose, I hear it's not bad with Red Bull, the only way I've had it was straight and it tastes just like NyQuil or any number of other Cough Syrups.

Have a look at your convenience, I'll be doing some more testing live in the A.M.
 
Translates to "Master Hunter" in German. Try a Jagerbomb. I find it really funny that you can learn about that on widipedia!

L D[AR2 said:
Just tried (for the first time) a German herb based drink called Jagermeister - cheers!
 
arkansascontrols said:
Jager..? Eck... Getting popular all over I suppose, I hear it's not bad with Red Bull, the only way I've had it was straight and it tastes just like NyQuil or any number of other Cough Syrups.

Have a look at your convenience, I'll be doing some more testing live in the A.M.

Its been a few years since I did any STL, but from what I can gather (and I have a very basic understanding of it) the only thing you do with #LoopCounter is load and transfer...there is no actual math done on it to increment/decriment it.

I'm probably wrong as 9/10 of that code is over my head, but thats something I noticed.
 
Christoff,

actually #LoopCounter is just the name of a temporary integer variable I defined in my function. In other functions I simply use it as a way to track iterations and condition jumps like in Basic Programming

begin:
x = 1 (do some stuff here)
x = x + 1
if x <= 5 then goto begin

which is another way of saying

For x = 1 to 5
do some stuff here
next

the for..next loop does the incrementing for you much the same as the
LOOP instruction in STL does. I've got some other functions that work fine using the STL equivelant of the First version but the second version utilizing the LOOP statement doesnt' seem to work.

But you're right the LOOP (label) statement is supposed to do the decrementing for you. Which is why I'm a bit baffled.

I am going to try using a manual looping procedure this morning. as well as some debugging tips from LD to see if I can get this working.

THanks for your reply
 
Coding errors from quick eyeball.

Code:
_006: NOP 0						 //Dwords, DINTS and REALS
	 L	 #TempHolder				 //Get the Span between addresses we saved earlier
	 L	 [b]20[/b]						 //Divide by 32 to get the number of elements
	 /D

RunningAverage temp variable not initialised to zero prior to summing

There are no open DB instructions either so the averaging is working on the last opened DB.

Real numbers have to be treated differently from DINTs
 
Last edited:
Simon,

I spotted that this morning early on as well.

I have made a few mods now that I'm past the loop issue. (I went to a manual loop)

Here is the revised code as it sits right now. The addition is coming out wrong. I'm only testing with INT's for the time being, so I'm sure I'll find other issues with Reals when I get there.

I'm calling the function with an intarray that has 10 elements [0-9] the values are 0 - 900 in increments of 100 so I should have a runningtotal of 4500 after the addition, yet I'm getting a very large negative number. If you don't mind have a look at the Addition Network (Network 3) I can't find anything wrong with it. I've installed some test variables in several locations so I can monitor values before and after various functions to isolate other issues that may be causing me grief, and everything is consistent all the way through to the end where the division takes place and the average is written only with the addition problem it's not coming out right. Sad I know to get so much of this of working and get stuck on a simple addition problem.
 
I've just been through the code in detail. I will post a corrected version so you can compare them to see where you went wrong. Do you have BeyondCompare or something similar ?
 
Yes. Corrected FC160 attached. I've tested this with 3 different array types, INT, REAL and DINT. I've not done exhaustive testing to check all of the error handling. Adding an error output is essential for this type of block.
 
Last edited:
Simon,

Thanks a million. I have some questions, but I'm going down to test and will try to figure out the answers before I bug you. If I hit my wall of ignorance again, I'll post a few questions. I understand the changes you made, I just don't understand how they made a difference.
 

Similar Topics

does anyone have an install or know if/where i can download it for the following "ABB PS501 Control Builder Plus V2.3 " the software was a free...
Replies
2
Views
48
They are installed in a control panel that was made in France and are intended for the termination of analog inputs. Each of the red capped...
Replies
3
Views
286
Hello everyone, I am currently working on a project that uses a Rockwell L33ER controller and the FTV Studio V13 as Supervisory computer...
Replies
0
Views
106
I have an old PLC (circa 2007) consisting of Telemecanique/Modicon/Schneider Electric devices. The system has developed errors and unfortunately...
Replies
2
Views
221
Need some help here (again). I tried to download my HMI to the PLC and I get this error message about a missing file. Can anyone help?
Replies
3
Views
774
Back
Top Bottom