Advance Trainning
Advance Trainning
01 DobotStudio Pro
CONTENT 02 Blockly
05 Scripting
01 DobotStudio Pro
DobotStudio Pro
DobotStudioPro is user-friendly, with easy-to-use functions and a simple and practical interface,
which can help users quickly master the use of Dobot robot.
DobotStudio Pro-Network Cable Connection
Connection
IP address
User Credential
WIFI
IP Address
• Input \\192.168.1.6
DobotStudio Pro-Connect the Robot
Connection
• Open DobotStudioPro
• Click【Connection】
DobotStudio Pro-Introduction
Blockly-New project
DobotStudio Pro-Points
[Point Management]
• Click【Pause】to
suspend the program.
• Click【Resume】to
continue the program.
• Click【Stop】to end
the project.
• Click【Script】to
convert the blocks
into scripts.
02 Blockly-
A d va n c e d
Applications
Advanced Blockly Programming
Subroutine
Initialization
Print:Start initialization
Print:Initialization completed
Initialization Program
Using subthread in material detection
Description Description
The main thread of the program. This The subroutine will run synchronously with the
block is included in the programming area main program, but the subthread cannot use
by default when you create a new project control commands, only variable operations or
IO control are available.
Restrictions Restrictions
There can be only one "Start" block in a project. A project can have up to 4 subroutines.
Material Detection
Subroutine start
- Select the DO terminal, including the controller and tool. 6.Quantity increase 1
End
Material Detection
Pickup
If there is a material
is
Description Description
Description
Create a pallet. Get the count of the pallet Get the coordinates of the pallet
points. point.
Parameters
Parameters Parameters · The name of the pallet
The name of the pallet. The name of the pallet. · The number of the point.
Configure Pallet Block
Configure Pallet Block
Dimension
Configure the pallet ——
• One-dimensional: The materials are arranged in rows and the
Click the block to enter the configure panel total number of materials is equal to the number in the X-
direction.
• Two-dimensional: the materials are arranged in a square, and
the total number of materials is equal to the product of the
number of X-direction and Y-direction.
• Three-dimensional: the materials are stacked in a cube, and the
total number of materials is equal to the product of the
numbers in the three directions.
Points
Placement
Move up
Physical layer, which provides the physical interface to the device and is compatible with
Layer 1
commercially available media/network adapters
Layer 2 Data link layer, formatting signals to source/destination hardware-addressed data frames
Function
Description Desccription
Code
Coil Output bits of the PLC, switchable, readable 0x01 read coil register
Register and writable in Modbus 0x05 write single coil register
Discrete Input bits of the PLC, switchable, read-only in
Input 0x0F write multiple coil registers
Register Modbus
0x02 read discrete input register
Registers that can only be changed from the
Input 0x04 read input register
analog inputs in the PLC, read-only in the
Register
0x03 read holding register
Modbus
0x06 write single holding register
Holding Registers for outputting analog signals in
Register 0x10 write multiple holding registers
PLC, readable and writable in Modbus
Modbus Communication - Four types of addresses
Based on our existing hardware interface, we currently use the Modbus-TCP.
Normally the Modbus address consists of 5 digits, including the starting data type designation, followed by
an offset address. The Modbus Master protocol library maps the standard Modbus address to the Modbus
function number, to read and write the data from the slave.
Temperature
Sensor
Create Modbus communication Transfer data via Modbus Control robot’s motion,
Connect
read the values Change the values
debuging software
in debuging software in debuging software
with robot server
Modbus Communication - Blockly
slave_id: ID of PLC
Description
【Case 2】
Create a Modbus master and connect it to the slave.
The robot works as a Modbus slave and the PLC
- The port of the Modbus slave. port: the port number of the robot
Description Description
Read the value of multiple consecutive coil Write the value of multiple consecutive coil
registers. registers.
Parameters Parameters
- Coil register start address, value range: 0 ~ - Coil register start address, the range of value: 0 ~
40z95. 4095.
- Read consecutive register bits.
- The bits of the value to be written.
Return Value
- Enter the value to be written, fill in an array with
The value of the specified address of the coil
register is stored in the table. the same length as the number of bits to be written,
The first value in the table is the value of the each bit can only be 0 or 1.
start address of the coil register.
Modbus Communication - Practice 1
Steps
02 Use the write coil instruction to write the value of addresses 1000 to 1004 to 1.
03 first write 1 to the 1006, 1007 and 1009 addresses, then print the values from 1005 to 1009.
10 Move to P1
Robot as 20 Move to P2
Read the data of
Write the data of
Start ModbusTCP
hold register 1000 End
30 register 1005
Server Move to P3
40 Move to P14
Connect
Send the data to Read the data of
debuging software
register 1000 register 1005
with robot server
Modbus Communication - Blockly
If the value of register address 1000 is equal to 10, move the robot to P1, then write the value
02 of address 1005 to 10.
03 If the value of register address 1000 is equal to 20, move the robot to P2, then write the value
of address 1005 to 20.
If the value of register address 1000 is equal to 30, move the robot to P3, then write the value
04 of address 1005 to 30.
05 If the value of register address 1000 is equal to 40, move the robot to P4, then write the value
of address 1005 to 40.
Modbus Communication - Blockly
Description Description
Get the value of the input register. Get the value of the discrete input register.
Parameters Parameters
· The start address, range: 0~4095. · The start address, range: 0~4095.
· Choose the data type:
- U16: 16-bit unsigned integer (2 bytes, 1 register)
- U32: 32-bit unsigned integer (4 bytes, 2 registers) Return Value
- F32: 32-bit single-precision floating-point The value of the discrete input register.
number (4 bytes, 2 registers)
- F64: 64-bit double-precision floating-point
number (8 bytes, 4 registers)
Return Value
The value of the input register.
Modbus Communication - Blockly
Description Description
Wait for a certain value of the input register Wait for a certain value of the discrere input
to trigger the next instruction. register to trigger the next instruction.
Parameters
Parameters
· The start address, range: 0~4095.
· Choose the data type: · The start address, range: 0~4095.
- U16: 16-bit unsigned integer (2 bytes, 1
register) · The required value of the register.
- U32: 32-bit unsigned integer (4 bytes, 2
registers)
- F32: 32-bit single-precision floating-point
number (4 bytes, 2 registers)
- F64: 64-bit double-precision floating-point
number (8 bytes, 4 registers)
· The required value of the register.
Modbus Communication - Blockly
Description
Reads the value of consecutive holding registers.
Parameters
· Holding register start address, range: 0~4095
Read consecutive holding registers
· Number of the values.
Return Value
The values of the specific address which are
stored in table.
The first value in table is the value of the
start address.
Modbus Communication
Create ModbusTCP communications, control the robot to perform the corresponding actions.
Coil Register
1002 Placement
Hold Register
The robot reads the coil address 1000 until the Set address 1000 to 1
coil value is 1, then starts initialization.
The robot reads the coil address 1001 until the coil
Set address 1001 to 1
value is 1, and then performs the pickup action.
No
End
Modbus Communication - Practice 3
Wait for coil address 1000 to be 1, start the initialization program, write coil 1005 to 1. When
02
initialization is completed, write coil address 1005 to 0
If the value of address 1001 is 1, the robot will start to pick up the material. Write coil 1006
03 to 1 when the pickup is complete.
04 If the value of address 1002 is 1, the robot unloads the material and sets address 1006 to zero.
05 After placing a material, write the current quantity value into the holding register address 1000.
06 Repeat 6 times.
Modbus Communication - Remote Control Definition
Remote Output Description
Remote Control Definition(V3.5.2.0)
Feedback on whether the current script is
Script running status
Remote Input running or not
The TCP/IP protocol refers not only to the TCP and IP protocols, but to a cluster of protocols such as
FTP, SMTP, TCP, UDP, IP, etc. It is called the TCP/IP protocol because the TCP and IP protocols are the
most representative of the TCP/IP protocols.
ICMP ICMP
Network layer IP
ARP RARP
Three-Way Handshake
Core Idea
Four-Way Wavehand
• A:OK, goodbye
Core Idea
Vision Application
Create TCP Server and wait for the Debugging tool open up a client and
debugging tool to connect. connect to the robot
Send OK to the debugging tool after Debugging tool receive the data from the
successful connection robot
The robot wait for the debugging tool to Debugging tool send hello to the robot
receive data
END
TCP/IP in Blockly
Description Description
Create TCP client, and communicate with the Create a TCP server and wait for the client
specified TCP server. to make a connection.
Parameters Parameters
• Select the SOCKET number to establish up • Select the SOCKET number to establish up to
to 4 TCP communication links. 4 TCP communication links.
• The port of the TCP server. • The port of the TCP server. Note that this
cannot be set to 502 or 8080.
TCP/IP in Blockly
Description Description
Close the specified SOCKET to Sending variables via TCP communication.
disconnect this communication link.
Parameters Parameters
描
Description
述
03 Use the TCP helper to send a "hello" to the robot, then the robot receives it and prints it out.
Note: You need to turn off your computer's firewall, otherwise you may not be able to connect.
TCP/IP in Blockly – Practice 1
TCP/IP in Blockly – Practice 1
How to implement TCP/IP communication with robots
The robot creates a TCP server port, connects to the debug assistant, sends data using the debug assistant,
and the robot parses through the commands to extract the useful data for judgment.
Start
Create TCP Server and wait for the Debugging tool open up a client and
debugging tool to connect connect to the robot
Robot wait for the data from the The debugging tool send
debugging tool “100,200,300 ”to the robot
Take the second number from the result Debugging tool receive the number
and send to the debugging tool from the robot
END
TCP/IP in Blockly
Description Description
Converts a specified string to an array, separating
Gets the element in the specified array at the
the strings according to the specified separator. For
specified subscript position. The subscript indicates
example, if the string is "1|2|3" and the separator is
the position of the element in the array, for
|, the converted array will be {[1]=1,[2]=2,[3]=3}.
example, the subscript of 8 in the array {7,8,9} is 2.
Parameters Parameters
• An oval block with a string return value or
• Target array, using the oval block with the
enter it directly.
return value of array.
• The separator used for the conversion.
• The subscript of the specified element.
Return Value
Return Value
The converted array. The value of the specified location in the array.
TCP/IP in Blockly – Practice 2
01 Create variables: [CPread] to store variables for incoming data; [SplitData] to store
variables for the split string.
Use the debugging tool to send a set of data, e.g. (100, 200, 300), splitting the data
02 using commas, and when the robot receives the data, it splits the data and prints the
result of the splitting 。
03 Send the second bit of the received data to the debug tool.
TCP/IP in Blockly – Practice 2
How to implement TCP/IP communication with robots
Create a TCP server port and send OK to the debugging tool after the robot has moved to the initial point.
The debugging tool sends coordinate offset data to the robot in a predefined format. After the robot is in
position, sends the In Position to the debug tool.
Y N
Description Description
Splice two strings into one string, the Compare the size of two strings according to
first string will be followed by the the ACSII code.
second. Parameters
Parameters The two strings to be compared. Can be filled in
The two strings to be spliced together either using oval blocks with a string return
Can be filled in either using oval blocks value or directly.
that return a string value or directly. Return Value
Return Value Returns 0 if string one and string two are equal,
The spliced string. -1 if string one is less than string two, 1 if string
one is greater than string two.
TCP/IP in Blockly
Description
Sets the value of the element in the
Parameters
• Target array, using the elliptical
building blocks whose return value is
an array.
01 Creation of a TCP server, IP: the robot's local IP, port 8000.
02 The robot moves to point P1 after connection, sends OK to the debugging assistant.
03 The debugging assistant sends the offset values to the arm in the format "GO,x,y".
04 The robot receives data cyclically, splitting the received data according to ",".
If the received command is GO, the robot will offset based on the P1 point and send
05
"GOOK" to the debug assistant, otherwise, send GONG to the debug assistant.
Program
5 Control the program
Control
Command Description
This allows the program to execute certain statements repeatedly when the
while…do…end
condition is true.
repeat… until() Repeats the loop until the specified condition is true
General keywords Logical Operators
Command Description Command Description
break Break the loop If one side is false, the result is false.
and
If both sides are true, the result is true.
Define local variables, valid only in the
local
script in which they are defined If one side is true, the result is true.
or
If both sides are false, the result is false.
nil Variable is a null value
return The return of the function The direct inverse of the result of a
not
judgment
enter Next line
Programming Language
Description
Robot global variables can be defined in the "global.lua" file, including the definition of global functions, global points,
global variables, etc.
Global Function
Global Points
Global point example in 6-axis robot.
Global Variables
Script Programming Standard
Queue Commands
Queue Commands
& Execute Commands
& Execute Commands
Queue
Common Queue Commands
The queue is executed in line, first-in,
first-execute. Motion Command, DO
Move(P2) -- Lift up
Without Sync(), the script runs quickly to the last line and returns
Sync command an isGrab value of 0. The robot is probably still on its way to P1. In
fact, we want the script to wait until the robot reaches P2 and the
two are synchronized before executing the last line to check for
isGrab. So add the Sync() command before the check, which
Use of Sync executes to the last line and returns an isGrab value of 1
Move(P1) -- Move to grabbing point
Sync() or
DO(1, ON) -- Grab the item
Go(P1,”SYNC=1”)
Wait(100) -- wait 100ms
Move(P2) -- Lift up
Standards
ReceiveData()
RobotInit()
E.g. receiveData={}
flagAgv=false
homePoint={}
Script Programming Standard
Programming
Specifications
01 按照脚本编程规范进行脚本编程;
Use blockly to control the push motor, after pushing the material, start the conveyor positive
01 rotation until the material is detected. After the robot finish picking, continue to repeat the
push action. The whole process will repeat 6 times and then end the sub-thread operation.
02 The robot picks up the materials and puts them into the tray.
03 Repeat the above process until 6 blocks are placed in the tray.
Emancipation of manpower
Optimization of Human-Machine Collaboration
Thank You
www.dobot-robots.com
400-800-7266
越疆机器人公众号