In the last four weeks everything has started to come together and the pace has really picked up. I've spent about another £200 on parts; mainly wires, connectors and fixings. Once all these parts arrived I layed out all the boards/components on a big sheet of aluminium and spent the best part of a day positioning everything in the most efficient manor. It soon became apparent that I had a lot of PCBs and not a lot of space to put them!
With everything positioned, I got a permenant marker, marked out over 120 holes and proceeded to drill each one ... twice. Now the original plan here was to use Rivnuts as I needed in excess of 100 M3 threaded holes which I didnt fancy tapping by hand. Unfortunatly I discovered very early on that M3 rivnuts are very difficult things to use as they have a nasty tendency to snap the insertion tool before theyve squashed down with enough grip into the aluminium sheet. Fortunately I discovered this on a test piece right at the start so at least I didnt have to deal with 120 oversized holes.
Reluctantly I went down to my local hardware store, purchased an M3, M4 & M6 tap and then spent an entire day just cutting threads. Although monotonous, it wasnt quite as bad as it sounds. Due to a spell of cold weather I had already moved my operations from the consevatory to the living room of our student accomodation (much to the confusion of my housemates) so I was sat on the sofa in comfort, cutting threads whilst watching top gear on Dave. Still, I was very glad to reach the final hole.
The next step was much quicker and involved screwing in about 100 x 30mm x m3 aluminium posts into each of the M3 holes. These posts are male on one end, female on the other and are for mounting all the PCB's so they are raised off the aluminium baseplate, thus preventing short circuits.
With the posts in place it was time for yet another supprise; turns out that the mounting holes on nearly every PCB were M2.5 not M3 which meant a lot of frantic last minute drilling which I hadnt planned for. With that done I was able to screw down all the PCB's within an hour or so. Next to go in was all the cable trunking. I had pre-cut this so it just had to be bolted down but I had to cut all the covers to size and drill through some holes that became covered over.
Now all the hardware was in place I was able to start putting in the wires. The great thing with this part was it had already been planned out on the wiring diagram so it really didnt involve too much thinking. Within about three days I had virtually all the wires in place which meant time for some testing.
First thing to be tested was the E-stop circuitry. When an e-stop button is pressed it is supposed to send a signal to tell the control software but also send another signal to a timer which energises a contactor. The idea is that the fastest and safest way to stop the machine is through software but as a backup in case that fails for any reason, a contactor will remove all power from the machine in a fraction of a second longer than it would expect the software to have done its job.
Despite having designed it correctly, a lot of the time I was just wiring stuff from memory which was fine except for the fact I was remembering a previous version of the diagram which had a few errors. As a result I had ended up wiring the power to the contactor coil to the output from the contactor. This meant as soon as the contactor was triggered it went into an infinate loop condition where it rapidly pulsed on and off until power was removed at source.... not really a huge problem to fix but I did check over the rest of the wiring a little more carefully after that.
The next problem was with another safety cutout; the charge pump. This device is a small PCB with a relay output which is energised when it recieves a 12.5khz signal from the control software. The purpose of this is to prevent any undesired operation from noise on the signal lines as a result of the software having not yet been loaded or crashing. That one relay then switches several other relays which cut power to anything potentially dangerous.
The first problem with this was I did not know how to make the software output a 12.5khz signal so I figured I could short the relay contacts for the time being to achieve the same effect. This should have switched on several other realys powering up everything else on the board but instead I got a medium sized blue spark. At first I thought this might have just been from a bad contact + inductance from the relay coils but after a bit more investigation I discovered the true cause.
The relays & holders were ones I had salvaged from the original control system that came with the machine when I bought it and I hadnt really noticed the diodes wired accross the coil connections - well they werent on my diagram so as far as I was concerned they didnt exist

. Of course the diodes were wired the wrong way round so rather than blocking back EMF from the coils they were just shorting the output from my 24v supply.
After swapping the diodes round I was then able to power up everything else and soon worked out how to output signal to enable the charge pump electronically. This wasnt made any easier by a typo on my diagram which meant all the output pins on the board in question had the wrong pin numbers written beside them so although the computer was sending out a signal I was always measuring for a voltage on the wrong output.
While installing the relays my next brainwave was the realisation that all the relays were double pole which hadnt been accounted for in my diagram. Thinking i was really clever being able to save some space I ripped out two of the relays/holders with the intention of switching 4 connections on two relays. This would have been fine but that was before realising that although all the relays were powered up together from the same source they could be powered down separately. Feeling quite retarded at this point I quietly wired the other relays back in hoping no one else would notice my mistake.
After playing round with a few more features of the software I decided it was time to move onto the servo motors, controllers and PID tuning. It didnt take me long to wire everything up and having borrowed an additional 24v PSU from the university cybernetics dept, I soon had everything ready to go.
I have been running my CNC control system off two PCI parrallel port cards which windows defines as LPT2 & LPT3 respectively. Unfortunately the PID tuning software is a bit fussy and requires some very specific options on the connection front.
For a start it requires to be connected to LP1 which meant going into BIOS to enable that port and then swapping over the data cable. With that done it still didnt work and it took several more reboots to realise that there was a bit more to it. Not only did it want the port LPT1 the software also requried the hexadecimal port address of 0x378 and IRQ 7. Once I had got these technicalities out the way I had a bit more success.
For a start I powered up the logic side of the servodrives but put no power to the motor connection. Looking on the screen the software told me it had a successful SPI connection and it had detected the encoder. Turning the motor shaft (and thus encoder as well) by hand caused numbers on an onscreen DRO to change -this was looking very promising! Particularly considering I was only using single ended encoders but had wired them into an interface expecting a differential signal.
With this stage complete, I set the default values on the software, saved them to the EEPROM on the drives and then switched on the power supply to the motor. Turning the motor shaft now revealed more good news; it was actually working as a servo, albeit very very overdamped. Within 15 minutes I had managed to find a good compromise for the PID settings but then spent more hours than I care to think trying to refine it further without success. It seemed I could only achieve very overdamped or a tiny bit undedamped but never critically damped which fustrated me immensly.
After consulting some friends they suggested that it was only possible to get a critically damped response in a perfect system and that perfect systems don't exist in the real world, though they still agreed with my thinking that a little overdamped would be better than a little underdamped.
At this point I had a few other questions in mind so I phone the supplier of my drives over at Rutex in the US and found the answer I was looking for. What I had experienced was both correct and normal. The test & config software simulates extreme conditions where in order to get a fast response it is normal for the result to be a little underdamped. Under normal operation the NC software will have accel and decel ramps which will prevent the under damped condition from occuring.
Having had so much success with one drive I thought i'd try my luck with a second and third. I dug out two more motors, connected up some longer wires and just ran them off the power supply directly to check they were running free and not drawing excess current. Until now all was going well but it had started to get dark, I had started to get very tired and accidently picked up the wrong two wires from a bunch and connected up the motor supply to the first servo drive backwards. After not seeing any movement for a few seconds I sensed something was amiss and quickly disconnected the power.
Fearing the wost I fired up the NC software to see if I could still operate the drive but it would not work at all because it was halting on an E-stop caused my a (non existant) limit switch signal. At this point I figured I had caused enough damage for one day and would sleep on it before trying to work out just what I had blown up.
After a lot of messing about I realised I had done no damage to my servodrive, motherboard or breakout board and what I had discovered was a whole new and unrelated problem.
Every time I plugged in a servo drive into one of the free slots on the motherboard it tripped a different limit switch input. What didnt make much sense was how it only seemed to affect the 3 spare slots and not the first slot I used. Eventually I realised that the first slot in the motherboard is considered to be the A axis slot, but I had disabled the limit switches for the a axis as I dont have one yet and was using the x limits for the a axis. This isnt a problem in itself and I can do that quite happily if I want to, but it explains why the problem wasnt showing up on the first drive. As soon as I enabled the A limits those tripped the system too.
After considering a whole range of possibilities from dodgy PCI parrallel port cards, to noise and incorrect paramaters in the servodrives I finally realised that the switches HAD to be normally closed. Most breakout boards and NC software allows you to choose if your inputs are normally closed or normally open but rutex doesnt give you this option. So I made the appropriate settings in Mach3 for the input state and shorted all the limit inputs with bits of wire and everything started to work again. Pulling out a wire would trip the system causing an e-stop condition BUT Mach3 was not recognaising this state change in the diagnostic screen.
A bit more experimentation revealed the problem. When a limit is pressed this causes an E-stop condition which stops the the enable signal going to the chargepump which in turn cuts power to the servo drives. Now this normally closed switch requirement only manifests itself whilst the servodrive/motherboard is powered. So as soon as the power is removed the signal dissapears so mach no longer registers a state change.
I suppose there are two ways to go about fixing this; either I can stop the servodrives being powered down in an e-stop condition (keep the charge pump running so long as the NC software is open on the PC) or I can try and change the program so hitting a limit doesnt invoke a full e-stop condition in the first place. Either way it will need a bit more thought.
Whilst looking through the diagram I've spotted another potential flaw. At the moment I have the spindle fan, field, spindle brake and enable switch all on the same output. While this did keep things simple its hardly ideal. Mach has a minimum speed setting to stop the motor stalling so I think when the motor is enabled by calling an M3/M4 it will try to switch on all that stuff and take it up to 25% or whatever the min speed is set to.
In which case what I really want is the ability to swithc on the field windings, brake and fan first then delay for a second or two and then enable the spindle drive. .. and the same thing in reverse for switching off. If I need to free up another output pin I can parrallel the oil pump relay onto the same output as the spindle fan/field/brake. This is how bridgeport did it originally anyway, I just wanted individual control of the oil pump for testing purposes.
I'll have another play with mach3 tomorrow and try to wire up the other two motors and run the PID tuning on those drives. After that I'll have to return the power supply to uni so the next big progression will have to wait until I get home.
Until then, here's a video of the latest developments:
http://youtube.com/watch?v=wY7I9xevxU8