Help using servos for my PC case mod

Hi everyone, Just to get off on the right foot, I’m a deffient a Noob at this! I’ve been trying to search this forum for some answers to what I’m trying to do, but the problem is I don’t even know what to search for.

I have little background in programming or robot building, but I do have some background in rc Servos.

Here is what I’m trying to do. I built a computer case that has some motorized doors on it. They are connected to some hitec servos. what I want to happen is when I turn the computer on, the doors open, then when I shut the computer off, they close. thats it! just a simple open/close.

What do I need to do to make this happen? I’ve looked at all the servo controller boards, Atom chips etc. and to be honest. Like my title says, I’m in way over my head. So if anyone can please help me out, I would really appreciate it!!!

Thanks

I can’t say I’ve done anything like this, however, my first thoughts would be a serially controlled SSC32 running the servos.

You could then use something like this url to edit the Windows startup/shutdown scripts to send the appropriate commands to the board.

If you save the SSC commands in a text file called open and close ( assuming 2 servos, channel 1 and 2, and the open/close postions are 2000/900 respectively):

c:\autodoors\open
#1 P2000 S750
#2 P2000 S750

c:\autodoors\close
#1 P900 S750
#2 P900 S750

Something like the DOS commands would do the trick:

TYPE c:\autodoors\open > COM1
TYPE c:\autodoors\close > COM1

Mounting the board and sourcing the voltage in there is entirely up to you, but you would have plenty of options in there.

Matt has summed a good solution pretty well with his post, provided the script has time to run before power gets yanked.
You might also want to include a line in the script to make sure the com port is at the correct baud rate before copying the file… something like
MODE COM1:9600,n,8,1
assuming of course you have the SSC-32 configured to communicate at 9600 baud.

I would recommend the SSC-32 over the MiniSSC-II because it can open and close the door slowly, where the MiniSSC-II does not have this capability. Plus the SSC-32 uses ascii commands, not the binary ones used by the MiniSSC-II. And it’s cheaper! :wink:

You may want to add some more servos to the PC… Laser pointer light show for your MP3 playing enjoyment. :smiley:

I don’t know much about the startup and shutdown scripts, but the servo motion should be easy. Oh and you can use a USB to serial cable too.

Excellent point on the mode command.

Shutdown scripts generally have time to run. Not 100% sure about what order and if Windows waits for them to complete, but my servos always seem to move a lot faster than Windows shuts down…

Once the SSC-32 receives the command it can slowly close the doors without need of further comunication from the PC. But unless the servos have their own power supply (not connected to the PC’s 5vdc supply) you do need to make sure power stays on till the servos finish moving. Honestly even if the servo move were set to 5 seconds windows will probably still be saving your settings long after the servos are done moving.

This is an example of the text to send to the SSC-32 to move the doors. This assumes two servos, one for each door.

Initialization:
#0 P1000 #1 P2000 <- this turns the servos on, the 1000 / 2000 will need to be changed to your servos closed position values.

Close:
#0 P1000 #1 P2000 T5000 <- this moves the servos to the "closed position, and the move will take exactly 5 seconds. You can change the 5000 to whatever time in uS you want the move to take.

Open:
#0 P2000 #1 P1000 T5000 <- this opens the doors, but you must do the initialization first.

You may be able to get the job done with out a servo controller. Assuming you will have a seperate wallwart to power the servos, you could use the servos as gear motors along with some diodes, limit switches, and a DTDP relay. The relay would be operated from the 5v or 12v computer power supply when the computer starts up. Near the bottom of the below page, there is a diagram of a DTDP relay in a motor reversing setup. Another approach would be to make a servo controller like below from a 555 chip and have a small relay switch the driver between the open and closed door positions (act as a jumper around the 50k pot).

geocities.com/zoomkat/switch.htm
uoguelph.ca/~antoon/gadgets/servo4.htm

I should add that the group policy stuff that allows the startup/shutdown scripts is XP Pro…

So if you’re running XP Home or Media editions. There are solutions if you search the net, though.

Thanks guys.

a few more quesitons, do I need to by anthing else other than the ssc-32 controller, like a chip or anything?

and does it send commands out in sequence to each servo or does it send them all simulateously?

Lastly, the text file script I create. What file extension should it be?

Thanks again!

Like I mentioned before you may want to use a USB to serial cable. We do sell a 6vdc 2amp wall pack for powering the servos if you do not want to use the PC’s 5vdc line. You shouldn’t need anything else.

The beauty of the SSC-32 is, you send the commands but nothing is acted apon untill you send the cariage return (CR). So the servos will begin moving as soon ans the CR is received. For the examples I made above the two servos will begin moving at the same time, and stop moving at the same time. The move will take 5 seconds.

Robot dude, Thanks.

Sorry, I must have edited my post after your responce.

I’m a little confused as to what the file extension should be.
For example. I create a text file called open.???

EDIT: I think I just found it, is it .wsf ?

So now my question is, once it runs that script, where in the script does it tell it to send it to the usb port?

I guess I’m not understanding how the script file gets sent to the usb or com port.

IF it is done thru a dos promt as show earlier, then how does this work with the xp script editor?

Sorry for being such a PITA.

I know the servo controller, but I’m not sure about the script stuff. Better let the guru’s field these questions.

The file extension you choose doesn’t really matter, as you’re just sending the contents of the file to the serial port.

That said, it’s probably best to call them open.txt and close.txt, as they are text files, and that way double clicking will open them up in notepad (or whichever editor is your default one).

Not a PITA at all.

I’m still not sure what version of windows you have. If it is Pro, and you’re editing the group policy to add a startup and shutdown scripts, you should be able to add batch scripts (.BAT). I’m not really familiar with windows script files (wsf), so can’t help much there.

OPEN.BAT:

MODE COM1:9600,n,8,1 TYPE c:\autodoors\open.txt > COM1

CLOSE.BAT

MODE COM1:9600,n,8,1 TYPE c:\autodoors\close.txt > COM1

The mode command sets the serial port speed, parity and such.

TYPE displays the content of the file. The addition of the > pipes the output away from the screen and into the file or device you specify.

So the type command in the batch file take the contents of open.txt and passes them on to the first serial port (COM1) and from there, it goes on to the SSC32.

If you have a USB to serial port adapter, you’ll need to change COM1 to whatever the adapter’s com port number is.

I’ve realised the MS site I originally linked to is a bit confusing, so here’s another attempt in ‘how to add Startup/Shutdown scripts’:

Click ‘Start > run’, type gpedit.msc and click ‘Ok’

This should open the local group policy.

Under ‘User Configuration > Window Settings > Scripts(Logon/Logoff)’, there are entries for logon and logoff scripts.

Double click on Logon and then click ‘Add’, browse to your batch file, OPEN.BAT.

This does work in Vista Business and XP Pro. I don’t have a PC with XP Home, so I’m just crossing my fingers for that one.

Good luck!

Matt, THANK YOU! actually to everybody!

yes I am running windows xp pro. and I was able to figure out how to edit the group policy to add the scripts.

So what I understand now is that you have to have essentially 4 files.
open.txt -that contains the script for the controller to open the doors,
close.txt -that contains the script for the controller to close the doors

then you also have to have .bat files
and those are what you load into the group policy startup and shutdown scripts.

Ok, so I think I’ve got it all figured out now. Thank you guys alot. I will place my order for the ssc-32 today.

Edit: -I just placed my order. -I went ahead and orderd 6 servos, the 6v power supply, wiring harnes and a bunch of hardware.

Here is a link to my thread of the computer case I’m building just in case you guys want to follow along. -I’m just getting started.
thebestcasescenario.com/foru … hp?t=10192

Thanks again.

That is really pretty cool! 8) Keep us posted with the progress.

well, I got everyting working last night. I had a little trouble getting the commands sent to the board at first because I didn’t notice the jumper setting on the board wasn’t set to 9600 baud rate. so Once I removed one of the jumpers. Everyting started working.

I also got the startup and shutdown scripts to work to! THANKS!

The shut down happens right after windows “saves settings” It says, “Running shutdown scripts” then shortly after the computer shuts off.

When I boot it up however, it takes quite a while before it runs the script.
Basically once I get into the screen to select the user and enter my password, that is where it runs the script. it does not wait for me to login, but it does have to boot into that screen before it will happen.

Is there anyway to add the command to send the open.txt file to the com port in the dos bootup sequence. (I’m on windows xp pro) I know you used to use the autoexec.bat, but that doesn’t exist any more. If I can only get it to work at the login screen, then thats ok with me, but If I could get it to happen sooner, that would be better. Thanks!

Congrats, I’m glad its working for you!

On the startup script, you might be a bit stuck. Autoexec.bat does still exist in XP, but it ignores everything except setting environment variables, so you can’t run anything from it. The windows XP boot sequence loads things in a very specific order, and the earliest you can run something is at the login screen (or perhaps a fraction earlier if you write your own service - not recomended).

The only other possible thing I can think of (and this one is a hell of a strech and really, really not recommended if you’re not familiar with partitions, bootloaders and system recovery. If you mess up the bootloader, recovery can be a PITA :open_mouth: ):

Another bootloader (GRUB, I’m looking at you) does have serial terminal support and can be run before windows starts to load. It may be possible - especially on a single OS System - to change the menu option itself to your SSC32 command and configure it to boot windows after a 1s delay.

If I can find a null modem cable I’ll give it a shot later this week and see how it pans out.

***Please note, the GRUB solution is pure conjecture. Untested and not recomended. ***

(We need a warning or ‘hazardous matter’ smiley :wink: )

You may want to consider a dedicate microcontroller to do this for you. It could monitor the 5vdc line to know when the PC is turned on, and move your servos for you, you could still use the shut down script to close it down. I know it would add a lot of complexity to what should be a simple procedure, but it would work.

Oh wait!

If you can live with it for a little while we will be offering an upgrade to the SSC-32’s processor and firmware to allow some interesting features. The one you will be excited about is it will allow startup sequences to be added that automatically run when the servo controller is first powered up. So as soon as the SSC-32 is turned on it will initialize the servos at the closed position, then slowly open them to the full open position. They can stay that way until the shut down script closes the doors. then the power is shut down turning the SSC-32 off.

It’s going to be a little while longer for this. We are working on it! :smiley: