Hello all, I was wondering if there is a way to auto select a program in the event of a power loss/restore? For example, I am in my PICK program when power loss occurs and I want to get back to my MAIN program when power is restored. Thanks!
Auto Select Program on Start Up?
-
dlanhart -
May 16, 2024 at 12:15 AM -
Thread is Unresolved
-
-
You've already asked about a variation of this process in an earlier thread with cycle start turning off......so what is the difference except for the condition.....
Simply:
- Set system switch to turn on an autostart.pc program(s).
- Set conditions/commands to use in the autostart.pc.
- The autostart.pc program(s) will execute on power up.You could also include subroutines within the autostart.pc routine and also variable states to monitor for as these states will be retained (programmatically) at the point of power loss, power cycle periods.
Using this method though, uses up a background task, for a single purpose.
So it's all about deciding on the most efficient way of using autostart programs on power up and during running.
That's where real understanding of just how the controller operates in terms of sequencing, functions available, understanding the full AS language commands available to use and logical programming implementation all relative to the application.There is no definitive way as many variations exist and each application is different:
- Control from a PLC to use dedicated signals, pg(x) naming convention and RPS system switch.
- Control from a standalone robot controller, pg(x) naming convention and RPS system switch.
- Control from a standalone robot controller without requiring any external influences.I would look into as a point of reference:
- System switch usage and functionality.
- MC Commands.
- SWITCH commands for monitoring of dedicated system conditions.
- SYSDATA command function and usage.
- WHICHTASK (not available in C controller) and TASK commands and usage.
- Argument (parameter parsing) through CALL instruction.
- Explore dedicated signals, pg(x) naming and RPS usage if using a PLC for the control.The above are what are used most often used when it comes to constructing complex autostart routines.
-
I have come up with a solution, that fits my team's specific needs, and this was the work around:
1. Our autostart.pc program was not declared correctly, this was the correct syntax:
2. We needed our MAIN program to run on power up so we added to autostart.pc:
Code.PROGRAM autostart.pc() WAIT SWITCH(POWER ) MC EXECUTE main 10 ; other functionality GOTO 10 .END
Thank you kwakisaki for the input, you are correct with how I outlined the conditions for returning to MAIN using cycle start as the indicator in my previous thread. After digging into the weeds more for this project, the solution above works best for what we are needing now.
-
That would work in it's literal state, I would recommend a TWAIT before the GOTO though.
- for example TWAIT 0.004.However that is easily broken by:
- Power up controller.
- Select teach mode for manual jogging.
- Turn on motor power.
- PC Task would generate an error as it will try and execute main program which it can't.
- PC Task will abort due to this error.Not knowing your application and just how you plan to control - local or remote from PLC etc.
There are some things to consider further as you develop but by no means a golden rule.
You can make PC Tasks as simple as you choose, or elect to go very complex.
So a couple of hints but by no means any kind of 'must do':
- Try and use PC Tasks for cyclic scanning (like a PLC) so you can do multiple functions.
- Try and avoid WAIT and SWAIT as these will stop the scanning until the conditions are met.
- Try and monitor for Teach and Repeat Modes so to separate functions applicable to mode(s).
- A simple example below.
- This is not a final solution as several other conditions should be monitored for.Code
Display More.PROGRAM autostart.pc(); ; MC PRIME main,,1; ; Loop: ; ; =====> repeat mode <===== IF (SWITCH(REPEAT)==TRUE) THEN; IF (SWITCH(CS)==FALSE) THEN; IF (SWITCH(POWER)==TRUE) THEN; IF (TASK(1)==2) THEN; MC CONTINUE; ELSE; IF (SYSDATA(MSTEP)<>-1) THEN; MC EXECUTE main,,1; ELSE; MC PRIME main,,1; END; END; END; END; END; ; =====> teach mode <===== IF (SWITCH(REPEAT)==FALSE) THEN; ;xxxxxxxxxx END ; ; =====> Goto label <===== TWAIT 0.004 GOTO loop; ; .END
-
Hi, since I found this topic I thought it would be interesting to ask some questions this way other people can benefit from it. I've been trying to learn and understand the basics of AS language and with plenty of help from Kwakisaki, I have managed to accomplish almost everything I need for my application. I am working with a C40 controller, what I wanted was being able to select and execute programs from teach pendant or externally via physical I/O , without the need to type in Execute, Hold, abort, kill, etc.......and that's exactly what we managed to do, Kwakisaki was extremely supportive and provided me an example o a task that is scanning continuously similar to the one above, and it is exactly what I need but there is only one problem, even if it works perfectly fine in simulation mode, when I am using the same code on the real controller it's not doing anything , what I mean by that is, even if all the buttons are displayed on the Interface Panel, they don' respond in any way when pressed. I have the internal signals enabled, it looks like it doesn't respond to the MC instruction or I am not understanding the exact issue.
At startup, the autostart.pc is running, I can see it on the teach pendant
When I press start, clear, hold, from I/P nothing happens
If I press the physical button on the controller Motor on, the following error is displayed: ERROR (-324) Cannot execute with MC instruction, No=1001 ,
Once the error appears the task stops automatically.
Any ideas?
Code
Display More.INTER_PANEL 1,5," Error"," "," "," ",6,0,2001 2,5," Repeat"," "," "," ",4,1,2002 3,1," "," Start"," Robot"," ",4,2,2006,0 4,1," "," Pause"," Robot"," ",4,2,2007,0 7,6," Program"," No.",1,0,-1,2010,2,0,3,1,0 8,1," "," Clear"," Program"," ",4,2,2008,0 9,5," MPower"," "," "," ",3,0,2003 17,5," Servos"," "," "," ",3,0,2004 25,5," Cycle"," "," "," ",4,0,2005 .END .PROGRAM autostart.pc() again: ; ;=========================================== ; Set IFP lamps to reflect status ;=========================================== ; IF SWITCH(ERROR )==TRUE THEN SIGNAL 2001 ELSE SIGNAL -2001 END ; IF SWITCH(REPEAT )==TRUE THEN SIGNAL 2002 ELSE SIGNAL -2002 END ; IF SWITCH(POWER )==TRUE THEN SIGNAL 2003 ELSE SIGNAL -2003 END ; IF SWITCH(RGSO )==TRUE THEN SIGNAL 2004 ELSE SIGNAL -2004 END ; IF SWITCH(CS )==TRUE THEN SIGNAL 2005 ELSE SIGNAL -2005 END ; ;=========================================== ; Hold Robot from button ;=========================================== ; IF ((SIG(2007)==TRUE) AND (SWITCH(CS )==TRUE) AND (SWITCH(RGSO )==TRUE)) THEN MC HOLD WAIT ((SWITCH(RGSO )==FALSE) AND (SWITCH(CS )==FALSE)) END ; ;=========================================== ; Interrupt and Clear Program Stack ;=========================================== ; IF SIG(2008)==TRUE THEN MC HOLD WAIT ((SWITCH(CS )==FALSE) AND (SWITCH(RGSO )==FALSE)) BITS 2010,2 = 1 MC KILL END ; ;=========================================== ; Start or Continue Robot from button ;=========================================== ; IF SWITCH(REPEAT )==TRUE THEN IF ((SIG(2006)==TRUE) AND (SWITCH(CS )==FALSE) AND (TASK(1)<>1)) THEN IF SWITCH(POWER )==FALSE THEN MC ZPOWER ON WAIT SWITCH(POWER )==TRUE END IF TASK(1)==2 THEN MC CONTINUE ELSE IF TASK(1)==0 THEN MC PRIME pg0,1 WAIT TASK(1)==2 MC EXECUTE END END END END ; TWAIT 0.0016 GOTO again .END .PROGRAM pg0() ; HOME ; prod.no = BITS(2010,2) ; CASE prod.no OF VALUE 1: CALL pg1 VALUE 2: CALL pg2 VALUE 3: CALL pg3 ANY : HALT END ; HOME .END .PROGRAM pg1() JMOVE #p1 .END .PROGRAM pg2() JMOVE #p2 .END .PROGRAM pg3() JMOVE #p3 .END
-
When posting error codes, please also provide STEP NO. of program.
In case main program error using either KRTerm (online) or MFP keyboard type in at prompt > or $
STATUS and press enter.In case pc task error using either KRTerm (online) or MFP keyboard type in at prompt > or $
PCSTATUS 1: and press enter.
These will display status information and also step no at which error occurs.So we need step no. where MC error occurs, that will open the door to troubleshoot issue.
Otherwise we are blind.Is PC Task running in PC Task area and not in Program area?
On IFP panel, do your lamps indicate status change:
- Repeat lamp, if you toggle teach/repeat switch does lamp light for repeat position.Using KRTerm or keyboard, if you type in IO and press enter, this will display status of IO.
So when pressing input buttons on IFP, do signals 200x display change of state.What are your dedicated input and output signals set to in aux functions dedicated inputs and outputs.
-
The PC task is running in PC task area, in the program area is nothing shown, I will check and answer all the other questions as soon as I will get there, thank you
-
-
The teach repeat lamp updates until the error apeares
-
Initially the teach/repeat lamp did update on the I/F, it also got to the POWER on stage but immediately the error occurred when it got to a certain stage: step No. 71 as it shows above .
-
also step 54 from what I see
My dedicated input signals are set to
30 EXT_CYC_START
31 EXT_ERR_RESET
32 EXT_MTRON
but I am not using them at the moment, same with the dedicated outputs. I am only using internal for now, and they do update util the error
-
Code
Display More; ;=========================================== ; Interrupt and Clear Program Stack ;=========================================== ; IF SIG(2008)==TRUE THEN MC HOLD WAIT ((SWITCH(CS )==FALSE) AND (SWITCH(RGSO )==FALSE)) BITS 2010,2 = 1 MC KILL SWAIT -2008;*************************; END ; ;=========================================== ; Start or Continue Robot from button ;=========================================== ; IF SWITCH(REPEAT )==TRUE THEN IF ((SIG(2006)==TRUE) AND (SWITCH(CS )==FALSE) AND (TASK(1)<>1)) THEN IF SWITCH(POWER )==FALSE THEN MC ZPOWER ON WAIT SWITCH(POWER )==TRUE END IF TASK(1)==2 THEN MC CONTINUE ELSE IF TASK(1)==0 THEN MC PRIME pg0,1 WAIT TASK(1)==2 SWAIT -2006;*************************; MC EXECUTE END END END END
Insert the two SWAIT modifications as above and let me know what happens?
-
Hi, same error on MC Prime, is there anything that I was supposed to enable from OPTIONS?
-
Code
Display More.PROGRAM autostart.pc() ; again: 100 IF SWITCH(REPEAT )==TRUE THEN IF ((SIG(2006)==TRUE) AND (SWITCH(CS )==FALSE) AND (TASK(1)<>1)) THEN IF SWITCH(POWER )==FALSE THEN MC ZPOWER ON SWAIT -2006; IF SWITCH(POWER )==FALSE THEN GOTO 100 END; WAIT SWITCH(POWER )==TRUE IF TASK(1)==2 THEN MC CONTINUE ELSE IF TASK(1)==0 THEN SWAIT -2006;*************************; MC EXECUTE main,,1; END; END; END; END; END; ;
if I am trying this simplified way , without MC Prime, it does work just fine
-
With your MC PRIME command, just use:
MC PRIME pg0 -
Strange issue, it does the same for MC KILL
It looks like PRIME and KILL are not included in the list, it is probably for newer controllers after C-type
-
It looks like PRIME and KILL are not included in the list, it is probably for newer controllers after C-type
I doubt that as those were available in the earlier AD Controllers.
Very strange.
What happens if you just create a PC task which contains 1 step:
MC PRIME pg0 and then PCEXECUTE it?Make a full file save and post it and I'll have a look over it.
-
With your MC PRIME command, just use:
MC PRIME pg0MC PRIME pg0,,1 will work if you want to prime it at line 1.
You may want a slight delay after confirming the main motion routine is killed before you prime or execute another motion routine.
-
Right, so.. it looks like MC used with PRIME it's literally missing from syntax or something, I've tried the simplest program possible and it's not able to do anything 😕 if I send PRIME pg0 from keyboard it does work but it doesn't like it with MC for some reason, strange problem. I even created a autostart.pc where there is only MC PRIME pg0 .... just one scan and the same error, I've added delays before and after IF conditions, wierd thing.. , If you have any other suggestions please let me know.
-
That's a first for me.................
Via the built in keyboard or via KCWin/KRTerm, if you type in:
help/mc and press enter.What is returned on the screen?
That should produce a list of the commands that are available for use with MC instruction.
If PRIME is not there, then that will answer this issue.The alternative (you've already discovered) is to use the MC EXECUTE.
There is also another option you could explore (which is a longer route) and that is to use the built in RPS option and external program reset input to prime pg0 but this route does include a PC Task control to accomplish this. -