3D Scanner using Hexabitz Modules

A CNC Machine scans shapes with XY axis and measure the height then send it to python program and plots it

IntermediateFull instructions provided406
3D Scanner using Hexabitz Modules

Things used in this project

Hardware components

4-Pin USB-Serial Prototype Cable
Hexabitz 4-Pin USB-Serial Prototype Cable
×1
STLINK-V3MODS Programmer (H40Rx)
Hexabitz STLINK-V3MODS Programmer (H40Rx)
×1
VL53L1 Time-of-Flight IR Sensor Module (H08R70)
Hexabitz VL53L1 Time-of-Flight IR Sensor Module (H08R70)
×1
Dual H-Bridge Motor Driver (H18R1x)
Hexabitz Dual H-Bridge Motor Driver (H18R1x)
×4
Anycubic i3 Mega 3D printer
Anycubic i3 Mega 3D printer
×1
3.3V/1A DC-DC Power Supply Module (H03R00)
Hexabitz 3.3V/1A DC-DC Power Supply Module (H03R00)
×1
DPS5005 mini power supply
×1

Software apps and online services

VS Code
Microsoft VS Code
STM32CUBEPROG
STMicroelectronics STM32CUBEPROG

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free
3D Printer (generic)
3D Printer (generic)
Cable Cutter, 130.17mm
Cable Cutter, 130.17mm

Story

Read more

Schematics

1D LiDAR IR Sensor (H08R6x)

Dual H-Bridge Motor Driver (H18R1x)

STLINK-V3MODS Programmer (H40Rx)

3.3V/1A DC-DC Power Supply (H03R0x)

Code

STEPPER Driver for 3D Printer (H18R1)

C/C++
No preview (download only).

LiDER module (H08R6x)

C/C++
No preview (download only).

Communication with computer

Python
this code establish the communication between computer and H08R6x module (master) and send it a Gcode command
import serial
from time import sleep
import os

def splitData(data):
    data =data.split(' ')
    return (data[1][1:],data[2][1:],data[3][1:],data[6][:-2])
dir = os.listdir('./')
cnc = serial.Serial('COM30',9600)
print("connected")
sleep(2)
print("start send")
x ,y =0,0
move_y=False
with open(f"./data{len(dir)}.csv","a") as f:
    f.write("x,y,z,ir\n")

while True:
    cnc.write(f"G1 X{x} Y{y} F3000\n".encode())
    sleep(0.01)
    data = cnc.read_until('\n'.encode())
    if move_y:
        y+=5
        move_y=False
    else:
        x+=5
    print(data)
    try:
        sleep(0.200)
        print(splitData(data.decode())  )
        a,b,c,d = splitData(data.decode())
        with open(f"./data{len(dir)}.csv","a") as f:
            f.write(f"{a},{b},{c},{d}\n")
    except:
        print(data)
    
    if x > 120:
        x=0
        move_y=True
    if y > 120:
        break
f.close()
print("done")
    # sleep(0.2)

PLOT

Python
from mpl_toolkits import mplot3d
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd 

df=pd.read_csv('./Square.csv')
print(df.columns)

fig = plt.figure()
fig.autofmt_xdate(rotation=180)

ir_val = df['ir'].values.tolist()
ax=fig.add_subplot(111,projection='3d')
ax.scatter(df['x'].values.tolist(),df['y'].values.tolist(),ir_val)
ax.set_title('3D Scanner')
ax.set(xticklabels=[],
       yticklabels=[],
       zticklabels=[])
ax.set_zlim3d(0, 120)
roll = 0
elev = -130
for angle in range(0, 360*4 + 1):
    # Normalize the angle to the range [-180, 180] for display
    angle_norm = (angle + 180) % 360 - 180
    azim =0
    azim =angle_norm
    ax.view_init(elev, azim, roll)
#     plt.title('Elevation: %d°, Azimuth: %d°, Roll: %d°' % (elev, azذ1im, roll))
    plt.draw()
    plt.pause(.00001)
plt.show()

Credits

Yaman jaddouh
2 projects • 1 follower
Contact
Mohammad Baher Karazeh
1 project • 2 followers
Embedded System Engineer
Contact
Mahmoud Mardnly
12 projects • 19 followers
Embedded System Engineer
Contact
Ahmad TASKIA
11 projects • 11 followers
MPhil. Bsc. ELECTRONICS Engineering
Contact
Bakry Rihawi
3 projects • 9 followers
Contact

Comments

Please log in or sign up to comment.