Software to control my servos

Hello.

I moved this to the Pololu Servo Controllers forum.

Controlling a Maestro from a computer program running in the background is possible. Since your programming experience is limited, I would recommend using the Maestro’s serial interface. Basically the Maestro has a serial port called the Command Port that it can make available to the computer. If you open this command port and send the right bytes you can command the Maestro to do a lot. Check out the Serial Interface section of the User’s Guide.

- Ryan

Thank you for sending me in the direction of this port!
I have no idea how to send bytes to it, or how to write a program.
Anyway, im very happy to hear its possible to have a background program running.

Nobody have made this program for themseves?

Can you estimate the time it will take for an experienced programmer to write this program?

Maybe i should ask someone to write it…

Thanks for your reply!

Kind regards!

/Orbert

Probably i should rephrase a sentence from my descripion of the problem:

I would like to have a software that runs in the background and makes it possible for me to create different hotkeys that sends different signals to the micro maestro, preferably via usb, and so that the micro maestro runs/performs different sequences it is scripted to upon recieving this signals.

(I dont know how big the need for redundancy is, but anyway… And maybe i added this to make sure for myself that i understand the process im talking about)

Kind Regards

/Orbert

Hello.

I thought of a better solution to your problem. Here is the guide to setting it up:

Install the Maestro Control Center (I assume you’ve already done this.)
Download and install Autohotkey_L autohotkey.com/download/
Make a textfile called maestro.ahk with these contents:

^!c::Run usccmd --servo 0`,8000
^!b::Run usccmd --servo 0`,0

Double click on maestro.ahk to run it. Now, when you type CTRL+ALT+C the servo on channel 0 will be set to a target of 2000 ms, and when you type CTRL+ALT+B the servo will be set to a target of 0 ms.

AutoHotkey should be flexible enough for you to get the hotkeys you want to send the correct commands to the Maestro through usccmd. You can run any of the usccmd’s you want to run in your AutoHotkey script, just make sure to escape commas (,) with backticks () like I have done in the example above (,).

- Ryan

Ok. I already have auto hotkey.

I will try this now!

Does this mean that i will run the servo from autohotkey directly without having to script the microcontroller?

This is seem to be a good solution if i can trigger a sequence with it: i need the servo to turn a bit and immediatly turn back

Anyway, tanks a lot for your help!

You will need to copy your sequences to Script and then run them by using usccmd’s subroutine calling command. To see the syntax for usccmd, go to a command prompt on your computer and type “usccmd”.

- Ryan

Ok, perfect!
Now i have everything i need!
I will figure out the rest myself!

I have one last question though
If i want this to run automatically, which programs do i have to put as autostart?
Is it enough that i put the .ahk script in autostart or do i also need to run Maesto control center? I will of course find out this myself soon enough.

A big thank you for your help, it was really great!

You don’t have to run the Maestro Control Center at all. So, just that Autohotkey script needs to be set to startup.

- Ryan

AutoHotkey has a sleep command that you could put in your Autohotkey script so that it sends a command to the Maestro, sleeps for a few seconds, then sends another command to make the servo go back. You should read the autohotkey documentation to find out exactly how to that. This method might be easier for you than using the Maestro’s internal scripting because you only have to write one script instead of two.

–David

Im testing now, but im not for the moment close to an electric source for the servos, and i cant do the different hotkeys if maestro control center is open cause then ahk crashes, so i cant really see whats going on.

But what struck me was that when i type the subroutine call commando, it says that it “restarts” the script from the subroutine i call. This must mean, i guess, that it runs the rest of the script from that line and then repeats all of the script over and over.

If i dont do a conditional script it will run all the sequneces. And if i do a conditional script i must have inputs as condition for it to run the different sequences, wich means i must get real buttons if i cant make autohotkey send something as a “fake” input signal, and create virtual “fake”, channels. Because if i just call a subroutine in a conditional script, that subroutine will only scan for the condition of its action and find nothing that motivates it.

(i know nothing about programming but only use my mixed philosophical logic to guess how it could work)

But another solution to this problem that i dont even know is real yet, could be to make a non conditional script that stops after every subroutine; that every sequence ends by it stopping the script, and that the script starts when i call it from where i want it to start.

I dont know why im writing this. Its just speculation. But it was pretty stimulating to think about programming. Now i will go to bed and dream about subroutines calling me back from the tundra.

Wow, David!

I missed your message just now, so what i wrote above should really be ignored.

This sounds perfect!
Thanx a bunch!

/Orbert

Actually i have some more questions…

:slight_smile:

1 About Autohotkey: How do i get the commandwindow that pops up at a random place and flashes for a half second each time i press a hotkey, to dissappear or stop popping up?

2 How would the script in autohotkey look like if i dont just want to set the position at 2000, but also speed and acceleration to, for example, 12? (is there a certain order of these commandos that i have to obey, if they are going to make up an equivalent to a frame?)

Kind regards!

/Orbert

  1. The documentation for the Run command seems great. It has something called Hide that does what you want.
^!c::Run usccmd --servo 1`,8000,,Hide
  1. You need to send the accel and speed commands separately. If you don’t want to change them though, you can configure them ahead of time and then you don’t have to send them at all during the actual command. Note that I used RunWait instead of Run. RunWait waits until the first usccmd finishes before running the next one.
^!c::
RunWait usccmd --accel 0`,12,,Hide
RunWait usccmd --speed 0`,12,,Hide
Run usccmd --servo 0`,8000,,Hide
return

^!b::
RunWait usccmd --accel 0`,0,,Hide
RunWait usccmd --speed 0`,0,,Hide
Run usccmd --servo 0`,4000,,Hide
return

- Ryan

  1. Thank you. Hide works perfect!

  2. This also works great now. I actually now set the speed and acceleration beforehand. But now i fully understand how i can do if i need to change around with these parameters,

What i cant get to work is how to make it move and then move back.
I looked at the documentation for the “sleep” command, but have now idea if it actually does what i want, or how i should include it in the script.

I also looked at the “run” command, about which it says:

“; To run multiple commands consecutively, use “&&” between each:
Run, %comspec% /c dir /b > C:\list.txt && type C:\list.txt && pause”

and i have tried many ways to write this into a script, and also to try writing commands after eachother, but its either no effect or usccmd crashes:(
Im really bad at including these different commandos in a script.
I would be great if you, someone, would want to show me how a autohotkey-script looks that a) turns the servo, b) makes an absolutely minimal pause, or no pause at all, and c) then turns back again.

This is also the last problem i have before the servos and software do exactly as i want.

(I speculated a bit and thought that if its not possible to do this with help from the “sleep” or “run” commando, maybe it instead is possible to make a conditional script for the maestro that responds to the effects of the usc-commandos , like if, for example, servo 1 moves to 4000 (in my thought scenario because of my hotkey-usccmd), then this script moves servo 1 to 3000. But i dont know the possibilities of conditional scripting for the micro maestro so that i could answer that question myself)

Kind regards

/orbert

Hello.

One way to run commands in sequence should be pretty obvious from my last post. You just put them on separate lines and use RunWait instead of Run. Here is a script that makes use of this technique and uses sleep:

^!c::
RunWait usccmd --servo 0`,8000,,Hide
Sleep 3000
RunWait usccmd --servo 0`,4000,,Hide
return

You don’t even need conditionals to do what you want. You just put each of your different behaviors into different sub-routines and then use usccmd to run those sub-routines as you need to. I would recommend continuing with the Autohotkey since it seems like you almost have it working.

- Ryan

Thanx a lot for all your help, Ryan!

I got it to work perfectly, both with and without sleep, now.
I thought that a few of my trail-and-error-sessions had included “runwait” on each line, but most tries had a normal “run” before the second servo movement. Probably this led me to fail finding the right solution.

In all my scripts i am working with servo 2, and from time to time servo 0 gives a motoric “cough” when servo two 2 moving. I have now idea if it can be hardware or software related, but it doesnt have to affect my project, i think.

Thank you also, David, for showing me the sleep-command!

Kind Regards

/Orbert

What are you using to power the servos? What kind of servos are you using?

- Ryan

The product page doesnt give exact model, but instead says: "servo is very similar in size and specifications to the Hitec HS-55. Includes hardware as shown.

Features:

  • 3 pole ferrite, all nylon gear
  • Top ball bearing
  • Operating Voltage: 4.8V~6.0V
  • Operating speed: 0.10sec/60 degree
  • Output torque: 1.4kg/cm (19.6oz/in)

Dimension:

  • 22.8 x 11.8 x 20.6mm
  • Weight: 9g "

Im getting power from my computer psu, and use this to get 5v: tinyurl.com/6delu5v

If your power supply has at least 1A@5V to spare for each of these servos you are using, that’s probably not the problem. Can you check to make sure your Maestro script isn’t running and that you don’t have any commands to servo 0 in the AutoHotkey?

- Ryan