Internet PLC Forum
General => Technical support => Topic started by: TTCSR 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?
-
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
-
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?
-
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
-
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?
-
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.
-
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.
-
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
-
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
-
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.
-
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
-
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.
-
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.
-
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.
-
I've attached a "zipped" version of the test code described in the previous post.
Gary D.
-
That is helpful, however, it still won't work for my application as there will still be times that an error message will be displayed for a brief moment, every five seconds. I will definitely use this for future programs on other projects.
I do have another question. I have a sequence that advances every 1 second unless an error occurs. Is there a way to monitor the sequence and set a bit on if the sequence does not advance for more than a second? If there is a way, it will totally solve my issue since I can use that bit in my HMI to change screens when that bit turns on.
-
You can use a 1 second clock pulse to trigger a custom function which is used to advance a sequencer counter if there is no error. If an error is detected (that is determined by your software) then the custom function can stop advancing the sequencer or set an alarm bit which is monitored by another custom function for actions.
-
I would suggest the use of a TIMER.
Gary d
-
My sequence is advanced by each cutom function via an IF THEN ELSE statement (shown below). Each completion of a test sets the CTRPV to the next sequence for the next test, hence, I cannot use a clock pulse for advancement. However, I am not sure how I could use a timer though?
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
-
I'm sorry, but I can not help you.
I think that your coding style has limited your options.
You might consider throwing more hardware at the problem. Add another PLC to manage the display.
I know that this adds extra cost to your project but if you can't change your coding style then a second PLC gives you the opportunity to manage the display of messages independently of the execution of your test sequence.
Gary d
-
I figured it out with a timer. I placed a timer on each test. If the test remains active for longer than 2 seconds, the timer bit triggers an output bit that I use to enable a display on my HMI. I had to create 50 timers, one for each test, but it works perfectly. ;D
I agree the coding has limited my options, however, it was necessary due to the application.
Thank you for all the input and feedback!