Setting the speed slider inside program
One example of switching between 2 speeds in the program and one example where the switching is controlled by an input
Examples are valid for:
CB2 Software version: 1.8.16941
CB3 Software version: 3.1.17779
E-Series Software version: All versions
Note that older or newer software versions may behave differently.
These examples can be used for both CB2, CB3 and e-Series.
What is important to notice is that on CB2 the WAIT command in the GUI or sleep() command in script are depended on the speed slider similar to the speed of the robot. This is not the case on CB3/e-Series and makes it possible to replace a loop of sync()'s with a WAIT instead.
Counter based:
This example moves the robot through 3 waypoints in the Robot Program.
In the Thread socket_open is used to connect to the Secondary Client Interface on the robot's own controller. The speed slider is controlled by a float between 0.0 and 1.0. Where 1.0 is 100%.
The example switches between 0.2 and 1.0. After each switch the loop waits 1 second before proceeding. On the CB2 controller the WAIT command in the GUI or sleep() command in script are depended on the speed slider similar to the speed of the robot. At 50% a 1 second wait would take 2 second. At 10% 10 second etc. It is therefore not possible to use these commands reliably. Especially as a speed at 0.0 would mean an infinite long wait.
Setting the speed slider from a running program is only possible on the script level. To send script commands to the controller one must use either port 30001 or 30002.
Primary and Secondary Client Interface link: Remote Control Via TCP/IP
To connect to a server running on the controller one must use the IP address "127.0.0.1", also known as localhost.
The script command sync() uses the frequency of the controller as reference. When no commands are to be executed or calculated a sync() takes 8ms. 125 sync() will therefore yield 1000 milliseconds equal to 1 second wait.
NOTE: Sync() on e-Series is 2ms. Therefore the above is no valid for e-Series
Find the program speedSliderEx_wCounter.urp attached - see bottom of this page.
Input based:
This example moves the robot through 3 waypoints in the Robot Program.
In the Thread socket_open is used to connect to the Secondary Client Interface on the robot's own controller. The speed slider is controlled by a float between 0.0 and 1.0. Where 1.0 is 100%.
The example switches between 0.2 and 1.0. It reads the current state of the input and sets the speed accordingly. The current state is stored and a wait is used to suspend the thread until the input changes state. There is no reason to continuously spending commands to the robot when there are no change in the state. Normally on the CB2 controller the WAIT command in the GUI or sleep() command in script are depended on the speed slider similar to the speed of the robot. But when used together with an expression or input then it uses sync() behind the scenes.
Setting the speed slider from a running program is only possible on the script level. To send script commands to the controller one must use either port 30001 or 30002.
Primary and Secondary Client Interface link: Remote Control Via TCP/IP
To connect to a server running on the controller one must use the IP address "127.0.0.1", also known as localhost.
The script command sync() uses the frequency of the controller as reference. When no commands are to be executed or calculated a sync() takes 8ms(2ms. on e-Series).
Find the program speedSliderEx_wInput.urp and speedSliderEx_wCounter.urp below for download