Timed switching operations via the LPT, parallel port

 

WARNING! Use at your own risk! This worked well on my Windows XP computer, then I upgraded to a dual-core. Using the same version of XP Userport caused a crash, "BSOD". I had to restart in Safe Mode and delete the files, I also removed the Registry entry. (1.) Delete the .sys file: del %WINDIR%\SYSTEM32\DRIVERS\userport.sys (2.) Remove the registry entry: My Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\UserPort.  System Restore did not work.

November 2009. I am reluctant to remove this page, it worked so well on my previous system........Userport makes a direct call to the LPT, Windows now objects in a drastic manner.. A more subtle approach is required.  For those using older systems?....  I am investigating Licht24 http://www.bksoft.de/licht24pro/licht24pro_e.htm This is Shareware but the demo does allow 2 channels to be switched, pins 2 & 3 of  LPT.

I know very little about programming computers. I wanted a simple program I could use to switch a single pin of an I/O port to give timed control of an external device.
After much searching I found an answer. Provided the computer time is kept accurate switching will always be within seconds of the preset times. Apart from switch times limited to a minimum of one minute an almost infinite sequence of switching may be set. Using all eight LPT pins 63 devices can be switched! Of course, pins do not need to be set high for on, it can be easier to arrange high as off to make the circuitry simpler!

Summary:- Collect userport.zip, out.com, Pycron-xxxx.exe, Install these as below. Modify my Batch Files as required, put these and out.com in the Pycron folder and setup Crontab Editor


It starts here:-  http://www.geocities.com/zoomkat/output.htm  This page deals with a more complex interface than I required but gives the basic procedures. To gain access to the ports in Windows NT based systems, including XP, an extra utility is needed, there is a link to "userport.zip" in the first paragraph of that page. The unzipped file can be put in "Program Files" and a shortcut made to UserPort.exe. There is a PDF that describes where to put the .sys file and then just run userport.exe, click "Start"  The default settings may be removed and just 378-37A added for LPT use. If Zoomcat's page is not available a search for "userport.zip" should find it somewhere.
Further down the page are some .bat files and descriptions of their function.

Below these batch file instructions is another batch file for making "out.com". This must be executed and the resulting "out.com" must be placed in the same folder as the batch files. (Or you should be able to use the one in my zip)

As an example, for the first timed period I made this file. This is just a text file but with ".txt" replaced with ".bat". I called it LPT2On.bat Just executing it turns LPT pin 2 ON, that is, it sets it to +5V 

File LPT2On.bat :- Just the single line of text. Ensure your path (inside the "inverted commas") matches your computer, it may be different.

"C:\Program Files\pycron\out.com" 01 378 


To turn it off LPT2Off.bat Note these commands can do more than just control pin 2. Further study would reveal how to make more complicated commands.


"C:\Program Files\pycron\out.com" 00 378 

 "00 378" turns all pins off. To test double clicking a batch file ( .bat suffix) should change the state of the selected LPT pin.

To make it easier HERE is a zip containing my two batch files, out.com (and crontab.txt this is only applicable to my own use!) These give an idea of what is required, I think out.com is ready to use I doubt it is specific to just one computer. (For beacon monitors:- control of a TX on the UK 5MHz beacon frequency my crontab.txt could replace that in the Pycron Folder, but only if your interface control is the same polarity)

To get this acting as an automatic timer these batch files have to be executed by another program. I already used Pycron  http://www.brothersoft.com/publisher/gerhard-kalab.html  to do a regular FTP upload. Run Pycron setup  file, let it install as a service. To set it up go to your Start Menu and select Crontab Text Editor. The easiest way to get it to execute batch files is to put them, AND out.com into the Pycron Program File. It seems  to be necessary to include the entire path in the batch files as I show in the files above. NOTE the 2 " marks are required in the batch file. In Crontab Text Editor select Item - New, Browse to select one of the Batch files, use the wizard to select timing intervals for that file. Repeat for any other batch files. File - Save. Pycron will start with Windows, Userport may be started manually, or put a shortcut in the Startup folder if you wish.
Pycron allows commands every minute, switching of mine operates from 1 up to about 10 seconds after the minute set, depends how busy the computer is, something else will be needed if you require more frequent switching. 

Of course, all you get here are pins that change from zero volts to +5 volts. You may need to search further to find out how to use this to switch as you require. "378" is the LPT port, for serial port switching this will need to be replaced (3F8, 2F8??). I have yet to check that out!

Control of a transmitter. My interface uses an optocoupler, the input fed by a diode from the serial port.  I just put a NPN (any small one will do) between the optocoupler input ground pin and ground. Feeding the base from the LPT pin with something like 2 or 5 K ohms will enable TX when this pin is set high. Other interfaces will be different. Assuming an interface something like this [ Serial Pin *--|>---^^^^----  ]  Diode, followed by resistor, then an NPN from the end of the resistor to ground will disable TX when the LPT pin is high. The LPT batch files will need to be set to execute  the reverse of my example. In the picture above LPT2On.bat will need to be selected for the time periods shown. Make sure the diode is feeding +ve to the circuit. In both cases the emitter goes to ground and the collector to the interface.


Below, a few notes, may help someone work it out!

p pin #2 #3 #4 #5 #6 #7 #8 #9

value  1  2  4  8  16  32  64  128

Add these values for pins required high, convert to hex, (Windows Calculator, scientific mode, decimal/hex, F6/F5) 00 is all off.

=====Q1-on.bat===

@echo off === Not required
status: 204 ===== Not sure what this is, but it does no harm!
echo. === Not required
echo. === Not required

out.com 89 378 :: 1+8+128 = 137 = 89 hex ======= The 1 sets parallel port pin #2 at +5V, The 8 sets parallel port pin #5 at +5V, the 128 keeps parallel port pin #9 high at +5V, 

out.com 99 378 :: 1+8+16+128 = 153 = 99 hex ====== The second line keeps the previous parallel port pin settings, and also sets parallel port pin #6 high at +5V. .

out.com 89 378 :: 1+8+128 = 137 = 89 hex ====== The third line lets the latch line pin 6 drop back to 0V, .

out.com 80 378 :: 128 = 80 hex ====== The fourth line sets all the parallel port pins back to 0V, except for pin #9, 

cls === Not required


Many thanks to Zoomkat for his explanations and inspiration! I include his instructions to make out.com




The below batch file will make a program called out.com (by Herbert Kleebauer) when run. Copy the below batch file, paste in notepad, save on the desk top as out.bat. Double click on out.bat and the out.com file will appear. out.com can be used in win95/98 to conrol the parallel port as is. Use with userport (see link above) in XP to control the port (open 378-37A for use of LPT1). The command line out.com 00 378 sets port 378 to 00. Substitute the desired hex numbers for 00 to make the desired parallel port pin +5v. ***Watch for word wrap***. There are 7 lines, with the the long ones starting with echo and ending with out.com. When you copy/paste, make sure it looks as described or adjust as necessary. I also put out.txt here, so you can just copy, paste in notepad, and save as out.com if desired. 

=========out.bat file to make the out.com================ 

@echo off
echo Bj@jzh`0X-`/PPPPPPa(DE(DM(DO(Dh(Ls(Lu(LX(LeZRR]EEEUYRX2Dx=>out.com
echo 0DxFP,0Xx.t0P,=XtGsB4o@$?PIyU WwX0GwUY Wv;ovBX2Gv0ExGIuht6>>out.com
echo ?@}IIHpkg~K=H?H_CgRNWH?wpBmNEFQNS@CbwH@S?pkoECIQ{_K?\qoCve>>out.com
echo {Sx{X?{Eu@Pq`Dkfk?a@o{A@CoCEFr@B@K~Tj~@CeK??BB0>>out.com
out.com 00 378
rem del out.com


========end out.bat file======================= 


The initial purpose of this was to provide a means of disabling my amateur radio transmitter during periods when I needed to monitor periodically operating 5.290MHz beacons on an adjacent frequency. I am now thinking of other things it will do... there are 64 pin combinations......  G4ZFQ August 2009

http://homepages.wightcable.net/~g4zfq/ Main Site Index

The background is an Argo display of QRSS reception on 80m.