Control a 3D printer and print gcode files using Matlab

Control a 3D printer and print gcode files using Matlab

Blog

Control a 3D printer using Matlab

Download our code and control or print gcode files using Matlab. A better version will follow! Subscribe to our newsletters!

Download for free a Matlab software
An interface of Matlab code for controlling a 3D printer and printing gcode files
DOWNLOAD FULL CODE: LINK


RECENT POSTS
How to make a fill pattern for 3D printing

How to make a fill pattern for 3D printing

Blog

Make various fill patterns

Slic3r is considered one of the best slicing software for 3D printing. Many features and widely used slicing procedures have been presented there for the first time. Among other things, they presented for a first time a pattern (3D honeycomb infill) that can be varied across the layers in three dimensions. Slic3r not only offers a large variety of patterns (Fig. 1), but also it gives the possibility to create your own.

 

 

Figure 1. Infill patterns at varying densities. Left to Right: 20%,40%,60%,80%.  (Source: Link).

 

Procedure: Coping a pattern (test)

A comparison will take place between the actual Concentric pattern offered by the Slic3r and the same pattern designed in a CAD software. The goal is to produce the same result. Therefore, the pattern Concentric with 50% infill density and without top or bottom layers was designed and was exported as STL (Fig. 2).

 

Figure 2.The designed Concentric pattern with 50% infill density.

A small cube (20X20X20 mm) will be tested using the Slic3r pattern and the designed pattern. By clicking on settings, Slic3r offers you an option to load a modifier (Fig 3.). The Concentric pattern as an STL was loaded (Fig. 4).

 

Figure 3. A cube (20X20X20 mm) and the ‘Settings’ option.

Figure 4. Loading Concentric pattern.


The main idea is that the loaded pattern should have 100% infill density, perimeters, top and bottom layers and in the general settings, these values should be zero (Fig. 5, 6a & 6b).

Figure 5. Modifier settings: 100% infill density, 3 Bottom and top solid layers, 3 perimeters.

Figure 6a. Print settings: 0 Bottom and top solid layers, 0 perimeters.

Figure 6b. Print settings: 0% fill density.

By exporting the gcode and clicking preview we can see the results (Fig. 7) and compare it by using the Concentric pattern of the Slic3r software (Fig. 8). Both of the gcode produce the same result.

 

Figure 7. The result of using the modifier to create our own pattern.

Figure 8. The Concentric pattern of the Slic3r software.

It has to be mentioned that using the same procedure but with exactly the opposite settings, the inverse pattern can be created (Fig. 9).

Figure 9. The inverse pattern of the Concentric designed pattern.

If you have a real object that you want to print using your own pattern, you have to repeat the pattern design and exported as an STL with the same volume of your object. The advantage of this technique is that you don’t need to use a Boolean difference to create a new STL. Also in most of the cases using a Boolean difference, the merged STL cannot complete and the relative software can fail (sometimes there are small holes). You have to experiment with the setting and find the proper result for your project. For example, in Figure 10 and 11 you can see the implementation of a different pattern and the result.

Figure 10. The design of the new pattern.

 

Figure 11. The results of the new pattern.


Procedure: Applying our pattern to a model

We want to print the bunny model (Fig. 12) with the designed pattern (Fig. 13).

Figure 12. The original model.

Figure 13. The pattern designed enough to fit the model.

As it was described earlier, clicking settings and loading the pattern STL as a modifier we can merge the pattern structure with the object (Fig. 14). The settings for the modifier are presented in Figure 15.

Figure 14. Loading the modifier.

Figure 15. Settings for the modifier.

At this time we want perimeter for the model. Therefore, we will use a 3 lines perimeter in the model but the rest of the settings will be equal to zero (Fig. 16a & 16b).

Figure 16. Print settings: 0 Bottom and top solid layers, 3 perimeters.

Figure 16b. Print settings: 0% fill density.


The results are presented in Figure 17 and 18

Figure 17. The bunny model in a preview.

Figure 18. A cut of the bunny model with the embedded pattern.


RECENT POSTS
IMU motion detection

IMU motion detection

Blog

How to detect if an IMU is in motion or not

The main issue using an IMU is that the estimated measurements (angle, velocity and position) present a drift caused by the single and double integrations. For the compensation of the drift errors, various methods have been presented for example using a Kalman Filter or even a simple removal of a constant value in every estimation. However, the identification whether an IMU is motionless or not could improve the results. Integrating the values when the IMU is in motion only, the drift error can be reduced firther.

An mpu6050 IMU was moved back and forward two times. Three methods have been implemented for the identification of the IMU movement.

 

1.Angular velocity magnitude

Transforming gyroscope’s raw data to angular velocity and using a threshold, the IMU movement can be recognised (Fig. 1).

angular_threshold = 5;
rate_magnitude = sqrt(sq(gyro_rate_x) + sq(gyro_rate_y) + sq(gyro_rate_z));
if (rate_magnitude < angular_threshold)
  {
    GyX = 0;
    GyY = 0;
    GyZ = 0;
    AcX = 0;
    AcY = 0;
    AcZ = 0;
  }

 

 

 

Figure 1. Using the angular velocity magnitude method.

 


2. Absolute acceleration

When the accelerometer is at rest it should record only the gravitational acceleration. Therefore, values higher than 9.81 m/s2 will include acceleration from the movement (Fig. 2). The acceleration method includes also false values due to the fact that an accelerometer is noisier than a gyroscope.

accel_threshold = 9.81;
  accel_magnitude = abs(accel_x_scaled) + abs(accel_y_scaled) +  abs(accel_z_scaled);
if (accel_magnitude < accel_threshold)
    {
      GyX = 0;
      GyY = 0;
      GyZ = 0;
      AcX = 0;
      AcY = 0;
      AcZ = 0;
    }

 

Figure 2. Using the summation of the absolute acceleration values.

 

3. Using both methods

Figure 3. Using both methods.

 

Components list:
(1x) Arduino Uno
(1-16x) IMU MPU-6050
Download Full Code: Link
Check also:
IMU holder for MoCap


RECENT POSTS
Calculating roll, pitch and yaw from XYZ coordinates of a plane

Calculating roll, pitch and yaw from XYZ coordinates of a plane

Blog

A brief post how to calculate the three angles (roll, pitch and yaw) of a moving plane defined by three points.

Matlab code:

filename_points = 'Points.xlsx'; % Excel file name
data = xlsread(filename_points); % Reading data from excel file
index = length(data); % Length of the data
rad2degree = 57.3; % Radians to degrees factor

for i=1:index
    Point_1 = [data(i,1),data(i,2),data(i,3)];
    Point_2 = [data(i,4),data(i,4),data(i,5)];
    Point_3 = [data(i,7),data(i,8),data(i,9)];
    % k
    V_1 = Point_1-Point_3;
    V_Magnitude = norm(V_1); % Magnitude V_Magnitude= sqrt(Vk(1)^2 + Vk(2)^2 + Vk(3)^2);
    V_1 = V_1 / V_Magnitude;
    Vector1 = Point_2-Point_1; 
    % i
    V_2 = cross(Vector1,V_1);
    V_Magnitude = norm(V_2); % Magnitude V_Magnitude= sqrt(Vk(1)^2 + Vk(2)^2 + Vk(3)^2);
    V_2 = V_2/V_Magnitude;
    % j
    V_3 = cross(V_1,V_2);
    V_Magnitude = norm(V_3);
    V_3 = V_3/V_Magnitude;
    Rotation_matrix = [V_2(1) V_3(1) V_1(1); V_2(2) V_3(2) V_1(2); V_2(3) V_3(3) V_1(3)]; % Creating the rotation matrix
    eulZYX = rotm2eul(Rotation_matrix); % Convert rotation matrix to Euler angles
    Angle_yaw(i,1) = eulZYX(1,1)*rad2degree;
    Angle_pitch(i,1) = eulZYX(1,2)*rad2degree;
    Angle_roll(i,1) = eulZYX(1,3)*rad2degree;        
end


RECENT POSTS
Plastic vs Resin 3D Printers

Plastic vs Resin 3D Printers

Blog

How Plastic and Resin 3D printers work

In Fused Deposition Modeling (FDM) also known as Fused Filament Fabrication (FFF), the filament is extruded in layers to create a 3D printed object. During printing, the material is fed through a hot extruder and by moving the nozzle in three directions the object can be printed.

  

Figure. A FDM printer.

A Resin 3D printer uses photopolymers as consumable materials. These are liquid materials that can react to light and be solidified. There are two types of Resin printers:

1) Using a laser beam printing the object line by line. This is called pure stereolithography (SLA).

2) Projecting the entire slice of the object using a digital projector. This process is called digital light processing (DLP).

DLP models are faster than SLA printers, since each layer hardens by projecting the entire image of one layer. A SLA or DLP printers uses an ultraviolet (UV) laser to harden the liquid materials; this process is called curing.

Figure 2. A Resin printer.

 

Materials

The Plastic 3D printers can print from the standard materials PLA and ABS up to a wide variety filament blends (mixed with wood, ceramics, metals, carbon fibres etc.). Also, a lot of exotic filaments are available in the market. The filaments can be found in two standardised diameters: 1.75 and 3.00 mm. However, some commercial 3D printers use filament boxes provided by the relative company. They are considered more expensive than standard spools but it is claimed that produce better quality.

 

In the Resin printers, regarding the materials and the colours, there are limited choices. It is recommended that the resin materials should not be from other companies.

 

Precision, smoothness and speed

In the FDM (plastic) 3D printers, the resolution depends on the nozzle diameter (0.2 up to 1.0 mm), the height layer and the precision of the extruder movements in the X and Y axis. The precision and smoothness are affected by a number of printing issues may occur such as warping, oozing or stringings and misalignment of layers.

 

The resin printers consistently produce higher resolution objects and are more accurate than FDM printers. The resolution is primarily determined by the optical spot size either of the laser or the projector, which is really small. SLA prints can produce objects with much better details than a FDM printer could have done (Fig. 1).

 

Figure 1. An object printed with FDM and SLA printers.

Adhesion/removal after 3D printing

In the FDM (plastic) 3D printers, the object can be removed easily. In some cases, a blue tape or specific glue is needed for better adhesion. Also, other tools such as palette knife can be used to remove the object.

 

In resin printers, it can be difficult to remove the printed model from the bed. Sometimes, there is a lot of resin on the bed that it has to be removed using a tool. It is more difficult to remove an object from an SLA printer than in a FDM printer.

 

Post-processing

In the FDM (plastic) 3D printers, there is no post-processing. There is only one case when it may be required when supports have been used and they have to be removed with a cutting tool or even with a hand.

In the resin printers, the printed objects are covered with resin which has to be removed in a bath of isopropyl alcohol. Also, supports have to be removed with a cutting tool.

 

Cost

For the common FDM (plastic) 3D printers, a lot of companies offer standardised filaments and the price for a spool with weight at 750-1000 gr can cost at 20-35 $. Specialised filaments are more expensive.

 

In the resin printers, the tank and the build platform may need to be changed after some printings. Also, the resins are much more expensive than the FDM’s spools and are offered only by the manufacturer of the printer.

 

Synopsis

 In Table 1, the cons and pros of a plastic and resin printer are demonstrated.

 

Plastic

Resin

Low-cost models

High-cost models

Large build volume

Limited build volume

Large variety of materials and colors

Limited variety of materials

Low printing speed

High printing speed

High strength and durability

Low strength and durability

Medium precision and very low smooth finish

High precision and smooth finish

Low post-processing

High post-processing

Table 1. A comparison between a FDM (plastic) and Resin printer.

 


RECENT POSTS
Multiple IMUs

Multiple IMUs

Blog

Connect up to 16 IMUs with an Arduino

By using a multiplexer (MUX), it is possible to connect more than one or two IMUs on a single board. A MUX can forward the signal of several analog or digital sensors into a single input. Figure 1 presents the connection of 4 IMUs (mpu6050 or you can connect mpu9250) with a multiplexer (CD74HC4067). The connected IMUs could be up to 16 and for the extraction of each IMU’s measurements, it is necessary to activate the related channel every time (Table 1). However, using an analog multiplexer the response of the IMUs will not be so accurate in comparison with an I2C address multiplexer such as TCA9548A. More you can find here.

Figure 1. Multiplexer and IMUs connection circuit.

Table 1.Truth table for the activation of the relative channel (0 = LOW, 1 = HIGH) with analog multiplexer.


Soon a low cost DIY 3D rotation system for the validation and calibration of IMUs will follow!!! Designs for 3D printing, code and tests will follow… Stay tuned for our newsletters.

Free designs, code and tests with a low cost 3D rotation system
Low-cost DIY 3D rotation system for IMU validation

 

Components:
(1x) Arduino Uno
(1-16x) IMU MPU-6050 or IMU MPU-9250
(1x) Multiplexer CD74HC4067 or TCA9548A (more here)
Download Code, Documents and Circuit: Link
Check also:
IMU holder for MoCap
IMU motion detection


RECENT POSTS