Author Topic: Custom Function error  (Read 10582 times)

BC SYSTEMS

  • Full Member
  • Posts: 146
    • View Profile
Custom Function error
« on: April 16, 2010, 04:28:57 AM »
Hi,

I was using the below code in a basic program with no problems, whilst debuging some ladder logic I re-compiled and now it wont compile??  i added some comments but can't see any issues??

'******************************START
IF

TESTIO (CONTROL_OK)

DM[10] = 1

ELSE

DM[10] = 0

ENDIF


'******************************

IF

TESTIO (CLOSE_CB_STATUS)

DM[1] = 1

ELSE

DM[1] = 0

ENDIF

'******************************

IF

TESTIO (OPEN_CB_STATUS)

DM[2] = 1

ELSE

DM[2] = 0

ENDIF

'******************************


IF

TESTIO (TRIP_CB)

DM[3] = 1

ELSE

DM[3] = 0

ENDIF

'******************************

' CB STATUS CONTROL ALARM - BOTH INPUTS LOW

IF

DM[1] = 0 ' CLOSE

AND

DM[2] = 0 ' OPEN

THEN

DM[4] = 1 ' FAULT

ELSE

DM[4] = 0

ENDIF

'******************************

' CB STATUS CONTROL ALARM - BOTH INPUTS HIGH

IF

DM[1] = 1 ' CLOSE

AND

DM[2] = 1 ' OPEN

THEN

DM[5] = 1 ' FAULT

ELSE

DM[5] = 0

ENDIF

'******************************

' CB STATUS CONTROL ALARM - EITHER ERROR CONDITIONS

IF

DM[4] = 1 ' ERROR LOW

OR

DM[5] = 1 ' ERROR HIGH

THEN

DM[6] = 1 ' CB STATUS ERROR

ELSE

DM[6] = 0

ENDIF

'******************************

' CB STATUS CONTROL ALARM - CLOSED WHEN CONTROL NOT OK

IF

DM[1] = 1 ' CLOSE

AND

DM[10] = 0 ' CONTROL OK

THEN

DM[11] = 1 ' FAULT

ELSE

DM[11] = 0

ENDIF

'******************************

' CB STATUS COMFIRMATION OUTPUT

IF

DM[1] = 1 '  CLOSE

DM[12] = 1 ' CB SHOULD BE ON

ENDIF

IF

DM[2] = 1  ' OPEN

DM[12] = 0 ' CB SHOULD BE OFF

ENDIF

'******************************

' CB STATUS CONTROL CB CLOSING CIRCUIT OK

IF

DM[1] = 1

AND

DM[12] = 1

DM[13] = 1 ' CB CLOSED WHEN COMMANDED

ELSE

DM[13] = 0

ENDIF


' CB STATUS CONTROL CB OPENING CIRCUIT OK

IF

DM[2] = 1

AND

DM[12] = 0

DM[14] = 1 ' CB OPEN WHEN COMMANDED

ELSE

DM[14] = 0

ENDIF

'******************************END


support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Custom Function error
« Reply #1 on: April 16, 2010, 06:57:48 AM »
Looks like the compiler doesn't handle well the comments inserted in between the AND statements and the THEN statements. If you reorganize your code a bit it should compile. E.g.

' CB STATUS CONTROL ALARM - CLOSED WHEN CONTROL NOT OK

IF

DM[1] = 1 AND DM[10] = 0 THEN   ' CONTROL OK

   DM[11] = 1 ' FAULT

ELSE

   DM[11] = 0

ENDIF

For i-TRiLOGI version 6.3x You can attach a meaningful name to describe the variable:

  E.g.  DM[1]_ControlOK  is the same as just DM[1]


Email: support@triplc.com
Tel: 1-877-TRI-PLCS

BC SYSTEMS

  • Full Member
  • Posts: 146
    • View Profile
Re:Custom Function error
« Reply #2 on: April 16, 2010, 07:19:32 AM »
Great thanks!