Hello folks,
Someone khow to use a string type variable in KRC4 ?
I’d like to call programs of products by name.
Hello folks,
Someone khow to use a string type variable in KRC4 ?
I’d like to call programs of products by name.
first of all there is no real string in KRL, but character array serves as substitute but this comes at a price... manipulation is rather cumbersome.
next you did not define what you mean by "calling program".
if you are thinking of calling program in a same interpreter by using name stored in a string, you would be out of luck ... unless you can sufficiently constrain the problem to a specific name format and/or predefined set of names.... in this case you can parse format and use SWITCH statement.
if you are thinking of selecting and running program from another interpreter.... that can work... even if name is completely unexpected (for example something received through network or somehow entered by user). check key manuals listed in READ FIRST topic.
Thank you for your help.
I want to create some programs with predefined names. examples: product1, product2.
Where product 1 would use program 1 and product 2 would use program2.
I understand that if I use swicth, I will have to enter an INT value, but in fact I would like to call the program by the name of the product.
Then, I would replace the name of product 1 and product 2 with the customer's internal code. So I can call the program using the client's internal code.
sounds good... evaluate string using format to recognize it is starting with "PROGRAM" and extract value that follows as an integer
then you can use Switch case...
Thank’s for the suggestions.
Hi,
I’m going to test here, too.
Thank you very much, for your help.
Hi,
I have some programs with predefined names. examples: productabcdef, productxywz.
I understand that if I use swicth, I will have to enter an INT value, but in fact I would like to call the program by the name of the product.
I load the programs with the directory loader option. This means that the program name can be anything as much as the skittle allows.
Isn't there a way to call program name?
As additional information, I use Siemens S71500 PLC and I can manipulate robot IOS with Profinet. I can run it externally.
What I really want to ask here is to be able to call the program name from external system. Could this be PLC or other etc.?
Sure.... Use CWRITE
Thank you for your answer,
Maybe it's not related, but you said this on another topic.
"CWRITE has no ability to modify files on the RAM drive. It only works on disc drives."
How can i use this command in the plc side, how can I call the program name from an external system? do you send any example program part about this? Thank you in advance
why don't you read the CWRITE manual...?
CWRITE is not a single thing, it is a common name for a collection of functions. And this collections includes routines that among other things can:
a) read/write files, map network drives etc. but you do not need that. you already have directory loader for that.
b) select/start/stop/reset/deselect programs. which is what you asked about in post #9.
your PLC can tell to KRC which program need to run:
this can be a number (in this case you can use EXT mode and CELL.SRC)
also this could be a string (program name). then Submit program using CWRITE can make sure that selected program is one chosen by PLC
The CWRITE $CMD channel allows the Robot (Level 1) interpreter to issue STOP, CANCEL, and RUN commands to the SPS (Level 0) Interpreter, and vice versa. You can find a lot of conversations on this in the forum archives.
You would need to write an SPS program that can accept strings from the PLC, build that into the correctly formatted string for the CWRITE RUN command, then fire that command (along with the anti-collision logic to clear the L1 interpreter correctly first).
Dear All,
I read cwrite document and tried all cwrite commands,
CWRITE($CMD,STAT,MODE,"RUN /R1/Abort()") This is ok, i call the program,
but, I have a char variable(different names) I need to
CHAR Abort[]
CWRITE($CMD,STAT,MODE,"RUN /R1/Abort[]()")
What can I do ? Thank you very much
Probably use SWRITE to build the entire string, then use just the string variable in the CWRITE:
CharArray[]="RUN /R1/Abort()"
CWRITE($CMD,STAT,MODE, CharArray[])