Vention's Blog

How-To Guide: MachineMotion Control Using the Universal Robot Controller

Blog / #tech
How-To Guide: MachineMotion Control Using the Universal Robot Controller
Markdown Plus exported HTML

Table of Contents

Introduction

The Vention MachineMotion controller supports direct communication with the CB3 Universal Robots controller. This integration makes it simple and cost-effective to create systems that unite UR six-axis robot arms with Vention automation components. Using standard URScript functions, MachineMotion can be controlled directly from the UR teach pendant.

Figure 0: UR5 Mounted on a Vention 7th Axis Range Extender

This article will explain the setup process to control MachineMotion from a UR controller.

Connecting Sensors & Motors

MachineMotion ships with pre-labeled motors and sensors. Depending on the application, the system can have up to six (6) motors (three [3] independent axes) and nine (9) sensors. Pre-labeled motors and sensors match their corresponding connectors on the controller front panel (see Figure 1).

Figure 1: MachineMotion Labelled Connectors

As an example, the system diagram below represents a singe-axis system that utilizes two end-of-travel sensors and one motor.

Figure 2: 1-Axis MachineMotion Example System

Connecting the UR Controller to MachineMotion

Communication between the UR controller and MachineMotion uses Ethernet. The UR controller has an Ethernet port available at the bottom of the unit, and the MachineMotion has one on its front panel. The two units shall be connected using the Ethernet cable provided with MachineMotion. This configuration is peer-to-peer.

Figure 3: 1-Axis MachineMotion Example System with Ethernet Peer-to-Peer Connection to UR Controller

In the system, the UR Controller is the master controller (client). It runs the application level program and sends commands and queries to the MachineMotion controller (server).

Configuring the Network

In order for the Ethernet communication to function, both devices need to be properly configured.

MachineMotion Ethernet Interface Configuration

  1. Connect MachineMotion to a 120Vac power source via the power cable and POWER connector.
  2. Connect a computer that has Google Chrome installed to the USB cable of MachineMotion.
  3. Power on the system using the green rocker switch.
  4. Wait ~ 65 seconds for the system to complete its booting sequence.
  5. Using Google Chrome, browse to 192.168.7.2:8888/_appControlCenter.html
  6. A window (see Figure 4) will be displayed.
  7. The field in boxed red can be edited to set the IP address of the MachineMotion controller. The default suggested IP is 192.168.0.17
  8. Once the field is modified with the proper IP address, simply click the green "update" button beside it.
  9. The new IP will become visible in the "Live IP" field just above.

Figure 4: Vention MachineApp: ControlCenter

MachineMotion IP Addresses

The MachineMotion controller has two (2) different network interfaces: ETHERNET and USB. These two (2) interfaces are distinct, and consequently can be configured differently. They have different IP addresses. The table below highlights the differences between the two interfaces:

Physical Port IP Address Configurable Default Netmask Default Gateway
ETHERNET [default = 192.169.0.17] YES 255.255.255.0 192.168.0.1
USB [192.168.7.2] NO 255.255.255.0 192.168.7.1

MachineMotion IP Ports

The MachineMotion controller serves different ports. The regular Vention Apps can be accessed on port "8888" and communication for the UR Controller is done via port "9999".

UR Controller Ethernet Interface Configuration

  1. On the teach pendant home screen, click on "Setup Robot" (Figure 5)

Figure 5: Polyscope Home Screen

  1. From the "Setup Robot" screen, click on "Network." (Figure 6)

Figure 6: Setup Robot Screen

  1. Enter the parameters as seen in Figure 7. Note that "192.168.0.18" is used here. Any address in the "192.168.0.xxx" subnetwork is acceptable. The other parameters should be configured as seen in Figure 7.

Figure 7: Network Parameters Setup

Controlling MachineMotion via URScript

Standard URScript Functions

Several commands can be sent to the MachineMotion via standard URScript functions. The most useful ones in the context of interfacing with MachineMotion are listed below.

  • socket open(address, port, socket name='socket 0')
  • socket read string(socket name='socket 0', prefix='', suffix='')
  • socket send string(str, socket name='socket 0')
  • socket_get_var(name, socket_name='socket_0')
  • socket_set_var(name, value, socket_name='socket_0')

MachineMotion Commands

The command table that is presented below details the different commands that can be sent to the MachineMotion controller via standard URScript functions. The command table basically explains what data should be placed in the standard URScript functions to successfully communicate with the MachineMotion controller.

Note that all fields between "<" and ">" are user inputs.

Commands Table

Command Number Command Name Description URScript 3.5.3 Call Command Completed Response Command Received Response
0 openConnection Open the socket connection with MachineMotion. socket_open("<ip_address>", 9999, "MachineMotion") "MachineMotion connection established" none
1 isReady Queries MachineMotion to know if it is ready to receive commands. This function indicates if the MachineMotion system is initialized and ready for operation after a connection event. socket_send_string("isReady", "MachineMotion") "MachineMotion isReady = true" or "MachineMotion isReady = false" none
2 isBusy Queries MachineMotion to know if it is busy processing commands or if its command buffer is full. socket_send_string("isBusy", "MachineMotion") "MachineMotion isBusy = true" or "MachineMotion isBusy = false" none
3 isMotionCompleted Queries MachineMotion to determine if motion is currently being executed. This function is useful for waiting for the completion of a movement. socket_send_string("isMotionCompleted", "MachineMotion") "MachineMotion isMotionCompleted = true" or "MachineMotion isMotionCompleted = false" none
4 im_stop Immediately stops motion on all axes. socket_send_string("im_stop", "MachineMotion") none "Ack"
5 im_home_axis_1 Returns axis 1 to its home location. socket_send_string("im_home_axis_1", "MachineMotion") "MachineMotion im_home_axis_1 = completed" none
6 im_home_axis_2 Returns axis 2 to its home location. socket_send_string("im_home_axis_2", "MachineMotion") "MachineMotion im_home_axis_2 = completed" none
7 im_home_axis_3 Returns axis 3 to its home location. socket_send_string("im_home_axis_3", "MachineMotion") "MachineMotion im_home_axis_3 = completed" none
8 im_home_axis_all Returns all axes to their home locations. sequentially: axis 1, axis 2, axis 3 socket_send_string("im_home_axis_all", "MachineMotion") "MachineMotion im_home_axis_all = completed" none
9 im_move_abs_1 Immediately moves axis 1 to the specified absolute position. socket_set_var("im_move_abs_1", <position>, "MachineMotion") none "Ack"
10 im_move_abs_2 Immediately (moves axis 2 to the specified absolute position. socket_set_var("im_move_abs_2", <position>, "MachineMotion") none "Ack"
11 im_move_abs_3 Immediately moves axis 3 to the specified absolute position. socket_set_var("im_move_abs_3", <position>, "MachineMotion") none "Ack"
12 de_move_abs_1 This is a delayed move. This will move axis 1 to the specified absolute position after the de_move_abs_exec command is sent. socket_set_var("de_move_abs_1", <position>, "MachineMotion") none "Ack"
13 de_move_abs_2 This is a delayed move. This will move axis 2 to the specified absolute position after the de_move_abs_exec command is sent. socket_set_var("de_move_abs_2", <position>, "MachineMotion") none "Ack"
14 de_move_abs_3 This is a delayed move. This will move axis 3 to the specified absolute position after the de_move_abs_exec command is sent. socket_set_var("de_move_abs_3", <position>, "MachineMotion") none "Ack"
15 de_move_abs_exec This command will execute the latest de_move_abs_1, de_move_abs_2 and de_move_abs_3 commands that were sent to the controller. socket_send_string("de_move_abs_exec", "MachineMotion") none "Ack"
16 im_move_rel_1 Immediately moves axis 1 by the distance specified relative to the current location of the axis. The distance parameter can be negative. socket_set_var("im_move_rel_1", <distance>, "MachineMotion") none "Ack"
17 im_move_rel_2 Immediately moves axis 2 by the distance specified relative to the current location of the axis. The distance parameter can be negative. socket_set_var("im_move_rel_2", <distance>, "MachineMotion") none "Ack"
18 im_move_rel_3 Immediately moves axis 3 by the distance specified relative to the current location of the axis. The distance parameter can be negative. socket_set_var("im_move_rel_3", <distance>, "MachineMotion") none "Ack"
19 de_move_rel_1 This is a delayed move. This will move axis 1 relative to the its current position by the distance specified in the distance parameter after the command de_move_abs_exec is sent. socket_set_var("de_move_rel_1", <distance>, "MachineMotion") none "Ack"
20 de_move_rel_2 This is a delayed move. This will move axis 2 relative to the its current position by the distance specified in the distance parameter after the command de_move_abs_exec is sent. socket_set_var("de_move_rel_2", <distance>, "MachineMotion") none "Ack"
21 de_move_rel_3 This is a delayed move. This will move axis 3 relative to the its current position by the distance specified in the distance parameter after the command de_move_abs_exec is sent. socket_set_var("de_move_rel_3", <distance>, "MachineMotion") none "Ack"
22 de_move_rel_exec This command will execute the latest de_move_rel_1, de_move_rel_2 and de_move_rel_3 commands that were sent to the controller. socket_send_string("de_move_rel_exec", "MachineMotion") none "Ack"
23 speed Configures the travel speed of the system in mm/minute. For single-axis movements, the travel speed of the axis will be equal to this setting. For multi-axis synchronous moves, the overall motion speed will be equal to this setting. socket_set_var("speed", <speed_value>, "MachineMotion") none "Ack"
24 acceleration Configures the travel acceleration of the system in mm/s2. For single-axis movements, the travel acceleration of the axis will be equal to this setting. For multi-axis synchronous moves, the overall motion acceleration will be equal to this setting. socket_set_var("acceleration", <acceleration_value>, "MachineMotion") none "Ack"
25 de_axis_1_microsteps_config This is a delayed command. It configures the microstepping of the software to match the hardware setting that is in place on the stepper motor drivers for axis 1. uSTEPPING IS NOT A SOFTWARE SETTING. THIS COMMAND IS INTENDED FOR USE IF THE HARDWARE SETTING PHYSICALLY IS CHANGED INSIDE THE CONTROLLER VIA THE DIP SWITCHES. Possible values here are: 1, 2, 4, 6, 8 and 16. This configuration will take effect after the command de_axis_1_config_exec is sent to the controller. socket_set_var("de_axis_1_microsteps_config", <micro_steps>, "MachineMotion") none "Ack"
26 de_axis_1_mechanical_gain_config This setting sets the gain of the axis system used in mm/turn for axis 1. For example, a system that utilizes a Vention ballscrew will have a gain of 5 mm/turn, and a system that utilizes a timing belt will have a gain of 200 mm/turn. socket_set_var("de_axis_1_mechanical_gain_config", <gain>, "MachineMotion") none "Ack"
27 de_axis_1_direction_config This setting sets the direction of the axis. Pass "-1" or "1" to the function. socket_set_var("de_axis_1_direction_config", <direction>, "MachineMotion") none "Ack"
28 de_axis_1_config_exec This command will execute the latest "de_axis_1_microsteps_config," "de_axis_1_mechanical_gain_config" and "de_axis_1_direction_config" that were sent to the controller. socket_send_string("de_axis_1_config_exec", "MachineMotion") none "Ack"
29 de_axis_2_microsteps_config This is a delayed command. It configures the microstepping of software to match the hardware setting that is in place on the stepper motor drivers for axis 2. uSTEPPING IS NOT A SOFTWARE SETTING. THIS COMMAND IS INTENDED FOR USE IF THE HARDWARE SETTING PHYSICALLY IS CHANGED INSIDE THE CONTROLLER VIA THE DIP SWITCHES. Possible values here are: 1, 2, 4, 6, 8 and 16. This configuration will take effect after the command de_axis_2_config_exec is sent to the controller. socket_set_var("de_axis_2_microsteps_config", <micro_steps>, "MachineMotion") none "Ack"
30 de_axis_2_mechanical_gain_config This setting sets the gain of the axis system used in mm/turn for axis 2. For example, a system that utilizes a Vention ballscrew will have a gain of 5 mm/turn, and a system that utilizes a timing belt will have a gain of 200 mm/turn. socket_set_var("de_axis_2_mechanical_gain_config", <micro_steps>, "MachineMotion") none "Ack"
31 de_axis_2_direction_config This setting sets the direction of the axis. Pass "-1" or "1" to the function. socket_set_var("de_axis_2_direction_config", <direction>, "MachineMotion") none "Ack"
32 de_axis_2_config_exec This command will execute the latest de_axis_2_microsteps_config, de_axis_2_mechanical_gain_config and de_axis_2_direction_config that were sent to the controller socket_send_string("de_axis_2_config_exec", "MachineMotion") none "Ack"
33 de_axis_3_microsteps_config This is a delayed (de) command. It configures the microstepping of software to match the hardware setting that is in place on the stepper motor drivers for axis 3. uSTEPPING IS NOT A SOFTWARE SETTING. THIS COMMAND IS INTENDED FOR USE IF THE HARDWARE SETTING PHYSICALLY IS CHANGED INSIDE THE CONTROLLER VIA THE DIP SWITCHES. Possible values here are: 1, 2, 4, 6, 8 and 16. This configuration will take effect after the command de_axis_3_config_exec is sent to the controller. socket_set_var("de_axis_3_microsteps_config", <micro_steps>, "MachineMotion") none "Ack"
34 de_axis_3_mechanical_gain_config This setting sets the gain of the axis system used in mm/turn for axis 3. For example, a system that utilizes a Vention ballscrew will have a gain of 5 mm/turn, and a system that utilizes a timing belt will have has of 200 mm/turn. socket_set_var("de_axis_3_mechanical_gain_config", <micro_steps>, "MachineMotion") none "Ack"
35 de_axis_3_direction_config This setting sets the direction of the axis. Pass "1" or "-1" to the function. socket_set_var("de_axis_3_direction_config", <direction>, "MachineMotion") none "Ack"
36 de_axis_3_config_exec This command will execute the latest de_axis_3_microsteps_config, de_axis_3_mechanical_gain_config and de_axis_3_direction_config that were sent to the controller. socket_send_string("de_axis_3_config_exec", "MachineMotion") none "Ack"
37 de_ethernet_port_ip_config This is a delayed (de) command. It will configure the Ethernet port IP address according to the value of the parameter that is passed. socket_send_string("de_ethernet_port_ip_config--<ip_address>", "MachineMotion") none "Ack"
38 de_ethernet_port_mode_config This is a delayed (de) command. It will configure the Ethernet port mode address according to the value of the parameter that is passed. Accepted values are static or dhcp socket_send_string("de_ethernet_port_mode_config--mode_here", "MachineMotion") none "Ack"
39 de_ethernet_port_config_exec This command will execute the latest de_ethernet_port_ip_config and de_ethernet_port_mode_config that were sent to the controller socket_send_string("de_ethernet_port_config_exec", "MachineMotion") none "Ack"

Commands Message Sequence Diagrams

im vs. de

Some commands utilize the "im" prefix, and some commands utilize the "de" prefix. These commands behave differently.

  • Commands that have the prefix "im" are commands that will be performed immediately by the MachineMotion controller. The "im" commands enable independent axis movements.
UR ControllerMachineMotionPhysical Machineim_move_rel_1, 200AckMotion StartsMotion Endsim_move_rel_2, 200AckMotion StartsMotion Endsim_move_rel_3, 200AckMotion StartsMotion EndsUR ControllerMachineMotionPhysical Machine

  • Commands that have the prefix "de" are commands that will be completed by the controller once a corresponding "exec" command is sent. The "de" commands enable synchronous axis movements.
UR ControllerMachineMotionPhysical Machinede_move_rel_1, 200Ackde_move_rel_2, 200Ackde_move_rel_execAckMotion StartsMotion EndsUR ControllerMachineMotionPhysical Machine

openConnection & isReady

UR ControllerMachineMotionopenConnection"MachineMotion connection established"isReady"MachineMotion isReady = false""MachineMotion isReady = true"alt[ is not ready ][ is ready ]UR ControllerMachineMotion

"Ack" Handshake

UR ControllerMachineMotionPhysical MachinecommandAckMotion StartsMotion EndsUR ControllerMachineMotionPhysical Machine

Pre-Built MachineMotion Functions in URScript

Transactional messaging is recommended when communicating between the UR controller and the MachineMotion controller. To simplify this task, a few pre-built function definitions were prepared by Vention and can be used in the URScript environment. These functions should be added to the top of the first script file used in the robot program. This allows for utilization of these functions throughout all other scripts in the same robot program (see Example Scripts).

# Waits for a certain message from the MachineMotion controller.
waitForResponse(expected_response)
# Sends a string and waits until the expected response is received.
def sendString(string, expected_response)
# Queries the MachineMoton with a string command as long as the expected response is not received.
pollString(string, expected_response)
# Sends a variable and waits until the expected response is received.
def sendVariable(var, data, expected_response):

URScript Program Examples

URScript files can be used inside the teach pendant and added as an execution element within a robot program. For more information on this procedure, consult the following documentation: UrSript From the UR Teaching Pendant

Configuration Script Example

The configuration script contains the necessary steps to set up the MachineMotion controller at the beginning of a robot program. A script similar to the one below should be put in place when using the MachineMotion controller in a UR robot program.

Script Flow Diagram

wait for connection
wait for isReady confirmation
start
1. open MachineMotion socket connection
2. send isready command
3. configure speed
4. configure acceleration
5. configure axes parameters
6. home axis 1
7. home axis 2

Example Configuration Script

# The configuration script defines some useful functions for simplifying transactional messaging.

def waitForResponse(expected_response):
    response = socket_read_string("MachineMotion")
    while response != expected_response:
        response = socket_read_string("MachineMotion")
    end
end

def sendString(string, expected_response):
    # Flushing the data buffer in case old data is in it
    # flush_buffer = socket_read_string("MachineMotion")
    
    socket_send_string(string, "MachineMotion")
    response = socket_read_string("MachineMotion")
    
    if(response == "nAck"):
        popup("nAck received")
    end
    
    while response != expected_response:
        response = socket_read_string("MachineMotion")
        if(response == "nAck"):
           popup("nAck received")
        end
    end
end

def pollString(string, expected_response):
    # Flushing the data buffer in case old data is in it
    # flush_buffer = socket_read_string("MachineMotion")
    
    socket_send_string(string, "MachineMotion")
    response = socket_read_string("MachineMotion")
    
    if(response == "nAck"):
        popup("nAck received")
    end
    
    while response != expected_response:
    sleep(1)
        socket_send_string(string, "MachineMotion")
        response = socket_read_string("MachineMotion")
        
        if(response == "nAck"):
            popup("nAck received")
        end
        
    end
end

def sendVariable(var, data, expected_response):
    # Flushing the data buffer in case old data is in it
    # flush_buffer = socket_read_string("MachineMotion")
    
    socket_set_var(var, data, "MachineMotion")
    response = socket_read_string("MachineMotion")
    
    if(response == "nAck"):
        popup("nAck received")
    end
    
    while response != expected_response:
        response = socket_read_string("MachineMotion")
        
        if(response == "nAck"):
            popup("nAck received")
        end
    end
end

# 1. Open the socket connection with the MachineMotion controller and wait for the connection completion handshake
socket = socket_open("192.168.7.2", 9999, "MachineMotion")
waitForResponse("MachineMotion connection established")

# 2. Send the isReady command to the MachineMotion controller to ensure that it is ready to receive new commands
sendString("isReady", "MachineMotion isReady = true")

# 3. Configure the travel speed
sendVariable("speed", 500, "Ack")

# 4. Configure the travel acceleration
sendVariable("acceleration", 50, "Ack")

# 5. Configure the uStepping and mechanical gain of each axis
sendVariable("de_axis_1_microsteps_config", 8, "Ack")
sendVariable("de_axis_1_mechanical_gain_config", 5, "Ack")
sendVariable("de_axis_1_direction_config", 1, "Ack")
sendString("de_axis_1_config_exec", "Ack")

sendVariable("de_axis_2_microsteps_config", 8, "Ack")
sendVariable("de_axis_2_mechanical_gain_config", 5, "Ack")
sendVariable("de_axis_2_direction_config", 1, "Ack")
sendString("de_axis_2_config_exec", "Ack")

sendVariable("de_axis_3_microsteps_config", 8, "Ack")
sendVariable("de_axis_3_mechanical_gain_config", 5, "Ack")
sendVariable("de_axis_3_direction_config", 1, "Ack")
sendString("de_axis_3_config_exec", "Ack")

# 6. Send a homing command for axis 1
sendString("im_home_axis_1", "MachineMotion im_home_axis_1 = completed")

# 7. Send a homing command for axis 2
sendString("im_home_axis_2", "MachineMotion im_home_axis_2 = completed")

Motion Script Example

Once the configuration script has been run, the MachineMotion move functions can be used. The script below shows a few different commands that can be utilized. Note that all functions used in the configuration scripts can also be utilized in real time to make configuration modifications of, for example, the speed or acceleration of certain specific moves, on the fly.

Script Flow Diagram

wait for move completion
wait for move completion
wait for move completion
wait for move completion
wait for move completion
URSrcipt start
1. immediate absolute move +100mm on axis 1
2. immediate absolute move +100mm on axis 2
3. delayed absolute move to 0mm on both axis 1 and axis 2
4. immediate relative move +100mm on axis 1
5. immediate relative move +100mm on axis 2
6. delayed relative move of -100mm on both axis 1 and axis 2

Script

# im abs
sendVariable("im_move_abs_1", 100, "Ack")
pollString("isMotionCompleted", "MachineMotion isMotionCompleted = true")
sendVariable("im_move_abs_2", 100, "Ack")
pollString("isMotionCompleted", "MachineMotion isMotionCompleted = true")

# de abs
sendVariable("de_move_abs_1", 0, "Ack")
sendVariable("de_move_abs_2", 0, "Ack")
sendString("de_move_abs_exec", "Ack")
pollString("isMotionCompleted", "MachineMotion isMotionCompleted = true")

# im rel
sendVariable("im_move_rel_1", 100, "Ack")
pollString("isMotionCompleted", "MachineMotion isMotionCompleted = true")
sendVariable("im_move_rel_2", 100, "Ack")
pollString("isMotionCompleted", "MachineMotion isMotionCompleted = true")

# de rel
sendVariable("de_move_rel_1", -100, "Ack")
sendVariable("de_move_rel_2", -100, "Ack")
sendString("de_move_rel_exec", "Ack")
pollString("isMotionCompleted", "MachineMotion isMotionCompleted = true")

sleep(5)

Create an Assembly in Your Browser
...in Minutes!

Machine top 68073c6052a33061d823ee14944f0871f1d8c8d0e0d1cde5fb64e5ff4029e918

Subscribe to the Vention's Newsletter:

Your Email Address:

Subscribe