Servo control from the X68000 printer port
The Sharp X68000’s Centronics-style printer port looks like an unlikely output for a hobby RC servo, yet its eight data lines are enough for software pulse-width modulation. Writing a Human68k program to control a servo motor via the printer port means treating one data bit as a logic-high gate, then measuring and regulating the time that gate stays open. No dedicated PWM controller or interface card is required; an X68000, a suitable servo and a small amount of wiring are enough to begin.
This is a useful experiment because it demonstrates how a general-purpose parallel port can replace a dedicated PWM controller. It also exposes the timing discipline required by early 16-bit software: delay loops consume processor time, pulse widths vary with clock and compiler settings, and electrical loading matters as soon as a real motor is attached. The approach suits a small SG90-style unit or a similar hobby servo, but it should not be confused with a serial servo bus or a professional industrial drive.
Why bit timing suits an RC servo
A typical hobby servo is a closed-loop actuator, not simply a motor whose speed follows a duty cycle. It measures the duration of each incoming pulse and moves an internal feedback mechanism towards a corresponding position. Many common models use a 50 Hz command stream: one positive pulse arrives roughly every 20 ms, while pulse width sets the requested angle. The familiar 1.0–2.0 ms range is only a convention; cheap variants may specify 0.5–2.4 ms, and the model’s datasheet must decide the limits.
The printer port is useful because the CPU can set and clear a data bit without waiting for printer handshakes. A Centronics connector exposes eight data pins plus control and status lines. Pin 2 normally carries D0, so a short wire from that pin can become the servo command signal. The other data pins can stay low, and the servo ground connects to the printer-port ground. Software then performs bit-banging: it raises D0, delays for the calibrated pulse width, lowers D0 and waits out the remainder of the frame.
| Control method | Extra hardware | Timing source | Best use |
|---|---|---|---|
| Direct printer-port bit timing | One servo, regulated supply and signal lead | Calibrated software delay and oscilloscope | Simple single-servo demonstrations |
| Timer-assisted pulse timing | Servo interface plus a scheduled pulse gate | Timer for frame cadence and a short calibrated busy-wait | More regular background operation |
| Dedicated PWM servo board | Controller module such as a PCA9685 | On-board oscillator and PWM logic | Multiple actuators or use with other computers |
| Serial servo bus | Serial transceiver or controller | Framed serial protocol containing position data | Daisy-chained bus servos and feedback models |
That method gives one useful channel at a time, but it is more than adequate for demonstrations. It does not generate an analogue voltage, and the 8255-style peripheral latch merely holds a clean digital level between writes. Because a servo draws far more current than an I/O pin can supply, the port should command the servo rather than power it. That division of duties keeps the X68000’s logic safe and makes failures easier to diagnose.
Building a safe printer-port interface
Wire the command lead to Centronics pin 2 and use one of the connector’s signal-ground pins, commonly pin 18, as the reference. Most hobby servos use brown or black for ground, red for supply and orange, yellow or white for signal, though colours vary between sellers. A 1 kΩ series resistor in the command wire limits accidental current and damps edges. A 100 nF capacitor across the servo supply can absorb switching noise, while a separate 5 V supply with ample current should power the motor.
At an Australian bench, treat the old computer and the servo supply as two separate electrical domains. Australian mains is 230 V, so a replacement or modified supply used with the X68000 should be RCM-compliant and have suitable isolation; leave mains-side work to a qualified electrician. The servo’s low-voltage supply should be regulated and rated above its stall current. Join its negative terminal to the servo ground and printer-port ground, but keep the servo’s positive lead completely separate from the printer port.
Before adding a mechanism, check the signal with a multimeter: D0 should be a 5 V logic level rather than an analogue voltage. A logic analyser or oscilloscope is better for confirming pulse width. Once the electrical test is sound, a retro computing theme can make the bench display feel at home without distracting from the experiment. Keep the servo horn removed for the first run and keep your fingers clear; even a small unloaded servo can move unexpectedly.
Writing the Human68k timing program
The X68000 I/O address space contains many byte-wide registers, so copying an address without checking the board documentation is easy to do. The example uses a commonly published standard-machine map in which the printer PPI’s port A is at 0xE9A000 and its control register is at 0xE9A005. Confirm those addresses against the schematic for the particular board, because clones and revisions may document them differently. The relevant idea is the verified printer data register, not the hexadecimal value itself.
Human68k C commonly exposes direct port access through an iop(address, value) function; some toolchains call the equivalent operation outb(). The control word below puts PPI port A into output mode and assigns the remaining directions for the printer’s status and control lines. It then clears the output latch. The program preserves the other seven data bits in software rather than assuming that a read-modify-write operation is safe on the peripheral.
#include "human68k.h"
#define PRINTER_DATA 0xE9A000
#define PRINTER_CONTROL 0xE9A005
#define SERVO_DATA_BIT 0x01
#define SERVO_PERIOD_US 20000UL
#define SERVO_MIN_US 500UL
#define SERVO_MAX_US 2400UL
#define TICKS_PER_US 2UL
static unsigned char printer_latch;
static void delay_ticks(unsigned int ticks)
{
volatile unsigned int i;
for (i = 0; i < ticks; ++i) {
/* Calibrated delay kernel */
}
}
static void printer_init(void)
{
/* Mode 0: port A output, port B input, port C output */
iop(PRINTER_CONTROL, 0x80);
printer_latch = 0;
iop(PRINTER_DATA, printer_latch);
}
static unsigned int position_ticks(unsigned int position)
{
unsigned long pulse_us;
if (position > 100)
position = 100;
pulse_us = SERVO_MIN_US
+ ((SERVO_MAX_US - SERVO_MIN_US) * position) / 100UL;
return (unsigned int)(pulse_us * TICKS_PER_US);
}
static void servo_frame(unsigned int high_ticks)
{
unsigned int period_ticks =
(unsigned int)(SERVO_PERIOD_US * TICKS_PER_US);
printer_latch |= SERVO_DATA_BIT;
iop(PRINTER_DATA, printer_latch);
delay_ticks(high_ticks);
printer_latch &= (unsigned char)(~SERVO_DATA_BIT);
iop(PRINTER_DATA, printer_latch);
delay_ticks(period_ticks - high_ticks);
}
int main(void)
{
printer_init();
for (;;) {
servo_frame(position_ticks(50));
}
}
The delay routine deliberately uses a volatile loop instead of pretending that C statements take a known number of microseconds. TICKS_PER_US is a calibration result, not a universal constant, and the example value must be replaced after measurement. It must include loop overhead and the time spent entering iop(). If the compiler supports a native NOP intrinsic, that can provide a tighter and more repeatable kernel, but every change in optimisation, memory wait states or processor clock needs another measurement.
The sample holds the midpoint by mapping 50 to a pulse between the configured minimum and maximum. Replace the minimum and maximum with the servo’s specified values before compiling, and start with a conservative centre position. Calling the frame routine continuously supplies the refresh pulses the control electronics expect. Do not mix in Human68k BIOS printing calls while the servo is attached, because those routines may change data or handshake lines behind the program’s back.
Calibrating pulse width and frame timing
Calibration begins with a known pulse target, usually 1000 µs, and a scope measuring from the rising edge to the falling edge on pin 2. If the measured width is too long, reduce the tick count; if it is too short, increase it. Test both a short and a long pulse because loop overhead is fixed while the delay itself scales. The measured period between rising edges should also be close to 20 ms, but many servos tolerate a range, so the datasheet remains the authority.
Do not copy popular pulse values blindly. Australian hobby shops such as Jaycar and Core Electronics stock servo-related parts, while specialist suppliers and overseas modules sold in Australian dollars can have very different documentation. Check whether a listing describes a hobby RC servo, a continuous-rotation unit or an industrial device; they can use the same connector and incompatible commands. A quick test on a quiet arvo, with the horn detached, can reveal reversed feedback or an unsuitable minimum pulse before anything is mounted.
Typical symptoms are informative. No movement usually points to a missing common ground, reversed servo wiring or insufficient supply; continuous rotation suggests the wrong servo mode; buzzing points to an invalid pulse width or frame interval; and resetting under load indicates voltage collapse. Keep the pulse within the maker’s limits, use a fused supply and avoid stalling the mechanism. A logic analyser can also catch a noisy line that an ordinary multimeter hides.
Preserving the X68000 while putting it to work
The electrical work is only one part of preserving an X68000. The same care applies to its ageing power supply, keyboard and storage: document every connector and modification, use thermally sound replacements, and keep the original board recoverable. In Sydney or Melbourne, an old machine is better kept on a stable indoor bench than in a humid cupboard or a hot garage. Sydney’s humidity and Melbourne’s summer heat can accelerate corrosion, so ventilation and a modest dehumidifier matter more than cosmetic cleaning alone.
Expansion and maintenance notes are valuable because each machine ages differently. For a companion storage example, the second floppy installation guide documents the care involved in adding another drive without compromising the original system. Record connector pinouts, switch settings and tested software alongside any hardware change. That habit turns a one-off servo demonstration into a reproducible X68000 preservation project and gives the wider hobby community something more valuable than an unlabelled cable bundle.
Start with one unloaded servo, a verified common ground and a short measured pulse sequence. Then publish the schematic, calibration values and test results to the X68000 community, and invite another enthusiast to reproduce the experiment on an unmodified machine. Keeping the power and storage work documented alongside the software will leave the Sharp X68000 active, understood and worth preserving.
Nereid-X Expansion Board
A personally-produced LAN+USB+Memory expansion board for Sharp X68000 series computers. Multiple production runs were offered, including a final batch and a later revival reproduction run.
Power Supply Repair
X68 power supply repair and modification services were offered by the site owner, with documentation shared through diary entries spanning 2001–2006.
Server & Networking
Notes on FreeBSD administration, ISP changes, server migration, and networking topics. The site itself ran on FreeBSD with the hns diary system and Namazu search integration.
Get in touch
X68K.NET connects Sharp X68000 enthusiasts through community links and shared projects. Reach out with questions about the Nereid project or X68 resources.