DEV Community


Posted on • Updated on

Hands Writing Robot

It's generally known that the hands writing Robots can not catch up with the printer in the actual production line because it lacks efficiency so it hasn't applied in many different industry scenarios. However, for beginners who want to learn Robots and may look to create one by themselves, hands writing robots is a good start as it has a simple structure and in line with human handwriting habits. The design of this writing robot includes path planning, line interpolation, acceleration and deceleration control, and other common-used motor motion control algorithms. Software part, DXF file resolution, openCV image processing, and other G code generation tools are taken in this project. Build a good foundation for a further in-depth study of laser cutters, engraving machines, 3D printers, and other large-scale equipment. My tutorial will share my experience of creating this project. I hope this helps you in some way.

Development Environment

RT-Thread Inside:v3.14
Development Tool:MDK-ARM5.31、VSCode

RT-Thread in this project

Kernel: Thread Scheduling、Resource Allocation、Synchronous Communication、Device-driven Frameworks.
Components: DFS File System、UART Serial Asynchronous Communication、CAN Communication.
Others: UDP Communication、cJSON Codec

Hardware Architecture

Alt Text

Software Architecture

  • Image processing module

  • Motion control module

  • G code generation module

The image processing module is responsible for pre-processing image files such as text images and photographs, removing clutter, and then decoding the image with appropriate algorithms, de-emerging the main information, and then extracting the outline skeleton to fit the machine writing.

The motion control module is one of the most complex modules in a writing robot, responsible for the precise and fast movement of each motion body. After receiving the G-code instruction, it is required to combine all the instruction information received for generating an appropriate initial speed and the maximum running speed of the current instruction, proceed with the linear interpolation according to the motion trajectory, and finally send pulses to the motor according to the SPTA trapezoidal acceleration and deceleration algorithm.

The G-code generation module serializes the image outline and then plans the path, selects a suitable machining precision, and then generates the NC processing file according to the G code specification that commonly used in CNC machining. In addition, for standard DXF files, G code is generated by file resolution.

Software Module Introduction

grbl is a high-performance, low-cost open-source CNC controller that delivers high-speed, precise motor control pulses based on the ATmega 328 chip. It accepts standards-compliant g-code, and includes full acceleration management with look ahead, to deliver smooth acceleration and jerk-free turning action.

As grbl includes full acceleration management with look ahead. That means the grbl controller needs to maintain 16-20 G code instructions. This requires ART-PI to send G-code instructions in a timely manner by reading the grbl controller buffer state to avoid buffer overflows and buffer emptying.

Therefore, RT-Thread real-time operating system is indeed for this project. By reading the NC file on the SD card, and communicate with the grbl controller, to control the devices running smoothly. In addition, RT-Thread has a wealth of human-computer interaction features so you may real-time display the device work path, progress and status on the screen, and may also add the features of resume breakpoint and many others.

Source Code


Alt Text

Check out Video.

RT-Thread Contact Info:

Website | Github | Twitter | Facebook | Youtube

Top comments (0)