What is the correct way to get coordinates from external device ?

  • Hi everyone,


    I am new on the KUKA.


    KUKA side:

    - KSS 8.3.42

    - KR300 R2500

    - Profinet&Profisafe 3.2.4 - package


    PLC side:

    - S7 1511 TF

    - TiaPortal v15


    Note : I have no safety interface board. I am using Profisafe communication for safety.


    Now, I guess i am in trouble with that content. I have profinet communication. And my work is sorting project. The coordinates of the objects I will sort will be sent to me from outside. And the coordinates of all these pieces are sent to me at once. Maybe 10 pieces, maybe 20 pieces. My questions are:


    1- Is it possible to import .dat and .src files from external device directly to the robot while the robot is running in automatic mode?


    2- When i researching in this perfect forum, i saw that CWRITE/CREAD functionalities. When i examined that documents, i have to do CREAD function for reading file where is in the UserFiles folder. Is it possible to read over Profinet connection ? And also, Can external device create files to this folder?


    3- And in the other hand, when the robot in auto mode, can external device create a new .dat files in R1/Program folder ? And Can this file be updated ? Or is there any other way ?



    If all these questions get negative answers, Please can you suggest the most logical and applicable solution to solve this problem?


    Thanks in advance sir!..

  • 1. Yes, but you need an option 'directory loader' (Iirc), but have no idea how you want to write those files with your Siemens plc.


    2. Cread can't read from profinet. But an external device can create files that can be read with cread/cwrite. Create a standard windows share, then you can write files during auto mode. But you have to be shure robot and external device don't access the file at the same time.


    3. Same as in 1 and 2. You need the option, and you can update files over a windows share.


    I would prefer 2.

    For the option (directory loader) you need to spend extra money and it is a bit fiddly to configure and to use.

  • Thank you for your quick answer hermann.


    1. Yes, but you need an option 'directory loader' (Iirc), but have no idea how you want to write those files with your Siemens plc.


    1- Actually, my external device is not siemens plc. I use windows-based pc. So, using the 'Directory loader' package, I can update the .src and .dat files that I call within the code, even though the robot program is not stopped and robot automatic (only AUT mode) running?



    2- Okay, i will update files over a windows share. [C:/KRC/ROBOTER/UserFiles/] Is this the path where I need to create the file? Can I use another path?


    3- Also, I read CWRITE/CREAD doc. However, i couldn't understand brightly.


    My coordinates points are : x,y,z,a,b,c


    Mytest.txt:


    154.6, 177.4, 196.8, 57.4, 87.6, 71.3

    1444.6, 557.3, 196.8, 57.4, 88.0, 66.8

    1665.4, 544.7, 196.8, 77.5, 74.3, 65.1


    For example mytest.txt file has a 3 line info about coordinates. I want to read these points and then seperate them. Could you give me example about that ? I want to read from "[C:/KRC/ROBOTER/UserFiles/Mytest.txt]"


    Thank you in advance...

  • 1 - you may want to check the manual for directory loader. it i recall there are some limitations.

    2 - that is possible (check mounting of volume). not really worth the effort if you ask me.

    3 - several examples (including ones from me) are already shared. basically open file, read from file, close the file. you can try to parse the values immediately in CWRITE or separately using SREAD. both are very similar but SREAD is a bit more flexible and forgiving.


    1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

  • Is there a reason why you would not just send over the coordinates as data using PROFINET communication?


    Declare 6 x 10 REAL variables, and a few BOOL signals as flags, to check if values have updated.


    Robot check flags cyclically, to see if variables has been updated, if so, use REAL values to create a E6POS, and start motion.


    Forgive me if I am missing the point of your question, but I am genuinly curious, what advantages does transfer by text-files have, when PROFINET communication is available.

  • out of curiosity, why do you think that PROFINET communication is available? the robot and PLC support ProfiNet but he already stated the data is actually arriving from PC.


    There are software stacks for Profinet and some are free but this is not quite as simple as writing text file. Just a guess...

    1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

  • 1 - you may want to check the manual for directory loader. it i recall there are some limitations.

    2 - that is possible (check mounting of volume). not really worth the effort if you ask me.

    3 - several examples (including ones from me) are already shared. basically open file, read from file, close the file. you can try to parse the values immediately in CWRITE or separately using SREAD. both are very similar but SREAD is a bit more flexible and forgiving.



    Thank you for your great example, panic mode. I used that piece of code and it is working. However, I want to assign that read values to variables. I added a few line to your example code.


    The number of coordinates that will come to me from outside will be able to change. In other words, 4 coordinate lines can come, 15 coordinate lines can also come.


    If you noticed this code that I added, it is possible to process 3 lines of coordinate information. I want to make this code dynamic. In other words, it needs to create as many variables as the number of coordinate lines that will come from the outside and write the value into it.


    When I send 2 coordinate lines instead of 3 in the .txt file that the current code is reading, my code stuck line 37 -wait for condition. Since there are already two lines of coordinate information and the reading is over, it shouldn't be stuck there, right?. How can I prevent this? We can accept the maximum coordinate line that will come to me from the outside as 100. Is there any chance you can help me with this problem I described?


    Thank you in advance.

  • Yes, that is an option of course. However, like said panic mode, this option will be too much of a burden for me in terms of software, algorithm and controlling many things. Thank you so much for suggestion.

  • It's been a while, but I had a program where I loaded massive amounts of XYZABC data from a text file whose line count was unknown. FEOF is the function that's supposed to detect the end of the file, but I found it unreliable at the time. However, also checking for an error on FGETS worked for me.




    CWRITE KRL_FGETS was used to get one line from the text file, then SREAD was used to parse the line into individual variables. I had to use two SREADs because a single SREAD command is limited to parsing 10 variables, and my data file was 13 columns of CSV data. The data file was generally about 5000-6000 lines.

  • Hello again,


    Sorry for the late response. Today I was able to find time to try to these codes. And thank you so much panic mode and SkyeFire. Both of them working..!

Advertising from our partners