First Servo Movement always at full speed and acceleration

Every time I load a new script and run it the first servo movement is always at full acceleration and speed.

I’d rather the servos be at Speed/Acceleration 20/20 from the first time I move them to when I run a new script.

I’m controlling a home-made pan/tilt mechanism with a webcam attached. So I don’t really want the servo to move at full speed.

Is there a way to disable this, or work around it?

I used the Maestro Control Center to manually set my Speed and Acceleration but it doesn’t kick in for the first servo movement.

I’ve tried setting Speed and Acceleration as the first two commands in my script. It successfully sets the Speed and Acceleration but not until the second servo movement.

I’m using ssh to remotely use UscCmd to load and execute pre-made scripts. I’m creating batch files so that I don’t have to type the program and start commands separately.

A script that uses the servos more than once is useless to me as I’m remotely commanding it to load and execute one set of commands and then quit the script.

~Cenyu

Hello,

Unfortunately, servos do not provide any position feedback to the servo controller, so there is no way to limit the speed or acceleration when moving to the initial position. However, once the Maestro has moved the servo to a specific location, it will use speed and acceleration to move to all subsequent locations until the servo is turned off with a position=0 command.

If you know the position of the servo (because it was there before being turned off), you can send a command to move to the old position first (without speed limits) and then immediately send a new command to move to the new position (with speed limits).

-Paul

Yes. I’ve tried that already. Firstly, the script has no idea where the servo is located because each script is written in a manner that allows it to be used independent of all other scripts. And each one is pre-written to avoid having to create new files on the fly.

I also tried using get_position at the start of the script and move it to that location or a very close one as that would have been a very simple workaround. However, as you stated, the servo’s position is set to 0 so this method won’t work either.

I’m a bit confused by what you said, however…

I understand that the signal wire works only towards the servo by using Pulse Width Modulation. But wouldn’t the position, speed, and acceleration be conveyed TO the servo via this protocol? I’m assuming that the servo controller tells the servo what position to move to and what speed and acceleration to use? Otherwise it would never be able to change the ‘hardwired’ ‘default’ speed and acceleration of the servo itself.

I may be missing something but I see only two possibilities. Either the controller itself is set to initialize the servo to it’s first location without regard for speed or acceleration, or the servo’s circuit board is doing this.

I’m just curious if you know whether it’s the Micro Maestro or the Servo.

It’s a small annoyance, but not so bad that it’s going to affect my project.

~Cenyu “^-^”

Actually, I just noticed that UscCmd allows me to call subroutines…

Does this mean that I can write a monolithic program (yes, I know of the memory limitations of the unit. ^-^;;:wink: and simply write subroutines for all the stuff I’d like it to do? It’s a bit late tonight (6:00 a.m.) so I’ll play with it tomorrow, but in addition to the questions I asked above, could you answer these too?

I really appreciate your patience as you guys have been really awesome to me thus-far! ^-^
I’m new to servos and pre-fab boards so bear with me.

If I write a script that basically idles until I use UscCmd to initiate one of its subroutines (after which it will return to the main program) will this solve my problem? I think it will as I will only have the quick jerky movement at the beginning of my script and then afterwords when my subroutines are executed they will be post-initialization and so will use the servos at the 20/20 speed.

Also, are there any advanced tutorials on how to use the Script area? I’m not certain what a frame is and what it is used for… :stuck_out_tongue: I am fluent in several programming languages (Java, C++, a little assembly (I really understand a stack because of this… lol), and more…) but the differences between them and this scripting language have me in the dark… I understand all the operators and such O.K. I’d just like to browse a tutorial (more in depth than the one listed in the manual, which I’ve already printed out ^_~).

Thank you!!!

~Cenyu

Hello,

First of all, we do not have any tutorials for Maestro scripting beyond what is in the manual. In fact, if you are doing more advanced things than the Example Scripts, you might be beyond what anyone else has done! Of course, we would be happy to help you if you post what you are trying to do here.

Second, no, servos do not have any built in acceleration or speed control. The Maestro sends pulses that correspond servo positions, and it is up to the Maestro to make those pulse values change according to your desired speed and acceleration limits. That is why there is no way to control those limits once the servo has been disabled.

-Paul

Sorry, I forgot to respond to one of your questions in my reply. The problem you will run into with using the subroutine feature is that the main script is entirely reset whenever you start a subroutine from UscCmd. So any data that you were hoping to save will be lost.

However, if you have a spare servo channel, you could use a slightly sneaky way to establish communication between UscCmd and your script - set the position of the channel to a code indicating an action you want to take, and have your idling main script watch for that code using GET_POSITION, then take the appropriate action.

All of this seems a lot harder to me than just saving a file with the previous servo position on your PC!

-Paul

Hello.

Just to add a tiny bit more detail to Paul’s answer in case there’s still any lingering confusion, most servos don’t have built-in speed or acceleration control; you send them a series of pulses that encode a position and the servo will go to that position as quickly as possible. If you want to slow the servo down, you have to send a slowly changing sequence of postition pulses. This is what the Maestro does, and it requires interpolation between two absolute positions. If the Maestro doesn’t know the starting position, it can’t interpolate between this unknown position and the target, and so the result is that the servo moves to an initial default position at full speed (as you’ve already noticed) before interpolating between this position and the target.

- Ben

1 Like

Is the script language able to write files to my harddrive? I assumed this was not so.

How would I go about saving the position of my servo if the language isn’t capable of writing to my hard drive?

~Cenyu

Oh, I just understood that what you are doing is loading pre-written scripts every time you want to move the servos. This is a really bad idea for a number of reasons! For one thing, if you are write code that constantly reprograms the Maestro, it is possible that you will wear out the flash memory in just a few thousand cycles.

Why not have the program on your PC actually take control of the device, sending the position commands directly?

-Paul

A customer once called me with a similar question. The basic problem is that whenever you click “Apply Settings” in the control center, or use UscCmd to load a new script on to the Maestro, the Maestro must restart which means that all the servos go to their default settings. If your default setting for a servo is “Off”, then the Maestro will lose its information about the current position of that servo, because the position variable gets set to zero. Once it loses that information, it can’t obey your speed and acceleration limits for the next servo movement.

If you want to make sure that the Maestro always obeys your speed and acceleration limits even after you have restarted the Maestro, then you should set a default position. To do this, go to the Channel Settings tab and select “On startup: Goto” and then enter some default position like 1500. Once you do this, the Maestro will start moving your servos to their default positions whenever you restart it, but it will respect your speed and acceleration limits on the way.

Also, I agree with Paul, you don’t want to be changing the script constantly. Instead you can use the --target option of UscCmd to set targets, and you can use the --status option to get the current positions if you need to read inputs from the Maestro on your PC.

–David

The complications with default positions are another reason that you should not be loading a new configuration for every command. Try just sending position commands, and you should be able to do what you want much more easily.

-Paul

O.K. Great advice guys! So here’s my original plan: I want to be able to remotely control several servos (by way of the Micro Maestro 6) and use said servos as pan and tilt for my webcam at home.

I knew I needed to be able to send commands to my Maestro from the command line so I looked into the best way to do so. When I found UscCmd it seemed like the best option. I could create a text file and execute a batch file which would program the controller and execute the instructions.

You guys say that I can tell the controller to do things straight from the PC without loading a program into it’s memory? How do I do this? Is this what’s covered in the “Serial Interface” section of the manual? That part of the guide is confusing me. I’ll have to take some time to sit down and tear apart the info in there if that’s what I need to do.

This is the first time I’ve ever played with anything like this so I’m really trying to understand it as best as I can.

~Cenyu

Oh wait… so --target and --status will allow me to manually position my servos using UscCmd?

Brilliant! That’s my new goal for tonight. Eventually I’ll get this working to a point where I can compile a C++ program to send these commands for me so I’ll actually have an interface rather than working completely from the terminal. If I use C++ should I still have it use UscCmd at the command line level, or are there libraries, etc… that I can import that allows easier direct access to the servos, etc?

~Cenyu

O.K… so --target only seems to let me target different Maestro cards… I only have one so this doesn’t seem very useful to me…

–status tells me what my servo positions are. This may be useful later, but I don’t see how it can help me right now.

What I need to know is how to directly tell the Maestro to, for instance, set channel 0 which is a servo to a specific position.

What do I use to communicate with the Maestro to do this without having to create a script, compile it, upload it, and execute it? Like, using the command prompt for example?

~Cenyu

Hello,

I do not think that there is any --target option to UscCmd. To set a servo position, use --servo. You can get help help just by running UscCmd without any options.

-Paul

There is a --target option to UscCmd, it simply lets you select which Servo Controller (if you have more than one) you’d like to send your commands to.

There is not a --servo command. At least not that I saw. It’s not listed in the help that is displayed by simply typing usccmd, and I tried 3 variations (usccmd --servo, usccmd --servo 0 7000, and usccmd --servo 7000 0) without any results.

I’ve downloaded HyperTerminal and I’m trying to use it to send commands to the board, but it’s simply not accepting any of the commands I send it (i’m using some of the examples from the ‘Serial Connection’ area of the manual). Then again, this is my first time ever using HyperTerminal so while I’m fairly sure I’m using it correctly, I just can’t be certain. I’ve searched all over for a tutorial on using TTL since that seems to be about the only way for me to accomplish what I want to, but I’m kind of starting from scratch as far as knowledge goes. Any suggestions or sites where I can learn more about what I’m doing wrong or how to actually do it right would be awesome.

I’m managing to set off the red light with HyperTerminal, so I’m accomplishing something. I’m also getting back an 8-bit binary number when I send it the command to move servo 0 to a specific location, but I don’t know what the binary number refers to or why the servo never moves.

~Cenyu

I think you might have an easier time sending commands with our serial transmitter utility than with hyperterm.

- Ben

Hello,

The command would look like “UscCmd --servo 0,7000”. Can you post the help you get when you run UscCmd by itself?

-Paul

I was wrong in my original post, there is no “–target” option for UscCmd. You should use “–servo”. Other than my post, why do you insist that UscCmd has a “–target” option? What is your evidence? Other than my post, is there any documentation that we created that would make you believe that UscCmd has a “–target” option? Please just run UscCmd with no arguments to get its complete documentation.

–David

Uh, yah. When you type UscCmd at the prompt it lists the available options. --target is right there. And what --target allows you to do is use UscCmd for several different Servo Controllers. Each one has a unique ID and you set which one you’d like your UscCmd commands to go to by using --> UscCmd --target ID# <-- where ID# refers to this unique ID.

Also, there is no --servo command. It’s not in the documentation, and I’ve tried the variation that you guys gave me and it is not working. So unless I somehow got ahold of the wrong version of UscCmd, there is no --servo command…

Maybe there is a different version for Linux? I haven’t played with it on my Debian, Gentoo, or Ubuntu machines as the machine that I want the end result to work on is currently running XP Pro.

Here is a copy of my command line when I use UscCmd with no options:

C:\Users\Cenyu>UscCmd
UscCmd, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null
Select one of the following actions:
–list list available devices
–configure <conf.txt> load configuration file conf.txt into device
–getconf <conf.txt> read device settings and write configuration file conf.txt
–restoredefaults restore factory settings
–program <prog.txt> compile and load bytecode program prog.txt
–status display complete device status
–bootloader put device into bootloader (firmware upgrade) mode
–stop stops the script running on the device
–start starts the script running on the device
–restart restarts the script at the beginning
–step runs a single instruction of the script running on the device
–sub calls subroutine n (can be hex or decimal)
–sub , calls subroutine n with a parameter (hex or decimal) placed on the stack
Select which device to perform the action on (optional):
–device 00001430 (optional) select device #00001430

C:\Users\Cenyu>

Also, I tried your Serial program and I’m finally getting some results.

Here’s my current setup:

From the Control Panel I know that Com16 is my Command Port and Com17 is my TTL port.

I’m using your utility to connect to Com16 since I’m in USB-Dual Port mode, which the manual tells me to use the Command Port (Com16) for.

My Maestro is the only device connected to Com16, so I should be able to use the Compact Protocol.

I used the example in the manual and finally managed to move servo 0 to a specific point. Now I just need to learn how to do this with HyperTerminal as it has a command line supplement (unless your Serial Transmitter has a way to control it from the command prompt…)

I’m using Windows 7 on the machine I’m using to test all this. As deep as this is going I just thought I should explain that.

~Cenyu