S7-scl problem

I really don't know anything about DMC but..

from the code listing in post 6:

A.Element[2,1]:=-0.0018;
A.Element[2,2]:= 0.0040;
A.Element[2,3]:=-0.0030;
A.Element[2,3]:=0.0009;
A.Element[2,4]:=-0.0001;

It looks like you are double initializing A.Element[2,3] and not initializing A.Element[2,5] at all. I don't know if that is intentional or if it is enough to cause a problem but it did catch my eye.

Keith
 
Thank you Keith, i changet it, but i still have unstable sistem when i call FB1 from OB1.

As L D[AR2,P#0.0] already said i don't have available OB32 on CPU we are using, and WinCC has available sampling times of 250ms, 500 ms, and 1s, which still makes my system unstable.

When i call FB1 from OB35, i have system failure because my cycle time is longer than 100ms.
I tried to split my code in 10 parts, and calling it from OB35 to get 1 sec, but now it's stuck on 20% which was good for a moment because my setpoint was 20%, but when i changed it, it was still working on 20% :(.

Now, again, don't have any idea.
 
Would it help to change CPU-s Scan Cycle Monitoring time from 150ms to 100 ms, and is this allowed? And then to call FB1 from OB35? Is this why i was getting system failure?
And how does that Scan Cycle Load from Communication affecting my program?
 
Mstr.

Investigate the diagnostics buffer to know for sure what is causing the 312C to fault. There may be several entries in the diagnostics buffer that pertain to your problem.
It can well be that the cycle time is to blame, in which case you have to increase the Scan Cycle Monitoring time, not decrease it.

Apart from that, if the block takes more than 150 ms to execute, it will still cause an SF even if the block is called in OB35 in stead of OB1.
A 312C is a really puny CPU, but more than 150 ms seems extreme, if there is no other code running in the CPU.
I havent analysed your code. So I cant say of there is an error somewhere.
You have to find out the real execution time of your code.
The update time set for OB35 has to be longer than the execution time that you find. Same for Scan Cycle Monitoring time.
 
Mstr - In your tests when switching between OB1/OB35 have you been keeping track of the blocks running in the plc ?

For example, in your SCL you call FB1 from OB1. If you modify the SCL and change OB1 to OB35 compile and download, you will now have FB1 being called from OB1 and from OB35.

If you are switching between the two (OB1/35) you must have OB1 and OB35 in your SCL source and call FB1 from one or the other and compile and download all blocks to the plc when you make a change.

Change your scan time monitoring to 1000ms
Call FB1 from OB1 using the following code to give you a one second sample rate.
There should be no code in OB35.

Code:
ORGANIZATION_BLOCK OB1

VAR_TEMP
  // Reserved
  Info: ARRAY[0..19] OF BYTE;
  // Temporary Variables
  TT:s5Time;

END_VAR

  // Instructions
M0.1:=NOT M0.0;
TT:=S_ODT(T_NO:=1,S:=M0.1,TV:=T#1000ms,Q:=M0.0);

IF M0.0  THEN 
   FB1.DB1();
END_IF;
  ;
END_ORGANIZATION_BLOCK

ORGANIZATION_BLOCK OB35

VAR_TEMP
  // Reserved
  Info: ARRAY[0..19] OF BYTE;
  // Temporary Variables

END_VAR

  // Instructions
  ;
END_ORGANIZATION_BLOCK
 
Once you have a running system - your problems can be split into two - fundamental design errors and coding errors.

Coding errors can be found by setting up test data, running the plc for one scan and then verifying that all calculated data is correct from an alternative method (calculator, matlab etc). PLCSIM is ideal for this.

Fundamental design errors - one possibility is to generate an ideal model of your process and contruct the SCL code to simulate this process. You can control your simulated process with your DMC implemenation using PLCSIM before getting near the real hardware.
 
Finally

Once you have a running system - your problems can be split into two - fundamental design errors and coding errors.

Coding errors can be found by setting up test data, running the plc for one scan and then verifying that all calculated data is correct from an alternative method (calculator, matlab etc). PLCSIM is ideal for this.
I wonder if they have simulated this in Matlab. Matlab was mentioned above but I have looked at Dynamic Matrix Control and it doesn't look like they have all the code necessary. Also, there is no definition of what they are controlling or where the system matrix comes from.

Fundamental design errors - one possibility is to generate an ideal model of your process and contruct the SCL code to simulate this process. You can control your simulated process with your DMC implemenation using PLCSIM before getting near the real hardware.
First I would implement this in Matlab or Scilab. There is an example on the Mathworks website.
 

Similar Topics

Guys Cant remember syntax for an if statment like this in studio 5000 Can someone help If ( some_tag == false) then do something end_if I can...
Replies
4
Views
1,395
Hello All, I am new to programming with Tia Portal and I am having difficulty with something that we have found "easy" in other programming...
Replies
3
Views
2,381
FUNCTION_BLOCK FB283 VAR_INPUT DB_number: BLOCK_DB; add : int; END_VAR VAR_OUTPUT out:INT; END_VAR VAR end_var BEGIN...
Replies
2
Views
3,182
Dear all, I don't know why the above section (written in SCL) switches the CPU to stop mode. When I delete the two lines highlighted with...
Replies
14
Views
2,882
The following code does some weird things with my outputs... is it just like in Lad, or stl not permitted to use outputs more the once ?? And if...
Replies
14
Views
4,960
Back
Top Bottom