Software to control my servos

I am very sorry that i cannot be more specifik in my topic, or that the problem that will present most likely will not be interesting to most people on this forum.
Im just hoping that there is by chance a person here that think its a bit entertaining to help a noob.

Project; General intro:

I know almost nothing of mechanics or programming. But 2 years ago a computerinterested friend of me told me to not by a htpc but buy the components and put them together.
I did and while i encountered problems of how to dissipate heat i read a lot about fans, passive sinks and watercooling. I soon solved my problems with google and experimentation.
A half year later i found a old radiofurniture from the fifthies. A beatiful thing. I was a bit dissapointed that it was so easy to build a computer with all readymade components so i decided to buy it, clean it out inside, and go from fan cooling to water cooling. It became great, and while i didnt manage to use the buttons on the front, i started to develop a taste of solving problems and going into and customise electronics.

Project; Specifik intro:

A few weeks ago i found this radiomuseum.org/r/grundig_mu … _7025.html
And this is going to be my new build. This time i will make all front buttons work, and build computer, amplifier, and usb-turntable inside! I didnt know how to make the buttons work but i came up with a solution:
I took a numpad, cut it open and unfolded the membrane, sandwiched it between two transparent pieces of plastic that i had drilled holes in, and that gave me the oppurtunity to solder from the numpad memrane to the mechanical front interface of the grundig furniture, using all its buttons and knobs.
On the softwareside i use a freeware called keytweek to create commands and hotkeys from the numpad scancodes. This is a good solution. And the commands i use, the hotkeys, i can also use with my “imon” remote and reciever, to also control the same processes via remote.

Problem; General intro:

I will build a usb-turntable into the machine in a way that i cant directly control its buttons, and these buttons start mechanisms i want to start from the grundic buttons, and if i can, also from the remote. The turntable is not controllable from the usb, sadly. I had to find a solution. I wanted something to go from hotkey to mechanism. I found by googling, this things called servos, and bought a few together with the “micro maestro”. Now i have tested the equipment and easily made sequences that uses three servos to push the three different buttons on the turntable and start the mechanisms. With some reading and brainwork i will make conditional scripts for them very soon. If i use the three connections on the micro maestro that is left i could make button inputs directly from the Grundig mechanic front, and i guess this would be an ok solution, but i want more.
Actually i dont want to spend this connections as inputs because i could use them to do something on the amplifier via servos. And especially i would like to have it so that i can both start the turntable mechanism via the grundig-buttons and via the remote.

Problem; Specific description:

I would like to have a software that makes it possible for me to create a hotkey that signals to the micro maestro, preferably via usb, and when it recieves this signal it runs a script. Then i would be able to start the turntable mechanisms both from the grundig buttons and from my remote. Preferably i would like this reaction, of the micro maestro to the hotkeys, to happen whenever i have the home entertainment system on, even i dont have Pololu Maestro Control Center running (i dont want to start that program everytime i start the computer, and i would like to control the turntable/servos with hotkeys even i have another program centered on the computer).

Is it possible to do that?

I have never programmed in my life, exept writing the command “list dir” on an amiga when i was small, so i would hope that somebody already made such an software and would be happy to share it with me.
Otherwise i would also be happy for suggestions of alternative solutions to my problem.
(I am using windows vista 64, but will with this build also upgrade to the latest windows version.)

I am extremely thankfull for all kinds of help. This became a rather expensive way to start a turntable, and it would be very sad if it turned out that the servos was a dead end.

Kind Regards!

/Orbert

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