1. Home
    1. Dashboard
    2. Search
  2. Forum
    1. Unresolved Threads
    2. Members
      1. Recent Activities
      2. Users Online
      3. Team Members
      4. Search Members
      5. Trophys
  3. Articles
  4. Blog
  5. Videos
  6. Jobs
  7. Shop
    1. Orders
  • Login or register
  • Search
This Thread
  • Everywhere
  • This Thread
  • This Forum
  • Articles
  • Pages
  • Forum
  • Blog Articles
  • Products
  • More Options
  1. Robotforum - Support and discussion community for industrial robots and cobots
  2. Forum
  3. Industrial Robot Support and Discussion Center
  4. Fanuc Robot Forum
Your browser does not support videos RoboDK Software for simulation and programming
Visit our Mainsponsor
IRBCAM
Robotics Channel
Robotics Training
Advertise in robotics
Sponsored Ads

KAREL send system var

  • RoboticsLan
  • December 16, 2020 at 9:47 AM
  • Thread is Resolved
  • RoboticsLan
    Trophies
    2
    Posts
    5
    • December 16, 2020 at 9:47 AM
    • #1

    Hello there,

    I have created a socket server (Fanuc robot LR Mate 200iC/5L with R30iA controller) and client on Pc with python.

    $SCR_GRP[1].$m_pos_enb = True

    The server code looks like this:

    Code
    PROGRAM tcpserver2
    
    %STACKSIZE = 4000
    %NOLOCKGROUP
    %NOPAUSE=ERROR+COMMAND+TPENABLE
    %ENVIRONMENT uif
    %ENVIRONMENT sysdef
    %ENVIRONMENT memo
    %ENVIRONMENT kclop
    %ENVIRONMENT bynam
    %ENVIRONMENT fdev
    %ENVIRONMENT flbt
    %INCLUDE klevccdf
    %INCLUDE klevkeys
    %INCLUDE klevkmsk
    
    -------------------------------------------------------------------------------
    
    VAR
    file_var : FILE
    tmp_int : INTEGER
    tmp_int1 : INTEGER
    tmp_real : REAL
    tmp_str : STRING[128]
    tmp_str1 : STRING[128]
    STATUS : INTEGER
    entry : INTEGER
    posreg : XYZWPR
    my_real : REAL
    
    -------------------------------------------------------------------------------
    
    ROUTINE get_real(prog_name : STRING;  var_name : STRING) : REAL
           VAR
           entry  : INTEGER
           i      : REAL
           STATUS : INTEGER
          
    BEGIN
          GET_VAR(entry, prog_name, var_name, i, STATUS)
          IF STATUS<>0 THEN
              WRITE('Error:[',prog_name,']',var_name,STATUS,CR)
          ENDIF
          RETURN(i)
    END get_real
    
    -------------------------------------------------------------------------------
    
    BEGIN
        -- DISCONNECT the server port BEFORE doing a CONNECT
        WRITE('Disconnecting..',CR)
        MSG_DISCO('S3:',STATUS)
        WRITE('Done.',CR)
        
        SET_FILE_ATR(file_var, ATR_IA)
        -- set the server port before doing a connect
        SET_VAR(entry, '*SYSTEM*','$HOSTS_CFG[3].$SERVER_PORT',1002,STATUS)
        WRITE('Connecting..',CR)
        MSG_CONNECT('S3:',STATUS)
        WRITE(' Connect Status = ',STATUS,CR)
        IF STATUS = 0 THEN
            -- Open S3:
            WRITE ('Opening',CR)
            FOR tmp_int1 = 1 TO 20 DO
                OPEN FILE file_var ('rw','S3:')
                STATUS = IO_STATUS(file_var)
                WRITE (STATUS,CR)
                IF STATUS = 0 THEN
                -- WRITE an INTEGER
                    FOR tmp_int = 1 TO 1000 DO
                        WRITE('Reading',CR)
                        -- Read 10 bytes
                        BYTES_AHEAD(file_var, entry, STATUS)
                        WRITE(entry, STATUS, CR)
                        READ file_var (tmp_str::10)
                        STATUS = IO_STATUS(file_var)
                        WRITE (STATUS, CR)
                        WRITE('Succesfull read data from client..',CR)
                        WRITE('Send data back to client..',CR)
                        
                        -- Write 4 bytes (REAL)
                        my_real = get_real('*SYSTEM*','SCR_GRP[1].$MCH_POS_X')
                        WRITE file_var (my_real::9::2)
                        STATUS = IO_STATUS(file_var)
                        WRITE (STATUS, CR)
                        WRITE('Done sending!',CR)
                    ENDFOR
                    CLOSE FILE file_var
                ENDIF
            ENDFOR
        WRITE('Disconnecting..',CR)
        MSG_DISCO('S3:',STATUS)
        WRITE('Done.',CR)
        ENDIF
    END tcpserver2
    Display More


    I am stuck on the following code below. I am trying to send a system variable to the client.

    Code
    -- Write 4 bytes (REAL)
    my_real = get_real('*SYSTEM*','SCR_GRP[1].$MCH_POS_X')    <<               
    WRITE file_var (my_real::9::2)

    Can someone help me, please?

    Edited once, last by RoboticsLan (December 16, 2020 at 10:13 AM).

  • R47
    Reactions Received
    11
    Trophies
    3
    Posts
    109
    • December 16, 2020 at 12:43 PM
    • #2

    Hi Roboticslan,

    try this.

    GET_VAR(entry,'*SYSTEM*','SCR_GRP[1].$MCH_POS_X',my_real)

  • RoboticsLan
    Trophies
    2
    Posts
    5
    • December 16, 2020 at 1:10 PM
    • #3

    my_real = get_real('*SYSTEM*','$SCR_GRP[1].$MCH_POS_X')

    Lol, I forgot $. Now it is working :smiling_face:

    Thanks for the response tho R47 .

Advertising from our partners

IRBCAM
Robotics Channel
Robotics Training
Advertise in robotics
Advertise in Robotics
Advertise in Robotics

Job Postings

  • Anyware Robotics is hiring!

    yzhou377 February 23, 2025 at 4:54 AM
  • How to see your Job Posting (search or recruit) here in Robot-Forum.com

    Werner Hampel November 18, 2021 at 3:44 PM
Your browser does not support videos RoboDK Software for simulation and programming

Tag Cloud

  • abb
  • Backup
  • calibration
  • Communication
  • CRX
  • DCS
  • dx100
  • dx200
  • error
  • Ethernet
  • Ethernet IP
  • external axis
  • Fanuc
  • help
  • hmi
  • I/O
  • irc5
  • IRVIsion
  • karel
  • kawasaki
  • KRC2
  • KRC4
  • KRC 4
  • KRL
  • KUKA
  • motoman
  • Offset
  • PLC
  • PROFINET
  • Program
  • Programming
  • RAPID
  • robodk
  • roboguide
  • robot
  • robotstudio
  • RSI
  • safety
  • Siemens
  • simulation
  • SPEED
  • staubli
  • tcp
  • TCP/IP
  • teach pendant
  • vision
  • Welding
  • workvisual
  • yaskawa
  • YRC1000

Thread Tag Cloud

  • abb
  • Backup
  • calibration
  • Communication
  • CRX
  • DCS
  • dx100
  • dx200
  • error
  • Ethernet
  • Ethernet IP
  • external axis
  • Fanuc
  • help
  • hmi
  • I/O
  • irc5
  • IRVIsion
  • karel
  • kawasaki
  • KRC2
  • KRC4
  • KRC 4
  • KRL
  • KUKA
  • motoman
  • Offset
  • PLC
  • PROFINET
  • Program
  • Programming
  • RAPID
  • robodk
  • roboguide
  • robot
  • robotstudio
  • RSI
  • safety
  • Siemens
  • simulation
  • SPEED
  • staubli
  • tcp
  • TCP/IP
  • teach pendant
  • vision
  • Welding
  • workvisual
  • yaskawa
  • YRC1000

Similar Threads

  • Send active alarm to PLC

    • tomexx
    • May 17, 2017 at 6:12 PM
    • Fanuc Robot Forum
  • motion profiler

    • flavien.J
    • April 19, 2017 at 5:20 PM
    • Fanuc Robot Forum
  • Personal Computer Communications: SEND_DATAPC

    • rastreus
    • March 5, 2020 at 12:06 AM
    • Fanuc Robot Forum
  • Dynamic control of FANUC Robot in Run-Time

    • Gokul N A
    • July 3, 2019 at 10:39 AM
    • Fanuc Robot Forum
  • handling KAREL program pause, which is caused by motion error

    • PeterHsiao
    • May 29, 2020 at 11:28 AM
    • Fanuc Robot Forum
  • TCP Window Update packet for every byte read on socket

    • schnepper
    • November 8, 2019 at 8:24 PM
    • Fanuc Robot Forum
  • KAREL program for weld weave

    • Vlad222
    • November 15, 2017 at 9:46 AM
    • Fanuc Robot Forum

Tags

  • karel
  • world coordinate
  • position robot
  • sockets
  • Socket Message
  • System Variable
  • socket server
  1. Privacy Policy
  2. Legal Notice
Powered by WoltLab Suite™
As a registered Member:
* You will see no Google advertising
* You can translate posts into your local language
* You can ask questions or help the community with your knowledge
* You can thank the authors for their help
* You can receive notifications of replies or new topics on request
* We do not sell your data - we promise

JOIN OUR GREAT ROBOTICS COMMUNITY.
Don’t have an account yet? Register yourself now and be a part of our community!
Register Yourself Lost Password
Robotforum - Support and discussion community for industrial robots and cobots in the WSC-Connect App on Google Play
Robotforum - Support and discussion community for industrial robots and cobots in the WSC-Connect App on the App Store
Download