scme
(Melanie)
April 17, 2026, 5:25am
1
Good morning,
I’m trying to program a small ST Code snippet in SafeDESIGNER, which increases a time value by 10s for every bit set in a word.
I already found that I need three time variables as I cannot write TempTime := TempTime + TIME#10s.
The remaining compiler error is not really helpful, as it tells me something about expected an empty datatype and contacting the technical support.
Maybe somebody can help me with this?
seunghwa
(Seunghwa Hyun)
April 17, 2026, 5:53am
2
Can you try T#10s instead of TIME#10s?
In IEC61131-3 datatype are using T#xxx. (Wikipedia - IEC61131-3 )
You can find datatype and how to use time and date.
AS help - Datatype
scme
(Melanie)
April 17, 2026, 5:56am
3
Thanks for your reply. Same error, when trying this.
In the docs for SafeDESIGNER the initialization is listed as following, so my syntax should be correct, I guess.
Hi @scme ,
Have you tried T# instead of TIME#?
From the manual :
but…long prefix should be ok too…
SOS @michael.bertsch …
Ciao
Valerio
Hello,
Sorry Valerio i do not yet have the final answer but i can tell you something…
I have opened MappSafety and created a Functionblock in ST with the Declaration given.
I have slightly modified the Name of TempTime2 to have in mind that i need it for the Feedback.
This one is compiling without issues.
These two are the same
If i add the Addition function from the Toolbox i get this. It looks like the Addition only likes a ANY_NUM.
Testing only this… error
Changing to DINT it compiles again
It looks like you need to solve the question if it is possible and how to ADD two TIME’s in SafeDesigner. The default Addition looks only to be declared for Numerical Values.
You could now think of doing this with a Numerical Value and then convert to TIME.
But i did not found a conversion from Numerical to Time eighter.
We may have to discuss the initial intend of the SafeApplication and if there is an alternative aproach to the use case.
Now its time for a weekend…
Greetings
Michael
Hello,
ok, i was a bit challanged and had a idea but then… There was another issue with a Datatype Conflict between the Loop-Index in INT and the BIT_TST requiring a BYTE.
It looks nasty but i think this could be a working solution which does the operation of the initaly posted code.
Temp := INT#0;
TempFeedback := INT#0;
IF BIT_TEST(ValveOffConfig, BYTE#0) THEN
Temp := TempFeedback + INT#1;
END_IF;
TempFeedback := Temp;
IF BIT_TEST(ValveOffConfig, BYTE#1) THEN
Temp := TempFeedback + INT#1;
END_IF;
TempFeedback := Temp;
IF BIT_TEST(ValveOffConfig, BYTE#2) THEN
Temp := TempFeedback + INT#1;
END_IF;
TempFeedback := Temp;
IF BIT_TEST(ValveOffConfig, BYTE#3) THEN
Temp := TempFeedback + INT#1;
END_IF;
TempFeedback := Temp;
IF BIT_TEST(ValveOffConfig, BYTE#4) THEN
Temp := TempFeedback + INT#1;
END_IF;
TempFeedback := Temp;
IF BIT_TEST(ValveOffConfig, BYTE#5) THEN
Temp := TempFeedback + INT#1;
END_IF;
TempFeedback := Temp;
IF BIT_TEST(ValveOffConfig, BYTE#6) THEN
Temp := TempFeedback + INT#1;
END_IF;
TempFeedback := Temp;
IF BIT_TEST(ValveOffConfig, BYTE#7) THEN
Temp := TempFeedback + INT#1;
END_IF;
TempFeedback := Temp;
IF BIT_TEST(ValveOffConfig, BYTE#8) THEN
Temp := TempFeedback + INT#1;
END_IF;
TempFeedback := Temp;
IF BIT_TEST(ValveOffConfig, BYTE#9) THEN
Temp := TempFeedback + INT#1;
END_IF;
TempFeedback := Temp;
IF BIT_TEST(ValveOffConfig, BYTE#10) THEN
Temp := TempFeedback + INT#1;
END_IF;
TempFeedback := Temp;
IF BIT_TEST(ValveOffConfig, BYTE#11) THEN
Temp := TempFeedback + INT#1;
END_IF;
TempFeedback := Temp;
IF BIT_TEST(ValveOffConfig, BYTE#12) THEN
Temp := TempFeedback + INT#1;
END_IF;
TempFeedback := Temp;
IF BIT_TEST(ValveOffConfig, BYTE#13) THEN
Temp := TempFeedback + INT#1;
END_IF;
TempFeedback := Temp;
IF BIT_TEST(ValveOffConfig, BYTE#14) THEN
Temp := TempFeedback + INT#1;
END_IF;
TempFeedback := Temp;
IF BIT_TEST(ValveOffConfig, BYTE#15) THEN
Temp := TempFeedback + INT#1;
END_IF;
TempFeedback := Temp;
CASE Temp OF
0: SurvTimeCalc := TIME#0s;
1: SurvTimeCalc := TIME#10s;
2: SurvTimeCalc := TIME#20s;
3: SurvTimeCalc := TIME#30s;
4: SurvTimeCalc := TIME#40s;
5: SurvTimeCalc := TIME#50s;
6: SurvTimeCalc := TIME#60s;
7: SurvTimeCalc := TIME#70s;
8: SurvTimeCalc := TIME#80s;
9: SurvTimeCalc := TIME#90s;
10: SurvTimeCalc := TIME#100s;
11: SurvTimeCalc := TIME#110s;
12: SurvTimeCalc := TIME#120s;
13: SurvTimeCalc := TIME#130s;
14: SurvTimeCalc := TIME#140s;
15: SurvTimeCalc := TIME#150s;
ELSE SurvTimeCalc := TIME#0s;
END_CASE;
I only did some quick tests in Simulation.
This is not a recommendation to use this code. Please make your own Validation.
Greetings
Michael
scme
(Melanie)
April 20, 2026, 5:31am
7
Thanks Michael, I guess this should work. I wanted to avoid writing this long code instead of using FOR, but if there is no other way, it will serve for what I need.