Author Topic: Message display  (Read 17953 times)

TTCSR

  • Newbie
  • Posts: 30
  • I'm a llama!
    • View Profile
Message display
« on: January 17, 2013, 05:44:04 AM »
I have a program that performs a large amount of tests in sequence and displays error messages and pauses the sequence until the error is cleared.

The problem is as the test runs, it displays each error for a short period of time which is something I do not want the user to see as they are not actually errors, they are just the program running.  I would like it to display something like "Testing..." until it has an error for more that 3 seconds which would indicate an actual error found.  Does anyone know how to approach this?  Or is there a function that can do this?

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3171
    • View Profile
    • Internet Programmable PLCs
Re:Message display
« Reply #1 on: January 17, 2013, 08:31:30 AM »
What the LCD will display is completely under your program control. So if you don't want it to be displayed then don't run the SETLCD command during the testing when the user is not supposed to see.

But if you want to be able to do both (say to display your diagnostic message for your technician and NOT to display messages for end user), you can use a digital input to connect to a switch so that the switch will determine if the SETLCD command is run:

E.g.

IF TESTIO(testmode)   ' only display when testmode input is ON.
    SETLCD x,y,"......."
ENDIF

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

TTCSR

  • Newbie
  • Posts: 30
  • I'm a llama!
    • View Profile
Re:Message display
« Reply #2 on: January 17, 2013, 09:42:48 AM »
This is what a typical part of my program looks like:

IF TESTIO(A3_CS)=0 & CTRPV[1]=1 THEN
   CALL 1:
   SETLCD 2,1,B$+"A3"
   DELAY 1000
ELSE
   IF TESTBIT (INPUT[1],1) THEN
      SETLCD 0,0,CHR$(1)
   ENDIF
ENDIF

By the time I get to the clear screen command, the error SETLCD 2,1,B$+"A3" is displayed for a brief moment in time.  I know the delay 1000 may be affecting it, however, without it my error messages flash too quickly.  Is there any way I can delay the message if it exists without delaying the cusfunc?

garysdickinson

  • Hero Member
  • Posts: 502
  • Old PLC Coder
    • View Profile
Re:Message display
« Reply #3 on: January 17, 2013, 10:35:48 AM »
You can and should do the delay in ladder logic.

If the only job for your custom function is to display error messages, then you could call the custom function periodically.  If it takes 5 seconds for a human to read a message, then call your message display function once ever 5 seconds.


Gary d

TTCSR

  • Newbie
  • Posts: 30
  • I'm a llama!
    • View Profile
Re:Message display
« Reply #4 on: January 17, 2013, 11:02:48 AM »
How do I perfrom a delay in the ladder logic?  

I have about 50 custom functions all which call up different variations of error messages if certain conditions are not met, so I would have to place the "delay" on each rung?  If so, what is the delay function?

TTCSR

  • Newbie
  • Posts: 30
  • I'm a llama!
    • View Profile
Re:Message display
« Reply #5 on: January 17, 2013, 11:13:53 AM »
Clock pulse bit?  Is that the delay you are referring to?

My big issue even with that need to have some kind of default display like "testing..." that will stay on unless the errors become true.  It seems as each custom function occur the error is true for a brief moment until the PLC reacts to the inputs provided.

garysdickinson

  • Hero Member
  • Posts: 502
  • Old PLC Coder
    • View Profile
Re:Message display
« Reply #6 on: January 17, 2013, 11:33:55 AM »
I will show you how to call a function once every 5 seconds.  This function will figure out what if any error message is to be displayed and display only one message.

In this ladder example, the CUSTOM FUNCTION, ErrorChk, has the following format:

' ErrorChk - custom function to display error messages
'
IF TestIO (Error01)
???SetLCD 0,0,CHR$(1)??????' clear screen
???SetLCD 1,1,"Error01 Problem"
???Return
ENDIF

IF TestIO (Error02)
???SetLCD 0,0,CHR$(1)??????' clear screen
???SetLCD 1,1,"Error02 Problem"
???Return
ENDIF

IF TestIO (Error03)
???SetLCD 0,0,CHR$(1)??????' clear screen
???SetLCD 1,1,"Error03 Problem"
???Return
ENDIF

IF TestIO (Error04)
???SetLCD 0,0,CHR$(1)??????' clear screen
???SetLCD 1,1,"Error04 Problem"
???Return
ENDIF

[/color]

The ladder logic for this simplistic example follows.  The COUNTER 5SecCntr has a set value of 5.

Gary D.
« Last Edit: January 17, 2013, 11:40:24 AM by garysdickinson »

TTCSR

  • Newbie
  • Posts: 30
  • I'm a llama!
    • View Profile
Re:Message display
« Reply #7 on: January 18, 2013, 04:14:00 AM »
That would work if all of my tests were happening at the same time, however, each of my 50+ tests happen in sequence and displays an error for a brief moment until it understands it is not an error and skips to the next test in the sequence.  

So calling a function every 5 seconds would only create a delay for this case.  However, this is useful for future programs on other applications for me.

The following is typical code for my custom functions.  I've also attached a *.jpg of the ladder logic, but I am not sure if it will show up....

'A3 OPEN TEST
IF TESTIO(A3_CS)=0 & CTRPV[1]=1 THEN
   CALL 1:
   SETLCD 2,1,B$+"A3" 'Line 2, Column 1
ELSE
   IF TESTBIT (INPUT[1],1) THEN
      SETLCD 0,0,CHR$(1)
   ENDIF
ENDIF
'SOCKET 33 TO A3 - NCS CONNECTOR TO NCS OPEN TEST
IF TESTIO (A3_CS)=0 & CTRPV[3]=9 THEN
   CALL 1:
   SETLCD 2,1,E$+D$+"A3"+G$+"2-A" ' LINE 2, COLUMN 1
ENDIF
'SHORT TEST
IF TESTBIT (INPUT[1],1) THEN
   IF INPUT[1]+INPUT[2]+INPUT[3]+INPUT[4]+INPUT[5] & &HFFFD THEN    'CHECK IF ANY OTHER INPUT #1 TO #16) IS ON
      CALL 2:
      SETLCD 2,1,D$+"A3 &"      
      CALL 8:
   ELSE
      IF CTRPV[1]=1 THEN
         CTRPV[1]=2
         SETLCD 0,0,CHR$(1)
      ELSE
         CTRPV[3]=10
         SETLCD 0,0,CHR$(1)
      ENDIF
   ENDIF
ENDIF

garysdickinson

  • Hero Member
  • Posts: 502
  • Old PLC Coder
    • View Profile
Re:Message display
« Reply #8 on: January 18, 2013, 08:52:54 AM »
I'm sorry, but I do not understand the problem that you are trying to solve.

Can you explain what you are trying to achieve?

I understand that you are trying to test 50 different things.

Do you test all 50 things, save the results and then display messages only for those tests that failed?

Are all of your tests pass/fail?

Gary d

TTCSR

  • Newbie
  • Posts: 30
  • I'm a llama!
    • View Profile
Re:Message display
« Reply #9 on: January 18, 2013, 09:39:49 AM »
Each test is performed in sequence and look similar to the sample I've shown. If the test is successful, the program moves forward to the next test, if there is an error, the error message is displayed continuously until the problem is resolved.  

In the ladder logic, each rung activates an output for use on the associated custom function test.  The issue is that even if there is no error, I see the error message for a brief instant and then it moves on to the next test with another error message for a brief instant.  

It seems I need a way to only show the errors if they last longer than 1 second.

garysdickinson

  • Hero Member
  • Posts: 502
  • Old PLC Coder
    • View Profile
Re:Message display
« Reply #10 on: January 18, 2013, 10:20:51 AM »
OK.

Let me see if I'm getting it.  

You want the sequence of tests to stop when an error is detected, display a message on the LCD and wait for a human to do acknowledge the error and then move to the next test in the sequnce.

Is this close to what you want?

Gary d

TTCSR

  • Newbie
  • Posts: 30
  • I'm a llama!
    • View Profile
Re:Message display
« Reply #11 on: January 18, 2013, 10:38:32 AM »
Close yes.  The PLC is a part of a diagnostic tool I've designed.  
The diagnostic tool is attached to a piece of equipment that requires testing. When the user sees an error occur, they fix the equipment.  When fix is complete, the PLC sees the error disappear and the program continues.  The next test does not occur until the current fault is eliminated.  When all the tests within the program pass, that indicates the equipment is good.

My issue is during the testing, the error messages are displayed for a brief moment, so a successful test, which takes a couple minutes, cycles through error messages every split second until it says "Test successful".  The program is able to perform the task well, but the display is not ideal for the end user.

garysdickinson

  • Hero Member
  • Posts: 502
  • Old PLC Coder
    • View Profile
Re:Message display
« Reply #12 on: January 18, 2013, 11:06:47 AM »
OK.

Perhaps this approach might meet your needs:

1. You have a loop of code that executes a sequence of 50 tests.
2. This loop of code runs continuously from test 1..50 and just repeats, forever.
3. For each test there is a RELAY that is set/cleared based on the success/failure of that test.  If no test fail then no RELAYs are set.

If you have 1..3 working, then you just need a method to display
a message for each failure (RELAY bit that is set).  The message for each failure is to be displayed for 5 seconds.

Is this close?

I do have a few questions about how you have structured this code that performs 50 test:
1.  Do all of the tests execute on a single scan of the ladder logic?
2.  If the tests are distributed across multiple scans of the ladder
     logic do any of the tests use the DELAY statement?

Depending on how your code is structured, I may have a simple solution to your problem.

Gary D.

garysdickinson

  • Hero Member
  • Posts: 502
  • Old PLC Coder
    • View Profile
Re:Message display
« Reply #13 on: January 18, 2013, 02:41:48 PM »
Let's assume that your test code sets/clears RELAYS to indicates the failure/success of each test.  Each test has it's own RELAY.

Now the displaying of error message is decoupled from the actual test.  This makes it very easy to control exactly how long messages are visible.

I wrote a simple PC6 file that only does the display.  The sample only supports 4 error bits and uses RELAY #1..#4 to represent the errors. You set/clear the bits using the on-line monitoring.

There are 2 custom functions involved. The first one sets up strings to display for each of the four errors and some varaibles
that are used by the ErrChk custom function.

' InitDisplay - code to provide one-time initialization for display mechanism
'
Save_EEP$ "Error 01", 1
Save_EEP$ "Error 02", 2
Save_EEP$ "Error 03", 3
Save_EEP$ "Error 04", 4

ErrMsgIndx = 1
ErrorCnt = 0
[/color]
This is the custom function that is called periodically to check for
errors that need to be displayed:

' ErrChk - function to display error messages
'
while (ErrMsgIndx <= MaxErrMsg)

???if TestBit(RELAY[1],ErrMsgIndx - 1)
??????' Error...
??????' Display message for this error
??????'
??????SetLCD 0,0,CHR$(1)??????' Clear Screen
??????SetLCD 1,1,Load_EEP$(ErrMsgIndx)
??????SetIO DispMsg
??????ErrorCnt = ErrorCnt + 1??????' Running count of errors

??????' Undate index into error bits
??????'
??????ErrMsgIndx = ErrMsgIndx + 1
??????if ErrMsgIndx > MaxErrMsg
?????????ErrMsgIndx = 1
??????endif
??????return
???endif

???' No error found at this index,
???'   Try the next index...
???'
???ErrMsgIndx = ErrMsgIndx + 1

endwhile

' If we got here then we have searched through
' all of the possible errors...
'
ErrMsgIndx = 1??????' Start over at the beginning

IF ErrorCnt = 0
???' No error messages posted on this pass
???'
???SetLCD 0,0,CHR$(1)??????' Clear Screen
???SetLCD 1,1,"No errors found"
ENDIF

ErrMsgIndx = 1??????' Start over at the beginning
ErrorCnt = 0??????'   With a fresh slate (no errors, yet...)??????
[/color]
At the end of this reply is the ladder logic that is required to get
the 5 second delay for displaying messages and the mechanism to call the custom functions.

Best of Luck,

Gary D.
« Last Edit: January 18, 2013, 02:49:27 PM by garysdickinson »

garysdickinson

  • Hero Member
  • Posts: 502
  • Old PLC Coder
    • View Profile
Re:Message display
« Reply #14 on: January 18, 2013, 02:47:10 PM »
I've attached a "zipped" version of the test code described in the previous post.

Gary D.