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

Communication between Matlab and FANUC Roboguide

  • MatlabXFanuc
  • May 11, 2021 at 11:37 AM
  • Thread is Resolved
  • MatlabXFanuc
    Trophies
    2
    Posts
    9
    • May 11, 2021 at 11:37 AM
    • #1

    Hello everyone,

    For my engineering school project I have to create a communication with MATLAB and ROBOGUIDE to be able to send informations from MATLAB to ROBOGUIDE so that the robot (i have an educational cell from FANUC with an LR Mate 200i) can move. I know that it is possible to do it with KAREL programmation and using TCP/IP connection between them but for now, i don't really know how. I heard some solutions with creating server with KAREL and client on matlab but it didn't work.

    Can someone help me for that ?

    Thank you by advance ! :smiling_face:

  • SkyeFire May 11, 2021 at 2:54 PM

    Moved the thread from forum General Discussion of Industrial Robots Only to forum Fanuc Robot Forum.
  • jmd2777
    Reactions Received
    34
    Trophies
    4
    Posts
    193
    • May 11, 2021 at 3:26 PM
    • #2
    Quote from MatlabXFanuc

    I heard some solutions with creating server with KAREL and client on matlab but it didn't work.

    Can you explain what you mean? Does that mean you tried a few approaches and they didn't work? What approaches did you try?

  • MatlabXFanuc
    Trophies
    2
    Posts
    9
    • May 11, 2021 at 3:44 PM
    • #3

    Hi jmd2777,

    I tried to connect Matlab and Roboguide with a program I found on internet. Roboguide create a server and Matlab is the client that communicate with the server but Matlab cannot connect to Roboguide.

    Here is my KAREL program to create the server :

    PROGRAM TestServer

    %STACKSIZE = 4000

    %NOLOCKGROUP

    %NOPAUSE=ERROR+COMMAND+TPENABLE

    %ENVIRONMENT uif

    %ENVIRONMENT sysdef

    %ENVIRONMENT kclop

    %ENVIRONMENT bynam

    %ENVIRONMENT fdev

    %ENVIRONMENT flbt

    %INCLUDE klevccdf

    %INCLUDE klevkeys

    %INCLUDE klevkmsk

    VAR

    file_var : FILE

    tmp_int : INTEGER

    tmp_str : STRING[128]

    status : INTEGER

    entry : INTEGER

    loop1 : BOOLEAN

    BEGIN

    SET_FILE_ATR(file_var, ATR_IA)

    SET_VAR(entry, '*SYSTEM*','$HOST_CFG[1].$SERVER_PORT',8000,status)

    WRITE(' VAR status = ',status,CR)

    -- Connect the tag

    MSG_CONNECT('C1:',status)

    WRITE(' Connect status = ',status,CR)

    MSG_DISCO('C1:',status)

    WRITE('Disconnect status=',status,CR)

    --loop1 = TRU

    END TestServeur

    I'm not sure if I have to do it like that or if I can just create a file .txt or an excel file and read informations on that excel file with Roboguide (maybe with a karel program or just with roboguide function, I don't know) but the thing is that I have to read these informations in real time. And I didn't found a function on roboguide to read file from my PC.

    Also just to be more precise, what I want to do is to move my robot with voice.

    Images

    • pasted-from-clipboard.jpg
      • 43.27 kB
      • 573 × 639
      • 33
  • jmd2777
    Reactions Received
    34
    Trophies
    4
    Posts
    193
    • May 11, 2021 at 4:01 PM
    • #4

    First, I have to warn you that this will not be easy. You will need to commit time to reading Fanuc manuals on Karel and User Socket Messaging just to get the communication working. To initiate robot motion from an external source is another entire challenge that you will need to tackle.

    Since you have a training cell from Fanuc, I would recommend trying to get as much help as possible from them. For example, they have software add-ons that provide "motion streaming".


    Also, RoboGuide is a simulation of a real robot. So you mentioned the possibility that RoboGuide could read motion commands from a file, thats not really possible. You have to approach it like an actual robot.

  • MatlabXFanuc
    Trophies
    2
    Posts
    9
    • May 11, 2021 at 4:20 PM
    • #5
    Quote from jmd2777

    First, I have to warn you that this will not be easy. You will need to commit time to reading Fanuc manuals on Karel and User Socket Messaging just to get the communication working. To initiate robot motion from an external source is another entire challenge that you will need to tackle.

    Since you have a training cell from Fanuc, I would recommend trying to get as much help as possible from them. For example, they have software add-ons that provide "motion streaming".


    Also, RoboGuide is a simulation of a real robot. So you mentioned the possibility that RoboGuide could read motion commands from a file, thats not really possible. You have to approach it like an actual robot.

    Actually, I have already read the manual from FANUC on KAREL programmation but it didn't really help me for now, I saw things on KAREL Server/Client but they are only giving us a program and the program didn't work when I put it in on Roboguide, there is some issues when I try to switch it from .kl to .pc with roboguide

    And they are not explaining what all functions on the program are doing..

    And yes, the problem is that i can't setup the communication, i'm trying to use User socket messaging but, didn't found how..

    What do you mean about "motion streaming" ? Can you tell me more about it ?

    And about your last sentence, I though maybe like an actual real robot, it can read a file like if it was an I/O from a PLC and then it's starting a program ?

  • jmd2777
    Reactions Received
    34
    Trophies
    4
    Posts
    193
    • May 11, 2021 at 5:01 PM
    • #6
    Quote from MatlabXFanuc

    What do you mean about "motion streaming" ? Can you tell me more about it ?

    Fanuc has an add-on software package for nearly everything. This includes packages for sending motion instructions from external sources.

    "Stream Motion

    Streaming motion option allows for an external device to perform path trajectory planning, streaming the path trajectory to the robot in near-real time, allowing for highly flexible and dynamic applications."

    There is another package named Dynamic Path Modification.

    Dynamic control of FANUC Robot in Run-Time

    I am mentioning this because using a software add-on like this would be the standard way of accomplishing your goal. So if you have access to help from Fanuc as a training cell, maybe they would give you the software. That would combine the communication and motion into one. Otherwise you need to figure out the communication first. Then how to take the input and convert it into motion.

    I guess its important to know what your goal is for the motion. The options are:

    1. Matlab sends commands to robot to run a motion program. That means the robot program has positions recorded in it that do not change. All you are doing is deciding which program to run.

    2. Matlab sends positions to the robot and the robot moves to those positions.

  • MatlabXFanuc
    Trophies
    2
    Posts
    9
    • May 11, 2021 at 5:07 PM
    • #7
    Quote from jmd2777

    Fanuc has an add-on software package for nearly everything. This includes packages for sending motion instructions from external sources.

    "Stream Motion

    Streaming motion option allows for an external device to perform path trajectory planning, streaming the path trajectory to the robot in near-real time, allowing for highly flexible and dynamic applications."

    There is another package named Dynamic Path Modification.

    Dynamic control of FANUC Robot in Run-Time

    I am mentioning this because using a software add-on like this would be the standard way of accomplishing your goal. So if you have access to help from Fanuc as a training cell, maybe they would give you the software. That would combine the communication and motion into one. Otherwise you need to figure out the communication first. Then how to take the input and convert it into motion.

    I guess its important to know what your goal is for the motion. The options are:

    1. Matlab sends commands to robot to run a motion program. That means the robot program has positions recorded in it that do not change. All you are doing is deciding which program to run.

    2. Matlab sends positions to the robot and the robot moves to those positions.

    Display More

    Ok thanks, i will contact FANUC to know more about "Stream Motion" or "Dynamic Path Modification"!

    My goal is the one you said : Matlab sends commands to robot to run a motion program. Because i meant to have like 4 or 5 differents program and I just want to decide which program to run using matlab.

  • jmd2777
    Reactions Received
    34
    Trophies
    4
    Posts
    193
    • May 11, 2021 at 6:17 PM
    • #8

    Ok. I misunderstood your goal.

    "Stream Motion" or "Dynamic Path Modification" is mostly for Option 2.

    If you only need Option 1, then the link below shows the typical way of starting programs remotely (PROGRAM NUMBER SELECT PNS). However, that requires a PLC.

    https://www.onerobotics.com/posts/2016/sta…robots-in-auto/

    You can also create your own custom version of this using Karel and User Socket Messaging. Which is how you started before I got you off on a tangent. Sorry.

  • hermann
    Reactions Received
    405
    Trophies
    9
    Posts
    2,596
    • May 11, 2021 at 10:38 PM
    • #9

    If Matlab can send http requests you can use those to start a program. But then you also need a small Karel program that handles those requests. There are examples in the Fanuc documentation for network interface.

  • HawkME
    Reactions Received
    568
    Trophies
    10
    Posts
    3,268
    • May 12, 2021 at 12:28 AM
    • #10

    If you can send HTTP then you don't even need Karel. HTTP can set register values. You can monitor them in BGLOGIC to start a main program. In your main program you can conditionally call subprograms based on the register values.

  • MatlabXFanuc
    Trophies
    2
    Posts
    9
    • May 12, 2021 at 4:43 PM
    • #11

    What are you guys meaning with HTTP ? I saw on the "Fanuc documentation for network" an option for HTML program but it's not what i want it's only to build new interface for the teach pendant.

  • MatlabXFanuc
    Trophies
    2
    Posts
    9
    • May 12, 2021 at 4:45 PM
    • #12
    Quote from jmd2777

    Ok. I misunderstood your goal.

    "Stream Motion" or "Dynamic Path Modification" is mostly for Option 2.

    If you only need Option 1, then the link below shows the typical way of starting programs remotely (PROGRAM NUMBER SELECT PNS). However, that requires a PLC.

    https://www.onerobotics.com/posts/2016/sta…robots-in-auto/

    You can also create your own custom version of this using Karel and User Socket Messaging. Which is how you started before I got you off on a tangent. Sorry.

    Don't worry it's my bad.

    But yeah I think i can do it using Karel and User Socket Messaging but the connection didn't work and there is not a lot of documentation about that ... :unamused_face:

  • jmd2777
    Reactions Received
    34
    Trophies
    4
    Posts
    193
    • May 12, 2021 at 5:41 PM
    • #13

    For socket messaging you need to first have

    1. Configure the SM server in Host Comm in the robot. This is covered in the "Setting up a Server Tag" section of the Karel manual. Pay attention to the tag that you use. I recommend that you configure S3 because that is what the example in the Karel manual uses.

    2. Build and Run the Karel program. I think theres a problem with the program you posted previously. For example, it shows MSG_CONNECT('C1:',status). That would be used if the robot were the client (C1 means use the settings in Client 1 slot of Host Comm). You want the robot to be the server. Use the example program from the Karel manual for a server.

    Pay attention to 2 of the lines in the server example.

    1. When they set the system variable for $HOSTS_CFG[3].$SERVER_PORT, that value is the port used for socket messaging. So when you try to connect with your Matlab client you will need to know the port to use. Also the [3] means that you are setting the port for S3 connection.

    2. MSG_CONNECT('S3:', status) - the 'S3' means that its going to use the settings configured in Server 3 of Host Comm.

  • hermann
    Reactions Received
    405
    Trophies
    9
    Posts
    2,596
    • May 12, 2021 at 5:59 PM
    • #14
    Quote from MatlabXFanuc

    .. I saw on the "Fanuc documentation for network" an option for HTML program but it's not what i want..

    Those HTML pages can trigger put/get requests to the robot, this can also be done with many programming languages. And I think also with mathlab.

    With the correct put/get requests you can start a Karel program with different parameters, or set register values and so on.

  • HawkME
    Reactions Received
    568
    Trophies
    10
    Posts
    3,268
    • May 12, 2021 at 7:29 PM
    • #15

    Matlab can send an HTTP request. I think that would be the simplest option.

    HTTP is the communication protocol used by all web pages on the internet and is commonly used for computer applications to communicate to each other. Google it.

  • MatlabXFanuc
    Trophies
    2
    Posts
    9
    • May 17, 2021 at 2:32 PM
    • #16

    Ok guys well, I found the solution, matlab updates a .txt file and I succeeded with the KAREL to read or write in this file what allows me to launch a robot program according to what roboguide reads !

    Now I hope it will work in real-time ! :grinning_face_with_smiling_eyes:

    Thanks you guys, you help me a lot ! :smiling_face:

    Edited once, last by MatlabXFanuc (May 17, 2021 at 3:16 PM).

  • mahboobelahi93
    Reactions Received
    1
    Trophies
    2
    Posts
    82
    • October 13, 2021 at 11:22 AM
    • #17
    Quote from HawkME

    If you can send HTTP then you don't even need Karel. HTTP can set register values. You can monitor them in BGLOGIC to start a main program. In your main program you can conditionally call subprograms based on the register values.

    Hi HawkME,

    can you provide some examples for HTTP and BGLOGI to start a program?

    Also, have a look at the following thread: PC and FANUC robot TCP/IP Communication and please provide your insight.

    Thanks

  • HawkME
    Reactions Received
    568
    Trophies
    10
    Posts
    3,268
    • October 13, 2021 at 1:44 PM
    • #18

    Use the following call to set a register value, in this example R[1], just replace the IP address with your robot:

    http://127.0.0.1/karel/ComSet?s…alFlag=-1&sFc=2

    Then have a BG Logic program monitor that register and if it changes value you can manipulate Flags. The flags can either be tied to UI signals to start the robot program or to a macro.

  • HawkME
    Reactions Received
    568
    Trophies
    10
    Posts
    3,268
    • October 13, 2021 at 1:52 PM
    • #19

    I looked at the other post and my insight is: I don't understand why you would want to do that. If it's just an academic exercise that's fine, but I would never use a cloud app to control the motion of a robot. I don't think it would be practical in the real world. The cloud app could be used for data collection, but sounds like a bad idea for motion control.

  • mahboobelahi93
    Reactions Received
    1
    Trophies
    2
    Posts
    82
    • October 13, 2021 at 2:01 PM
    • #20

    Hi HawkME,

    Thanks for your response.

    Yes, it is an academic exercise.

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

Tags

  • robot
  • Fanuc
  • karel
  • Ethernet
  • TCP/IP
  • MATLAB
  • Karel programming
  • Karel compilator
  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