Software to control my servos.

Support for Pololu RC servo controllers and our RC servos.

Software to control my servos.

Postby orbert » Fri Feb 04, 2011 12:02 pm

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 http://www.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
orbert
 
Posts: 14
Joined: Fri Feb 04, 2011 10:55 am

Re: Software to control my servos.

Postby ryantm » Fri Feb 04, 2011 4:04 pm

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
User avatar
ryantm
Pololu Employee
 
Posts: 1267
Joined: Mon May 19, 2008 1:00 pm
Location: Las Vegas, NV

Re: Software to control my servos.

Postby orbert » Sat Feb 05, 2011 2:49 am

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
orbert
 
Posts: 14
Joined: Fri Feb 04, 2011 10:55 am

Re: Software to control my servos.

Postby orbert » Sun Feb 06, 2011 5:18 am

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
orbert
 
Posts: 14
Joined: Fri Feb 04, 2011 10:55 am

Re: Software to control my servos.

Postby ryantm » Mon Feb 07, 2011 11:53 am

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 http://www.autohotkey.com/download/
Make a textfile called maestro.ahk with these contents:
Code: Select all Expand

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
User avatar
ryantm
Pololu Employee
 
Posts: 1267
Joined: Mon May 19, 2008 1:00 pm
Location: Las Vegas, NV

Re: Software to control my servos.

Postby orbert » Mon Feb 07, 2011 12:25 pm

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?
orbert
 
Posts: 14
Joined: Fri Feb 04, 2011 10:55 am

Re: Software to control my servos.

Postby orbert » Mon Feb 07, 2011 12:29 pm

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!
orbert
 
Posts: 14
Joined: Fri Feb 04, 2011 10:55 am

Re: Software to control my servos.

Postby ryantm » Mon Feb 07, 2011 12:37 pm

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
User avatar
ryantm
Pololu Employee
 
Posts: 1267
Joined: Mon May 19, 2008 1:00 pm
Location: Las Vegas, NV

Re: Software to control my servos.

Postby orbert » Mon Feb 07, 2011 12:56 pm

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!
orbert
 
Posts: 14
Joined: Fri Feb 04, 2011 10:55 am

Re: Software to control my servos.

Postby ryantm » Mon Feb 07, 2011 12:59 pm

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

- Ryan
User avatar
ryantm
Pololu Employee
 
Posts: 1267
Joined: Mon May 19, 2008 1:00 pm
Location: Las Vegas, NV

Re: Software to control my servos.

Postby DavidEGrayson » Mon Feb 07, 2011 3:31 pm

orbert wrote:i need the servo to turn a bit and immediately turn back


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
DavidEGrayson
Pololu Employee
 
Posts: 2697
Joined: Thu Apr 03, 2008 12:30 pm
Location: Las Vegas, NV

Re: Software to control my servos.

Postby orbert » Mon Feb 07, 2011 4:15 pm

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.
orbert
 
Posts: 14
Joined: Fri Feb 04, 2011 10:55 am

Re: Software to control my servos.

Postby orbert » Mon Feb 07, 2011 4:19 pm

Wow, David!

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

This sounds perfect!
Thanx a bunch!

/Orbert
orbert
 
Posts: 14
Joined: Fri Feb 04, 2011 10:55 am

Re: Software to control my servos.

Postby orbert » Wed Feb 09, 2011 3:05 am

Actually i have some more questions...

:)

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
orbert
 
Posts: 14
Joined: Fri Feb 04, 2011 10:55 am

Re: Software to control my servos.

Postby ryantm » Wed Feb 09, 2011 11:00 am

1) The documentation for the Run command seems great. It has something called Hide that does what you want.

Code: Select all Expand


2) 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.

Code: Select all Expand


- Ryan
User avatar
ryantm
Pololu Employee
 
Posts: 1267
Joined: Mon May 19, 2008 1:00 pm
Location: Las Vegas, NV

Next

Return to Pololu Servo Controllers and Servos

Who is online

Users browsing this forum: No registered users and 1 guest