Setting Servo speeds and Initialization Script Tutorial

Step 6. UARTInit() Commands.

Quote:

[/b]Taken form the EZ-Script menu.[/b]

UARTInit( boardIndex, port, baudRate )

Initialize the Peripheral UART on the EZ-B v4 with the specified baud rate. The UART will stay initialized until the EZ-B v4 is power cycled, and therefore this command only needs to be called once. The Board Index is the EZ-B index starting at 0. The port can be 0, 1 or 2. The baud rate can be between 1 and 3750000 bps. The UART receive buffers on the EZ-B v4 are 5,000 bytes. Look at the UART Port section in the EZ-Script menu for the EZ-B Pin’s associated with each UART Port. Example: UARTInit(0, 0, 9600 )

When using the UART0 port it always has to be initialized the first time you use it after power up by using the UARTInit() command. Once initialized, you don't have to send that command again untill the next time you power on the EZ-B.

Breakdown of the UARTInit() command.

UARTInit(0, 0, 9600 )

.) In the "UARTInit" command above, the first number is for defining the EZ-B v4's board number (the board number that the EZ-B connects to in the connection control),

.) The second number is for defining the UART port number (on the EZ-B),

.) And the last number is the baud rate, which must match the same baud rate number on the device you are going to use (Roomba, Sabertooth, Kangaroo ect).

There are lots of other reasons to use "Init" scripts, such as using an iRobot Roomba vacuum cleaners with an EZ-B. These require an "Init" script to initialize the controls. There are projects in the EZ-Cloud that use a Roomba Movement Panel which has a built in "Init" button, but it can be written as a script as well. Such an "Init script could look like the following...

#Init script for "Roomba 530".
UARTInit(0, 1, 115200) 

Another example for a UARTInit() command, is for the SSC-32 servo controller. There is a dedicated control for the SSC-32 found in EZ-Builder, found by selecting "Project", "Add controls", "Servo", "SSC-32". But if you wish to use a script to control servos connected to the SSC-32, you will need a UARTInit() script first...

#Init script for "SSC-32" that has a choice 
#of baud rate baud rate.

UARTInit(0,0,9600)
UARTInit(0,0,38400)
UARTInit(0,0,115200)

These types of "Init" scripts can be placed in a connection script like has been mentioned previously, or can be put in to a script, and run when needed.


ARC Pro

Upgrade to ARC Pro

ARC Pro will give you immediate updates and new features needed to unleash your robot's potential!

#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