The Road to CNC (part 3: computer configuration)

Despite picking up a decent computer, compared to LinuxCNC’s minimum system requirements, I was still getting some awful results when running the latency test. At about over 100K for both servo thread and base thread max jitter values, I started to worry that the entire pc would be unusable for cnc work.

Luckily, with some light reading, I found a few settings to tweak that could improve these results. In short, here’s the list of changes I made

  • Disable all power-saving settings in the BIOS
  • Disable Hyperthreading in the BIOS
  • Enable all (4) cores in the BIOS
    • make sure the lscpu command returns the expected value.
  • add the isolcpus=1,2,3 option in the grub bootloader settings with a modified version of Kent Reed’s 07_rtai script
  • redirect all interrupt requests (IRQs) to one processor by means of spainmann’s script

With these tweaks, servo thread jitter is below 64K nanoseconds and base thread jitter is below 10K nanoseconds–woot, it’s usable for LinuxCNC!

There are some other settings worth investigating later, documented on IBM’s webpage on reducing jitter for real-time linux operating systems. I haven’t played around with them much yet because my system performance is far better (and now good enough) than before the initial listed tweaks.

The Road to CNC (part 2: custom kinematics)

As I kept reading about LinuxCNC, I figured I’d try it out with the CoreXY Laser Engraver I made a while back.

LinuxCNC supports a number of typical machine kinematics out of the box. (Kinematics are included for 3-axis mills, scaras, and pumas.) A CoreXY isn’t one of them, though, so I needed to write a new kinematics file for CoreXY gantries.

To add custom kinematics, I wrote a corexykins.c based on the “trivial kinematics” file, trivkins.c, and followed OOOVincentOOO’s guidelines on the forums for installation. The actual changes were staggeringly simple–only about 5 lines were changed!

To load my new configuration, I ran the StepGen Configuration Wizard, which output the needed *.ini and *.hal files. I had to edit these files manually in two places, though. In the *.hal file, to load the new kinematics, I switched the line:

loadrt trivkins

to

loadrt corexykins

Lastly, in the *.ini file, I also needed to bump up the FERROR and MIN_ERROR from 0.05 to 0.5; otherwise LinuxCNC would throw the error

 

joint 0 following error
joint 1 following error

when switching from joint mode to world mode, at which point it actually uses the inverse kinematics equations to see if the tool’s current location matches where the forward kinematics actually brought the tool. (I’m assuming that either rounding error or the fact that my pc’s software stepping can’t keep up with the desired input speed could be the reasons for this error.)

For more references on writing up custom kinematics (with examples), here’s a few links.

The Road To CNC (pt 1)

I always wanted to setup a garage workshop! Now that I’m finally living in a place with a spare garage, I decided to get started.

LinuxCNC was my first choice for numerical control of any machine that I thought I might want to setup. Since 1952 when the first CNC machine was made at MIT to crank out aircraft parts, numerical control (NC) has revolutionized the way parts are made in the modern day. Pre-1952, many, but not all, industrial fabrication machines (mills, lathes, and many more) were operated by hand; furthermore, the complexity of the part that could be fabricated was limited by the skill of the machinist. Nowadays, the instructions are defined as 2D or 3D lines and arcs and uploaded to a machine that makes cuts along these paths. Don’t worry, we still have machinists! They just have a far-more augmented toolset, and the limits of “what we can can make” have been redefined to be both the limits of what we can define parametrically and the precision of our cnc machine. (Here’s an article from Scientific American way back in 1952, when it all got started.)

LinuxCNC is one of many software packages for “numerical control” of fabrication machines. In a nutshell, it’s mature, open source, under constant improvement, and “generic enough” to extend control to all sorts of machines (lathes, mills, laser cutters) with a user-definable “hardware abstraction layer” for defining custom machine kinematics. In other words, as long as I can write down the “rules” (equations) for how my machine moves around its tool in 3D space, I can control it with LinuxCNC.

The drawback? There’s a learning curve that’s biased towards those familiar with Linux already–not to mention that LinuxCNC needs to run on its own computer with a parallel port (DB25 connector). While there’s work done on the hardware-compatibility end to run LinuxCNC on a (much cheaper!) BeagleBone, I figured it’d be great to get support from the forums with a familiar hardware setup, so I picked up a refurbished PC on the Neweggs and installed LinuxCNC 2.6 via a liveUSB key that I made with another computer. (BeagleBone, maybe next time, bub..)

I admit that before I committed to the desktop I first picked up a cheap solid-state drive, installed the latest LinuxCNC image onto it, and booted it up on my normal pc to play around with. The ethernet connection didn’t work (hardware was too new), but everything else checked out cleanly. From there, I picked up the refurbished desktop, dropped in the hard drive, and everything checked out OK (except for the parallel port which is recognized in Linux, but I haven’t yet verified if any of the I/O pins are sending signals.)

For reference, here’s the hardware list so far: