XY-Plotter

Introduction

By: Kyle Chrzanowski, Matt Egan and Brendan Lynch

This project consists of two main parts. Part 1 deals with setting up one working printhead. Part 2 deals with setting up a second working printhead, and using an application that will talk to the mbed application. This application will allow the user to select to draw either a Spirograph or a custom image that the user can draw by dragging their mouse in the allotted space. The GUI then converts the drawn spirograph or custom image from the screen into coordinates that the mbed is able to draw accurately.

The below figure depicts the overall flow of the program.

http://i.imgur.com/IRUvAxE.png

Parts List

  1. Two Printer Axis
  2. Mbed
  3. H-Bridge
  4. 12 Volt Barrel Jack
  5. Included Printer DC Motors
  6. Computer Running Visual Studio or similar IDE

Part 1: Setting up one working printhead

Introduction

Most inkjet printers operate on the same principals. The printer carriage (n. a moving part of a machine for holding or shifting another part) holds the inkjet cartridges and moves it in a reciprocal motion over the paper and deposits ink in the correct places. This printhead needs to move at a high speed (to keep printing speeds high) and with high accuracy (to make sure ink is put in the right places). While stepper motors are perfect for this task, since they can be moved in precise intervals, stepper motors with enough torque and speed are expensive and bulky. Instead, most printers use plain, cheap DC motors in combination with photo interuppter and an optical encoding strip. Here's an exploded view on an HP Deskjet 1200C, which was first released in 1993.

https://developer.mbed.org/media/uploads/mattegan/deskjet_exploded_view.png.pagespeed.ce.NJEe6OHO9c.png

  • 10 is the optical encoding strip, it is a clear plastic strip with numerous opaque (usually black) ticks along its length. The clear spaces let light through, and the black slits block light.
  • 7 is the printhead, which holds the inkjet cartridges, moves along 9, the carriage support bar.
  • 12 is the carriage motor, which operates in conjunction with 11, the carriage belt, to move the printhead along the carriage support bar.
  • 43 is the "spot sensor assembly" which houses the photo interrupter that senses the clear and opaque strips on the encoding strip.

These parts are pretty ubiquitous on almost every inkjet printer of this type. To prove this point, below is a photo of the carriage assembly from an inkjet printer that was purchased about 7 years ago. Though quite ancient in technology-years, consider that this printer (from 2011 or so) is almost 20 years older than the Deskjet discussed previously, and still uses the same technology: DC motor, belt drive, encoding strip. Differences between then and now may be the size of the DC motor to allow for larger ink cartridges and faster priting, improvements in the rigidity of the carriage assembly to increase unwanted movement of the printhead and a higher density of ticks on the encoding strip to increase printing resolution.

https://developer.mbed.org/media/uploads/mattegan/carriage.jpg.pagespeed.ce.4kWi6ke6o_.jpg

Lastly, note the frequency of which this motor control technique is used. In the printer I tore apart there was an encoding strip on the print head motor, the paper feed motor, and the scanning bed motor. This is the same in the old Deskjet in the exploded view above, look for the additional optical encoding pieces, they are usually linear or circular discs.

Note

Old printers are incredible part mines. In addition to all of the motors/encoder assemblies, there are additional encoders used throughout the printer. Many have color bitmap LCD panels that can be reused, and some have custom LCD multi-segment displays (the one torn apart above had a 3-star print quality that would be fun to use in another project). Smaller components such as pushbuttons and passives can also be harvested, but may not be worth the work. Printers/scanner/copiers also have a linear CCD that could be reused, and usually come with a piece of glass. Also, for the mechanically inclined, there are a multitude of springs, gears, metal shafts, and rubber bits that can be harvested.

Photo Interrupters and Linear Encoding Technique

Here's what a photo interrupter looks like:

https://developer.mbed.org/media/uploads/mattegan/interrupter.jpg

You don't need to understand much about photo interrupters. Think of them as a black box that houses an light source on one side and a photoresistor on the other with some sort of logic buffer on the output to ensure the output is only "low" or "high". In reality, it could be much more complex than this, but for our purposes we don't need to go much deeper than this. The polarity of the interrupter could differ from model to model (active high vs. active low), but for now, just consider them to produce one output when interrupted and the opposite output when open.

The other component is the strip, here's what that looks like close up:

https://developer.mbed.org/media/uploads/mattegan/strip.jpg.pagespeed.ce.Kk4F-dsdN-.jpg

https://developer.mbed.org/media/uploads/mattegan/strip_close.jpg.pagespeed.ce.Gr37_YG7Ff.jpg

There are lots of fine slits on the strip. This is what is continuously interrupting the light in the photo interrupter as the carriage is moving. Looking at the output of the interrupter on an oscilloscope would reveal a square wave with a frequency that is dependent on the speed that the carriage is moving. Unfortunately, if there is only one interrupter then this is the only data that can be extracted from the output, the velocity. To determine direction, two interrupters are needed that are spaced apart from one another at a distance of one half of the black slits on the encoding strip (or an even integral multiple of this distance). The interrupters intended for use with these strips usually contain a pair of detectors and one light source.

When this pair of detectors is used, two square waves can be observed, 90 degrees out of phase with one another. By determining which one leads in phase, the direction of movement can be determined. Trace through the motion of the two interrupters in the diagrams below to see how the output from each interrupter changes when they are moving left or right on the encoding strip. If more information is desired, this short white paper from National Instruments is useful, as well as the Wikipedia article on rotary encoders which uses a similar encoding technique.

https://developer.mbed.org/media/uploads/mattegan/xleft.png.pagespeed.ic.VWBH_lZwAh.png https://developer.mbed.org/media/uploads/mattegan/xright.png.pagespeed.ic.-qhohOimjG.png

Reverse Engineering

The first step to using a printer carriage is determining the pinout of of the photo interrupter. Documentation can sometimes be found by searching for any part numbers that appear on the interrupter itself, but because many printer manufactures use proprietary or one-off custom parts for this integral component of the printer, these documents can sometimes be difficult or impossible to track down. Another option is tracing the connections back to the microcontroller and power/ground planes. Whichever pins go to the microcontroller can usually be assumed to be the outputs. If taking this approach, be careful not to over-current the LED, use incrementally larger current limiting resistors if possible.

For the particular printer that was torn apart above, none of these methods were viable. The last resort is to solder bond wires to the pins that come from the interrupter itself (these would be needed eventually anyway), and then plug the guts of the printer back together. If lucky, the interrupter will always be powered when the printer is on, and the carriage can be dragged left and right while the output is observed on an oscilloscope or logic analyzer. An oscilloscope or voltmeter can also be used to determine the voltages on the pins of the interrupter that are not outputs, which will help determine how the interrupter is powered.

https://developer.mbed.org/media/uploads/mattegan/xbond.jpg.pagespeed.ic.ZCgBxmLP-C.jpg

Here's a video of the output being probed on a logic analyzer. Note the little wooden stand that was built to hold the carriage assembly and the breadboard.

Driving the DC Motor

This is specific to each setup setup, the easiest method to control the motor is using an H-Bridge IC such as the TB6612FNG. Alternative circuits can be built using discrete components. Here, a test was performed with the motor from the disassembled printer and the H-Bridge driver. The two pushbuttons are simply controlling the direction of the motor.

Implementing A Simple C++ Driver Library and Control System

Since most printer carriages are going to have the two encoder outputs, and the motor as an input, a generic driver library can be written for these carriage systems. In writing this library, it was assumed that there are three outputs to the motor: a PWM output to modulate the motor speed, and two digital IO pins which select the motor direction. This should be common if using an H-Bridge driver. The two inputs to the system should be the outputs of each of the interrupters.

To sense the movement of the carriage, two interrupts are used, one for each interrupter output. On a rising or falling edge of either interrupter the status of the other interrupter is polled and from this the direction can be determined. Re-examine the diagrams above to see this in action. After the direction is determined, a "location" variable is either incremented or decremented based on the direction of the movement. Right is defined to be the positive direction and left is defined to be the left direction. This was tested by sending the current location to the serial port on the MBED. The MBED has a low enough interrupt latency to ensure there are not any missed counts unless the carriage is moving uncharacteristicly fast, faster than the motor would be able to obtain.

To turn the carriage into something "commandable" a goal location variable was added to the class, such that other code may change the location that the carriage should be attempting to move to. A ticker was then used to constantly monitor the difference between the goal location and the current location (the positional error) and then porportionally control the motor speed and direction to reduce the error. This works! But unfortunately without some more work on the feedback control (adding the I and D terms) there are some unwanted oscillations. Laugh along here with this video. As soon as the platform is perturbed it instantly starts oscillating. The buttons now increment or decrement the setpoint by 500 ticks. So it works, but not really in a desireable fashion.

One easy solution is to add some sort of allowable error. Basically, keep the motor off unless the position is more than some tolerance away from the goal position. This prevents the self oscillation. The next video is of this working. Notice how force can be applied to the platform and it tends back to it's previous position. The buttons still adjust the goal positions.



Part 2: Setting up the second working printhead and using the Windows application

Introduction

This part deals with adding a second axis, as well as running and using the Windows application.

Adding a Second Axis

In order to add a second axis, simply secure a second carriage on top of the first using multiple brackets and screws. Although this works well enough, for a commercial application, one would want a more elegant mechanical solution that prevents the second carriage from wobbling too much due to the weight of the DC motor. Below is an image of the brackets attached to the print carriage assembly. This, in turn is attached to the second print carriage assembly above the first, creating a 't' shape.

http://i.imgur.com/8VCeQYx.jpg

Below is the Resulting T-Shape

This also should be powered and controlled similar to the single printer head but with additional pins. In this case, the other side of the H-Bridge was used exactly the same as the first printer head.

The Mbed Application

Download and run the below application on your mbed. Included are all the libraries and dependancies needed.

Mbedded XY Plotter Application

The program above serves several purposes:

  1. Establishes communication to the attached computer over USB serial port
  2. Responds to a series of commands that can be sent from the computer
    1. Heartbeat- Test to see if the mbed is attached and is working
    2. Position- The location of each of the printer heads
    3. Positioning mode- Sets or returns the current printer mode. Absolute or Relative.
    4. Feedrate- Sets the speed at which the printer moves or returns the current feedrate
    5. Move- Move to a certain location (specified number of ticks) at the current feedrate

Already, the mbed can do enough to make the plotter dangerous. Simply by sending a few serial commands over the USB from a terminal session, one can find the location and get the motors to move.

The Windows Application

Download the Windows Application and run it while connected to the mbed via USB serial. This will sample the on screen picture and create a virtual buffer, sending each point to the plotter.

Creating a Serial Buffer

So that information is not lost, the file XYPrinter.cs creates a buffer for commands to pile up to and sends them only after receiving an ack from the mbed. This prevents printer stalling and lost information.

Drawing a Straight Line

Since the printer will be drawing using tiny, sampled vectors, all the plotter needs to know how to do is to draw a straight line. If it can draw a straight line at any angle, then it can draw anything. The current reason it cannot draw a straight line is because it works entirely on position. The motors move at identical speeds, no matter where the plotter is drawing to. If the plotter is drawing along the axis (one motor is moving) or at a 45 degree angle (both motors moving at same speed) this is not a problem, as the plotter will draw a straight line. However, if say the plotter is assigned to go 100 ticks up and 1000 ticks right, the first motor will arrive in 1 second, while the second motor will arrive in 10 seconds. This creates an almost triangle drawn shape, when it should have drawn a straight line from (0,0) to (1000,100).

In order to fix this, the top motor must know to move at a slower speed than the bottom motor. This is exactly what is implemented.

Using the GUI

The windows application allows creation of a spirograph or a user image and allows calibration of the allotted drawing space. By going to File->New->Spirograph, you can change the parameters at the bottom of the screen to get the desired spirograph. Once this is found, by going to File->Print, a new box opens with several options. The prompts will guide you through the process but the overview consists of the following.

  1. Using the buttons on screen, the user positions the Plotter into the top-left most corner of the desired drawing space.
  2. The user then uses the buttons on screen to position the plotter in the bottom right most corner of the desired drawing space.
  3. The application then scales the on screen image into the proper dimensions of the desired drawing space.
  4. The application samples this on screen image, and creates a vector of all the locations that the plotter should move to.
  5. The application sends this information over USB serial with the command to print them.
  6. The plotter responds by printing each vector and then responding with an ack.
  7. The application uses the information of the location of the plotter to trace in red what has been drawn on screen.

In a similar fashion, the user drawn image is scaled and converted from the on screen representation to vectors that the plotter draws.

The below video shows a sample of a user using the GUI windows application.




First Scaled Printing Success




Full Functioning Demo

Future Additions

The weakest part of our design was the wobbly attachment of the two printer carriages. In the future, the group would like to have a mechanical engineer design a more stable way for the second printer head to rest on the first. This would decrease the small jittery writing that is sometimes produced as well as completely eliminate the occasional axis-sticking.


Please log in to post comments.