If you want to build your own control system, you can review some options at Control Systems. The option described here, to build your own controller device, is that you could leverage an Android device, USB-OTG port, and USB parallel printer adapter. For that option, first lets cover some background on the approach, and then the steps to take to build this controller.
The USB interface is directional with one host that can communicate with a number of connected accessories. The connector on many smartphones only allow them to be an accessory. This allows the smartphones to be charged or connected to a personal computer to sync data such as photos. However, some smartphones, such as the Android Samsung S# series, allow an adapter to be plugged in that then allows USB accessories to be plugged in directly to the smartphone as a host. An example of this would be to plug in a USB memory stick to an Android smartphone with USB-OTG which then allows the user to use the Android File Manager to look at or move files to the USB memory stick.
With a smartphone with USB-OTG support and an adapter, you can connect a USB to parallel port cable. Parallel ports were designed for early dot matrix printers. Early dot matrix printers had a print head consisting of a row of seven to nine metal pins connected to solenoids. When power was applied to the solenoids, the pin was pulled forward to strike the paper and leave a dot. The parallel port was designed to make it simple to set or clear these pins. However, instead of a printer head, a parallel port could control any number of other items like turning on an electric motor for a wheel on a robot or switching on or off a control valve for a thruster on a spacecraft.
If you want to use the parallel ports data bits to control items like an LED light or an electric motor, depending on your parallel port, you will probably need electronics that respond like an older printer. Otherwise you'll only be able to send one byte, which will cause the computer to think that the printer is busy and it won't send any more bytes of data. The parallel or centronics port handshake uses the following pattern.
First, data is presented on the parallel port pins 2 to 9 representing data bits 0 through 7. The computer then lowers the Strobe line (pin 1), waits a minimum of 1 μS, and then raises the Strobe line. The data bits would normally be read by the printer on the rising edge of the Strobe line. The printer electronics would indicate that it is busy processing the data by raising the Busy line (pin 11). The computer then checks to see if the printer electronics are indicating it is busy, and waits for the Busy line to go low. Once the printer has accepted data, it will acknowledge receiving the data by a low pulse, about 5 μS, on the Ack line (pin 10). Quite often the computer will ignore the Ack line to save time, but it won't ignore the Busy line.
Thus, depending on the parallel port hardware or cable you have, any electronics you wire up may need to respond as printer electronics would. Your electronics might not need to do anything. They might need to keep the Busy line (pin 11) low so the computer sees that it can keep sending data. Alternately they might need to raise the Busy line and then lower it to indicate the data has been accepted. In rare cases your electronics might need to both raise and lower the Busy line and also lower and raise the Ack line (pin 10). Other parallel port input pins like the Paper-Out line (pin 12), Select line (pin 13), and Error line (pin 15) should be kept low.
|Pin (DB25)||Pin (36 pin)||Signal Name||Direction|
For this to work you need both your operating system (OS) and hardware to support USB-OTG. USB host mode is directly supported in Android 3.1 (API level 12) and newer platforms. Windows Embedded Compact is reported to support USB OTG as of Windows Embedded CE 6.0. Windows 10 introduces support for USB Dual Role or OTG connectivity. However, the app we're suppling is only for Android 4.0 or later.
Determining which smartphone hardware supports USB-OTG or USB host is a little hard because you have to have a USB device attached to the Android device in order for the software to determine if USB-OTG is supported. To check your hardware, download the Android USB-Controller app to your Android smartphone that you think has USB-OTG support.Link to USB-Controller for Android smartphones
Then plug in a USB-OTG adapter to the smartphones USB port and a USB to parallel port cable to that adapter. Run USB-Controller and select the USB Host Check. This will tell you what USB devices were identified as being connected to your Android device, or it won't recognize any devices. If the later occurs, then your Android device doesn't support USB-OTG (aka USB-Host).
I've confirmed that a Samsung Galaxy S5 supports USB-OTG. The list of devices that should support USB-OTG includes (but is not limited to):
If you have confirmed that other smartphones or tablets support (or is on this list and doesn't support) USB-OTG please email us at teraKUHN so we can update the list for others.
As mentioned above, any electronics you wire up may need to respond as printer electronics would. The most common handshake you will need to produce is to raise and lower the Busy line (pin 11) after the Strobe line is lowered and raised indicating data is available. In order to do this you could just invert the Strobe line and delay it slightly. This can be done with a transistor circuit to invert the Strobe line signal, and then an RC (resistor/capacitor) circuit to delay that signal. The RC circuits output is then fed back into the Busy line. The RC circuit generates the delay in the signal based on the time constant of it's components. When an increasing DC voltage is applied to a discharged capacitor, the capacitor charges, and when the voltage is reduced over a charged capacitor, the capacitor discharges. This charging and discharging of a capacitors energy is not instant If a resistor is connected in series with the capacitor forming an RC circuit, the capacitor will charge or discharge slower through the resistor. The time constant T of an RC circuit, is measured in terms of T = R x C, in seconds, where R is the value of the resistor in ohms and C is the value of the capacitor in Farads. The bigger the combination of R and C in your circuit, the longer the data bits will be held in their state before then next pulse of data bits. To provide the small amount of current this circuit needs, you can leverage the Linefeed, Reset, or Select-Printer lines which are outputs that should be held high (5v). Here's a diagram of the circuit you want to wire up.
You typically shouldn't wire up a digital output directly to a motor since a motor will probably draw more current than the digital output is rated for. Instead you should have a small amplifying switch circuit, and a separate power supply to drive the motor. This can be done with a transistor circuit to amplify any of the 8 digital output signals from the parallel port. A diode and capaciter in parallel to the motor prevents problems with the circuit when the motor is stopped and it momentarily acts as a little generator. This circuit can be used for driving a small motor from just about any digital output like an Arduino, PC parallel port, etc., not just this project. Here's a diagram of the circuit you want to wire up.
Every time a byte is written to the data ports, the data is only present as long as the Busy line is high. However, the Strobe to Busy circuit above regularly lowers the Busy line so that you can continue to send control bytes. Thus you need to continusouly send control bytes to the port in order to be able to change the state in the future.
In order to do this, you can use the Android USB-Controller app that you downloaded to your Android smartphone earlier.Link to USB-Controller for Android smartphones
Set the bits you want to turn on and the select the Send Data button. The data will be held as long as a countdown counter is running. The countdown counter can be set in the USB-Controller apps Settings.
Here's a video of a Android smartphone (ARM) controlled Snap Rover robot using this PWM Strobe to Busy circuit and simple Motor circuit and USB-Controller.
Alternatively, instead of using a pulse width modulated (PWM) signal, you could build a digital logic circuit that latches (saves) the data ports triggered by the Strobe line. You would then connect any motors or lights to the output of these latches. This might be a better solution for some, but would then require a more complex circuit and a separate power supply for the digital circuit. You could still use USB-Controller to send the data by using it's Settings to set the countdown counter to 1.
Copyright (C) 2017 R. J. Kuhn. Please note that you are not allowed to reproduce or rehost this page without written permission.