ARC Pro

Upgrade to ARC Pro

Unleash your creativity with the power of easy robot programming using Synthiam ARC Pro

Initialize Servos

Some robots may have servos that brownout or reboot the EZB on start-up. The first solution is to ensure the robot gets enough power. To complement the power requirements of the robot, we also have a suggestion that will initialize each servo into position individually rather than together at once.

Choosing Power Type


Why Do Servos Require Initialization

There are two types of servos, hobby-style and bi-directional servos. The hobby-style servos are most common, and they do not report their position to the EZB. Instead, a hobby servo responds to position requests from the EZB. This means that the servos will "jump" to their position on start-up. If the servos are resting at a random position 120, and you specify to move to position 90, they will JUMP to 90 no matter what speed is set. When servos jump into position all at once, the combined current draw can exceed the power supply, which causes a voltage dip, and the EZB will brownout or reboot. This is because hobby-style servos are not "Smart" and therefore do not report their position on power-up.

How Servos Work


Work Around

There is a workaround to ease the current draw of servos initializing. The most straightforward workaround is to initialize each servo individually into a position when the EZB starts up. You can do this by creating a script, naming it something like "INIT", and running it when the EZ-B receives a connection from ARC.


*Note: We will use JavaScript for the code examples


Example #1

In this example, servos ports are not linear, or the init positions are different per servo/joint. Also, tweak the sleep() time to give each servo enough time to move into position. It may require one full second (1000 ms) per servo.

Code:

// Initialize every servo into their startup position

Servo.setPosition(d0, 90);
sleep(500)
Servo.setPosition(d1, 10);
sleep(500)
Servo.setPosition(d3, 90);
sleep(500)
Servo.setPosition(d4, 110);
sleep(500)
Servo.setPosition(d6, 90);
sleep(500)
Servo.setPosition(d7, 50);
sleep(500)
Servo.setPosition(d9, 75);
sleep(500)
Servo.setPosition(d10, 90);


Example #2

In this example, the servo initialization positions are all the same degree positions, and the ports are linear. So we can loop through each servo and set the port and position.

Code:

// Initialize every servo into their startup position
for (var port = 0; port < 10; port++) { Servo.setPosition(port, 90); sleep(500); }


How To Run Scripts When EZB Connects

The above example mentions having the script execute when the EZB receives a connection from ARC. You can add scripts to the ARC Connection Control, and they will be executed when the connection is established. There can be a script per EZB so that each EZB will have its script based on the connection. You can either edit & paste the above code examples into the Connection Control script or put the code in a separate script and have the connection control execute it. To have a script execute another script, check out the ControlCommand() syntax.

Connection Control Manual