Skip to content

Open-source firmware for popular cnc3018 stm32-based offline controller

License

Notifications You must be signed in to change notification settings

positron96/cnc3018-offline-controller

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

81 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Open-source firmware for an STM32-based "cnc3018 offline controller"

Video demonstration:

mqdefault

This popular chineese (most probably) controller is frequently sold with 3018-type CNC machines. The machines themselves run GRBL on ATmega328 MCUs, while the controller uses STM32F103 MCU. The stock firmware is somewhat lacking in features (no DROs, no spindle speed, for example).

The goal of this project is to make an alternative firmware to control a CNC machine. The information provided can be also useful for those who want to turn this controller into something else (a small gaming console, a controller for other equipment).

The firmware is written for Arduino framework and PlatformIO build system. VS Code IDE is used for development.

This firmware is for a controller with an OLED display and a full-sized SD card. There are other, probably newer controllers with a colored TFT display and micro-SD cards. They have different hardware and this firmware will not work with them!

There is no USB bootloader on the MCU, no access to BOOT pins, so flashing must be done via SWD. Therefore soldering will be required to flash the firmware! An SWD programmer will also be needed.

Goals of the project:

  1. Reverse-engineer the schematic of the board (to the required extent)

  2. Make custom firmware with these features:

    1. Move axes via buttons, display coordinates on screen, etc.

    2. Send gcode from files on SD card.

    3. Stream gcode from USB.

Backlog

  • ✓ Jogging

  • ✓ Spindle control (with 1% option for laser "pointer")

  • ✓ File chooser UI

  • ❏ Job control (pause/cancel)

  • ✓ Grbl state tracking (alarm, error)

  • ✓ Menu

    • ✓ Change work offsets (set zero to current position). Only G54 supported.

    • ✓ Homing ($H), unlocking ($X)

    • ✓ Grbl reset (Ctrl+X)

  • ✓ Display coordinates in WCS (done, but not intuitively for now)

  • ❏ Bridge GRBL and USB UART

  • ✓ Detection of GRBL USB connection via dedicated pin (works to some extent)

  • ❏ Improve continuous jogging

Schematic and hardware

display
display

The schematic reversing is complete to the necessary degree. Everything that’s needed to interface with MCU (pins, interfaces) is discovered.

The board features:

  • STM32F103C8T6 MCU. 64K Flash, 20K RAM. As usual, 128k is usable.

  • 128x64 OLED display with SSD1306 IC. 2-color, 16 rows are yellow, the rest is cyan. Connected via 4-wire software SPI.

  • Mini USB (no external crystal, so not datasheet-compliant).

  • Full size SD card socket. Connected to MCU via SPI interface.

  • 8-pin IDC connector for CNC machine. Has 5V, GND, UART and USB detection pin (when the CNC is connected to PC via its own USB-UART, the controller detects that and does not send data over UART).

  • 8 buttons. Buttons short MCU pin to ground, internal pullup required.

  • An unpopulated SWD socket

display
display

You can clone the EasyEDA project of the schematic here: https://oshwlab.com/positron96/cnc-offline-controller-stm32

Build & Install

Build

Use PlatformIO. It will install everything required to build the firmware.

You can also download the precompiled binaries (elf and hex) on Releases page.

Install

The easiest way to flash the firmware is to solder 4 wires to SWD pads. They are located at the top right corner of the PCB underside. The order is (from the corner) GND, SWDCLK, SWDIO, +5V (see schematic above).

The PlatformIO project is configured to use stlink. OpenOCD will be configured with no flash size autodetection to allow more than 64k firmware on 64k MCU. Other SWD programmers like J-Link or Blackmagic Probe will work as well, though extra configuration should be made to allow >64k firmware to be flashed. I have no idea how to tell these programmers to do so. If you do, please let me know.

Due to non-standard configuration used for >64k firmware, if you need to debug the firmware, you first need to upload it via upload command. This way, the programmer packages are downloaded and installed.

Original backup firmware from my controller can be found here.

About

Open-source firmware for popular cnc3018 stm32-based offline controller

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages