Sunday, May 29, 2011

Stepping into firmware

Having had good experience with the Rapman's PIC32-based controller, I decided to stick with that MCU for my new printer.  As I mentioned earlier, rather than buy a $1k+ C compiler from Microchip, I bought a much less expensive, full-featured BASIC compiler for the PIC32 {they also offer C and Pascal compilers} and a full development board from Mikroelektronika in Belgrade.  Friday night, with the last of the z-axis brackets being printed on my Rapman and the 19 June exhibition in San Francisco coming up, I decided that I'd better get cracking on the firmware.

When I bought the PIC32 development board from Mikroelektronika, I also picked up a little stepper controller board from them.  

It uses an Allegro A3967 driver chip rated at .75 Amps.  Now ordinarily I wouldn't have considered getting such a thing, but in this case it seemed reasonable to have a ready made stepper tester board that I knew worked with my development board and I knew I had a number of small stepper motors that I could use with it.  Nothing I'd consider using on the printer, mind, but all the same useful in the learning process.

Like Darwin and Rapman, I'd decided to be conservative and use NEMA 23 steppers.  The price on these has dropped dramatically since we were building Darwins several years ago.  While shopping for NEMA 23 steppers, I happened across this little jewel.

Oddly enough, this 6 wire NEMA only drew 0.4 amps but produced a lot of torque.  I bought it, too, just so I could have have a NEMA the right size that I didn't necessarily want to use on the printer.  At that time I was looking at using the much heavier capacity Pololu stepper drivers that have recently proved so popular with Mendel electronics.

Now here is where serendipitous good fortune intruded.  The firm selling this stepper also had a special on 24 volt power supplies

When we began with Reprap about the only reasonably priced power supply we could lay hands on was a salvaged  5-12v ATX box out of old PCs.  24 volt supplies at the time were quite dear.  We knew very well that we could get a lot better performance out of steppers if we used 24 volts, but nobody wanted to invest in a 24 volt supply.  This bad boy put out 6.5 amps at 24 volts for $19.  The economics of that were hard to argue with given that my development board power conditioning circuit would eat anything up to 30 v DC.

Friday night and Saturday I spent the necessary hours skating down the learning curve of the Mikroelektronika development board and compiler IDE.  This took longer than it should have in that the PIC32 boards and compiler are very new to Mikroelektronika.  As a result, while they had code samples in BASIC for their stepper controller board, they were for 8 bit PIC chips and development boards, not their new 32 bit offerings.  I don't know why firms don't offer extremely simple sample code patches.  Instead, they always clutter it up with nonsense that runs LCD boards and makes LEDs flash on and off prettily.  Of course, how that works on an 8 bit board is very different than it is for a 32 bit board.

By Saturday afternoon, I'd managed to unclutter and migrate their code to PIC32 and had the stepper controller connected to the NEMA 23 working properly.

I knew there was a lot of friction in my cable z-axis system, so I did an initial gear design of 3.5:1 to insure that I got plenty of torque.  I had rigged the 6 wire stepper in series at Bogdan's suggestion so that the amperage pull was considerably below 0.4 amps.  Imagine my surprise when I discovered that there was ample torque even at half-step to happily push that stiff z-axis lead screw collar back and forth under serious load at 660 pps, a step rate just short of the resonance speed of the stepper.  Even under those loads the controller chip never got above about 50 C even after several hours under load.  That means that no heat sink is necessary.

When you translate that pulse rate out to an MXL belt driven x or y axis powered by an 18 groove pulley you get a calculated top speed of about 60 mm/sec.  That's about three times the head velocity that I print at.  It would appear that running a stepper with 24 volt power makes a very big performance difference.

Here you can see the stepper controller attached to the NEMA 23 and the PIC32 development board.

I've been thinking about that cool controller chip and that NEMA 23 and wondering about the possibility of driving a Wade extruder design with a NEMA 23.  The technology and economics are certainly attractive.

I'm going to buy some more of those controllers and also a relay card so that I can control the hot ends and heat lamps on the printer.

Mikroelektronika certainly has a very big toolbox of accessory boards that let you prototype just about anything without having to build up circuitry from scratch.  They're not as cheap as you could build from scratch, but if you count the time and cost of building up purpose made boards while you are developing a printer and not sure of everything you want in it, they're very cost effective.


Forrest Higgs said...

Earlier today, I noted an occasional bit of slippage on the z-axis while running the NEMA 23, so I tightened the cables till they sing when plucked. It appears to have no effect on the ability of the lead screw drive's ability to move the axis. No stalling or skipped steps.

chylld said...

I would have imagined the cables need to be extremely tight anyway, if only to counteract the slack when changing direction (e.g. after homing at the start of every print)

My 5th prototype appears to remove 90-95% of the wobble... invisible now with normal plastic but I'm using super white to make sure it's really all gone.

Really not sure where the remaining amount is coming from as I've totally isolated from the studding's XY wobble...

Forrest Higgs said...

@Chylld The downward pressure from the weight of the print table pretty much does away with the slack/backlash issue.

Great to hear about your progress with the wobble reduction! When are you going to blog so the rest of us can see how to do it? :-)

chylld said...

I'll upload to the forum and Thingiverse once I'm sure the wobble is gone :) or maybe I should start a blog...

Forrest Higgs said...

Great! BTW, my son is putting together a next-generation website which he thinks will supplant Thingiverse for people like you. According to him it will allow Makers more flexibility to include assembly descriptions with lots of photos as well as space for STL and 3D CAD files. From what I hear it will be a bit like a miniblog for Makers to describe their inventions. :-)

Bogdan Kecman said...

I believe almost anything would be improvement to current reprap site so .. I keep my fingers crossed :)

murd said...

A local electronics mag here in Australia recently published a project based on PIC32, a great little controller that has a USB socket, plugs into a monitor and keyboard. Lot of potential, and it looked like a natural fit with Reprap from the moment I saw it.

Forrest Higgs said...

LOL! I recently discovered that the PIC32 core is actually a licensed MIPS design. Back in the 1990s, MIPS cpu's running windows were used in high end workstations that required more computing power than Intel CPUs could generate.

Similarly, the ATMega 32bit equivalent chip, I'm told, licenses an ARM core. ARM was originally used in the Apple Newton. :-)