Wednesday, 30 December 2015

NiCr



NiCr (read as 'nicrome') is the name of my CNC Hot Wire Foam Cutter, an OpenSource/OpenHardware project that I'm making public with this post.

The github repository: https://github.com/JMG1/NiCr

 

Description:

As the name says, the machine cuts shapes from foam blocks, being the original intention to cut wing cores for lamination and molding.

I've composed a little video about it:


I'm opening this project in exchange of all the good things that the OpenSource world has given to me (I like to think about it as 'from the OpenSource to the OpenSource').

Details:

The NiCr project can be divided in three parts: Machine, Arduino and FreeCAD


-Machine:

The machine is the physical thing, and is being designed to be built from easy to find, easy to work with materials, like extruded aluminium tubes and simple bolted joints, taking into account a low budget and the DIY factor (only cut/drill/bend operations).

It features two CoreXY frames, easy-to-find Nema17 motors, and a spring tensor for the wire. The design is also very scalable and can, possibly, be applied to other type of machines.

The design has taken place between FreeCAD and the real world:

FreeCAD pictures:

Detail of the Nema17 stepper, X axis slider and belt pulleys

Machine assembled inside FreeCAD
Real world pictures:

Frame size

Slider on the X axis

First version of the cut-wire tensor




-Arduino:

The machine movement is done with an Arduino Mega 2560 board and a Ramps shield, that, together with four stepper drivers (A4988), some limit switches and a power source form all the electronics.
The firmware is being developed specifically for this machine, you can see some of its parts in this links:


-FreeCAD:

The shapes are created using FreeCAD existing tools and converted later to .nicr (similar to GCode) in a custom workbench.

This workbench features a parametric machine, a shape-to-path algorithm, trajectory planning and simulation tools.

Some pictures of the workbench:

Workbench and parametric machine

Cut path simulation result for three wings with different precision settings

Workbench demo video:



The result of the shape-to-path algorithm is a .nicr file that contains instructions similar to GCode and with this comes a question:
Why I have not used the path workbench (in development) and the existing GCode standard?
 Because this machine produces 2.5D shapes (could do '2.75D' with the addition of a fifth axis, to be studied) and the movement is very different to the movement of a 3D printer or mill, and by using 4 axis, someone can be mistaken and use the code for the wrong machine.
Anyway, it is going to be a documented language so export-import tools can be created if needed.


Conclusion:

NiCr is in active development, at the moment I'm trying to achieve a basic stability and usability of the software before releasing (and some documentation too, maybe the hardest thing!).
Once I achieve that, the code and machine 3d parts will be uploaded to github (I have not decided the particular license yet) After a complete day of reading about licenses, I have chosen the GNU GPL.

I'll be updating this post with any news I have.
-> January 1, code uploaded to github: https://github.com/JMG1/NiCr








By the way, have a happy 2016!

Javier.


Tuesday, 3 November 2015

Arduino: Live Instruction Feed To CNC

This is the conclusion of the posts reading instruction from serial and stepper sync:


While the video itself is not very exciting, it shows a machine moving using custom code (of course, I'm excluding the bootloader and stepper firmware, not to mention the complete Linux core running on the pc...).

You can find the code used in the video (Arduino and Python) in this github repository The code is as is (being it a test I have not taken the time to clean it).

The next step is to achieve a continuous movement (currently, it stops completely between instructions) using some kind of instruction buffer.

The machine of the video is not the target machine (see here another video about this mini CNC)

EXTRA (because 200 youtube subscribers :) )

This is the frame of the target machine:



Full aluminium.

More to come in a few weeks its here!

Thursday, 29 October 2015

Arduino: Move 4 Stepper Motors Synchronously

...but, theoretically, it would work for an n number of motors.

Part of the machine inside FreeCAD
This is the algorithm that plans the trajectory and syncs the movements of the stepper motors, in the new CNC machine that I'm designing (and building!)

The input is an int array { MA, MB, MC, MD } where each int means the number of steps (positive or negative).

The stepper movement logic is stored into a boolean[8] array { SA, DA, SB, DB.... } where SA means step for motor A and DA is the direction bit of the motor A (for a 2 wire stepper driver, like the a4988). This array is erased and re-computed every loop cycle with the next movement, so real motor stepping has to take place inside this loop.

The image below (created with FreeCAD) shows a representation of the algorithm output for a requested movement of ( 5, 15, 25, 40 ) steps.

Input ( 5, 15, 25, 40 ), step bit only

It would be possible to do some kind of buffer by translating that boolean array into an int inside an int array. This should be a more-less memory efficient way of decoupling motion logic and motion execution, something to try in a future.

The code:

/*
 * JMG October 2015
 * NiCr Stepper Sync Algorithm V1
 * Tested on Arduino Nano (Ide 1:635)
 * 
 */

// stepper_instruction { Step1A, Dir1A, Step1B, Dir1B, Step2A, Dir2A, Step2B, Dir2B }
bool stepper_instruction[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };

void moveAB( int Adx, int Ady, int Bdx, int Bdy )
{
  int delta[4] = { Adx, Ady, Bdx, Bdy };
  int aux = 0;
  for( int i = 0; i < 4; i++ )
  {
    if( abs(delta[i]) > aux )
    {
      aux = abs(delta[i]);
    }
  }
  float R[4] = { 0, 0, 0, 0 };
  for( int i = 0; i < 4; i++ )
  {
    R[i] = (float)delta[i] / (float)aux;
  }
  int inc[4] = { 0, 0, 0, 0 };
  int acc[4] = { 0, 0, 0, 0 };
  int j = 0;
  while( ( acc[0] != Adx )||( acc[1] != Ady )||( acc[2] != Bdx )||( acc[3] != Bdy ) )
  {
    j++;
    for( int i = 0; i < 4; i++ )
    {
      inc[i] = round( R[i]*j - acc[i] );
      acc[i] = acc[i] + inc[i];
      stepper_instruction[2*i] = abs( inc[i] );
      if( inc[i] < 0 ) { stepper_instruction[2*i+1] = 1; }
      else { stepper_instruction[2*i+1] = 0; }
    }
    for( int i = 0; i < 7; i++ )
    {
      Serial.print( stepper_instruction[i] );
    }
    Serial.println( stepper_instruction[7] );
    for( int i = 0; i < 8; i++ )
    {
      stepper_instruction[i] = 0;
    }
  }
  for( int i = 0; i < 4; i++ )
  {
    Serial.print( acc[i] );
  }
  Serial.println();
  for( int i = 0; i < 4; i++ )
  {
    Serial.print( delta[i] );
  }
}
void setup()
{
  Serial.begin( 115200 );
  delay( 500 );
  moveAB( 100, -5000, 780, 25 );
}
void loop()
{
}

It prints by serial (115200 baud) the values of stepper_instruction at each loop cycle, and the counted steps vs the requested steps at the end of the loop.
I'm sure this is not the optimal way of doing it, but it works.

Update: the algorithm in action

PS:
I will reveal more info about the machine soon. NiCr