Author Topic: Line continuation  (Read 5124 times)

cdenk

  • Full Member
  • Posts: 161
  • newbie
    • View Profile
Line continuation
« on: September 28, 2009, 06:41:12 AM »
Several years ago, I questioned the correct way to continue a Trilogi "IF" line, and thought the correct way, was to start the new line with a boolean (AND, OR, etc.). I prefer keeping the lines to length so they print nicely. The statements below, don't execute inside the "IF" to "SETIO EXERCISE".

If the web page messed the line lengths, The first 2 ?? lines are really on the first line. The line starting AND (DM[3984], and the following line are the 2nd line. The remaining 4 lines are as shown, individual lines.
========================
IF ((DATE[3] > (7 * (DM[3975] - 1))) AND (DATE[3] < ((7 * DM[3975]) + 1)) AND (DATE[4] = DM[3976])
AND (DM[3984] = DM[3977]) AND (TIME[2] < 1) AND (TIME[3] <= 30))
   'Turn the generator on
   SETIO EXERCISE
   TIMERPV[9] = 6000
ENDIF
========================
This is in a Cusfn with a 1.0 second special bit. I have numerous times checked the values being compared, pairing of "()", where everything is true, but the SETIO doesn't happen. Also have looked for something being reset elsewhere in the code.

Any thoughts, appreciated. :)

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3171
    • View Profile
    • Internet Programmable PLCs
Re:Line continuation
« Reply #1 on: September 28, 2009, 12:30:02 PM »
You can try to put a PAUSE statement before or after the SETIO just to be sure that the condition ever branch there.

For testing purpose perhaps you can break them down into multiple nested IF ...ENDIF statement and put the PAUSE statement one step at a time to see if the program would move down the nested IF THEN blocks until it is supposed to hit the SETIO statement.

You can have multiple PAUSE statement and by clicking on the "Pause" button you can continue execution of the program. That will be the best way to identify where the condition that may not be true.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

cdenk

  • Full Member
  • Posts: 161
  • newbie
    • View Profile
Re:Line continuation
« Reply #2 on: September 29, 2009, 08:29:40 AM »
Thanks for the quick reply. I think the problem is solved. I broke the long "IF" into numerous nested "IF". Each one had a SETLCD to print a character in an unused area of the LCD, followed by a pause. Then I one at a time commented out the pauses aft the PLC paused at that one. The issue was with how I had been checking the time including first minute and 30 seconds. Now I only check the minute >= 1, and if the "Exercise" relay had been set.

A side benefit of the nested "IF" is now I can comment on each "IF", which I couldn't do before, only at the beginning.