Showing posts sorted by relevance for query a3977. Sort by date Show all posts
Showing posts sorted by relevance for query a3977. Sort by date Show all posts

Sunday 13 December 2009

Motoring on with the A3977

Previously I have blogged about how to set up the Allegro A3977 driver chip to suit a particular motor: -

hydraraptor.blogspot.com/2009/07/lessons-from-a3977
hydraraptor.blogspot.com/2009/08/motor-math
hydraraptor.blogspot.com/2009/08/mixed-decay-mixed-blessing

Most boards I have seen using the A3977 and similar chips just have a current adjustment, with all the other values fixed. Unless you strike lucky this is not going to allow accurate microstepping because the off time and PFD need to be adjusted to suit the motor and supply voltage.

A while ago Zach sent me samples of the prototype V3 stepper controller kits and the NEMA17 motors used on the MakerBot. I made up the board using my SMT oven (pizza oven controlled by HydraRaptor, more on that later).



It works well, but the initial component values are not optimum for the motor, so I decided to make a test bench from the older prototype board that I have been experimenting with. I RepRapped a chassis for it with a panel to mount some switches to vary the timing components.



The chassis is one of the biggest parts I have made, not in volume, but in overall expanse. It warped a little, despite being PLA, heated bed coming soon!



The switch on the left must be at least 20 years old and the one on the right more than 40 but they both still work fine. I save all this junk and eventually it comes in handy.

I also have potentiometers on V
ref and PFD, so together with a bench PSU and a signal generator I can vary every parameter.

I knocked up a label on a 2D printer, it's so much easier to make this sort of thing than it was when the switches were born!



Zach has updated the board to have four preset potentiometers to make it fully adjustable. There are test points to allow the pots to be set to prescribed values with a multi-meter.

Vref and PFD can be measured as a voltage, but the two RT values have to be set by measuring resistance with the power off. My multimeter seems to give accurate readings of these despite them being in circuit. A good tip is to measure the resistance with both polarities and if it reads the same either way round then it is most likely the chip is not affecting the reading.


So here is a list of motors and optimised settings: -

MakerBot Kysan SKU1123029 NEMA17





This is the motor that MakerBot use for the axis drive on the Cupcake, details here. It is actually a 14V motor, so is not ideally suited to being driven from a 12V chopper drive. You normally want the motor voltage to be substantially lower than the supply.

You can't run it at its full current because the duty cycle would tend to 100%. With a fixed off-time, the on-time tends towards infinity and the frequency drops into the audio range.
In practice I found the maximum current at 12V was 0.3A, any higher and the microstepping waveform was distorted on the leading edge due to the current not being able to rise fast enough.



To maintain the sinusoidal waveform at faster step rates requires the current to be lowered further, 0.25A gives a good compromise. It is not a bad idea to under run steppers anyway, otherwise they can get too hot for contact with plastic.

I used the minimum values for CT and RT, i.e. 470pF and 12K to keep the chopping frequency as high as possible, so that it is outside of the audio range. Not only is this a good idea to keep it quiet when idling, but also you want it much higher than your stepping frequency, otherwise they beat with each other.

The values give a minimum frequency of ~17kHz @ 0.3A and a maximum of ~150kHz on the lowest microstep value.
17kHz is not audible to me, but younger people might be able to hear it. There is still some audible noise at the point in the cycle when both coils have similar currents and so similar high frequencies. The beat frequency, which is the difference of the two, is then in the audio range. It isn't anywhere near as loud as when the chopping is in the audio range though.

I can't see any spec for the maximum switching frequency although a couple of parameters are given at less than 50kHz. I suspect 150kHz is a bit on the high side, which would increase switching losses, but with such a low current compared to the rating of the chip I don't think it is a problem.

One problem I had initially was that the switching waveform was unstable. It had cycles with a shorter on-time than required, which let the current fall until it then did a long cycle to catch up. The long cycle gave a low frequency that was back in the audio range.



I think it was a consequence of the motor needing a very short off-time in order to be able to have the duty cycle nearly 100%. The current hardly falls during the off period, so a little noise due to ringing can trigger it to turn off too early. It is not helped by using the minimum blank time. I fixed it by putting 1uF capacitors across the sense resistors.

The PFD value is best set to 100% fast decay with this motor.

It works better with a 24V supply. The full 0.4A current can be achieved (but it gets much hotter of course) and it maintains microstepping accuracy at higher step rates than it does on 12V.

MakerBot Lin SKU4118S-62-07 NEMA17





This is the NEMA17 that MakerBot used to supply. It is at the opposite extreme compared to the one above, i.e. it is a very low voltage motor, only 2V @ 2.5A. As mentioned before, this causes a couple of issues: -
  1. The inductance is so low that the ripple current is significant compared to the lowest current microstep, causing positional errors. OK at 2A, but gets worse with lower currents.
  2. It is difficult to get 2.5A from the A3977 without it overheating. The PCB layout has to be very good. The datasheet recommends 2oz copper and four layers. 2A is no problem and that is the maximum with the 0.25Ω sense resistors fitted to the board.
At 2A the motor runs at about 40°C, so just about OK for use with PLA. The chip gets a lot hotter, about 77°C measured on the ground pins.

I used a value of 56K for RT and 2.1V on PFD. To some extent the optimum PFD value depends on how fast you want it to go.

Motion Control FL42STH47-1684A-01 NEMA17





This is the recommended motor for the Mendel extruder, details here. After buying a couple of these a friend pointed out that Zapp Automation do the same motor with dual shafts for about half the price!

This is a high torque motor so it is longer and heavier than the previous two NEMA17s. Electrically it is in the sweet spot for the A3977 with a 12V supply. The A3977 can easily provide the full current and the switching frequency doesn't have wild fluctuations or drop into the audio range.

When microstepped at 1.7A it gets to about 43°C but the chip only gets to 56°C.

I used 39K for RT and 0V on PFD, i.e. 100% fast decay.

I have high hopes for this motor as a replacement for the one above that is in my extruder currently. It should give me almost twice the torque and has the correct sized shaft, i.e. 5mm. The Lin and Kysan motors both have imperial shaft sizes which caught me out as I drilled the worm gear for 5mm thinking NEMA17 specified that, but it must just be the frame dimensions.

MakerBot Keling KL23H251-24-8B NEMA23





This is the motor I used on my Darwin. It has 8 wires so it can be connected in bipolar serial or parallel. Series has the advantage that the full torque can be achieved with 1.7A which is easily within the range of the A3977. Parallel has one quarter of the inductance so torque will fall off with speed four times slower. To get full torque 3.4A is needed but I found 1A was enough for the X and Y axes. I think Z needs more torque but my z-axis uses different motors so I don't know how much.

An RT value of 56K is fine for currents in the range 1-2A. PFD is best at 0v, i.e. 100% fast decay.

Summary

Here is a summary of the motor specifications :-

Motor Resistance Max Current Voltage Max Power Holding Torque Inductance
LIN 4118S-62-07 0.8 Ohm 2.5 A 2.0 V 10.0 W 0.30 Nm
Kysan SKU 1123029 35.0 Ohm 0.4 A 14.0 V 11.2 W 0.26 Nm 44.0 mH
Motion Control FL42STH47-1684A-01 1.7 Ohm 1.7 A 2.8 V 9.5 W 0.43 Nm 2.8 mH
Keling KL23H251-24-8B Series 3.6 Ohm 1.7 A 6.1 V 20.8 W 1.10 Nm 13.2 mH
MakerBot Keling KL23H251-24-8B Parallel 0.9 Ohm 3.4 A 3.1 V 20.8 W 1.10 Nm 3.3 mH

Here are my suggested settings :-

Motor Current Vref CT RT PFD
Kysan SKU 1123029 0.25 – 0.3A 0.5 – 0.6V 470pF 12K 0
LIN 4118S-62-07 1 – 2A 2 – 4V 470pF 56K 2.1V
Motion Control FL42STH47-1684A-01 1 – 1.7A 2 – 3.4V 470pF 39K 0
Keling KL23H251-24-8B Parallel 1 – 2A 2 – 4V 470pF 56K 0

Thursday 30 July 2009

Lessons from the A3977

Having established that I want to move to a stepper driven extruder I set about designing a new extruder controller for HydraRaptor. I fancied using one of the Allegro micro-stepping chopper drivers.

With these chips there are a few things you can adjust by changing component values, like the off time, minimum on time and percentage fast decay. The data sheet explains what they do and gives the formulas but it's not obvious what you should set them to for a particular motor.

Not having any previous experience with Allegro drivers I decided I needed to knock up an evaluation circuit. Fortuitously Zach had sent me some PCBs a long time ago that were his first version of the Stepper Motor Driver v2.0. They used the PLCC version of the A3977.

PLCC packages were a bit of a halfway house between through hole and surface mount. They have leads which come out of the side and then curl underneath.



They are handy for programmable devices because you can either surface mount them or put them in sockets (which can be either SMT or through hole). The problem with them in this application is that using a socket is not recommended for current and heat dissipation reasons.

That makes the package a worst of both worlds solution. It is big and bulky like through hole parts but still difficult to hand solder because the pins are underneath. The surface mount version of the A3977 is a fine pitch (0.65mm) TSSOP with a heat slug underneath, so again not easy to solder by hand, it really needs to be done by the solder paste and oven / hotplate method.

Zach moved to the A3982 on subsequent versions, which is easy to hand solder because it is in a SOIC package with 1.27mm pitch. It also has a lower external component count. The down side is that it does not do micro stepping and is only 2A rather than 2.5A. I will probably use the A3983 (which is like the A3982 plus micro stepping and in a TSSOP package).

I managed to hand solder the PLCC at my second attempt. My first attempt had a short, which damaged the chip. I damaged the board removing it (with a cutting disk), so I had to start again on a second PCB. Lots of cursing! The lesson is always to meter a PLCC for sorts before powering up as you can't see shorts underneath it.

Here is my test lash up: -



I can set the step rate with a signal generator, vary the supply voltage from 8 to 35V, see the temperature of the chip and look at the current waveform on a scope .

The initial results were disappointing due to a couple of problems: -

The first was that the chopping occasionally had glitches in it. With the motor stationary I could hear it clicking, and with a scope I could see some cycles shorter than they should be. It got worse with higher supply voltages. At low speeds it did not make much difference, but it did lower the maximum speed. I tracked it down to a lack of high frequency decoupling on the 12V rail. I added a 220nF de-coupler close to the chip and the problem went away. Adding it further from the chip actually made it worse.

The next problem was that the microstepping was very uneven. I had noticed that same effect with the z-axis of my Darwin using the $800 microstepping drivers (that I got cheap) that I use on HydraRaptor. At the time I put it down to the small, large step angle tin can motors I was using at the time not being very linear. When I moved to larger 7.5° tin can motors I still had the same problem, and even with the Keling NEMA23 1.8° motors it did not seem right. This puzzled me because they are very similar to the NEMA23 motors on HydraRaptor, which work well with the same drivers. The shaft encoders have the same resolution as the ×10 microstepping and they are always spot on or one count out, so pretty linear.

With the A3977 it is easy to get an idea of the current waveform of the motor by measuring the voltage on the sense resistors. It should be a stepped sine wave like this: -



Regardless of which way the coil is energised, the current flows to ground through the sense resistor, so the waveform looks like a full wave rectified sine wave. The current only flows in the sense resistor when the chopper is in the on state though. In the off state the current is circulating through the coil and the bottom two transistors of the H-bridge, so the current in the resistor is zero. That is why there is a bright line along the X-axis. On the falling edge of the wave you can see the sense current goes negative. That is because the chip switches to fast decay mode. When the chopper is in the off state, instead of short circuiting the coil, it reverses the voltage on it, causing the current to flow backwards through the sense resistor onto the supply rail. It only spends part of the switching cycle in fast decay so you see positive current, a lot of zero and some negative current, hence the relative brightness of the lines. This is a case where an analogue scope gives you more information than a digital one.

Initially the waveform looked like this, it was somewhat distorted: -



The current rises too quickly at the start of the waveform. The chopper has a constant off time (20uS in this case) and varies the current by changing the on time simply by turning it on until it reaches the target value. But, there is a minimum on time of about 1.4uS, called the blanking period. During that time it ignores the current sense signal to avoid false readings due to ringing on the switching waveform. That means there is a minimum mark space ratio of 1.4 : 21.4 in this case. That sets a minimum current, which also depends on the ratio of the supply voltage to the motor voltage. If this minimum current is more than the lowest microstep value (19.5% of the peak for 1/8 steps) then you get a distorted waveform as above, and the steps are uneven.

To fix it you can lower the supply voltage, raise the current setting or increase the off time. The latter reduces the chopping frequency. If it is below about 15 kHz it will be audible when the motor is stationary. It can also start to beat with the stepping frequency when running at high speeds, particularly when micro stepping, as the step rate is n times faster.

This form of distortion is analogous to crossover distortion on a class B audio amp. You can also get the equivalent of clipping if you use a high voltage motor on a low supply voltage. If the current setting is set to a value which is more than the motor will draw when connected to the supply, then the top of the waveform is flattened off and again the microsteps will be uneven.



Yet another form of distortion occurs when running at high speed: -



Here the back EMF from the motor acting as a generator is preventing the current from falling fast enough to follow the sine wave. This can be fixed by increasing the Percentage of Fast Decay, set by the voltage on the PFD pin. If there is too much you get excessive ripple as shown here: -



For a particular speed and motor there is a sweet spot which sounds audibly quieter: -



So setting up a microstepping drive is not straight forward unless you have an oscilloscope. You can tune the PFD by ear though, as this video demonstrates: -

Tuning PFD from Nop Head on Vimeo.

You can also see the other forms of distortion if you attach a long pointer and step it round slowly.

Another lesson is that you cannot simply just set the current to accommodate different types of motor. You really need to be able change the off time and the PFD as well, especially if you use different supply voltages.

So I solved the mystery of why microstepping does not work well with the expensive drives on my Darwin. They are rated at 7A but I am only using them at 1A, I am also using low voltage motors on a 36V supply. I bet it is a constant off time chopper and the minimum current is too high.

Friday 6 April 2012

StepStuck

When I built my Mendel I used A3977 stepper drivers. Before that I did some maths to show that the component values need to be carefully selected to match the motor in order to achieve 8× microstepping. Makerbot produced a board with four potentiometers and I published settings for motors popular at the time.

Since then Pololu stepper drivers have become popular (and the StepStick clone), but they only have one thing that you can adjust: the current. They also have 16× microstepping, which makes the range of component values that work even smaller. I was always pretty sure the off-time would be wrong for the motors we use and while commissioning my second Mendel90 I could hear that it was wrong, so I decided to look into it.

When stepping one motor at a constant speed you should hear a single pitch at the step rate. If the off-time is too short then the lowest current microsteps cannot be achieved, the motor pauses twice every 16 microsteps so you hear a lower pitch sound as well.


If you step the motor very slowly (G1X10F1) you can hear a sequence of steps with a pause.


The reason for this is that the lowest current step when ×16 microstepping is 9.8%. If the current is set to 1A then that is only 98mA. The minimum on-time for the chip is fixed at 1μs and my formula predicts the off-time needs to be at least 54μs with 1.65Ω motors. That would require a 47k resistor but the value fitted is only 10K. That gives an off time of 12μs which isn't even long enough for 8× microstepping. The situation is even worse on the Z axis with two motors in parallel.

The problem with increasing the resistor to 47k is that the switching frequency drops to 14kHz, which is audible. So my conclusion is that the A4983 is not really suitable for driving such low resistance motors. The A3977 allows you to control the minimum on-time so you can avoid the switching frequency becoming too low.

Later Pololus and some StepSticks use the A4988 chip. That has an interesting section in the datasheet: -
Low Current Microstepping. Intended for applications where the minimum on-time prevents the output current from regulating to the programmed current level at low current steps. To prevent this, the device can be set to operate in Mixed decay mode on both rising and falling portions of the current waveform. This feature is implemented by shorting the ROSC pin to ground. In this state, the off-time is internally set to 30 μs. 
Conceptually an easy mod to do, simply short out R4, but due to the size and location of the resistor and the age of my eyes it was not at all easy. I applied the mod to a StepStick and it worked, the steps are now regular, no missing beats. Running is a bit quieter but I think the motors are more noisy when stationary. More investigation is needed.

What to do with my A4983 Pololus? Well if I increase the current to 1.3A and change the resistor to 36K then the minimum frequency is 17kHz, which is ultrasonic to me nowadays due to the age of my ears. Alternatively switching to 8× microstepping and using a 22K resistor keeps it above 30kHz and the current can be 1A.

I don't think constant off-time choppers are the best idea. The current range is too limited and the switching frequency varies wildly. As the two halves of the chip run at different frequencies they can generate beat frequencies in the audio band.

The other thing I don't like is that they regulate the peak current so there is an offset of half the ripple current which can make the first step inaccurate.






Thursday 6 August 2009

Motor Maths

In a previous post I showed the pitfalls of constant off time choppers like the A3977. Basically you have to set the off time long enough to be able to deliver the lowest current step of the microstepping, otherwise the steps are not equally spaced.

Forrest raised the point of how do you do that without a scope. It is fairly easy to calculate from the target current, supply voltage and motor resistance using nothing more complex than Ohm's law. It did take me a few days to come up with a formula that matched my measurements, but that was because I was accidentally running the chip without synchronous rectification enabled.

The motor current is equal to the reference voltage divided by 8 times the sense resistor. The maximum sense voltage is 0.5V, so a sensible value for the sense resistors is 0.2Ω, giving 2.5A maximum with 4V at the reference pin. My lash up uses two 0.5Ω resistors in parallel giving a 2A maximum.

The minimum current required on the first step of the microstep will be I × sin(π/2n), where n is the number of microsteps. In this case n is 8 so the smallest current step is 19.5% of the full current. To calculate the minimum off time needed we need to be able to work out what the duty cycle will be to get a given current.

Here is what the sense resistor waveform looks like when the current is set to 1A and the motor is stationary. The on period is 3μS and the off period is 20μS. The supply voltage is 12V.



The sloping top of the waveform is actually an exponential curve, but at this scale it is very close to linear and to simplify the calculations I have just used the average value.

So we know that 1A flows from the supply for every 3 out of 23μS. That gives an average current from the supply of 1A × 3 /23 = 130mA. Indeed the supply current measures 260mA as there are two coils energised (I set it to full step mode to make this measurement).

When the chopper is on energy flows into the inductance of the motor, increasing its magnetic field slightly. During the off time the current flows in a loop consisting of the motor and the two low side transistors. Power is dissipated by the motor's resistance, so it loses energy by its magnetic field decreasing slightly. We can calculate the duty cycle by reasoning that the energy going in during the on state must equal the energy coming out in the off state.

The motor is a Lin 4118S-62-07 NEMA17 motor I got from Makerbot. It has a coil resistance of only 0.8Ω. That means the resistance of the sense resistor and the on resistance of the FETs in the chip are significant in the calculation.

During the on state current flows through one top transistor, the coil, one bottom transistor and the sense resistor. All the resistances convert electricity to heat so the power going into the magnetic field is the power drawn from the supply minus the resistive losses in the circuit.

Power = VI or I2R, Energy = PT.

So we have (Vsupply × I - I2 × (Rmotor + Rsense + RDS(on) source +RDS(on) sink)) × Ton.

In this example (12 - (0.8 + 0.25 + 0.36 + 0.45)) * 3 = 30.4 μJ.

During the off state the current flows through the motor resistance and two low side transistors, so the energy lost is: I2 × (Rmotor + 2 × RDS(on) sink) × Toff.

In this example (0.8 + 2 × 0.36) × 20 = 30.4 μJ, so theory matches practice (using typical values from the datasheet for RDS(on)), always very satisfying.

So if we call the total resistance in the circuit with the switch on Ron and the total when it is off Roff we have: -
Ron = Rmotor + Rsense + RDS(on) source +RDS(on) sink = 1.86Ω
Roff = Rmotor + 2 × RDS(on) sink = 1.52Ω

Then Toff = Ton (V/I - Ron) / Roff
For our example if we set the minimum Ton (Tblank) to be 1μS, I = 0.195A, so Toff is 39μS.

At 1A Ton will then be ~6μS. So the minimum chopping frequency will be ~22kHz and the maximum will be 25kHz.

CT = Tblank / 1400 = 714pF, so use 680pF.
RT= Toff / CT =58K, so use 62K.

So in conclusion using the simple formulas above it is easy to calculate the correct values for a given motor, supply voltage and minimum current. I wish the datasheet and apps note had included this formula.

Sunday 9 August 2009

Mixed decay, mixed blessing

Having set the correct off time to suit my motor I can now micro step it with equal spaced steps, but only if I disable the mixed decay mode.


When the chopper switches off it can do it two ways. It can turn on both low side transistors. That short circuits the motor and lets the current recirculate. If the coil was a perfect inductor and the transistors perfect switches, the current would circulate forever and you would have a superconducting magnet. Real coils and transistors have some resistance, which causes the current to decay, but as these are relatively small the mode is called slow decay.

This is fine and efficient until you take the motor's back emf into account. During the rising part of the sine wave the magnet is moving towards the pole piece, so it generates a voltage that causes the current to fall faster. The on time gets longer to compensate and all is well.

On the trailing edge of the sine curve the magnet has gone past the pole piece and generates a voltage that increases the current in the coil. If it is going fast enough it can mean that the current doesn't fall at all during the slow decay period. As I showed previously that can cause a severely distorted waveform which makes the motor noisy.



The Allegro chips offer a mixed decay mode, where they switch to fast decay for part of the chopping cycle on the downward half of the sine curve. In fast decay mode one low side and one high side transistor turn on and reverse the voltage across the motor. That overcomes the BEMF and causes the current to fall much faster. It also returns current to the supply rail, which can upset some power supplies if there isn't some other load to absorb it.

Mixed decay gives a current waveform like this: -



The off time is fixed, so the current falls further making the ripple greater. If you set the percentage fast decay to give a clean waveform at your top speed, then the ripple increases at slower speeds. It is maximum when stationary, when there is no BEMF and fast decay is not required at all.

The problem is that the target current is the trip point of the comparator, so it is the peak of the chopping waveform. That means the average current is less by half the ripple current giving a positional error.

With the low inductance motor I am using, the ripple current has a large amplitude, so the error introduced when the motor is stationary is about the same as a micro step. That means the first step with fast decay is about twice as big as it should be and the last step is virtually zero.

With the A3977 I can disable fast decay and the steps are fairly even, but fast running is then distorted. The PFD setting needs to change with speed.

With the A3983 that I have used on my new extruder controller the PFD setting is fixed at 31.25%. That means I can't get evenly spaced microsteps with the NEMA17's that I have, when running slowly. Not a big problem with the extruder because I plan to gear it down 40:1, which means one micro step is only about 0.02mm. I am only using microstepping to give smooth motion rather than extra resolution.

The problem is exaggerated because not only am I using a low inductance motor, but I am also trying to run it at 1A, whereas it is rated for 2.5A. At 2.5A the off time would be about 2.5 times smaller, so the ripple would be 2.5 times less. The steps in the current waveform would be 2.5 times bigger, so the distortion would be reduced by 6.25 times. As it is about one microstep now, it would reduce to 1/6th of a microstep, so would be acceptable. The temperature rise would then be 6.25 times greater of course.

I was planning to use A3977s for my axis control though, where positional accuracy is important. I am beginning to think I will be better off just using dual H-bridges and doing the rest in software using a powerful micro with a fast ADC.

To be able to cope with a wide variety of motors you need to change the current, the off time setting and the percentage of fast decay. You also need to take the ripple current amplitude into account to control the average current, rather than the peak. All these things could be automated with a software solution.

Sunday 21 March 2010

Making Mendel

I aimed to build my Mendel in time to show it at the Makerfaire in Newcastle but completely failed. I had two weeks to build it, which I thought was plenty. In actual fact it took closer to three weeks before I got it printing successfully. I had no major problems, just a few snags here and there and a severe underestimation of how long it would take on my part.

Printed Parts

Unlike when I printed two sets of Darwin parts, printing the parts was the easy bit. This was due to three breakthroughs I had at the beginning of the year: -
  • The heated Kapton bed removed the need for rafts, which not only take a significant time to print, but also can take a lot of manual work to remove.
  • The extruder fast reverse got rid of all the strings, which also took a long time to clean up, especially from inside the Darwin corner blocks.
  • The "no compromise" extruder is so reliable that I have the confidence to do multi-part, layer by layer builds, which gets a lot more on the table, allowing longer unattended operation.


I printed the parts with 0.4mm or 0.375mm filament and with 25% infill. For the larger parts I used two outlines for strength. Since the large parts don't need fine detail, I think printing them with 0.5mm filament and one outline would be quicker, but that would need a bigger nozzle.

The weight of the parts, not including the extruder, was only 730g. I printed the outlines at 16mm/s and the infill at 32mm/s, so it's hard to say the total time. Assuming an average speed of 24mm/s at 0.4mm diameter gives about 3 mm3/s. That would put the total time at about 65 hours. I did it as a background task over a few weeks. A lot of the parts were printed as experiments with heated beds.

Rods

I took me an evening to cut all the rods. The method I used was to nail a stop to my workbench to line up the rod against a metre rule.



I then lined a piece of masking tape up with the correct measurement and wrapped it round the rod to mark the place to cut. I also wrote the name of the rod on the tape to make it easy to identify later.



A Black & Decker workmate makes an ideal vice to hold the rods while sawing. I rotate the studding until the thread lines up with the edge of the masking tape. That guides the saw to start in exactly the right place.



I used BZP for all the studding except the z-leadscrews, for which I used A2 stainless steel because it is smoother and generally straighter. I bought the rods from Farnell and even the BZP studding was very straight, a lot better than the stuff you get in B&Q. I also used A2 for all the bars.

It was very hard work sawing the A2 until I switched to a new blade and used Trefolex cutting compound. I am not sure which made the most difference, but I could then cut the A2 much easier than I had been previously cutting the BZP. I wish I had done that earlier, it would have saved a few hours.



Thick Sheets

The thick sheet parts are not really suitable for making by hand, particularly the squashed frog. They have lots of slots, which are hard to make without a milling machine or a laser cutter, etc.



I am not sure exactly what the hole in the bed and the purge plate are for, so I made the bed a simple rectangle with four holes. I am using my own electronics, so I made the two circuit board plates to suite. I simply cut rectangles and I marked the holes and drilled them in the right place, so no need for slots. That just left the squashed frog.

I made a much simpler design with drill centres on it. There is no need for the bulging legs and sloping shoulders. I think they must be just to make it look more like a frog. Fine if you you are CNCing it, but a PITA if you have to make it by hand. Also the holes for the opto tab and the purge plate are mirrored for no apparent reason, so I made it chiral.



This just starts as a rectangle with some holes in it. Then the large slots are made with a saw thin enough to turn in the holes. The outer holes that mount the bearings can be round because they are in a a fixed place, dictated by the holes in the bed. The inner holes need to be slots because the bearings are adjustable. I just left them off the template and marked them with the bearings adjusted and in place.



I made the sheets from 3mm Dibond, which is below the recommended thickness, but seems stiff enough. It is also light weight and very easy to machine.

Thin Sheet

I didn't have any optos, so I used micro switches for my end stops, hence didn't need any thin sheet parts. I simply attached them to the bars of each axis with P-clips. A little RepRapped bracket would be better but I was building this in a hurry, so had gone into bodging mode at this point!







They seem to have sufficient repeatability and certainly will when I replace the electronics with my new design, which will know the motor phase, reducing the uncertainty by a factor of 32. It is the same switch that I have used on the z-axis of HydraRaptor, which has proven totally reliable. They seem to be this one from RS, not cheap.

Belts

These were easy enough to split but, because the reinforcing wires run in a spiral, the blade tends to follow one for a while before managing to cut through it. That leaves a ragged edge with a bit of wire sticking out.

I didn't understand the rationale for slackening the belts until you just don't see backlash when moving one motor detent. I am microstepping anyway, so a motor detent is not significant. I made my belts good and tight.

Snags

I had a few snags with the mechanical assembly: -

The x-axis spacers are too short. The STL files are 5mm shorter than the parts in the STEP assembly. That caused the motor to clash with the nuts on the 360 bearing.



The 180 bearing at the other end was about 10mm from where it should be.



A simple fix was to slide the axis along leaving a 10mm gap to the spacer, the only problem remaining is that the spacers rattle at certain step rates.



The STEP model shows this gap should be only 5mm, but I have been unable to find the discrepancy. My rods and inspection distances are correct and the ends of the rods are flush with the clamps, as they are in the model.

The bed springs seemed to be too long to compress to the length of the bed-height-spacer-31mm_1off, which is not actually 31mm, but 29mm, so I don't know what gives there, I just spaced them a bit higher.



The bolts in the z-bar clamps are too long to allow the bearing to be inserted. I replaced them with shorter ones.



Similarly the bolts in the x-carriage get in the way of the extruder I fitted.



The J3 jigged distance did not seem correct. The distance between the y-bars is set by the J2 distance and the 3 nut spacers.

Extruder

I used Wade's extruder design as I didn't have time to adapt any of my own.



The gears work well, with very little backlash, but the small one has some movement on the motor shaft. It is just a press fit with a flat on the shaft. I need to redesign it with a captive nut and grub screw.

I didn't have a suitable M8 shoulder bolt so I made one from brass by attaching a nut with a pin through it.



I hobbed it with an M3.5 tap. I haven't measured the grip, but I get the impression it is not as high as Wade gets, I am not sure why.

For the bottom half of the extruder I used some parts that Brian was looking for volunteers to test for him.



The insulator is made from PEEK with a PTFE liner. The idea being to get the strength of the PEEK and the slipperiness of the PTFE. It seems to work well with PLA, which is all I have run through it so far.

The barrel is long because it is designed to take nichrome, but I just screwed it into a block of aluminium with a vitreous enamel resistor in it.



This was left over from a previous experiment. I have now moved onto a smaller resistor size, so this block could be smaller. The barrel could be a lot shorter with this arrangement and that would give less ooze and less viscous resistance.

The extruder works well with PLA. The main problem with it is that it mounts at right angles to the x-axis, so the motor severely restricts the maximum height of the z-axis. Another issue is that to remove it you have to remove the motor to get at the bolts. To remove the motor you have to remove the big pulley to get at the motor's bolts, to do that you have to remove the pinch wheel assembly. I.e. to remove the extruder you have to completely disassemble it!

Electronics

To get up and running quickly I used the same electronics that I use on HydraRaptor. The only difference being that I used MakerBot V3 stepper drivers. These use the A3977 chip and give x8 microstepping. That gives an axis resolution of 0.025mm, but more importantly gives nice smooth running.

When the weather was exceptionally dry I found they are very sensitive to static. A discharge to any part of the machine would cause the A3977 to shut down its outputs and draw enough current from the 5V rail to cause the 100mA regulator to current limit. The red LED on the power rail goes dim. Powering off and on again fixes it and there doesn't seem to be lasting damage. I suspect that might not be the case if the 5V rail was not current limited. Apparently the only way to fix it is to add external Schottky diodes. That is very disappointing as one of the nice features of the chip is that it is supposed not to need them. I will investigate further to see if all eight diodes are needed before making my own board.

Firmware

I used the same firmware as HydraRaptor. I just added some compile time conditionals to cope with two pin outs and a different IP and MAC address for each machine. I also had to change from 16bit to 32 bit positional commands because the axes are bigger.

Software

I used the same Python software as HydraRaptor but I had to re-factor it quite a lot to support both machines. I added a class to represent the Cartesian bot which holds the axis resolution, direction, maximum speed and acceleration plus the IP address. I also added a class to represent the extruder controller as I have calibration values unique to each board. I already had classes to represent thermistors and extruders.

I can run both machines at the same time from one PC and, because I only use the Skeinforge output for the toolpath, I can use the same sliced files for either machine. This is despite the fact that they run at different speeds and are loaded with different plastic.

Results

So here is the finished machine: -



And here is a video showing it being tested: -


I am running the X & Y motors at about 0.75A and Z at about 1A. I have set the maximum XY speed to 100mm/s, but I think it could go a lot faster. Z only goes at about 5mm/s because not only is it a threaded rod drive, but it is geared down by the belt and pulleys!

I haven't printed a lot yet, but so far the results look as good as they do from HydraRaptor. The next thing to do is add a heated bed and try ABS.

Monday 24 August 2009

Time for a new extruder controller

Having decided to switch to stepper drive for my extruder I needed to make a new extruder controller for HydraRaptor, the previous one has served me well for two years.

The spec for the new one is: -
  • I2C or RS485 comms link to the main controller.
  • Micro stepping bipolar stepper drive.
  • Heater control from a thermistor.
  • Fan control output.
  • Second fan control and second thermistor for controlling extruder heatsink temperature.
  • A spare output for a solenoid, etc.
  • A filament empty input.
I designed it in Kicad and got the PCB made professionally. Here is the schematic: -



U4 generates a local 3.3V rail from the 12V supply. C8 and C9 are the bulk low frequency decoupling for the 12V and 3.3V rails respectively. C1, C2, C3, C5, C7, C12 and C13 are the high frequency decouplers placed close to the chips that they are decoupling. D2 is a green LED to indicate the board is powered.

U2 is an RS485 transceiver which I intend to use on my Darwin. It is slew rate limited and ESD protected but somewhat expensive compared to the older 5V versions. R1 ensures the transmitter is off until the micro takes control of it. HydraRaptor uses I2C to talk to its heads at the moment, via K1.

Q3, Q4 Q5 and Q6 are NIF9N05CL protected MOSFETs to control fans, heaters and solenoids, etc. They are protected against over current, over voltage (hence no back EMF diodes), over temperature and ESD. They also have controlled edge rates to minimize RFI. Q1 and Q2, together with R3 and R4, are level translators to increase the gate drive voltage on the two higher current drives. That minimises the on resistance to ensure they stay cool without heatsinks, even at 2A or more. R13 and R14 ensure the drives are off before the micro starts. D6, D7, D8 & D9 are red LEDs to indicate when the outputs are on. Essential for the heater output, but a luxury for the others.

R15, R16, R17 & R18 form the correct potential dividers to give a good approximation to linear temperature response for 10K thermistors, see here for details. For a 100K thermistor they would simply be 10 times bigger. C10 and C11 remove high frequency noise. Probably unnecessary as a little noise actually seems beneficial because it converts bang-bang control to proportional.

The thermistor inputs have their own analogue ground rail, which is only linked to the main ground at one point close to the VSS pin of the MCU. This is done via a zero ohm link, R25, on the schematic. On the PCB this is the smallest footprint available and is shorted by a bit of copper, so no part is actually fitted. The reason for this bodge is to keep the track separate from the ground fill, so that no current from the heater or motors is passing along it. That might cause a small voltage offset that would affect the temperature reading.

U1 is the stepper motor driver. I used the Allegro A3983 as it gives micro stepping with a smaller external part count than the A3977, but as mentioned previously it does have some disadvantages.

C6 and C7 form a charge pump which generates a supply rail for the gate drive that is higher than the main supply voltage (12V). That allows the top transistors of the H-bridges to be N-channel devices, rather than P-channel, which have inferior performance.

R22 sets the off time of the chopper and needs to be different values for different motors as described here.

R23 and R24 are 1W current sense resistors. I found them to be expensive in the 2512 SMT package. It is actually cheaper to use two 1210 0.5W resistors in parallel, or through hole parts mounted vertically, which take up less board area.

The reference voltage for the chopper is generated by a high frequency PWM output on the micro and smoothed to DC by R2 and C4. That allows software control of the motor current. As I had plenty of spare I/O on the micro I also have software control of the step mode (full, half, quarter or eighth), the enable and the reset pin. R5 ensures the stepper is disabled before the micro is running. As with R1 it ensures the circuit is well behaved before the micro is programmed, or when it is being run under a debugger.

D3, D4, D10 and D11 indicate the state of the stepper outputs, a bit of a luxury really. With SMT parts there is not much point in using bi-colour LEDs. It is cheaper to use back to back red and green next to each other.

I used an MSP430F2012 micro on my first extruder controller because you get a full development kit including an excellent C compiler, in circuit programming and source level debugging for $20. I think there is also open source support via gcc, but I have not investigated that yet.

For this one I had to move up to an MSP430F2112 to get a UART for the RS485. As it is the same core with different peripherals I assumed my $20 eZ430 SpyBiWire debugger would still work. Big mistake! It programs OK but it locks up when trying to debug. It also miss-identifies the chip. I have two, and the second one I tried said the firmware needed updating and offered to do it. JUST SAY NO, if you say yes it reprograms the eZ430 and it never talks again. I contacted TI and they have no plans to fix this firmware updating bug so I got an MSP-FET430UIF debugger for $99. It does JTAG as well as SpyBiWire so I should be able to mend my second eZ430, as it has JTAG test points and I read the security fuse is not blown. I also suspect a new eZ430 may well work as the web page has been updated to show it supports the F21x2 now.

D1 and D5 are red and green status lights. I light the green one to show the processor is running and blink it whenever it receives a command. The red one indicates errors.

P3 is a connector for a filament out switch. I haven't implemented one of those yet as a spool of filament usually lasts many months. It uses an internal pullup resistor to pull it high when the switch is open.

P1 is the SpiBiWire connector for programming and debugging.

Even with extravagant motor control I had three spare I/O lines, so I brought them out to a connector with the supply rails for future expansion.

This is what Kicad predicted the populated board would look like: -



I found 3D models for all the parts on the web but the connectors were a bit of a nightmare. I used Tyco MTA100 and MTA156 connectors as they seem to be about the cheapest form of wire to board connector. As usual there is an expensive tool to insert the wires, but you can get away with using a pair of needle nosed pliers, or even make a tool as it is only a metal plate with slots in it mounted in a plastic handle. We should be able to RepRap one.

Tyco have STEP and IGES 3D models on their website. Kicad needs VRML, which should have been no problem as CoCreate can import STEP or IGES and export VRML. But Kicad did not like the VRML from CoCreate, it seems it has to come from Wings3D. Wings can import STL but it does not like the STL from CoCreate or AOI either. In the end I had to do IGES -> CoCreate -> STL -> AOI -> OBJ -> Wings-> VRML -> Kicad! I coloured the body and pins in Wings.

I got five boards made by PCB-Pool in 8 working days for €125 including shipping, certainly not the cheapest, especially as it included Irish VAT at 21.5% (VAT is only 15% at the moment in the UK), but I like the web interface, the quality is good and they include a free solder paste stencil.



They also email pictures of the board being made at five different stages, although two of mine went missing. Here it is before the tin plating was added: -



And here it is finished apart from routing the outline: -



Using the stencil is very easy. You trap the board between two L-shaped pieces of PCB material stuck to a flat surface with some masking tape. You then align the stencil over the pads and stick one edge with masking tape. Spread some solder past along the edge that is stuck and then wipe it across the board with a metal squeegee to force it through the holes and leave it exactly level with the surface of the stencil.

You then lift the stencil carefully from the edge that is not taped down.



Notice how the paste for the heat slug on the A3983 is split into four and reduced in area. This is recommended to stop the chip floating on the paste and sliding across the footprint. It was not easy to do in Kicad. It doesn't seem possible to do it in the component footprint, so I had to draw on the stencil layer of the PCB. That means if I use the chip again I will have to do it again. I had the same limitation when expanding the resist layer around the fiducials. These are the two copper circles bottom left and mid right. They are used for optical alignment of pick and place machines.

The next stage is to place all the parts with tweezers. I used 0805 footprints for all the passives, so they were not too fiddly to do by hand. I hope to be able to automate the pasting and placement with HydraRaptor soon.

Then I cooked the board in a cheap electric oven, a Severin TO 2020 for €45.



I believe you can get these for as little as £15. I expect they give more even heating than using a hotplate, as they heat from above as well as below, but a hotplate has the advantage of taking up a lot less space and probably uses less power. I will be making a heated bed for HydraRaptor, so I might be able to use that.

The temperature profile was controlled by a thermocouple attached to a PID controller that I borrowed from work.



When I have time I will connect one of Zach's thermocouple boards to a spare analogue input on HydraRaptor and plug the oven into the software controlled mains outlet that HydraRaptor has, and then program it as a PID controller. Not another head, but certainly another manufacturing capability. I will also try putting extruded objects through a heat cycle in the oven while they are still attached to the base. It should release the stress so they don't warp further when removed.

This was the finished result after hand soldering the connectors: -



U2 is not fitted because I got the footprint wrong, doh! I can bodge one on when I need RS485. There are two construction faults on this picture, can you spot them?

The reflow was not perfect. The big capacitor did not flow at all. The temperature needs to be a bit higher, or perhaps the warm-up a bit slower. There were solder bridges on the TSSOP chips. That was because you are supposed to shrink the stencil apertures by an amount related to the stencil thickness to get the correct amount of paste. Normally the stencil manufacturer will do that for you but PCB-Pool do not offer it on their free stencils, presumably because they are shared with other designs. Unfortunately Kicad only seems to be able to make them 1:1 with the pads. It is open source, and written in C++, which I know well, so I could have a go at adding that facility if I had the time.

I have tested the board and used it to control one of my experimental extruders, more details tomorrow. The only thing wrong with it apart from the foorprint error is that the A3983 gets too hot to deliver its full rated current of 2A. 1A is no problem, which should be plenty for the extruder designs I have in mind.

The back of the board is nearly all copper to give a good heatsink but at 2A per coil the chip will dissipate 2 × 2A2 × (0.3Ω + 0.3Ω) = 4.8W. The datasheet recommends a 4 layer board with 2oz copper on the outer layers. I am not sure what the extra cost of 2oz is. I will investigate the heat distribution in more detail at some point.