July 31, 2003
This page is to explain how I found a way to use batch files to control the mini-ssc II servo controller (and similar controllers) on my Windows XP, 95, and 98 machines. My XP pro machine does not like the compiled quickbasic that works on my win98/95 machines, and on NT/2K machines (so I've been told), so this is a different approach to get around this problem. On my XP Pro machine the batch file "ECHO" function can write ascii characters to the com port like it is a file. This batch file method does not work on win95/98 machines unless the machine is tricked into thinking a modem is connected to the serial port. To trick the Windows 95/98 machines, connect pins 1, 4, and 6 together, and connect pins 7 and 8 together (this is for a DB-9 connector, a null modem picture here). Do not connect pins 2 and 3 together as shown on null modem loop-back tester. Connect pin 3 (Tx) to the micro controller input, and pin 5 (ground) to the micro controller ground. These pin cross connects are not needed on the XP machine. This echo method is for the hardware dos com ports and may not work for Windows "virtual" com ports. For web based control, I use the Ivista webcam software which includes the Apache based IWS.EXE web server. This web server module can be used independently of the Ivista software for a simple web server setup if desired. This batch file control should also work with the regular Apache web server. I'd like to hear about other web servers that work using the batch files. For mini-ssc servo control, bytes 0-255 need to be written to the com port. Generating bytes for the batch file "ECHO" to send to the com port is tricky (at least for me). I found a slick application made by Herbert Kleebauer called "ECHOO" (do a google search for the ube.zip file or echoo) that can generate and echo the needed 0-255 bytes to the com port or to a file. Here is how to make the echoo.com application. Copy the 4 lines between the ===== lines below (watch for word wrap, each line starts with echo and ends with com), paste them in notepad (with word wrap turned off), and save as echoo.bat. Double click on the echoo.bat file and the echoo.com file should appear. Use the echoo.com file in a batch file in the command line fashion (example on down below).
=============ECHOO.BAT========================================================
echo Bj@jzh`0X-`/PPPPPPa(DE(DM(DO(Dh(Ls(Lu(LX(LeZRR]EEEUYRX2Dx=>echoo.com
echo 0DxFP,0Xx.t0P,=XtGsB4o@$?PIyU WwX0GwUY Wv;ovBX2Gv0ExGIuht6>>echoo.com
echo ?@xAyJHmH@=a?}VjuN?_LEkS?`w`s_{OCIvJDGEHtc{OCIKGMgELCI?GGg>>echoo.com
echo EL?s?WL`LRBcx=k_K?AxVD?fCo?Cd?BLDs0>>echoo.com
==============================================================================
The bytes desired to be used have to be supplied to the echoo.com application in Hex format. The Windows scientific calculator in the programs accessory folder can be used to convert the decimal numbers normally associated with the servo controllers into hex format. The first byte that has to be written to the mini ssc controller is 255. To convert 255 to hex, place the MS calculator in the scientific mode, enter 255 in the calculator, click the hex dot, and FF will appear. This is the hex value you use for 255. If you want to control servo 02, click the Dec dot, clear the calculator and enter 02, click the hex dot, and 2 will appear. For a servo position such as 248, in the dec mode, enter 248, click the hex dot and F8 will appear. Precede each hex value with a $ sign when used in the echoo command line. If you don't want to mess with the calculator, I made a simple table here so you can just copy/paste the hex values. The 3 hex bytes for echoo would be $FF$02$F8. This will move the 02 servo to the 248 position. For a web cam pan/tilt preset position, servos 00 and 01 hex strings would look something like $FF$00$$f8-$FF$01$7F (a dash can be put between the hex groupings to better see them if desired). When using a brouser and a web server to control the servo controller, %query_string% can replace the hex byte strings in the echoo command line, and the hex strings will be supplied in the web page URL sent by the brouser. Below is the webcam.bat file for use in the cgi or cgi-bin folder of the web server. Also below is the type of URL that would be used via a brouser to position the cam in a preset position (the hex strings come after the ? in the URL). The echoo.com file and webcam.bat file always need to be in the same folder unless you want to specify the full path to the echoo.com file. The "mode" line is added to make sure the com port is set for the servo controller baud rate. The mode line can be removed and put in a batch file by itself and run once after each computer reboot to set the port parameters if desired. Removing the mode line will allow the batch file to run a little quicker. The test URL below would position servo 00 to the 248 position and servo 01 to the 127 position.
127.0.0.1/cgi/webcam.bat?$FF$00$f8-$FF$01$7F
===========webcam.bat=======================
@echo off
echo status: 204
echo.
echo.
mode com1:9600,N,8,1 >nul
echoo %QUERY_STRING% >com1
cls
==============================================
Below is a test batch file that will move servo 01 to the 050 position, then to the the 250 position when a key is pressed. Copy, paste in notepad, and save as test bat. Double click on this file (in the same folder or on the desktop with echoo.com) and the servo will move. Press any key and the servo will move the other direction. You can use this for initial testing or other tinkering.
===========test.bat================
@echo off
mode com1:9600,N,8,1 >nul
echoo $ff$01$32> com1
pause
echoo $ff$01$fa> com1
pause
========servohex.bat==================
This batch file makes URL lines for use with the echoo.com application (a lot easier than copy/paste by hand!). Copy the script here (starting at the @ECHO OFF line) and paste in notepad with word wrap turned off (there should be 9 lines, and you do not need to copy the lines above the @ECHO OFF that start with ::). Name it servohex.bat and save it on the desktop. Double click the servohex.bat file and it will generate the desired files that contain the URL lines to put in a web page. In the batch file URL line the first $FF is the 255 byte (which is always used with the Mini-SSC servo controller, other controllers may be different), the middle $00 is the servo number (use $00 thru $07 as desired for servos 0-7 that you want to control), and the $%2%3 is where the individual positions 0-254 will be generated. Change the 127.0.0.1/cgi/servo.bat to fit your IP and server path. Double click the servohex.bat file after you make the desired changes and it will generate the desired files with the new URL lines.
==================================
If you don't want or need web control and just want to control the servos locally from your desktop, then just put the batch files (or shortcuts to them) on the desktop or in a folder. Double clicking the batch file file/shortcut will control the servos. For the web page control panel, copy the source of the below parallel port switcher demo page and substitute the decimal control strings (like 01&148&00&050) with the hex versions discussed above. Look at the other info on the zoomkat home page for additional info on the basic web setup. Nothing is guaranteed about this (but mine works on my XP machine), so you will have to experiment like I have. And as always..., YMMV!!! zoomkat
Parallel port switcher demo page (as of 4/10/02) here, where you can see the simple web based control page in action.