MiXley 3D printer - Main electronics
Note: This blog and four others have been held up for a looooooong time. Sorry about that, but I had other priorities. I will try to publish them during this and next week.
The last two blogs were an introduction into 3D printers in general and an explanation of our heated printing surface. I highly suggest you read those before you read this blog as I will not repeat the basic terminology. The topic of today is the circuit board that receives commands from a computer or SD card and translates that into motor movement and other actions. We'll abbreviate this to 'main electronics' from now on. There is room to improve on these electronics.
For starters, the total cost of the main electronics for your homebuilt 3D printer is currently around 200 euros. Another motivation, and probably the most important one, comes from the fact that the open source RepRap community is still really a hacker's community. Not a lot of people are interested in making a 3D printer for the masses - a safe, compliant and practical device. No, most people are just concerned with getting the damned thing to work in the first place, spending the rest of the time improving performance. I myself believe very much in the concept of 3D printers and I think that now is the time to start thinking ahead - ahead to a future where 3D printers are much more commonplace and to be operated by people without a PhD in electronic and mechanical design. So, what needs to change?
- Previous blog: building and improving a 3D printer
- Previous blog: designing a heated print bed
- This blog
- Overview of existing electronics
- MiXley's improvements over other electronics
- Schematics, layout and connections
- Next up
Overview of existing electronics
First of all, let's list the functions and components of the main electronics:
- Receive and process commands from the computer, done with a microcontroller
- Drive four motors/motor sets (XYZ+extruder), usually done with Allegro or TI stepper motor drivers
- Closed-loop control of the heaters, usually done with a MOSFET open-drain output and thermistor
- Monitoring of the endstops (switches at the end of the XYZ axes), no external electronics needed for this
It's a very modular system; what you see here is just part of it. RAMPS consists of:
- An Arduino development board (separate from the picture)
- The RAMPS board, little more than wiring and connectors, plus one or two MOSFET outputs and power regulation
- A number of 'pololu' motor driver boards
- optionally other interface boards, e.g. i2c/rs-485 boards
When designing electronics, you inherently have many points of failure. You can't fix this by making everything modular and easily replaceable; that would be madness. The key to safe and compliant electronic design is to identify and neutralize possible points of failure. If something in your design is then still, inadvertantly, more likely to fail than something else and if it is economical to be user-replaceable, then you can make it replaceable. If not, the added cost of connections plus the additional risk you get from having connectors (and don't underestimate this - connectors are every design engineer's worst nightmare) just don't weigh up against the benefit of the user being able to fix his own gear. This is how electronics have become so good through the years. Integration and minimization wherever possible ( A ), and prevention of catastrophic failure where necessary ( B ). Mendel-parts understood this last sentence partially, and they came up with 'generation 6' electronics:
It's just one PCB. The motor drivers and microcontroller have been integrated, it's just one board. Nice, although... When talking to users and the designers of this board there was still the issue of frequent hardware failures around the motor drivers, just like RAMPS. And that's because this board did a fair job on integration, but not on point B: prevention of failure where necessary. Additionally, generation 6 is a 4-layer board, which kills the bill-of-material cost in small production runs, partially explaining the higher market price of gen6 even though it is more integrated than RAMPS.
MiXley's improvements over other electronics
So, ample room for improvement, eh? Well, it's easy to criticize designs, but truly improving it without any drawbacks is not easy. MiXley is still in its first iteration; the boards I will show you in this blog are the very first prototype. So right off the bat I have to say: we're pretty confident, but it's not perfect yet!
Safety and foolproofing
The fuse rant
As you might guess from the title of this subchapter this is my main gripe with current electronics. Basically the only 'safety' precaution I have seen in existing designs is an input fuse, usually poorly chosen. And whenever I ask people what should be done to improve on the electronics, they say 'just make room for a fuse'. Let me explain: A fuse interrupts the circuit if the current through the fuse exceeds some value. A 4A fuse will ideally blow at 4.0001A. Ideally. My choice of words should reveal what I'm about to say here.
|A traditional glass fuse (like you'll find in lots of consumer electronics) or blade fuse (like you use in your car) doesn't blow at its rated capacity. Its rating is the current it can always safely conduct. A glass fuse has the characteristic of being able to conduct between 50 an 100% more current for 60 seconds, and a many times its rating for still pretty significant amounts of time (0.1-1s).|
It's just a misunderstanding about what fuses are for and what fuse to use for what situation. Glass fuses are still important - to prevent fire! If something short-circuits, the device will eventually blow and cut current.
|But to prevent individual drivers from dying you need to fuse each motor independently with a very fast, very small and easy to blow fuse. This definitely means SMD fuses, and those are not easy to replace. Because I do foresee people misconnecting stuff and short circuiting, I decided to use PTC resettable fuses; fuses that trip pretty fast and restrict current, but after some time when they cool down they reset themselves. That's even better than replacing. These devices are sometimes called polyfuses.|
Motor disconnect arcing
Another common failure mode is driver failure when the user disconnects a motor while running. This is caused by the motor inductance causing an arc (high voltage spike) over the driver output when motor current is suddenly interrupted. MiXley fixes this in two ways: first of all, the arc energy is dissipated by an MOV device over the motor terminals. MOVs are nonlinear resistors: normally, its resistance is very high. If the voltage over its terminals becomes more than some value, its resistance drops sharply. This effectively limits the maximum voltage (like that destructive arc voltage) over its terminals. That's the theory and seems pretty simple. Now we get to the technical part.
There is one practical problem. I wanted MiXley to be 24V compatible, which means that the MOV should not trip at 24V. However, when I look at MOVs that are guaranteed not to trip at 24V, the voltage at which they are guaranteed to clamp a voltage spike is more than 35V, i.e. there is a chance that it will not suppress these motor voltage spikes to under 35V. Why is this relevant? The Allegro and TI motor drivers I am planning to use are rated for absolutely no more than 35V or they will die.
Even though the design margin in this instance is really small, it would be bad design practice to overlook this. So in order to further suppress voltage transients I reused another MiXley-unique function: the motor driver output filter. Instead of hooking up the driver output directly to the motor terminals, I put an LC-filter in between the driver and motor to smooth out the PWM output wave. This has the added benefit of voltage spikes being absorbed partially by the output capacitor, avoiding damage to the driver. This completes the driver protection and in theory prevents any and all motor disconnect arcing. This will have to be tested in practice with a simulated inductive load discharging into the motor output.
This concludes the entire output filter for MiXley.
Reverse polarity and overvoltage protection
Something that is oddly missing in most designs is reverse polarity protection. MiXley first of all fixes the problem of accidentally reversing polarity by using a standard 5.5mm barrel connector for its power input instead of screw terminals. More about that in the chapter 'foolproofing'. In the highly unlikely case that you're hooking up a connector that is the wrong polarity (even though 5.5mm barrel connectors are standardized - negative terminal is the outside of the barrel, positive is the inside - you can still get the wrong polarity on those cheapo universal power adapters) there's a diode antiparallel to the input voltage behind the fuse. This way, when the polarity is reversed the diode shorts the fuse and the fuse blows, interrupting current to the device.
You might ask: why not use a diode in series with the input voltage, that way the fuse won't blow if you connect it wrongly. Well, this is again a conscious cost-benefit tradeoff: I know that the likelihood of reversing polarity is very small and something non-recurring (you do it wrong once, change out the fuse and that's that). Glass fuses are literally a dime a dozen.
On the other hand, if I would design the diode in series with the input voltage there will always be a voltage drop and power dissipation in the diode. This is not just a few milliwatts - at nominal input current (about 4A) a very good Schottky diode would dissipate about 1W - a reasonably cheap one would dissipate 1.8W. That's a lot of power for a small device, i.e. I would need to design in a larger diode and either a small heatsink or a lot of thermal vias to dissipate the heat. That will most definitely cost more in the long run than the antiparallel solution. And in fact this is how many similar devices are designed - either because the input current is so high that it is simply not possible to put a series diode in the circuit or because the failure mode is very rare. As a design decision I must admit that 4A is a borderline situation, so I expect the series diode to pop up in plenty of other designs.
Overvoltage is handled in much the same way by the MOV and glass fuse. Testing is needed to see if the 0603 MOV is actually capable of dissipating the energy needed to blow the fuse. My simulations show that it should work.
Another small but important attention is ESD protection on the USB data lines. This is actually very important, because you will usually connect power and USB to different (isolated) devices that float at different potentials. If on interconnection the equalizing charge goes through the USB data lines, it will instantly destroy the microcontroller and probably all other electronics as well. Always protect outgoing data lines!
This is more of a design philosophy section and as such the answers aren't as clear-cut. Foolproofing means that the end-user cannot, with a reasonable usage model, do something to damage the device or impair (part of) its functionality. Electrically the biggest 'thing' in foolproofing is really keeping people from plugging stuff in backwards - or plugging stuff in the wrong sockets. How do you do that? Well, use dissimilar and asymmetrical connectors for every separate function. In a discussion on IRC with a few knowledgeable people I found out that the connectors currently used for the motors - which is not necessarily keyed (i.e. the connector can be flipped or translated, there is no certainty that you always plug it in the same way) - is considered a good thing because if the motor runs in the wrong direction, you can turn the connector around and bob's your uncle. Wrong. This particular problem can easily be solved in software. And besides, if the connector is keyed and always the same, motors shouldn't be produced with wrong connector layouts. It should be standardized. People should not work around broken designs.
Now that we established the need for connectors that cannot be misunderstood by the end user, the question arises: what connectors do we need to implement? Well, cost reduction is a big factor. Cabling and connectors are notorious for driving up system cost, because believe it or not but connectors are a whole science on their own. The reason that your average HDMI cable is so cheap is not that it is a simple connector - not at all, it is probably the single most engineered component in all of your electronics. But it's made in great quantities - billions. It's a commodity product. That's good, we can profit from the availability and price of these connectors by choosing widely available computer interconnections.
For the motors, we have chosen Molex 70553. This is a keyed variant with positive retention (i.e. it closes with a latch, there is no way to accidentally disconnect the motor) but it still has the 2.54mm pin pitch of the widely used 4-pin Molex 22-05 connector (that's the one you use to connect PWM fans to your motherboard).
There is also a cooling fan output on the board. It's got the standard 3-pin fan connector (Molex 22-05):
Next up are two groups of connections: actuators and sensors. I decided that the end user shouldn't worry about what kind of sensor he is using - every 'sensor' should just have the same connection. Same goes for actuators (signals that tell something to do something). We settled on standard 2.5mm audio jacks for actuators and standard 3.5mm audio jacks for sensors.
Now, you ask, how do these work? Well, the actuators are nothing more than an open-drain signal output. They can send a 1 or 0 and that's it. This means that the board cannot provide power to actuators; actuators need their own supply and switches. I have done this to give the user the freedom to use actuators that are mains operated or that are low-voltage DC operated. Currently the only type of actuator on 3D printers are heaters (both in the printing head and heated print bed), and I plan on using mains power for these. If anyone wants to use low voltage DC, they can go right ahead and don't need to change out the electronics.
In the case of sensors it's a bit different. The sensors employed in 3D printers are mainly endstops (switches that are activated when the platform reaches the end of its rail and shouldn't go further), but there's also temperature sensors (NTCs, mostly). The sensors are wired in such a way that both endstops and analog resistive sensors can be connected and - best of all - the software will be able to figure out what is actually connected on which port. It won't know exactly which endstop is which, but it will be able to tell if it's an endstop or a temperature sensor and configure itself accordingly. Neato.
Now there's a few small foolproofing gripes to address; first of all what if some idiot decides that audio ports should be connected to speakers or headphones, will it blow up their equipment? No, because the peak voltage here is 3.3V - not enough to blow anything up. Short circuits are prevented by another set of PTC resettable fuses.
With all this emphasis on safety and foolproofing it's important to keep in mind that we're also trying to reduce cost. Don't be fooled by my meticulousness on safety practices and good engineering - I look at everything with the cost-benefit tradeoff in mind. It should be safe, compliant and foolproof but not an inch more.
You can do a lot of cost reduction without sacrificing any functionality. First of all, we observe that these PCBs are made in very small quantities - even generation 6 PCBs (sold by tens or even hundreds) are made in batches of a few dozen. In small quantities, it is very easy to cut costs by:
- Using 2-layer boards
- Using as many identical components as possible
- Using fairly coarse design rules
This enables us to produce these boards at very low rates in prototyping houses like iteadstudio.com who sell you 10 2-layer boards of 10x10cm for just $38. Compare that to 4-layer prototypes which will cost you at least $150 for 10 pcs.
Using as many identical components as possible means you can profit from volume discounts which are very significant when moving from really small amounts (<10 components) to medium amounts (100-250 pcs.). You can do this by for instance combining 100k with 47k resistors - by replacing 47k with two 100k resistors in parallel.
Using coarse design rules is actually much less of a restriction than you'd think. You can still use LQFP packages like this:
but not for instance BGA packages. This is relevant because BGA packaged microcontrollers are usually cheaper and seem like an easy choice to slice a buck or two off your BOM cost.
Other cost-cutting measures
Integration is that other keyword I like to use so often. For MiXley, I opted to use an Atmega32U4 microcontroller because it integrates USB along with all the other necessary functions that I need. This is contrary to using a microcontroller ánd a separate USB chip like FT232RL, which costs more than the microcontroller in itself. The only downside to Atmega32U4 is its limited I/O capability, but we can resolve that by using shift registers and analog muxes which are - again - almost literally a dime a dozen.
Besides that there's the issue of power conversion. The microelectronics on the board need low voltages while the motors want something between 12 and 24V. Using a linear supply to convert the motor voltage to low voltage is very lossy and would require a lot of heatsinking while a switching converter would mean at least $2.50 in additional components (using MC34063) but more likely something in the realm of $4.50 (using a more modern, high-frequency converter). In the end, I settled on using the USB voltage (5V) and stepping it down using a cheap low dropout linear regulator to make 3.3V. The small, predictable voltage drop meant I had very little power to dissipate and a cheap device, while the nature of the LDO meant I would have rock-solid voltage stability for the microcontroller.
Something that is again overlooked for prototype and 'hacker' designs is EMI compliance, but again I think we should start doing something here. EMI is short for electromagnetic interference, and it is caused by rapidly changing voltages and currents in your circuit. There are two ways to reduce EMI: (1) reduce the frequency and magnitude of your voltage and current, and (2) reducing the area where these large changes occur.
This is done by filtering. How does this work? Well, say you have a device that instantaneously draws a lot of current and then suddenly stops drawing current, and then starts again - that's square wave current. That device is hooked up to a wire going some stretch to a power source - say a battery. On the edge of drawing a lot of current and drawing very little current, the change in current is very rapid. This is a source of EMI. Now, this rapid change in current propagates through the entire wire all the way to the battery. This means in this example we have 'a lot' of affected area (without putting exact numbers to this).
Now let's connect a capacitor (a small reservoir of energy) directly to that very quickly changing load. As the load starts drawing a lot of power, initially that power is now drawn from the capacitor instead of from the battery through the wire. As the capacitor drains, the battery starts slowly refilling the capacitor until it delivers the entire load. Now the area affected by the very rapid change in load is just the capacitor and the load itself, which are close together. The wire and the battery experience much slower current changes and thus the overall EMI is greatly reduced. This type of capacitor is called a decoupling capacitor - it effectively decouples the load characteristics from the power source.
There are two examples of long power lines that experience large current or voltage changes in the 3D printer electronics: the motor cabling and the wire from the power adapter to the board. On both occasions we use an LC-filter (an inductor in series with the load and a capacitor parallel to the load) to filter the load and make the EMI area as small as possible. For instance, the motor drivers output a PWM signal: a very quickly changing voltage tens of thousands of times a second that propagates through the entire cable run to the motors. With the filter in place, the dominant EMI frequency is reduced to the step frequency which is about ten times lower, a many-fold improvement for compliance. An added benefit is that this filter also improves motor efficiency and thus reduces both motor and driver heat output.
And then there's other features. MiXley doesn't add much to the tried and true formula but it's still worth mentioning:
- PWM Fan output. Mixley features one standard 3-pin fan connector useful for cooling your workpiece after printing
- Three actuator outputs enabling the use of double extruders
- four-area thermal sensor inputs for the heated bed (on hpb connector) and two additional thermistor inputs (combined with endstop inputs)
- Eight endstop/digital sensor inputs (combined with thermistor inputs)
- SD card socket (future functionality, requires 5V source which currently is a usb cable, so as of now it cannot run independent from a computer or at least a 5V usb wall wart)
- Digital motor current setting. No need to solder and desolder resistors anymore to set your motor current. It can now be set using an on-board digital potentiometer, via USB.
Peculiarity: the HPB connector
There's one... less desirable connection on the MiXley board, and that's a custom pinout 10-pin connector directly connecting to the heated print bed via a standard ribbon cable. The heated print bed has four temperature zones, one actuator (heating the entire bed) and two (optionally a third one) endstop switches. Connecting these via the 'standard' connections would mean a whole bunch of wires going to the moving platform. That would mean higher cost, more points of failure and a general mess. Because the connector is still fairly standard (ribbon idc connectors are the bread and butter of electronic connectors) and the amount of functionality it has should cover most everyone's needs, I figured this was the better design choice. Also, the main electronics were seriously running out of board edge space.
Schematics, layout and connections
Now I've told you everything there is to the hardware of the MiXley main electronics. Here you can download the schematic (TinyCAD) and layout (FreePCB) files:
Already we've discovered a few hardware issues, the most pressing of which are:
- Power input connector is the wrong way around (heh...)
- Fan connection does not have a freewheeling diode
- Fuseholder footprints are rotated
- A few minor layout issues
This concludes the electronics hardware part of our discussion of the MiXley printer design. Next up will probably be assembly and software. I hope that our schedules sync up at some point in the near future so we can finish the printer!
Keep up the good work!
Btw gaan jullie kits verkopen als alles klaar is?
Isn't a FET a suitable option for reverse polarity, but then again doesn't really help against overvoltage.
Rafarion: That's a great point. However, while shielding does alleviate EMI, it doesn't fix the ESD hazard. Note: I'm not putting the protection on those USB lines for EMI, just for ESD protection.
The idea is a bit like this: the ground (shield+GND pin) are connected first and entirely by themselves, so that poses no ESD problem. Then both data and power lines connect. The power line is fairly heavily decoupled (given the current and wire resistance), and more importantly I don't use 5V directly but feed it to an LDO that gets rid of the ESD problem on those lines. That just leaves the data lines. It is not true that USB devices must have ESD protection built-in. USB lines (especially USB 2.0) need to have very low line capacitance and generic HBM ESD protection is too bulky for that. So, like I2C lines, they often have much worse ESD protection than GPIOs. Even though Atmel has a pretty decent track record (especially when compared to NXP devices) I like to be complete in my protection. Also, don't forget that this is by far the most often handled connector, it may connect to many different kinds of devices and it has a lot of exposure to ESD sources.
I'm not sure if an active device is a good idea for protecting against non-operational hazards. Also, a FET almost always fails in conduction while a diode will also fail in conduction, but do so in a way that causes the input protection to work (because the diode SHOULD conduct on failure). So even when the input protection fails, it still works!
Why wouldn't you care that the board is almost impossible to break in normal usage?
That the motor drivers survive a jammed motor or a loose connector?
Also, soldering SMD components is not much harder than soldering trough-hole components.
Also it isn't very expensive to do the SMD components if you do some preparation:
- Make a solder stencil (lasercut plastic sheet)
- Make a PCB holder ( out of old blank pcb's and tape)
- Place the pcb in the holder with the stencil aligned and tape it together so that the board can be switched easily.
- Take a stack of boards and one by one put the in the holder, and use a squeegee to put some solder paste on all the smd pins.
- Handplace the components which is just putting them on the right place with a vacuum pencil.
- Reflow the board (in an oven or on an electric grill or something)
Very cheap and fast, but takes some preparation.
And you are also forgetting that SMD parts are usually a LOT cheaper than trough-hole parts and a lot of parts are very hard or impossible to get in trough-hole packages.
Dat zijn de connectors voor de sensoren.
I'm explaining as well as I can how to get from the current state of art (hobbyist level) to a mature, safe, compliant and cheaply mass-producible product. We're not there yet by a long shot, but it's definitely a big step in the right direction.
But because of the massive cost benefit 3D printers will certainly push away most other processes that are used for prototyping today, and even extend it to new markets - hobbyists, consumers even!
While a 3D printer is nice for prototyping you can't really use it for mass production. First off you are stuck with "plastic". Can't make strong metal parts with it. Second, most 3D printers are verry slow.celina schreef op donderdag 10 november 2011 @ 14:23:
3D printing is gonna be the only manufacturing process in the near future supply chain.
The board looks fantastic no hacker circuit design good and ready for the market and production, are you guys pro's? Or just diehard electro jedi's?
Nonetheless great to see such a well thought off initiative to get the homemade 3D printer out of it's alpha fase and into beta. Or even final?.....
But one thing I disagree on is the usage of 3.5mm jacks for sensors, I know it is used a lot but it takes in SO MUCH SPACE. They are very high which would drive up costs for the enclosure and it's just not that handy having something stick around so much, that makes it a vulnerable point.
I would probally have gone for regular 2.54 mm 2x8 conncetors because you cannot connect micro switches and thermisistors the wrong way around.
[Reactie gewijzigd op donderdag 10 november 2011 23:19]
View it as a beta before the feature freeze We can still change it and I totally agree: the first and maybe even only hardware aspect I'd like to change is the 3.5mm audio jacks.
Actually, you can "print" metal parts by sintering. It is the upcoming "hype" for prosthethics manufacturing.Blokker_1999 schreef op donderdag 10 november 2011 @ 19:56:
While a 3D printer is nice for prototyping you can't really use it for mass production. First off you are stuck with "plastic". Can't make strong metal parts with it. Second, most 3D printers are verry slow.
@mux: I like the way you describe your design. You clearly put a lot of time in it!
How many are you planning to sell?
By the way:
made me grin...My simulations show that it should work
[Reactie gewijzigd op dinsdag 6 december 2011 17:25]