Setting Servo speeds and Initialization Script Tutorial
Step 3. Servo Speed Init with Multiple Boards
You may have multiple EZ-B's connected to your EZ Builder project, with servos connected to each board. In this case, some slight changes need to made to the servo speed and position "Init" script. To use an example, we will say that we have two EZ-B's connected to "Board 0" and "Board 2" in one EZ Builder project.
1.) Follow one of the previous steps to create an "Init" script, and open it's script editor.
2.) For servos connected to "Board 0", no change in the original "Init" script is needed.
3.) Any script lines that are controlling servos connected to "Board 2" will need to be started with a 2. (a number two and a period), so the script should look something like this...
#Servo speed initialization.
# Servos connected to board 0.
ServoSpeed(D1, 0)
ServoSpeed(D2, 0)
ServoSpeed(D3, 0)
# Servos connected to board 2.
ServoSpeed(2.D4, 0)
ServoSpeed(2.D5, 0)
ServoSpeed(2.D6, 0)
ServoSpeed(2.D7, 0)
# Desired starting positions.
# Servos connected to board 0.
Servo(D1, 90)
Servo(D2, 40)
Servo(D3, 90)
# Servos connected to board 2.
Servo(2.D4, 90)
Servo(2.D5, 38)
Servo(2.D6, 82)
Servo(2.D7, 40)
# Newly set servo speeds
# Servos connected to board 0.
ServoSpeed(D1, 2)
ServoSpeed(D2, 3)
ServoSpeed(D3, 1)
# Servos connected to board 2.
ServoSpeed(2.D4, 2)
ServoSpeed(2.D5, 1)
ServoSpeed(2.D6, 3)
ServoSpeed(2.D7, 2)
In the next step, I will explain further uses for an "Init" script with a couple of examples.
What I have found is that when I set to ServoSpeed(D3,0) , and then add position Servo(D3, 90) and finally ServoSpeed(D3, 4), servo D3 runs as fast as it can to get into startup position. I also found that if I insert ServoSpeed(D3, 4) in the line before Servo(D3, 90) it moves slowly to startup position. The tutorial says not to set final speed until after setting position or you will have a problem. What am I missing?
Sorry for the last comment. It was sent by accident.
I tried to submit it in the tutorial but I got an error message and could't send it.
The tutorial I was reading is above "Setting servo speeds and Initialization Script Tutorial"
I am sending the information here so I don't need another thread.
I am having problems with my initiation script. I have found that when I set ServoSpeed(D3, 0) , and then add position Servo(D3, 90) and finally ServoSpeed(D3, 4), servo D3 runs as fast as it can to get to position given by Servo(D3, 90) startup position. I also found that if I insert ServoSpeed(D3, 4) in the line before Servo(D3, 90) it moves the correct slow speed to Servo(D3, 90) position.
The tutorial says not to set final speed until after setting position or you will have a problem. What am I missing?
I believe what the tutorial is trying to convey is initialization of a servo position. That means the very first time a servo is moved or set into position
a servo doesn’t have a position when power is applied. There’s no way to slowly transition to the initialization position because there is no previous position. so, you must set a position first, which initializes the servo and then set the speed. Once the speed is set, it’ll always have that speed for moving until speed is specified again.
The first initialization of servos will always move quick as they can to the specified position. It’s annoying, but it’s how servos work.
Now, if you’re hardcore and want to get around that issue. You can look up my hack on adding adc position monitoring. That way, you can know the position the servo is in and initialize at that position. Then, set the speed. There would not be any jumping if you did that
heres the plugin which has the video and details: https://synthiam.com/Products/Manual/PWM-Servo-Feedback-ADC-18047
Is there a problem with adding ServoSpeed(D3. 4) code in the line before Servo(D3. 90) line .
If I do this, it doesn’t jerk into D3 position. D3 controls up and down movement of the head of the robot. Without the control the heavy robot head slams int position D3. I am afraid over time I will damage the servo and robot body. This is a five foot Robot called max. He weighs about 70 lbs. t will soon post a picture.
I’m surprised that works, but if it does then yeah go for it. Really if anything does work, keep doing it as the phrase goes, don’t fix it if it ain’t broke
If it is working now, great, just be sure you are testing after first power up and not just running the script after you have already moved the servos before trusting it.
Alan