Sunday, June 12, 2011

It's Alive!

I installed the motor mounts and mounted the steppers this weekend. I'm used to the various phases, stages, sub-projects, etc. taking pretty long, so this seemed like it went really fast. The instructions were good but could have been better. Some of the illustrations were lacking detail. I had to put on the "preload nut" at one point. This nut is not symmetrical yet the instructions didn't mention it and the illustration wasn't good enough to show which way to install it. It didn't take much to figure out what was likely the right way, but still it would have been more reassuring to have it spelled out in the instructions.

There was nothing in the instructions about inserting the bearings into the motor mounts. One set went in just fine but the other was a little tricky. The inside bearing was difficult to press in and hard to tell if it was in all the way. My exploration of the preload bearing earlier led me to conclude the bearing wasn't in all the way. I was a little worried about jamming it in cockeyed or such that it wouldn't go in all the way, but I found a piece of PVC pipe just the right size and carefully pressed on it and it popped in.

After getting the mounts on I started with the Z-axis motor and found it wouldn't quite mate all the way with the mount. If I forced it I could feel the coupler compress which I'm sure would be bad. I fashioned a crude measuring device out of a note card and music wire to measure the depth of the coupler hole. The shaft on the stepper motor was a bit too long and bottoming out on the coupler. I had to grind about a 1/16" of an inch off the shafts (for you metric folks that's about one sixteenth of an inch). I was quite careful with the grinding not wanting to subject the shaft to severe trauma. I also did a lot of quenching to keep it cool.

Here's the mill with all 3 motors installed:


The spindle and motor is suspended over the mill on a counter-balanced pulley system. It's not attached.
Here's a closer view of the Y-axis motor installed along with a hand wheel and the bottom half of the encoder for the DRO.


And another shot with the spindle and motor back on:


I ran the motors a bit and it's a thing of beauty. The top speed was not as fast as I thought it would be. It's fast enough if I can't get it any faster. The acceleration curve is pretty conservative. I'll tweak the ramp so it gets up to speed faster. I'm sure a pure linear ramp will be good enough. I ran it up to full speed and hit the E-stop which results in the maximum "hard stop" and it really seemed like no big deal. It's a pretty light machine.

Next step is to finish putting the encoders and hand wheels back on. Then on to the limit switch installation.

Friday, June 10, 2011

Process Control

Since my last post I've spent my time on the firmware working in "process control". This basically means dealing with things going wrong, or e-stop and limit switch operation. This work was not very glamorous, not like the VectorBuffer or LightManager that have well-defined and limited responsibilities. There was no obvious best solution and I didn't sit down to really concentrate on it. I just poked at it when I had time, so progress was slow and frustrating. Most the work was done in the Controller class but it was still a lot of wiring of software components and managing many state transitions. It's hard to debug this sort of thing given that it's running on the microcontroller and I don't have the benefit of stepping through code in a debugger. I can throw in print statements here and there but it's a tough code/deploy/test cycle.

There are some things unique to microcontroller development that would be difficult to analyze with print statements. Raw experience and a little intuition can help. When the E-stop button is engaged or the limit switch is open (both "stop" conditions) all the lights turn on. I noticed that when I hit E-stop, then opened the limit switch, the lights when from bright to less bright. There's no "dimmer" switch, or alternate electrical path through resistors or something. The only way the lights can go from bright to dim is by toggling them very rapidly. So I knew I would be looking for a spot in the code that would turn them all off then back on. I determined the state was switching back and forth from E-stop mode to limit switch stop mode. With each change in mode the LightManager resets the lights to off.

I decided to go with the polling approach for both E-stop and limit switches. There's no need at all for a hardware interrupt on the E-stop button since the other set of poles disconnects the power to the stepper driver control signal circuit. The limit switches probably could benefit from hardware interrupt. It appears there is about 60-70 milles of travel on the limit switch past the trigger point. That's like 600 steps on the motors. Polling might be fast enough to stop it before the motors crush the switch. I intend to test it well within the hard limits of the mill with stop blocks hot-glued to the machine so they should pop off if the machine overruns the limit switch before the firmware can stop things.

Anyway, it's in pretty good shape now. I've run it through its paces in manual mode and with a program run. There will certainly be tweaks, but it's clear the safety measures are in place and I can mount the motors.