Sunday, 3 June 2007

Less speed more torque

This weekend I built a speed controller for my milling spindle motor, AKA Minicraft drill, after attending and recovering from the Stockport Beer & Cider Festival . I used one of the MSP430F2013 micros I described in the previous post. I built it on Veroboard, but hopefully all my future boards will be milled PCBs.



I never plan my Veroboard layouts in advance, I just make it up as I go along. In fact this circuit was so simple I didn't even draw a schematic. I did come a cropper this time though. I started on a board that was too small!



I only realised this after I had put on a regulator, LED and connector, so I had to desolder them and start again. The LED did not survive the ordeal. In my experience, they are one of the most fragile electronic components. They certainly don't like stress on their legs while being soldered.

The circuit is very simple, I will publish a schematic and the software when I complete it, assuming it works, which I have no reason to think it won't.

You may think "how is that puny little micro controlling a 40W motor"? What you can't see in the picture above are two surface mount FETs on the underside.



The big one is a BTS134D "smart low side power switch" with over voltage, over current, thermal and ESD protection. It has an on resistance of only 50mΩ so I can get away without a heatsink. With devices like these I don't know why anybody uses Darlingtons for switching nowadays. Darlingtons have a fundamental flaw in that they cannot be saturated so the on voltage is over a volt leading to significant power dissipation, and hence a large heatsink, for these sorts of currents.

The tiny FET next to it simply boosts the gate drive from the 3V output of the micro up to 12V to ensure the big FET delivers the smallest possible on resistance.

The picture below shows the board being tested. It is connected to a 39W PSU, the drill motor and a scope.



I have verified that it can turn the motor on and off OK. It just needs some software now. The micro has a timer with a PWM facility so controlling the speed of the motor should be pretty simple. The large resistor at the bottom left is for sensing the motor current. The micro has an ADC so I should be able to measure the speed to allow some feedback and also shut it off if it stalls. The unpopulated connector is the I²C link which will go to HydraRaptor's main controller.

PIC your micro

The official RepRap project uses Microchip PIC micro controllers. I have done several projects at work with these because they have such a wide range of parts that they often have the best fit price wise. However, I have never liked them very much. They have a horrible instruction set which does not lend itself to running C efficiently. Also, the development kit is a bit primitive by today's standards. When doing a home project ease of use and development kit cost becomes more important than part price. I have been following the RepRap forums and people are having lots of problems with a buggy open source PIC compiler and programmer.

I recently did a project at work which needed a micro with a very low power consumption so we used a Texas Instruments MSP430 series micro. I was very impressed with the USB key development kit which only costs $20. For that you get an IAR C compiler, assembler, simulator and debugger. The instruction set of the chip is very small but has just the right instructions to run C efficiently and the C compiler does a good job of using them. The code size is limited to 4K but, as I am only using a 2K part, that doesn't matter. The USB key contains a programmer / "Spy Bi-Wire" in circuit debugger and a little detachable target board. The chip is surface mount but the target board brings all the pins out to a 0.1 inch header so you can incorporate it into a through-hole board and you can get additional target boards at $10 for three.





So for $30 I get a development kit and micros to control four of HydraRaptor's heads.

The smaller parts don't have UARTs but they do have I²C which is easier to make a multi-drop bus with.

Wednesday, 30 May 2007

Underpowered

I have done quite a bit of milling with my Minicraft drill attached to HydraRaptor. I always considered it a bit underpowered for the job but it mills plastic and copper clad board reasonably well. Recently I started using it for drilling plastic. The first thing I drilled was 6mm Perspex. I programmed a pecking action to avoid the drill clogging as Perspex tends to melt when it is drilled at high speed. Again this worked reasonably well. The next thing I tried was drilling 25mm metal loaded resin. No matter how slowly I went I could not stop the drill from stalling once it got to a certain depth.

I decided the only way to solve the problem was to monitor the drill speed, detect when it was about to stall and automatically back off until it speeded up again. To this end I started investigating ways to monitor the speed. Off the top of my head I came up with four alternatives :-

  1. Monitor the current, because it increases as the speed reduces.
  2. Turn it off occasionally and monitor the generated voltage.
  3. Measure the frequency of the commutation noise.
  4. Put a black spot on the chuck and use a reflective opto detector to count shaft revolutions.
I attached the drill to a 12V switch mode PSU in order to take some voltage and current measurements and look at the current waveform on a scope. To my surprise the drill went much faster on the 12V PSU. The PSU that came with it is labelled 11.5V 400ma 4.6W but when loaded by the drill it was only giving about 8V. Then I looked at the drill and saw it was labelled 12V 40W. A bit of a mismatch! When driven from 12V it takes about one amp with no load. No wonder it was stalling so easily. It also explained why when it does stall it does not seem to care. Most drills start smoking pretty quickly if you stall them.

So it looks like the drill is ten times more powerful than I thought. The only problem is that it could do with some speed control as it goes a bit fast for plastic when running from 12V.

So now my next task is to tame it with PWM and monitor the speed somehow. I also want to control the vacuum cleaner with software as I am too lazy to switch it on and off.