Serial Communication (PC -> KUKA KRC2 5.2)

  • Hi, Robot Forum! :help: :help:
    I'm an engineering student and still have very few experience in robotics.
    I would like some help in Serial Communication between a PC (Python programming) and KUKA Robot.
    I'm working with a KUKA KR 6 Arc, its controler is KRC2 and the software that comes with it is the KSS 5.2.21 version. Can somebody help me with an example code? I'll leave here a picture of my code on the PC side (Python) and on the KUKA side.
    Thanks in advance for your help and support! :icon_smile: :icon_smile:

  • Hi Skyefire, thanks in advance for your response.
    I want to send a letter (for example "a") or a number (for example "1") from Python (PC) to KUKA. When receiving the letter or the number successfuly, it will execute a function I developed on KUKA, where the robot will move into a certain position.
    I've no idea how to do it successfuly.


    - When I comunicate with the Hyper Terminal of the robot, it works fine.
    - I'm using COM3 on KUKA.


    Can you please help me with any example of a code?

  • What code? You just said that when you test communications with the robot using HyperTerminal, it works fine, so you must have working code in the robot already. If you want help with the Python code, this is the wrong forum -- I suggest StackOverflow.

  • I guess he used terminal on controller instead of KRL program just to see if it can work and if his cable us ok.



    Now he wants to do a real thing.



    But this is 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

  • Well, I never did a lot of serial on KRC2s, and it's been at least ten years since I did any, but I dug a set of old test files out of my archives that I know worked. I was emulating a serial console connection to a Keyence camera.


    IIRC, setting COM3 to use XON/XOFF in SERIAL.INI was important -- that's the "bare bones" protocol.


    Adding ASCII control characters (like CR and LF) to a string before sending requires adding them to the end of a string variable as integers.

  • Yup, for software handshake (XON/XOFF) only three wire cable is needed (Tx, Rx and GND).
    For hardware hanshaking, control lines also must be wired.

    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

  • Thanks for all the help messages :icon_smile:
    I've solved my problem.
    My problem was in the file $custom.dat and its parameters.


    Many thanks again for the excellent support :merci: :merci: :bravo:

  • I can't speak to the previous poster's specific issues, but these are the settings in $CUSTOM.DAT that influence the serial ports.

    On most later KRC2s, SER_3 was the usable serial port. Some of the earlier ones may have used SER_2 -- I don't recall exactly.


    I've attached an old KRC1 manual that should be the same as for the KRC2, aside from the serial port numbers.


    Code
    DECL SER $PSER_1={PROTO 1,PROC 0,RCO 5,BL 0,BAUD 19200,NOC 8,NOS 1,PARITY 2,TRC 1,FLP 0,LLP 0,RT 300,PT 5,DSR 0,WCCXON 0,VXON 0,VXOFF 0,WEOBC 0,VEOBC 0} ;SCHNITTSTELLE 1
    DECL SER $PSER_2={PROTO 0,PROC 3,RCO 0,BL 0,BAUD 9600,NOC 7,NOS 2,PARITY 2,TRC 0,FLP 1,LLP 60,RT 0,PT 0,DSR 0,WCCXON 0,VXON 11,VXOFF 13,WEOBC 1,VEOBC 3} ;SCHNITTSTELLE 2
    DECL SER $PSER_3={PROTO 0,PROC 3,RCO 0,BL 0,BAUD 9600,NOC 7,NOS 2,PARITY 2,TRC 0,FLP 1,LLP 60,RT 0,PT 0,DSR 0,WCCXON 0,VXON 11,VXOFF 13,WEOBC 1,VEOBC 3} ;SCHNITTSTELLE 2
    DECL SER $PSER_4={PROTO 0,PROC 3,RCO 0,BL 0,BAUD 9600,NOC 7,NOS 2,PARITY 2,TRC 0,FLP 1,LLP 60,RT 0,PT 0,DSR 0,WCCXON 0,VXON 11,VXOFF 13,WEOBC 1,VEOBC 3} ;SCHNITTSTELLE 2
    DECL SER $PPG={PROTO 2,PROC 4,BAUD 9600} ;PG-SCHNITTSTELLE
    CHANNEL :SER_1 :SER_1 $PSER_1
    CHANNEL :SER_2 :SER_2 $PSER_2
    CHANNEL :SER_3 :SER_3 $PSER_3
    CHANNEL :SER_4 :SER_4 $PSER_4
    CHANNEL :PG :SER_1 $PPG
  • Hi,

    I want to send a letter (for example "a") from Python (PC) to KUKA.

    my code on the PC side (Python) works fine , but on the kuka side not work ,my code on the kuka side can open the channel but could not read the character with CREAD function .


    I'll leave here a picture of my code on the PC side (Python) and on the KUKA side.

    - I'm using COM1 on KUKA.


    Can you please help me

  • "Does not work" does not have enough detail to offer any advice.


    Do you know that the character is being sent? Do you have the flow control set the same on both ends? Have you tried opening a port on the KRC and testing it with HyperTerminal or MobaXTerm or some other manual RS232 program?

  • Thanks for reply

    KRC1, V4.1.5


    1. flow control in my laptop is on XON/XOFF mode and in serial.ini (attached file) i can see XON_VAL=17 & XOFF_VALUE=19 how can i sure they are the same on both sides?


    2. haven't test with hyper terminal but i think COM port works fine, i am using a serial to USB converter and whenever i press Drives ON bottom on the pendant i can hear "USB inserted sound" on my laptop(python side). COPEN() module works without any problem(HANDLE gets true value) but in the next module i.e. send() program wait ten second (i have defined timeout=10) in CREAD line during these ten second i try to send a simple character from python side to KRC and python shows "1Byte successfully written" but after ten second KRC program jumps to "transmission error" line(my main .src program is "hhh" attached text file).


    so i think programs in both sides work fine, and channel successfully can open but they can't send any data to each other.

    is there any idea what can be the reason? thanks for any help.

  • USB to serial adapter and python are on what machine? your laptop?


    You are using what serial cable? what connections?

    It need to be RS232 crossover (nullmodem). basic nullmodem cable is 3 wire (2-3, 3-2, 5-5) but if using hardware handshaking, additional connections are needed.


    KRC1 can use com1 and com2.

    KRC2 can use com3 and in some cases com2.

    KRC4 does not support serial comms


    you can test ports using loopback adapter and sending data. it all ok you will receive send data.

    simplest loopback (no handshake lines) simply has jumper on 2-3

    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

  • thank you for clearing that up... yup, since there is no node number or master slave setup with RS232, communication settings on both sides must be identical.

    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

Advertising from our partners