Forum

1769-L33ER watchdog...
 
Notifications
Clear all

[Solved] 1769-L33ER watchdog fault, type 6 code 1, after adding an ST WHILE loop

8 Posts
3 Users
0 Reactions
85 Views
(@finn21)
New Member
Joined: 1 year ago
Posts: 0
Topic starter   [#143]

Hey guys,

Apprentice, second year, plastics plant. The granulator line runs on a CompactLogix 1769 L33ER, Studio 5000 V32 I think. My supervisor let me add a Structured Text routine that looks up a product code in a DINT array of 50 entries and gives back the position.

Downloaded it Friday afternoon and within about ten seconds the OK light went red, Type 06 Code 01, task watchdog expired. Cleared it, back to run, faulted again exactly the same way.

```
i := 0;
WHILE Codes[i] Product DO
i := i + 1;
IF i >= 50 THEN
i := 0;
END_IF;
END_WHILE;
Position := i;
```

I raised the continuous task watchdog from 500ms to 2000ms and that made no difference, then I ran it in Emulate at home over the weekend and got the same fault there.

It's only 50 entries so it should take nothing. Is ST just too slow for this on a 1769?


Advertisement

   
Quote
(@carav9)
New Member
Joined: 1 year ago
Posts: 0
 

What happens when Product isn't in the array? Read the loop again with that case in mind, and tell me what the IF at the bottom is for. Also, continuous or periodic task?


Advertisement

   
ReplyQuote
(@finn21)
New Member
Joined: 1 year ago
Posts: 0
Topic starter  

Continuous. The IF is there because the first download gave me a type 4 code 20 array fault when i got to 50, so I put i back to 0 and that fault went away.

If Product isn't in the array... it goes back to the start and looks again. Oh.



   
ReplyQuote
(@jcasey)
Trusted Member
Joined: 1 year ago
Posts: 59
 

> it goes back to the start and looks again

Forever, inside one scan. The controller never reaches the end of the task, so the watchdog fires. Raising it to 2000ms only changes how long it waits before faulting. TIA would give you an OB80 cycle time error for the same loop, different name, same thing.

What's in Product at the moment of download? If nothing has written it yet it's 0, and unless 0 is in your list the loop starts spinning on the very first scan.



   
ReplyQuote
(@finn21)
New Member
Joined: 1 year ago
Posts: 0
Topic starter  

It's 0 after a download, the HMI writes it when the operator picks a product. So the first scan has Product 0 and there's no 0 in Codes.

Took the wrap out and downloaded again. Now it faults on the array read instead, type 4 code 20, same as the first time. So I'm stuck between the two faults.



   
ReplyQuote
(@carav9)
New Member
Joined: 1 year ago
Posts: 0
 

You're choosing between two ways of not bounding the loop. Bound it. A FOR has a fixed range and finishes in one scan no matter what the data is:

```
Position := -1;
FOR i := 0 TO 49 DO
IF Codes[i] = Product THEN
Position := i;
EXIT;
END_IF;
END_FOR;
```

Not found gives -1 and the rest of the program can act on that. Same rule on every platform: every loop needs a counter or a fixed range, and never wait for an input inside a loop, the input image doesn't change until the next scan anyway. ST isn't slow, 50 compares is microseconds. There's a writeup on what the scan does here: https://plctr.com/understanding-plc-scan-time-and-cycle-time/



   
ReplyQuote
(@finn21)
New Member
Joined: 1 year ago
Posts: 0
Topic starter  

FOR version's been in since this morning, no fault, Position shows the right entry and -1 when I type a code that isn't there. Ok so my WHILE simply never ended when the value wasn't in the array, and the wrap I added to stop the first fault was hiding that from me. The FOR over 0 to 49 with EXIT when found does both jobs.

The way I understand it now, the loop has to finish inside the scan whatever the data is, so the range can't depend on the data.

One thing I don't get. At home Emulate faulted on the watchdog straight away, but at the plant the first download faulted on the array. Same code both times. Thanks carav9 and jcasey.



   
ReplyQuote
(@jcasey)
Trusted Member
Joined: 1 year ago
Posts: 59
 

Product probably had a value at home. Bounded loop, either way.



   
ReplyQuote
Share: