ST common errors and fixes
Build checks the saved source. Read the message beside the line or select the entry in Problems, fix it, then build again.
Unknown tag
A name must exist in the tag table and be visible to this program. Check the spelling. Choose Create tag beside the error to open the tag dialog with the name and inferred type. Confirm its type and scope, then create it. For this example, create MotorRun as BOOL.
MotorRun — BOOL.MotorRun := TRUE;BOOL versus number
Assigning 2 to a BOOL fails. Use TRUE, FALSE, 1 or 0. For a condition based on a numeric tag, compare it with a number; do not use the numeric tag alone as the condition.
MotorRun — BOOL; Count — DINT.MotorRun := Count > 0;DINT versus REAL
Assigning a DINT tag to REAL requires DINT_TO_REAL. Assigning REAL to DINT requires REAL_TO_DINT. The error names the mismatch and suggests the conversion. For Speed := 7 / 2;, use REAL literals for fractional division, or explicitly convert the computed integer if that is what you meant.
Speed — REAL; Count — DINT.Speed := DINT_TO_REAL(Count);
Count := REAL_TO_DINT(Speed);
Speed := 7.0 / 2.0;Missing semicolon
If the message expects ;, check the preceding assignment, call or END statement. Add the semicolon, as after TRUE below.
MotorRun — BOOL.MotorRun := TRUE;Missing END_IF
Close each IF with END_IF and a semicolon. An error at the end of the routine may point back to an unfinished block.
StartPB — BOOL; MotorRun — BOOL.IF StartPB THEN
MotorRun := TRUE;
END_IF;