Setting Servo speeds and Initialization Script Tutorial

Step 5. Another Init script example.

In this example, we use another variable to set ARC to tell you the current date using your computers clock.

1.) As before, in either a "Connection" script in the "Connection Control" script editor, or in a connection script in a script manager, enter the following "Init" script and save it...

$SayDate = 0
$lastDay = $day

2.) From the EZ Builder menu ribbon, either add an EZ-Script control by clicking on "Project" then "Add Controls", "Scripting", then "EZ-Script" and click on the gear icon to open the script editor.

2A.) or click on "Project" then "Add Controls", "Scripting", then "EZ-Script Manager". On the script manager, click on "Add Script" and click on "Edit" to open the script editor.

3.) Copy the following script in to the script editor then hit Save when you're done...

# Script courtesy of Rich Pyke.

if ($lastDay != $day)
  goto(sayDay)
endif
if ($SayDate  = 1)
  goto(toldYou)
endif

# Say day, date, month
:sayDay
SayWait("Today is " + $dayName + " , the " + $day  + " of, " + $monthName )
$lastDay = $day
$SayDate  = 1
halt()

# Repeat day, date, month
:toldYou
SayWait("Haven't I already told you, it is " + $dayName + " , the " + $day  + " of, " + $monthName )
$SayDate  = 0
halt()

4.) Power on your EZ-B and connect it to your EZ Builder project. When the connection is made, the "Init" script will automatically run and set the vairabe. When You press "Start" on your date script, you computer will tell you the current date. Pressing "Start" again, you computer will tell you that you already asked for the date, and tell you it again.


ARC Pro

Upgrade to ARC Pro

ARC Pro is your passport to a world of endless possibilities in robot programming, waiting for you to explore.

#1  

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?

#2  

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?

PRO
Synthiam
#3   — Edited

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

#4  

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.

PRO
Synthiam
#5  

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

PRO
USA
#6  

Quote:

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
I want to revisit this on my robot heads. They could uses an init, that could read head positions from the dynamixels, then move them to a beginning state. Not sure how I missed this use case!

#7  

Quote:

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
Yeah, I thought servo speed only worked after an initial servo movement.  Never fully understood why, but just dealt with it.  The new HD servos make it easy because they pretty much hold their last position when shut down.  On robots without HD servos, I have a "safe" position I try to remember to go to before shutting down as long as I get to it before the battery dies.

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