Timed_Switching_LPT_COM

November 2020.

This page is very much out of date. I leave it for those who still use old computers and XP.

Some methods of simple timed switching. Set DTR pin 4 or RTS pin 7 high on a serial COM port (Should work on all Windows versions) or any or all of the data pins on a parallel LPT port. (Windows including 7.)

This is just simple ON/OFF switching, nothing else.

There seem to be no simple, free solutions and I present below what I have found to work. I use batch files. To avoid the Command Window appearing I run these within VBS.

For Serial, COM port switching I use the Command Line facility of Realterm https://realterm.sourceforge.io/ This is said to work on all Windows versions. Realterm needs to be active when switching, Windows takes control when Realterm closes.

The batch file opens Realterm minimised DTR pin 4 and/or RTS pin 7 controllable.

Taskkill closes Realterm, releases port.

In my example a USB/Serial adaptor COM7 is used. Mine has an FTDI chip. When using as a switch note the voltages on pins 4, 7 are around -6 volts when OFF and around +6 volts when ON.

Batch file to set pin 7 high:- [Com7=RTSon.bat] Realterm is started minimised.

start /min "D:\MoreProgramFiles\Realterm\realterm.exe" port=7 rts=1 [Better, use Realterm's "invisible mode "D:\MoreProgramFiles\Realterm\realterm.exe" VISIBLE=0 port=7 rts=1]

EXIT /B

VBS file to run this batch file in the background:- [Com7=RTSon.vbs]

Set WshShell = CreateObject("WScript.Shell")

WshShell.Run chr(34) & "D:\MoreProgramFiles\Realterm/COM7=RTSon.bat" & Chr(34), 0

Set WshShell = Nothing

Realterm remains active on the Task Bar. [So far I have not managed to send another command to Realterm, it has to be closed. This may be possible see https://realterm.sourceforge.io/#Command_Line_Parameters]

Batch file to close Realterm [RealtermQuit.bat]

taskkill /im "D:\MoreProgramFiles\Realterm/realterm.exe"

VBS file to run this batch file in the background:- [RealtermQuit.vbs]

Set WshShell = CreateObject("WScript.Shell")

WshShell.Run chr(34) & "D:\MoreProgramFiles\Realterm/RealtermQuit.bat" & Chr(34), 0

Set WshShell = Nothing

For more than two switched outputs more COM ports could be used. 16 switch states could be achieved using two ports with BCD coding.

To get this acting as an automatic timer these batch files have to be executed by another program.

Windows Task Scheduler should work.

System Scheduler https://www.splinterware.com/products/scheduler.html has a free alternative with some interesting additions.

I use Pycron http://www.brothersoft.com/publisher/gerhard-kalab.html on my XP system to do a regular FTP upload. I am not sure if there is a version that runs on later Windows. Run Pycron setup file, let it install as a service. To set it up go to your Start Menu and select Crontab Text Editor. It is 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,

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.

Timed switching operations via the LPT, parallel port only tested on XP.

I use DX Switcher http://www.dxsoft.com/en/products/switcher/ However, Switcher is only specified to work up to Windows 7/Vista. The parallel port is not dead, there are still a few motherboards with a header. Note nearly all USB adaptors are printer ports only.

Starts minimised does not work with LPT Switcher..

Title Bar is focus for approximately a second when started via a VBS file but the Command Window is not seen.

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.

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 any sequence of switching may be set. Using all eight LPT data pins 63 devices can be switched using a logic switch. 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.

Switcher has a basic, small interface with buttons that will change the state of the pins. For automatic switching the program can be launched with several command line parameters.

As an example, for the first timed period I made this file. This is just a text file, use Notepad, but with ".txt" renamed ".bat" . I called it On.bat Just executing it (double click) turns LPT1 pins 2 and 6 ON, that is, it sets them to +5V

"C:\Program Files\Switcher\Switcher.exe" /LPT1 /M /S1 /S5 /EX

Sets 2 & 6 on and exits. Below LPTOff.bat it turns all pins of LPT 1 off and exits.

"C:\Program Files\Switcher\Switcher.exe" /LPT1 /M /S0 /EX

The batch files are just the single line of text. The /EX is important. Ensure your path (inside the "inverted commas") matches your computer setup, it may be different.

To hide the Command Window run the batch files under VBS as above for the COM port. Use one of the timer utilities mentioned above.

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.

Notes about DXSoft Switcher from the Download page. Also see "README.TXT" in the program folder.

DXsoft Switcher is a simple software to handle devices connected to an LPT-port.

The "1" button erects a logical one at pin 2 of an LPT-port while the "2" button sets high level at pin 3 and so on.

The program can be launched with several command line parameters.

The /LPTn parameter defines used LPT-port (/LPT1 , /LPT2 or /LPT3). LPT1 is used by default.

The /LPTxNNNN parameter defines LPT-port with non-standard base address (for example, LPT-port at PCI-card). There NNNN is hexadecimal base address of a port, 'x' is just letter 'x', not number.

The /M parameter enables to switch on several switches at one time.

The /Sx parameter define a switch switched on at the program start (/S1 ... /S8). /S0 means "all switches are off". To switch on several switches use several /Sx commands.

The /Ttext parameter defines a title of program window.

The /B1text ... /B8text parameters define text on button 1...8 respectively.

The /Ontop parameter puts Switcher in front of all windows.

The /EX parameter means "to set switches and close program".

Control of a transmitter. Describes a TX inhibit except when LPT pin is high. 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. Crontab.txt is edited to set the periods required. Many other uses are possible.

The parallel port is not quite dead. . New motherboards with them may still be found after a good search. PCI and PCIe cards are available. From what I've heard Windows 7 will not allow access to the parallel port but XP used carefully behind a firewall should be no problem.

A few USB adaptors are available one is http://www-user.tu-chemnitz.de/~heha/bastelecke/Rund%20um%20den%20PC/USB2LPT/index.html.en This works with my XP system but only on the USB outlet on which it was first setup. Be careful many USB adapters are not true parallel ports, just printer adaptors. Check the address LPTx278h is what I need in Switcher. Check "Device Manager".

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