Mapping large amount of errors in InTouch

twibs

Member
Join Date
Feb 2014
Location
Satakunta
Posts
8
Hello, I have the following problem. I'm trying to create error list mapping to a servo drive. The drive sends and integer value which should be turned into text according to a scv file. There are approximately 650 different errors/states that would need to be mapped. Creating tag for each error is obviously out of the question. There can be only one error active at any given time from each drive. If there is another, it will come active once the first one is cleared.

I have only recently started working with InTouch though I have experience with the STL PLC coding and PanelView.

You may wonder why I need the same structure in the second FOR loop. well the errors are of different length so I need to count the offset to the right error.

Things I have noticed so far:
-I currently use 11 tags for the script, I think it will work faster if I add more though I'm wondering if there's a better
-FileReadFields did not seem to work with DIM MESSAGE tags? (hence the number for PLC tags)
-I can use the script asynchronously and it is allowed take some time. The operator rarely is by the screen when the error happen so some time is acceptable
-Currently it's about 500ms (for the last error) on my laptop, though I don't know yet how fast it will be on the final comp.
-SQL database did cross my mind, though that's another area I need to study more. Would it be more efficient? Or easier?
-IndirectTag.NAME does not seem to work with FOR LOOP (It would've saved me lot's of tags and time. Already missing the array[] from 'normal' PLC language. Anyway to dynamically reference the text tags within FOR LOOP?


(script= AlarmText(AlarmNumber) )
DIM found;
DIM Offset;
DIM index;
DIM AlarmNum AS MESSAGE;

found = 0;
Offset = 0;
AlarmNum = StringFromIntg( AlarmNumber, 10 );

FOR index = 0 TO 650 STEP 10

Offset = FileReadFields( "C:\comp path\AlarmNumber.csv", Offset, "text1", 10 );

IF text1 == AlarmNum THEN
found = index;
EXIT FOR;
ENDIF;
IF text2 == AlarmNum THEN
found = index+1;
EXIT FOR;
ENDIF;
IF text3 == AlarmNum THEN
found = index+2;
EXIT FOR;
ENDIF;
IF text4 == AlarmNum THEN
found = index+3;
EXIT FOR;
ENDIF;
IF text5 == AlarmNum THEN
found = index+4;
EXIT FOR;
ENDIF;
IF text6 == AlarmNum THEN
found = index+5;
EXIT FOR;
ENDIF;
IF text7 == AlarmNum THEN
found = index+6;
EXIT FOR;
ENDIF;
IF text8 == AlarmNum THEN
found = index+7;
EXIT FOR;
ENDIF;
IF text9 == AlarmNum THEN
found = index+8;
EXIT FOR;
ENDIF;
IF text10 == AlarmNum THEN
found = index+9;
EXIT FOR;
ENDIF;

NEXT;

Offset = 0;
FOR index = 0 TO 650 STEP 10
Offset = FileReadFields( "C:\comp path\AlarmText.csv", Offset, "text1", 10 );

IF found == index THEN
AlarmName1 = text1;
EXIT FOR;
ENDIF;
IF found == index+1 THEN
AlarmName1 = text2;
EXIT FOR;
ENDIF;
IF found == index+2 THEN
AlarmName1 = text3;
EXIT FOR;
ENDIF;
IF found == index+3 THEN
AlarmName1 = text4;
EXIT FOR;
ENDIF;
IF found == index+4 THEN
AlarmName1 = text5;
EXIT FOR;
ENDIF;
IF found == index+5 THEN
AlarmName1 = text6;
EXIT FOR;
ENDIF;
IF found == index+6 THEN
AlarmName1 = text7;
EXIT FOR;
ENDIF;
IF found == index+7 THEN
AlarmName1 = text8;
EXIT FOR;
ENDIF;
IF found == index+8 THEN
AlarmName1 = text9;
EXIT FOR;
ENDIF;
IF found == index+9 THEN
AlarmName1 = text10;
EXIT FOR;
ENDIF;
NEXT;
 
For loops will work, you just need to understand the syntax. I personally use SQL all the time to store reference information such as this.

Assume you take care of all the sql connections and such, see the following:
Code:
SQLSelect( SQLConnectionId, TableName, BindList, WhereExpr , OrderByExpr );  
SQLFirst( SQLConnectionId );
SQLRows = SQLNumRows( SQLConnectionId );
    FOR y = 1 TO SQLRows
        {Temp String Tag is indirect message}
        TempStringTag.Name = "My_String_Tag_" + StringFromIntg(y,10);
        TempStringTag = bind_List_item_tag;
        SQLNext( SQLConnectionId );
    NEXT;
SQLEnd(SQLConnectionId);
This will populate tags

My_String_Tag_1
My_String_Tag_2
My_String_Tag_3
.
.
My_String_Tag_<y>

I would also write this as a data-change script so it only runs when you need it to.
 
Thanks for your reply. But don't I need PLC tag for every SQL row? Or am I missing something? Or does SQL support DIM tags?

I think my FOR LOOP didn't work because I had DIM tags assigned for the FileRead function.
 
The number of tags you need depends on the number of results you wish to store.

If you have an alarm number, lets say 123. The data change script executes once it sees that the alarm number changed from 0 to 123.

In this case, the SQL query only needs to return a single value, the text value of 123. The for loop script above would only execute a single instance of the loop logic, as a result it would store a single instance of the text value of the alarm. So only one tag is required, well two tags really the indirect tag, and the message tag where the final text will reside. As the alarm number changes, the same text holder tag is updated with the corresponding text.

If your SQL query could return multiple results of data, then you would need tags for each result to be stored.

The example I gave you wasn't to solve your problem directly, but to demonstrate how you can use for loops and dynamically change your tag references, as well expand upon using SQL to store data and scripting to retrieve it.
 

Similar Topics

Hi everyone, Kind of new at this, so we recently upgraded our 1769-l32e to the newer 5069-L320erm, i converted the file over and Verify the...
Replies
8
Views
399
Hello Guys I have an 1756-L73S Controller with a Fanuc Robot mapped as follows: - In 1756-EN2TR Slot 2 the Fanuc Robot is defined as an...
Replies
5
Views
260
This has been on my mind for a while now, wondering if anyone here has any best practices or insights. I have been working with a plant that has...
Replies
8
Views
544
Hi long time out... I´m in a project now, that request to upgrade an old SLC to a new ControlLogix. Just the PLC. It is connected now to a...
Replies
5
Views
1,956
Hi all, I'm really new to this. I need to export the Modbus register mapping from a Modicon M580 through Control Expert for the registers that...
Replies
4
Views
948
Back
Top Bottom