Create a DB matrix

reisjao

Member
Join Date
Feb 2013
Location
Sorocaba
Posts
9
I want to create a matrix on a DB like this:

After an rising edge of I0.0, move an REAL data MD0 to DB1.DBD0. Another rising edge and move MD0 to DB1.DBD4. Next to DB1.DBD8 and that's go on for about 200 samples.

I've searched a lot and it seems quite easy to use indirect address and array on SCL, but I don't know how to do it and still haven't find the answer.

PS.: I'm not familiar with SCL.

Thanks in advance
 
Hello Reisjao,

I have created a sample here for some inspiration.



FUNCTION_BLOCK FB666

VAR_TEMP
// Temporary Variables

END_VAR
VAR
count : INT; // this is used as a "Dummy" value, I will count it from 1-150 the reset it. The values are added in the array elements.
array_i : INT; // this is used as my array index
END_VAR
VAR_IN_OUT
ARRAY_IN : ARRAY [1..30] OF INT; // my input array of 30 objects of the type INT
END_VAR

IF count < 150 THEN
count := count + 1;
ELSE
count := 0;
END_IF; // my "Dummy" value it will count from 0-150 and then reset


IF array_i < 31 Then
ARRAY_IN [array_i] := count;
array_i := array_i + 1;
ELSE
array_i := 1;
ARRAY_IN [array_i] := count;
END_IF;

//I'm using my array_i as an index for my array input ARRAY_IN for looping through the elements in it, I move the value of count to the current array element at ARRAY_IN [array_i] := count;
END_FUNCTION_BLOCK


This is sort of diffused explained but hopefully it will give you some help in the right direction (its lunch time).


'edit'

If this dosen't help you just give me a shout and I will write it more detailed for you,
Best regards Victor
 
Hello, Victor

Thanks for the reply, but it didn't help yet. I'm just a begginer in SCL, so maybe after a lot of practice I will read this again and see that the answer was on my face.

I got the idea of the count and array index. It's something like this that I thought doing with the DBD index. But I don't know how the DB will be adressed here and how to move my REAL (or INT, DINT...) to the DBD.
 
Done in 5 minutes:

Code:
FUNCTION_BLOCK FB_ADD_TABLE 

VAR_INPUT
  Trigger : BOOL ;
  Value : REAL ;
  Reset : BOOL ;
END_VAR

VAR_OUTPUT
  Full : BOOL ;
END_VAR

VAR_TEMP
  i : INT // General index var
END_VAR

VAR
   Trigger_mem : BOOL ;
   Trigger_impulse : BOOL ;  
   Table_index : INT ;
   Table : ARRAY[0..199] OF REAL ;
END_VAR 

Trigger_impulse := Trigger AND NOT Trigger_mem ;
Trigger_mem := Trigger ;

IF Trigger_impulse AND NOT Reset THEN
    IF Table_index < 200 THEN
       Table[Table_index] := Value ;
       Table_index := Table_index + 1 ;
    ELSE
       Full := TRUE ;
    END_IF ;
END_IF ;

IF Reset THEN
   Full := FALSE ;
   Table_index := 0 ;
   FOR i:=0 TO 199 BY 1 DO
       Table[i] := 0.0 ;     
   END_FOR ;
END_IF ;

END_FUNCTION_BLOCK

edit : added Table_index := Table_index + 1 ;
 
Last edited:
Thanks a lot Jesper, it worked perfectly. Ah, and thanks Victor again.

It helped a lot and I think it will save a lot of lives out there. I've seen some doubts about it.
 
and I think it will save a lot of lives out there. I've seen some doubts about it.
.. ?!

If there are human lives involved, I hereby state that my code should not be used in a way that is related to personal safety.
I take no responsibility if my code is used in any way that is related to personal safety.
 

Similar Topics

Hello, I've been trying to learn this a while now and still have not found out how this works. I have an Omron CJ2M PLC and an ABB ACS 355 VFD...
Replies
1
Views
191
Hello, I have to deal with iFix again and am looking at the most efficient way to create alarms to display in iFix, i.e. not creating an...
Replies
0
Views
138
Good morning to all, I have the following issue, I installed everything of intouch including the patch, it is the 2023 version. The...
Replies
0
Views
284
So, I finally got versioin 27 installed on my Windows 10 VM. However, now I can't upload a project from my lab controller. I have the above error...
Replies
0
Views
1,117
Hi all, I have few GB of logged data created by RS View 32 Works, it is all in .DBF format. At the moment, my company wants to shift all data to...
Replies
14
Views
1,395
Back
Top Bottom