Share this

Open-type laser galvanometer motion controller for CAD graphic marking under Ubuntu + Qt

2026-04-06 03:03:54 · · #1

In previous lessons, we discussed how to perform galvanometer calibration using Ubuntu + Qt (click for details → Laser Galvanometer Calibration with Open Laser Galvanometer Motion Controller under Ubuntu + Qt). This section on CAD graphic marking is implemented under the premise of galvanometer calibration.

Before we begin our formal learning, let's first understand the ZMC408SCAN-V22 motion controller. The ZMC408SCAN-V22 controller supports development and use in a Linux environment.

01ZMC408SCAN-V22 Hardware Introduction

The ZMC408SCAN-V22 is a high-performance dual-galvanometer motion controller from Zheng Motion Technology. It integrates two 100Mbps Ethernet ports, supporting EtherCAT, EtherNET, CAN, RS232, RS485, 24 general-purpose digital inputs, 20 general-purpose digital outputs, 2 general-purpose analog outputs, 2 general-purpose analog inputs, 4 local differential pulse axis interfaces, 1 MPG handwheel encoder interface, 2 galvanometer interfaces with feedback, 1 LASER interface, and 1 FIBER interface. The open system block diagram is shown below:

The ZMC408SCAN-V22 bus controller supports EtherCAT bus connection, a refresh cycle of up to 500μs, and motion control of up to 16 axes. It supports linear interpolation, arbitrary circular interpolation, spatial circular interpolation, helical interpolation, electronic cam, electronic gear, synchronous following, virtual axis setting, etc.; and can achieve real-time motion control by using an optimized network communication protocol.

The ZMC408SCAN-V22 can connect to various expansion modules via CAN and EtherCAT buses, thereby expanding digital, analog, or motion axes. It can be developed for various operating systems including Windows, Linux, Mac, Android, and WinCE, and provides DLL libraries for various environments such as VC, C#, VB.NET, and LabVIEW. For upper-computer software programming, refer to the "ZMotion PC Function Library Programming Manual".

02 Developing a CAD Graphic Marking Project using Ubuntu + Qt

1. In Qt Creator, select "File" → "New File or Project..." to open the Project Creation Wizard. Select the Application project set to create a Qt Widgets Application project, and set the project name and save location.

2. Import the relevant function libraries and header files provided by the manufacturer. (1) Copy zmotion.h, zmcaux.h, zmcaux.cpp, ZmotionCad3.h, libzmotion.so and libZmotionCAD3.so libraries to the newly created project folder.

(2) In Qt Creator, right-click on the newly created Qt project and select "Add Library..." → "External Library". Click Next to import the libzmotion.so and libZmotionCAD3.so library files that you just copied to the project folder into the project.

(3) In Qt Creator, right-click the newly created Qt project, select "Add existing file...", and add the header files zmotion.h, ZScancorrect.h, zmcaux.cpp and zmcaux.h that were previously copied to the project file to the project.

(4) After the function library is successfully added, you can open the .pro file to see the relevant function library and header file information. At this point, the function library and header file required by the routine have been added to the project. Next, we will start implementing the routine.

03 Introduction to CAD Graphic Marking Process and Related Functions

1. CAD graphic marking flowchart

2. Introduction to relevant functions (1) Connecting the controller.

(2) Import CAD drawings.

(3) Cancel the import of CAD drawings and release the entire layer list.

(4) Obtain the range of the CAD drawing.

(5) The linked list structure after CAD drawing parsing: The CAD library uses a doubly linked circular list to store the specific drawing data and the parsed coordinate data.

typedef struct Struct_ZCad_VectGroup{ int m_itemtype; // Type struct Struct_ZCad_VectGroup *m_prev; struct Struct_ZCad_VectGroup *m_pnext; int m_GroupNum; // Group number uint32 m_ColorPen; // Color DWORD Struct_ZCad_Vect *m_pVect; // Curve list }Struct_ZCad_VectGroup;

(6) Download the file three times.

(7) General command execution interface.

(8) Obtain the status of the output port.

04 Implementation Example of CAD Graphic Marking

The CAD drawing marking routine mainly uses a CAD library to parse CAD drawings, parses the drawing data into a linked list structure, obtains the coordinate data of the drawing by traversing the linked list, generates three file strings of all coordinate point data, and downloads them to the controller, thus realizing the marking of CAD drawings.

1. Import CAD drawings.

·

void MainWindow::on_import_2_clicked(){ data_Load(); // Get the interface settings parameters strFile3.clear(); LaserScan_z3p_Init(); // Initialize the file string three times QString qstr = ui->file_route->text(); // Get the path and filename of the CAD drawing QByteArray byteArray = qstr.toUtf8(); const char* cstr = byteArray.constData(); m_pGraph = ZMotionCad3_ImportVectGraph(cstr,1016,0,0.001,0); // Import the drawing and generate the trajectory update(); // Update the interface drawing}

2. Traverse the linked list and generate three file strings. First, obtain the CAD drawing data, then traverse the linked list, generating three file strings using the internally implemented functions for empty movement, activation, marking, and deactivation. The following is a partial implementation code.

·

if (m_pGraph != NULL){ Struct_ZCad_VectGroup *ps = m_pGraph; do { Struct_ZCad_Vect * pVect = ps->m_pVect; do { Struct_ZCad_Seg * pSeg = pVect->m_pLine; // Empty move to the starting point LaserScan_z3p_EmptyMove(strFile3,pSeg->x1,pSeg->y1,markPara.JumpSpeed,markPara.JumpDelay); // Open Light LaserScan_z3p_OpenLight(strFile3,io_value.emit_io,markPara.OpenDelay,markPara.MarkSpeed); int i = 0; do { if(!pSeg->m_Param1) { // Move strFile3 += QString("MOVESCANABS(%1,%2)\n").arg(pSeg->x2).arg(pSeg->y2); } i++; pSeg = pSeg->m_pnext; }while(pSeg != pVect->m_pLine); //Turn off the light LaserScan_z3p_CloseLight(strFile3,io_value.emit_io,markPara.CloseDelay,markPara.JumpDelay); pVect = pVect->m_pnext; }while(pVect != ps->m_pVect); ps = ps->m_pnext; }while(ps != m_pGraph);}

3. Cancel the graphics import, clear the graphics linked list, call the interface function to clear the linked list, and update the interface at the same time.

·

void MainWindow::on_cancel_clicked(){ ZMotionCad3_DeleteChain((Struct_ZCad_Item *)m_pGraph); m_pGraph = NULL; update();}

4. Download the file strings three times to the controller.

·

void MainWindow::on_create_File3_clicked(){ ZMC_DownMem3File(g_handle,strFile3.toLatin1().data(),strFile3.length(),"Zmc_CAD.z3p"); QString filePath = "Zmc_CAD.z3p"; QFile file(filePath); if (file.open(QIODevice::WriteOnly | QIODevice::Text)) { QTextStream stream(&file); stream << strFile3; file.close(); qDebug() << "File saved successfully:" << filePath; } else { qDebug() << "Failed to open file for writing:" << filePath; }}

5. Use online commands to execute the file three times to mark the CAD drawing.

·

void MainWindow::on_but_Mark_clicked(){ if( 0 == g_handle) { QMessageBox::warning(this,"Prompt","Controller not connected!"); return; } char Response[1024]; ZMC_Execute(g_handle,"FILE3_RUN \"Zmc_CAD.z3p\",7 ",500,Response,1024);}

05. Implementation effect of CAD graphic marking

1. Connect the controller and set the laser and process parameters.

2. Select CAD drawing import and draw the drawing.

3. Generate three files to mark the CAD drawing.

4. Use an oscilloscope to capture the marked CAD drawings.

Full code download address

That concludes our presentation on CAD graphic marking using the open-source laser galvanometer motion controller developed with Ubuntu and Qt.

For more exciting content, please follow the "Zheng Motion Assistant" WeChat official account. For related development environment and example code, please contact Zheng Motion's technical sales engineer: 400-089-8936.

This article is original content from Zheng Motion Technology. We welcome everyone to reprint it for mutual learning and to jointly improve China's intelligent manufacturing level. Copyright belongs to Zheng Motion Technology. Please indicate the source if you reprint this article.

Read next

CATDOLL 108CM Sabrina (TPE Body with Soft Silicone Head)

Height: 108cm Weight: 14.5kg Shoulder Width: 26cm Bust/Waist/Hip: 51/47/59cm Oral Depth: 3-5cm Vaginal Depth: 3-13cm An...

Articles 2026-02-22