Week 3 : CCC


Speed - Power characterization

The aim of this characterisation is to find out the result of a combination of the two main parameters of a laser cutting operation: speed and power.

The classic test is to create a square matrix by modifying the speed horizontally and the power vertically.

Two laser cutters are available at the FabLab, but only the more powerful, the “Lasersaur”, will be tested here.

SVG Files

The first step is to create an SVG file by creating a matrix of squares and varying the colour. Differentiating the colours will then allow the laser cutter’s control software to assign different parameters to each colour. You then import the file and manually set the parameters for each square/colour.

fittingparameters

MDF 3mm

An initial test was carried out with 3mm MDF. The results can be seen below. Now, depending on what you want to cut or engrave, we can use the parameters defined here.

fittingparameters

Cardboard 2.9mm

The same thing is done with 2.9mm cardboard.

fittingparameters

Fitting characterization for joints

As part of this week’s group assignment, one of our tasks involved determining an optimal fitting parameter to achieve a perfect fit between two parts without the use of any adhesive. To do so, a “fitting ruler” has been designed and fabricated using one of the laser cutter of our fablab - the Lasersaur.

Fitting ruler design on FreeCAD

The “fitting ruler” is basically a piece of wood (MDF) in which multiple slots of slightly different size are cut.

To create the design, we did a spreadsheet with different parameters on FreeCAD: the thickness of the wood, the depth of the slots, the gap between each slot, and the step, which is the increment in slot size.

fittingparameters

fittingrulersketch

When the design is ready on FreeCAD, it can be exported as a DXF file, to be read by Inkscape in order to vectorize it and then send it to the laser cutter.

fittingrulerinkscape

We used the parameter defined earlier during the power and speed characterization of the laser cutter to cut through the wood:

Here is the results:

fittingruler

We can then test the various slts insertion to determine the best fitting. After experimentation, we identified the optimal press fit to be 3mm - 0.2mm ➔ the fitting parameter is 0.2mm.

Creating calibration matrix

We developed a script that generates a calibration matrix in the form of an SVG, featuring a grid of uniquely colored squares within a larger square. Each color corresponds to different power/speed values, enabling precise calibration. The script is designed to be parametric, allowing for customization of the number of columns and rows, as well as the minimum spacing between each square.

Below is the result for a 5x5 grid :

Calibration

The code is the shown below :

from xml.etree.ElementTree import Element, SubElement, tostring
from xml.dom.minidom import parseString
import random

def generate_parametric_svg(small_square_width, small_square_spacing, large_square_spacing, N, M):
    # Calculate the total width and height needed for the small squares including their spacing
    total_small_squares_width = N * small_square_width + (N - 1) * small_square_spacing
    total_small_squares_height = M * small_square_width + (M - 1) * small_square_spacing
    
    # Adjust SVG dimensions to include the large square spacing
    svg_width = total_small_squares_width + 2 * large_square_spacing
    svg_height = total_small_squares_height + 2 * large_square_spacing

    # Create the SVG element
    svg = Element('svg', width=str(svg_width), height=str(svg_height), xmlns="http://www.w3.org/2000/svg")

    # Generate the large square, offset from the small squares by large_square_spacing
    big_square = SubElement(svg, 'rect', 
                            x=str(large_square_spacing - large_square_spacing), 
                            y=str(large_square_spacing - large_square_spacing),
                            width=str(total_small_squares_width + 2 * large_square_spacing), 
                            height=str(total_small_squares_height + 2 * large_square_spacing),
                            fill="none", stroke="black")

    # Generate the array of small squares without fill, starting from the large_square_spacing
    for row in range(M):
        for col in range(N):
            x = large_square_spacing + col * (small_square_width + small_square_spacing)
            y = large_square_spacing + row * (small_square_width + small_square_spacing)
            SubElement(svg, 'rect', x=str(x), y=str(y), width=str(small_square_width),
                       height=str(small_square_width), fill="none", stroke="#{:06x}".format(random.randint(0, 0xFFFFFF)))

    # Convert to a prettified (indented) string
    rough_string = tostring(svg, 'utf-8')
    reparsed = parseString(rough_string)
    svg_pretty = reparsed.toprettyxml(indent="  ")

    return svg_pretty

# Example parameters
small_square_width = 40
small_square_spacing = 10
large_square_spacing = 20
N = 5  # Number of square columns
M = 5  # Number of square rows

# Generate SVG content
svg_content = generate_parametric_svg(small_square_width, small_square_spacing, large_square_spacing, N, M)

# For demonstration purposes, here's how you might output or save the SVG content
print(svg_content)


# This is how you would save the SVG content to a file (adjust the path/to/save


# Example of saving the SVG content to a file (not executable here)
with open('./squares_with_spacing.svg', 'w') as file:
     file.write(svg_content)