home / projects / legoprinter



A Wiring processing board handles receiving print commands from the computer over USB and then co-ordinating the motors to print the page using feedback from the sensors.

overview circuit

Any standard microprocessor/PIC could do this job, some more easily than others.

End stop sensors

So that the print head "knows" where the left and right edges of the track are a sensor is mounted at each end. The sensors are simply push buttons inside a lego x1 beam, a few other bits and a x4 axle that transfer force to the button. The beams were drilled out slightly to get the push button to fit. This allows them to be easily incorporated into the build. There is almost certainly a similar mindstorms component for this job.

detail photo of push sensor

The sensor has 3 wires, ground +5v, and output. The output is pulled down with a 1k resistor. The output is fed into one of the digital input pins on the wiring board.

diagram of push sensor circuit

Home brew shaft encoder.

The print head makes many hundreds of movements whilst printing a page, and these need to be precise. Therefore a feedback mechanism is needed. A shaft encoder is mounted onto the horizontal print head drive so that the firmware can accurately position the head. The gearing used in the drive mean that there are approximately 3 encoder steps for every 1mm the head moves, this should be good enough.

overview photo of shaft encoder wheel overview photo of shaft encoder with sensor

This uses a SYCR102 photo reflector, available from Maplins UK, for the very reasonable price of 0.89 GBP. A photoreflector consists of an LED and phototransistor in the same package. Reflective surfaces moving close to it reflect light back allow more current flow through the transistor.

detail photo of shaft encoder opto sensor mounted in lego

The SYCR102 is mounted inside a x1 beam piece with bluetac. Two resistors are used, one for the LED (current limiting, 390), and one as a voltage divider (10K) for the transistor. The output line is connected to an analog input pin on the wiring board.

The lego-integrated-photoreflector is then mounted against a spinning lego wheel which has alternating 2x2 black and white flat smooth pieces. As this rotate the voltage rises and falls as the resistance of the phototransistor changes.

shaft encoder circuit diagram.

Motor control

Motors cannot simply be connected to the digital outputs of the wiring processing board. Instead a motor driver is required for protection, higher voltages, and bi-directional control. The standard circuit for this is called an H-bridge.

It all started off with a L293N which is a quad half-H driver chip. However when in use this got finger-burning-hot, perhaps because the stall current of a 9v lego motor is a reportedly whopping 700mA. Backtracked, and rebuilt using the more meaty L298N quad driver. This driver has both a higher current rating and an integrated heat sink. Unlike the L293, the L298 does not have internal protection diodes to prevent back EMF, so these were added these to the circuit.

There are three H-bridges, one for each motor, each with two control lines per hooked into digital out pins on the wiring processing board. With both controls low the motors stop, and with either one high the motor will go in either direction. Both lines high performs a "brake" function, which is unlikely to be needed for a printer. For speed control PWM is used rather than varying analog voltage. This will allow interfacing of more motors as there are many more digital pins than analog pins

H bridge driver circuit diagram.