Panel Cookies

3D scanner
page 1/1

Una publicación compartida de ELECTRONOOBS®️ (@electronoobs) el

3D Scanner - Arduino + Step motors

Help me by sharing this post

What’s up my friends, welcome back. Almost all of my DIY project have a 3D printed case of some sort of printed part. To print an object, you first need the 3D file. You have the file, you print the object. This project will do just the opposite, you have the object you get the 3D file. This machine should be able to 3D scan small objects with dimensions up to 13cm in the x and Y directions.

Arduino DIY 3D scanner IR

See the full part list here:

PART 1 - Building the frame

Below you can find a link for the STL files for the frame. Download it and print the files using your 3D printer. I've used 2 perimeters, 20% infill, 0.4mm nozzle and 0.2mm layer height.

Get STL files here:

3D printed scanner

Follow this steps and build the frame. Place the two NEMA17 motors in place on the frame base. Fix them in place with M3 screws and the printed top parts. Now, fit in place the two smooth rods. Prepare the Z-axis carrige with the linear bearings. Use zip ties and fit those in place and then, add a 8mm nut on the back.

Now place the carrige on the smooth rods, add the plastic pulley on the shaft of the motor and put the threaded rod or lead screw. Finally, add the turntable on the front motor.

3D scanner sharp GP2Y0A51SK0F

The sensor will give a direct analog output according to the measured distance. Finnaly, add (or not if using no homming code) the limit switch for the Z-axis. This limit swithc is used to home the axis at the beggining of the code loop when we start the machine. The frame is ready.

PART 2 - 3D scanner schematic

This below is what we need for the electronics part. The schematic is with an end stop limit switch. If you don't want to use it, make sure to later upload the code without limit switch. The push button is used to start the scanning process. Remember to connect Vref to 3.3V. We do that because the amximum voltage of the sensor is 2.4V. To increase precision, we use external voltage refference for the ADCs.

See the full part list here:

Arduino 3D scanner schematic

I've made all teh connections on a drilled PCB. We have the Arduino NANO with female pins so we could remove it. The SD card module on the side and the rest of the components. The input of 12V will eb connected to those two screw PCB connectors. I've used 0.1mm wire to make the connections. Remember to add those 47uF capacitors for the motor drivers. Connect the wires from the motors and sensor to the PCB. Make sure the rotation is in the desired direction. If not, juse reverse the motor inputs.

Arduino 3D scanner circuit PCB

PART 3 - The code

Let's see the code. Don't change anything in the code. Just the first variables at the beginning of the code acording to the parts you have used and the layer height you want. You have a code for the schematic using limit swithc for z-axis and for the manual homming. Download from below the code you want to use. If you don't have the limit switch connected, just use the other code.

3D scanner code (with limit switch):
3D scanner code (NO limit switch)

//Editable variables
int scan_amount = 40;                   //Amaunt of scans for each point. The result is the mean. This would increase the delay for each scan.
String file="scan_001.txt";             //Name of the saved file on the SD card
int z_axis_height = 12; //in cm         //Maximum height of the scaned file
int step_delay = 3000; //in us          //Delay for each step for the stepper motor in microseconds
float z_layer_height = 0.5; //in mm     //Layer height. The amount of mm for each layer. 
int lead_screw_rotations_per_cm = 8;    //How many rotations needs the lead screw to make in order to make 1cm. 
int steps_per_rotation_for_motor = 200; //Steps that the motor needs for a full rotation. 
int distance_to_center = 8;             //In cm. Distance from sensor to the turntable center in cm

Read all the comments in the code for better understanding. The code is simple. Create a loop that will make 360º rotation of the turntable. Each step we measure the distance. The X and Y increment is given by simple trigonommetry as seen below. Next, the x, y and z variable are stored to the SD card divided by a "," character. This step is important for later.

point cloud scanner STL

PART 4 - Point cloud to STL

Place the object on the turntable in the middle. Connect power supply and wait for theamchine to home itself. When reached, press the scanning push button and wait. Depending on the layer height you choose and object size it will take more or less to complete. Once complete, remove the SD card.

3D scanner point cloud

Remove the SD card and copy the file to your PC. The file should have the next format. Three columns separated by a comma with the values of the x, y,and z coordinates. This are just points in a format of a point cloud. To obtain an STL file, we use the MESHLAB software which you could download from a link below.

MESHLAB software (windows):

example point cloud


Downlad and install MESHLAB with the default install. Open meshlab and go to file, inport mesh. Here open the scanned file. In the next window select XYZ format and as a separator select the comme ','. Now the point cloud is open. We haev to give normals to the points. For that go to filter, normal curvature and orientation, compute normal for point set and in this window play with the settings. 10 was a good number. Click apply and close the window.

MESHLAB point cloud to STL

Now go to filter, remeshing simplification and reconstruction and here select screened poisson surface reconstruction. Play with the settings if you want and then click apply. Close the window and there we have our file.

MESHLAB point cloud to STL

Now, the file was scanned. The precision is not that good. For learning purposes, this project is more than enough.

So, there you have it guys. The precision could get better using a better distance sensor. Maybe a laser based one would give better precision. Also have in mind that in the code, the sensor makes 40 measurements and give the mean of those in order to increase precision. Consider using a lead screw instead of a normal threaded rod, better sensor, more measurements, add an end stop switch and improve this project however you want.

Help me on PATREON.

See more tutorials

Help me by sharing this post

Affiliate Disclosure


PCBWAY PCB service

Curso Arduino Online nivel bajo