I am calculating and converting the variables in the sps.sub, but only if some statement become true (boolean variable from PLC). Here is an example code, what I would like to do. I have to calculate for example a sum of real variables, but only when the PLC sends me a CALCULATE_REQUEST. If there is no CALCULATE_REQUEST I have to hold the variable in robot memory and send it to the PLC as well. This example code is similar like mine, but there is more variables to calculate in my program.
Posts by KarmanGergo
-
-
Hello!
I have a project with APAS KUKA robot, with KRC4 robot controller. The robot has Nexeed option package, to communicate with a Bosch Rexroth PLC. I want to send REAL variables to the PLC, but as you can see in the attached video, the variables are not working perfectly in the PLC.
I have REAL global variables in the config.dat files, that I write only, when some statement become true. Then I have to convert the real variables, to integer variables with the following conversion function.Code
Display MoreGLOBAL DEFFCT INT REAL_TO_INT(INPUT_VALUE:IN) DECL REAL INPUT_VALUE DECL INT OUTPUT_VALUE DECL CHAR real_to_out[32] DECL INT B DECL INT OFFSET B=0 FOR B=1 TO 32 real_to_out[B]="0" ENDFOR OFFSET=0 CAST_TO(real_to_out[],OFFSET,INPUT_VALUE) OFFSET=0 CAST_FROM(real_to_out[],OFFSET,OUTPUT_VALUE) RETURN OUTPUT_VALUE ENDFCT
After the conversion (that I do only when some statements become true), I store the values in global integer variables in the config.dat, and in the sps.sub I send out these integer variables to the output (output signal size is 32 bit long) every sps.sub cycle.
Do you have any idea what can cause the problem? The variables are not not written at any other place. In the KUKA Actual Variable display the variables are consistent, the values are good, and not "jumping" back to 0, as I can see in the PLC variable list.
Thanks very much for your help!
Gergő