Well I’d planned on spending the evening snapping pics and scratching out the next part in the inkjet and servo lab series, but when I pulled my trusty Olympus SP-350 out of the backpack, I discovered it made some odd grinding noises, extended and retracted the lens a couple times eventually displaying “Zoom Error” on the screen. ARGH!!!

After turning it off and on a few times I finally admitted to myself that it wasn’t going to get fixed that way.

A few weeks ago I’d successfully managed to perform a pocket-lint cockroach from the screen inside my iPhone 3GS, so I decided I’d try my hand at one of the more difficult surgical procedures known to consumer electronics.

2 1/2 hours of tiny cables, connectors, wires and screws and several false-starts at sub-assembly removal later, I’d found the culprit, and had it all back together.  A single crumb probably from the folds of my backpack in between two teeth of the zoom mechanism.  Guess I should use the camera case after all.

In the midst of the procedure I remembered this clip from an old movie.  I have to say I felt I could relate, but also felt I’d triumphed over the limitations of my so-called race.

[youtube]http://www.youtube.com/watch?v=96iJsdGkl44[/youtube]

Partially inspired by John Kasunich’s EMC2 wiki article “Tuning EMC2/HAL PID loops, it grew from an extension of his beginning steps to a full lab exercise to help the community grow.

First of all, I’d like to send my thanks to NIST, the EMC and EMC2 teams for an excellent platform!

EMC2 is a popular choice among hobbyists, academics and a growing group of professionals for CNC and robotic machine control. Most commonly it seems to be used to drive machines using stepper motors because of their low cost and simplicity. EMC2 drives servo motors equally well. While doing my research preparation for my own projects I found that there was a need for a simple tutorial laying out basic procedures for integrating servo control under EMC2. As always, the very best way to learn is to do so I ended up playing with a small servo “lab” so I could visit as many concepts and parameters as possible before applying them to a larger machine.

Machine integration is an important and unavoidable step along the way of building or converting to CNC operation. This is where planning, patience and practice come together and you start to see results as your machine comes to life for the first time. Sometimes spastically or even with spectacular violence! Hopefully you can avoid any real excitement and bring your machine into this world in a very sedate and controlled way. My goal here is to help you transition more gracefully from static metal/wood/plastic sculpture to a kinetic moving and useful addition to your life.

Servo motors, feedback, control and mechanics are huge topics each with their own sub disciplines and collections of textbooks. The idea here isn’t to educate you on every possible combination of configurations you may run in to, but to show you how you can set up and play with servo control under EMC2 for very little cost and do it safely.

Eventually you can move on to implementing it on a larger scale. I’m going to make certain assumptions about your level of knowledge ie. basic electronics knowledge, multi-meter use, passing familiarity with the EMC2 Live installation, etc.

Fair warning, I’m by no means an authority on EMC2 or servo control and have only limited experience with the actual tuning portion to do with servo drives, but the other pieces and concepts of machine integration are well known to me.  None of this should be taken as gospel, it’s simply what my process is and I welcome any queries or feedback. My focus here will be on EMC2 and small servo drives but the steps and concepts can be applied to most servo control implementations.

The devices as described are low cost, and fairly lightweight so generally they should be pretty safe for anyone to work with. However care should still be exercised and this project treated just like a giant multi-ton machine. Get in the habit of being over-careful to the point of paranoia and stay there. It will help keep you safe as you progress to work with larger machines.

WARNING: Most automated machines CNC related or otherwise contain or can generate dangerous energies. These energies can be but may not be limited to mechanical, electrical, optical, thermal or acoustic in nature and appropriate care and precautions should be taken. Injury to operator(s) or bystanders may result as well as damage to the machine and its mechanisms. No machine should be operated with guarding removed or interlock mechanisms bypassed unnecessarily. If you are at all uncomfortable with this by all means seek a mentor who can supervise your activities or find something else to do with your time. You have been warned and I cannot be held responsible if anyone or anything is damaged. I am supplying this in good faith that anyone reading this will do their own research and pursue additional training/supervision as needed.

Peculiarities of Servo Drives – A little more challenging

Compared to stepper motors which don’t do much without explicit instructions, servo drives should be approached with a touch more respect because they inherently have the property of constantly correcting their position by themselves using a feedback loop. This means that they’re reacting to a feedback signal and if the drive and feedback signals aren’t working together in concert, ie. polarity is reversed on one of them, or a signal is operating intermittently, then the axis may behave unpredictably, erratically or run away violently. The product of this article should allow you to experiment and screw up with a forgiving mechanism that won’t break the bank if damaged, and shouldn’t cause injuries as long as you don’t play with them in the bath.

Managing Expectations – Some more challenges

One of the things I’ve found is that it appears that inkjet printer mechanisms are geared mostly around moving the print head quickly.  This means that they may not perform as well at lower speeds.  Issues may arise from the looseness of constraint in the system, ie. the print head can bounce a bit on its guides, the tension pully is spring-loaded and may not have enought resistance in some circumstances, etc.  I’ve found the mechanism I’m working with most is noisier at slower speeds.

If you think about it, a printer doesn’t have to position the print head accurately.  All a printer normally needs to do is “fly” the head over the page it’s printing at some set speed, then using the encoder to know where the head is and pulse the ink jets to deposit drops at precise positions as the head is moving by.  The only time the print head is moving at slower speeds, is when it’s performing a homing or head cleaning operation and these both rely on simple velocity commands as well until the print head hits some kind of mechanical stop.  That’s not to say that ALL printers work this way, but it makes sense that the majority would as it’s a much simpler problem to solve mechanically and programatically than the one of managing a velocity and position profile for intermediate positions across the page and thus lower cost.

All this means is that your results may vary when trying to get the system tuned to perform well across a wide performance envelope.

A second challenge that I’ll talk more about later is that in order to keep costs for this project down we’ll be relying on EMC2’s own software counters to track encoder pulses.  This will put an upper limit on the frequency that can be counted and thus the velocity of the axis.  So far I’ve been very pleased with the performance of EMC in the regard, but for more critical applications than a teaching aid it’s important to consider this and plan for a hardware-based counter system when needed.

Emergency Stop Control – For when things are going badly

Emergency Stop ButtonFrom what I’ve seen this is an often neglected topic in hobbyist CNC forums and understandably so. It’s much like discussing insurance and premiums. It’s one of those things that you don’t care about until you need it. You want it to be reliable, easily accessible and provide you with the protection required.  Again it’s a large subject deserving of a textbook or two and possibly a good subject for a later post.

For this project I consider e-stop control to be an optional piece. Again, this should be a relatively safe mechanism to work with, but as part of the learning process you may consider adding an e-stop circuit to your servo “lab”. However when you do go to move on to the “real world” and an actual CNC machine ensure the e-stop system works and become familiar with it.  If the machine doesn’t have an e-stop system, DON’T USE IT UNTIL IT DOES!

Practice – Your own Servo Drive Lab

As I’ve alluded to a few times, integration is a process where things can and sometimes do go wrong. It is possible to break stuff or people. In Part 3 you’ll find that the steps we’re going to follow for integrating a servo-driven axis are laid out so they slowly and incrementally grow the risk as you progress. Observing, Testing predicted results against actual results and tweaking/correcting as you work through the process.

Your “lab” can be set up at surprisingly low cost with just one or two evenings of effort. The apparatus for a Servo Drive Lab is as follows:

PC (with printer port?) Free You knew you needed a PC to run EMC2 anyways right? I’ll assume you already have this.
Printer port card (Optional) $10-$20 If you have one available, it’s preferable to use an add-on card for your printer port. If you’re not careful (and even if you are sometimes) it’s possible to damage the printer port. To keep things simple and more accessible I’m not going to bother with things like opto-isolation, and that means it’s possible to damage the port you’re working on, and it may be best to avoid damaging any ports that are directly connected to the motherboard.
EMC2 Software Free Thanks to NIST for starting this project and making it open source, and the community for picking it up and running with it!
DB25 Cable Free-$3 Plugs into the printer port so it needs a DB25 Male end. The other end doesn’t matter, just hack it off and use a multimeter to figure out which wires go to which pins. The ideal cable is a DB25 – DB25 with a thicker body. This makes it more likely that all 25 pins will be connected to 25 wires of a gauge that is easily used. Printer cables with centronics connectors tend to have 36 wires of very fine gauge making them harder to work with.
Old Inkjet Printer Free-$10 Check under your bed, your neighbor’s basement, garage sales or local thrift store. A gold mine of stepper and servo components as well as other sensors, switches and mechanisms. We’re gonna break it, so make sure it’s not one that the kids are relying on to get their homework off of.
H-Bridge Motor Driver $3-$25 Build from scratch, buy a kit or buy an assembled unit
12 to 24VDC power supply Free-??? I’ve found this can be any set output voltage between these two values. 12VDC is working great for me. Should be capable of at least 1Amp.  An old PC power supply is fine.

Inkjet Printers – A goldmine of small parts

Aside from the pieces we’re really interested in, inkjet printers and multifunction scan/print machines contain a fair assortment of motors, sensors, springs shafts and gears. Some are easier to disassemble than others, but most will do the trick for our purposes here. What we’re after is the motor and encoder mechanisms that make the physical parts of the servo system. At a bare minimum you should be able to pull out a whole linear mechanism that has the motor, linear guide that carries the print head (with the encoder reader), encoder strip, toothed belt and tensioning pulley. It may also be possible to use other parts like the power supply, flex cables, etc.

Epson Stylus C86

So here you’ll have to get creative in tearing apart the printer and finding the mechanisms you want to work with. All the printers I’ve looked at so far have their print heads moved by servo control while the paper feed mechanisms may be either stepper or servo control.

Before buying anything, just double check that the print head uses an encoder strip by opening the access panel on the front or top where you have access to the head. Running parallel to its direction of travel you should find a transparent plastic strip with fine lines etched across it. Really expensive printers and plotters often have laser cut metal strips but you probably won’t be using those for this project.

In this case I’m using an Epson Stylus C86 colour inkjet which has a stepper on the paper feed, is nice and compact with solid construction.

I’ve also found a Lexmark (X2350?) multi-function machine drives the paper feed with servo control. This combination is really neat as you can experiment with the paper feed first which has a shaft encoder giving you continuous rotation without limit (if you get a run-away situation there’s nothing to collide with or jam). Then when you’ve mastered that, you can move up to the linear axis of the print-head which has a limited amount of travel and will bang into stops at either end.

An HP All-In-One unit I tore apart had servo control of all three actuators including the movement of the scanner.

Ensure you have the power supply or power cord to go with the printer as well as this will help in reverse engineering parts of the printer.

In Part 2 we’ll get into the guts preparing the printer mechanically and electronically for its new life as a teaching aid.

In Part 3 we’ll go through the actual steps of integrating the servo mechanism with the PC and EMC2.

In Part 4 I’ll address the PID tuning of the servo drive from within EMC2 to get the best performance out of your new servo mechanism.

Another concept for 3D printing on a re-purposed inkjet printer.

[youtube id=”2nbtZOolSIY” w=”240″ h=”190″]

 

More Links:

Servo and PID tutorials from Galil Motion Control Inc.

Servo Tuning Tutorial (PDF)  from PMC Corp.

Pololu A4983

Pololu A4983 with a nickle for scale

One of the things I need to do while working towards motion control projects is to practice some of the fundamentals.  I’ve worked with many of the concepts and mechanisms professionally, but more from the support end.  I haven’t touched the stuff for a few years now, and want to learn things at a more fundamental level.  In order to do this my plan is to pull motors and mechanisms from recycled equipment (printers, scanners, etc.) and set up a few labs for myself along the way.  Perhaps I’ll try to salvage some of the electronics as well with some good old-fashioned circuit bending.  I should be able to at least reuse motor drivers that are found, but for now I’m going to rely on inexpensive motor driver kits to allow myself more freedom to experiment. continue reading…

Some links that have turned up while doing research:

Musings on the usefulness of inkjet printers for a variety of applications.  So ok, I’m not the only one who’s been thinking about this, but here I hope to actually do something about it!

Anders is playing with EMC2 and RepRap functionality as well.  I’ve experimented with some of his temperature control ideas already, but need to work at the PID tuning a lot more.

PyroElectro has a bunch of tutorials for all kinds of fun stuff like this basic DIY servo/encoder setup.

 

Background

I started playing with EMC on a simple home-build concept mill I built about 9 years ago and it’s been shelved for most of the time since.  I really enjoyed the experience of getting that to work and have followed several other software/hardware projects online since including EMC2 and the RepRap/Makerbot crowd with great enthusiasm.  A couple years ago I was even able to apply what I’d learned to a job running some small CNC machines for a manufacturer in Aurora Ontario.

continue reading…

To quote the Bad Astronomer, “This picture is totally freaking cool”
b1509

agc2A number of years ago I read a contractor’s report about Computers In Spaceflight.  It was fascinating to me to understand just how much went into this one facet of space programs, and just how little computing power it took.  Any college student familiar with basic electronics can understand the fundamentals of these early computers, but the true magic was what the programmers did to squeeze so much out of such a “small” package.  Now it’s easier for us to have one of our very own thanks to one man’s hard work.

continue reading…

pins8lHere’s one of my early projects done while the Canadian Women’s Hockey Team were winning the gold medal in 2002 with the use of my 7×12 minilathe from Grizzly.

These are nesting pin pushers for a couple types of electrical connectors I was using commonly at the time. They combine together into a nondescript brass rod to carry in a pocket.

continue reading…