I opened a topic "SFC jumping steps - TwinCAT" yesterday but did not get any answer - also i think it is not possible to jump steps in SFC as i hoped so i need to find a different solution. First what my problem is:
I generate .csv File where lines look like:
"RunningNo";"UTCTimeStamp";"StingInput1";"StringInput2";"StringInput3";"Measuredvalue1";"MeasuredValue2";"MeasuredValue3"
RunningNo is with every line +1;
UTC TimeStamp is time when we measured our Value or when we save a line;
StringInput1 is place of machine or smt where measurement is made;
StringInput2 is name of measurement that is made;
StringInput3 is group of measurement that is made;
Measuredvalue1 is value that we measure.
For this file i measure Errors. I get 1 when error happend and 0 when it is not. Till now i cyclicly measured values - every minute.
Now would i like to save a line ONLY WHEN ERROR HAPPENS - SO WHEN OUR VALUE IS 1 (TRUE).
Ex:
"560";"1542027630";"StingInput5";"Error5";"Stingkey";"1";"";""
"561";"1542027631";"StingInput8";"Error8";"StingKey";"1";"";""
"562";"1542027690";"StingInput9";"Error9";"StingKey";"1";"";""
"563";"1542027750";"StingInput5";"Error5";"StingKey";"1";"";""
"564";"1542027810";"StingInput1";"Error1";"StingKey";"1";"";""
I have 43 different errors that can happen: That is from Error 1 to Error 43.
I generaded .csv til now like SFC - example on picture. LineToWrite is string which i want to write in every line.
So.. Do you have any ide how to save a line only when Error happens?
Since in SFC I can not jump a step i tried to write ST, but i get an Error at FB_FilePuts: ErrorID 1795: invalid index offset.
So does anymody have any idea how to change SFC or what can cause an error at ST at FB_FilePuts? Thank you
Here is example of new code wehre i get an error at FB_FilePuts:
CASEnStepOF  0:    IFrtStart.QTHEN      bStart:=FALSE;      q_bFinished:=FALSE;      nStep:=1;    END_IF      1:    fbFileOpen(      sNetId    :='',      sPathName  :=sPathName,      nMode    :=(FOPEN_MODEAPPENDORFOPEN_MODETEXT),      ePath    :=PATH_GENERIC,       tTimeout  :=DEFAULT_ADS_TIMEOUT,      bExecute:=TRUE);    IFNOTfbFileOpen.bBusyTHEN    fbFileOpen.bExecute:=FALSE;    nStep:=2;    END_IF      2:    IFError1THEN      LineToWrite1_active();      fbFilePuts(        sNetId  :='',        hFile  :=fbFileOpen.hFile,        sLine  :=CONCAT(sLineToWrite,'$N'),        bExecute:=TRUE);      IFNOTfbFilePuts.bBusyTHEN        fbFilePuts.bExecute:=FALSE;        nLineIdex:=nLineIdex+1;              nStep:=3;      END_IF    ELSIFNOTFehler_ST_0010THEN      nStep:=3;    END_IF  3:    IFError2THEN      LineToWrite2_active();      fbFilePuts(        sNetId  :='',        hFile  :=fbFileOpen.hFile,        sLine  :=CONCAT(sLineToWrite,'$N'),        bExecute:=TRUE);      IFNOTfbFilePuts.bBusyTHEN        fbFilePuts.bExecute:=FALSE;        nLineIdex:=nLineIdex+1;                nStep:=4;      END_IF    ELSIFNOTFehler_ST_0015_00THEN      nStep:=4;    END_IF  4:    IFError3THEN      LineToWrite2_active();      fbFilePuts(        sNetId  :='',        hFile  :=fbFileOpen.hFile,        sLine  :=CONCAT(sLineToWrite,'$N'),        bExecute:=TRUE);      IFNOTfbFilePuts.bBusyTHEN        fbFilePuts.bExecute:=FALSE;        nLineIdex:=nLineIdex+1;                nStep:=5;      END_IF    ELSIFNOTFehler_ST_0020THEN      nStep:=5;    END_IF      5:    nStep:=50;  50:    fbFileClose(      sNetId  :='',      hFile  :=fbFileOpen.hFile,      bExecute:=TRUE);    IFNOTfbFilePuts.bBusyTHEN      fbFileClose.bExecute:=FALSE;      nStep:=60;    END_IF      60:    q_bFinished:=TRUE;    bStart:=FALSE;    nStep:=0;    END_CASE
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
So my solution was parallel bench for every line where transition is RT_TRIG Error1,... I have 43 parallel steps so i took time to do ti but is working. If anyone have quicker solution i would still like to hear it eventhough this is working fine.
Why i had problem a long time is that i did not know what is the difference between alternative and parallel bench. This doc. helped me: https://assets.omron.eu/downloads/manua ... ide_en.pdf m
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In general, coders tends to be lazy. If you may reuse some code, then do it. (copy paste edit fails are frequent)
For this code, if "Fehler_ST_0020" is a fault bit, do some code or place it directly in a boolean array.
Then just code your error logging block for each array item in a loop. This will reduce 43 steps in 1 slightly bigger.
That said, you should know that working with files is slow, so opening and closing cyclicaly a file is something I dont recommend.
Maybe you could just open it once, then close it to copy it over some media.
Your ST code error may be dues to severall simultaneous write at a time in your file.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello guys,
I opened a topic "SFC jumping steps - TwinCAT" yesterday but did not get any answer - also i think it is not possible to jump steps in SFC as i hoped so i need to find a different solution. First what my problem is:
I generate .csv File where lines look like:
"RunningNo";"UTCTimeStamp";"StingInput1";"StringInput2";"StringInput3";"Measuredvalue1";"MeasuredValue2";"MeasuredValue3"
RunningNo is with every line +1;
UTC TimeStamp is time when we measured our Value or when we save a line;
StringInput1 is place of machine or smt where measurement is made;
StringInput2 is name of measurement that is made;
StringInput3 is group of measurement that is made;
Measuredvalue1 is value that we measure.
For this file i measure Errors. I get 1 when error happend and 0 when it is not. Till now i cyclicly measured values - every minute.
Now would i like to save a line ONLY WHEN ERROR HAPPENS - SO WHEN OUR VALUE IS 1 (TRUE).
Ex:
"560";"1542027630";"StingInput5";"Error5";"Stingkey";"1";"";""
"561";"1542027631";"StingInput8";"Error8";"StingKey";"1";"";""
"562";"1542027690";"StingInput9";"Error9";"StingKey";"1";"";""
"563";"1542027750";"StingInput5";"Error5";"StingKey";"1";"";""
"564";"1542027810";"StingInput1";"Error1";"StingKey";"1";"";""
I have 43 different errors that can happen: That is from Error 1 to Error 43.
I generaded .csv til now like SFC - example on picture. LineToWrite is string which i want to write in every line.
So.. Do you have any ide how to save a line only when Error happens?
Since in SFC I can not jump a step i tried to write ST, but i get an Error at FB_FilePuts: ErrorID 1795: invalid index offset.
So does anymody have any idea how to change SFC or what can cause an error at ST at FB_FilePuts? Thank you
Here is example of new code wehre i get an error at FB_FilePuts:
Hello,
So my solution was parallel bench for every line where transition is RT_TRIG Error1,... I have 43 parallel steps so i took time to do ti but is working. If anyone have quicker solution i would still like to hear it eventhough this is working fine.
Why i had problem a long time is that i did not know what is the difference between alternative and parallel bench. This doc. helped me: https://assets.omron.eu/downloads/manua ... ide_en.pdf m
In general, coders tends to be lazy. If you may reuse some code, then do it. (copy paste edit fails are frequent)
For this code, if "Fehler_ST_0020" is a fault bit, do some code or place it directly in a boolean array.
Then just code your error logging block for each array item in a loop. This will reduce 43 steps in 1 slightly bigger.
That said, you should know that working with files is slow, so opening and closing cyclicaly a file is something I dont recommend.
Maybe you could just open it once, then close it to copy it over some media.
Your ST code error may be dues to severall simultaneous write at a time in your file.