Giter VIP home page Giter VIP logo

cnc3018-offline-controller's Introduction

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.

cnc3018-offline-controller's People

Contributors

dturner avatar friebel avatar positron96 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cnc3018-offline-controller's Issues

No comunication after baudrate is set

Hardware:
-Offline Controller based on SMT32F (same as shown in the developer pictures)
-CNC Controller is woodpecker v3.3 with grbl firmware v1.1

What Works:
-Serial probing cycle for baudrate seems to work
-Controller shows interface,.
-All menu entries are shown and can be selected.

What doesn't work:
-The only serial output from the offline controller is the $I sent in different baud rates to probe for the correct baud rate.

Test made:
-With a serial probe in tx rx terminals to check for comms, the behavior is as follows:
-A few $I are sent by the offline controller in different baud rates.
-The machine responses with [VER:1.1f.20170801:] [OPT:V,15,128] ok
-The offline controller understands the response and stops sending any further comunication.

The offline controller only shows the machine as X idle or sometimes Lockpad Idle, but no further comand comes out of the offline controller, not with a SD card file, not with the DRO, or any other entry on the menu.

Original firmware backup

I want to try this firmware on my offline controller that came with an STM32 clone, but st-info reports 0kb of flash size. I'm guessing the flash is locked and I would need to unlock it, but I want to make a backup of the original firmware before flashing yours.
Did your controller come with locked flash?

File chooser UI hangs after job completion if you attempt to access subfolder

Steps to reproduce

  • Create a folder on the SD card and add a GCode file to it
  • Access the file chooser menu (via "Open")
  • Open the folder
  • Select the GCode file to start the job
  • Wait for the job to complete (or produce an error - for testing purposes it's quicker to just not home the machine and attempt to run a job then it will error)
  • The menu returns to the main screen
  • Now access the file menu again and attempt to open the folder

Expected result

  • Folder opens as previous

Actual result

  • The folder does not open and instead the UI hangs. Buttons do nothing.

Cause

  • Inside FileChooser, trail keeps track of the current path. This path isn't reset after job completion which means that when you go back into the file chooser menu and open a folder, that folder name is appended to the existing path.

Feedrate when running file

Is it possible or add an option to change feed rate when running the program? I always start slow and adjust feedrate to make it run smooth

Same issue as #5 from vinpinto - Reopen

I am having the same issue with the same offline controller (ST32 based, same as you project photos) and the same CNC board (woodpecker cnc v3.3).

Looking at the schematics for Woodpecker CNC v3.3 it does not look like there is any connection to pin 8 of the offline controller jack

1 - 5v
2 - Gnd
3 - 5v
4 - Gnd
5 - TX
6 - Rst
7 - RX
8 - NC

When I connect the USB to the computer and use Putty to watch the out put I get

Detected GRBL device
GrblDRO::onButton(1,1)
GrblDRO::onButton(1,0)
GrblDRO::onButton(0,1)
GrblDRO::onButton(0,0)
GrblDRO::onButton(5,1)
GrblDRO::onButton(5,0)
GrblDRO::onButton(6,1)
GrblDRO::onButton(6,0)
GrblDRO::onButton(3,1)
GrblDRO::onButton(3,0)
GrblDRO::onButton(2,1)
GrblDRO::onButton(2,0)
 > (f 15,128) ''(len 0) 
 > (f 15,128) 'Grbl 1.1h ['$' for help]'(len 24) 
Msg '[MSG:'$H'|'$X' to unlock]'
 > (f 15,128) '[MSG:'$H'|'$X' to unlock'(len 25) 
GrblDRO::onButton(1,1)
GrblDRO::onButton(1,0)
GrblDRO::onButton(0,1)
GrblDRO::onButton(0,0)
GrblDRO::onButton(5,1)
GrblDRO::onButton(5,0)
GrblDRO::onButton(6,1)
GrblDRO::onButton(6,0)
GrblDRO::onButton(3,1)
GrblDRO::onButton(3,0)
GrblDRO::onButton(2,1)
GrblDRO::onButton(2,0)

Pressing the buttons will show as above but pressing [Exit/Step], selecting Reset (Ctrl-X), and [OK/Spindle] does not show any output on the Putty screen. If I press the reset button on the CNC the I will get the little bit of output shown in the middle (lines that start with > (f 15,128) ) and the display changes to add a line below "x Idle" that says "'$H'|'$X' to unlock" but the buttons and menu selection still do do not produce any output.

I tried connecting a UART directly to the offline controller and when I sent "[VER:1.1f.20170801:]" after I saw "$I" in the terminal window the display will change to the "x Idle" screen but pressing any buttons does not get any output. I tried sending the "[OPT:V,15,128]" and "ok" as well but it did not change the behavior.

Above vinpinto "Thanks man, that got everything solved, I'm still not sure why both states X and padlock are dependent on this, but removing this feature made everything work" Do you know what he removed to make it work? Any other thing I might look at?

Below are pics of the offline controller and CNC board I'm working with.
E0666ACE-AD04-4F67-86E6-2C5CF9D1630B
F0F32BC2-E9D0-48D2-8DF4-BA02CA7ACFB1
DE4D69C2-4E50-41DF-9B58-B76CE9EC1363

Originally posted by @mppkll in #5 (comment)

Unable to Connect

I'm trying to install this firmware on my STM32F103C8T6 based offline controller. I've installed all drivers for the St-Link V2 (Clone) updated its firmware and verified the pins are correct. I've soldered the SWD connection point wires, and installed Platformio within VS Code. I've cloned the files and compiled them. When I hit upload I get "init mode failed (unable to connect to target)" Do I have to delete the original firmware first? Or am I missing a reset process?

Hex for download

Could you please publish your resulting hex file for downloading.

*** [upload] Error 3221225477

Any idea why this error?

Building in release mode
Checking size .pio\build\controller\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [===== ] 46.3% (used 9484 bytes from 20480 bytes)
Flash: [===== ] 51.9% (used 68040 bytes from 131072 bytes)
Configuring upload protocol...
AVAILABLE: blackmagic, cmsis-dap, dfu, jlink, serial, stlink
CURRENT: upload_protocol = stlink
Uploading .pio\build\controller\firmware.elf
xPack OpenOCD x86_64 Open On-Chip Debugger 0.11.0+dev (2021-10-16-21:19)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
debug_level: 1

0x20000
hla_swd
*** [upload] Error 3221225477

No communication after baudrate is set

Hardware:
-Offline Controller based on SMT32F (same as shown in the developer pictures)
-CNC Controller is woodpecker v3.3 with grbl firmware v1.1

What Works:
-Serial probing cycle for baudrate seems to work
-Controller shows interface,.
-All menu entries are shown and can be selected.

What doesn't work:
-The only serial output from the offline controller is the $I sent in different baud rates to probe for the correct baud rate.

Test made:
-With a serial probe in tx rx terminals to check for comms, the behavior is as follows:
-A few $I are sent by the offline controller in different baud rates.
-The machine responses with [VER:1.1f.20170801:] [OPT:V,15,128] ok
-The offline controller understands the response and stops sending any further comunication.

The offline controller only shows the machine as X idle or sometimes Lockpad Idle, but no further comand comes out of the offline controller, not with a SD card file, not with the DRO, or any other entry on the menu.

Incorrect Labeling for the SWDIO Interface Pins?

I had just started reverse engineering my own little Controller (which seems to be identical to the one shown), when I stumbled across this awesome repository. However the Pin furthest from the Edge, which is labeled +5V, seems to be connected directly to the supply pins of the STM32F103, aswell as the output of the regulator (at least on my board). Am I missing something here or is it misslabeled as +5V?

Love the firmware but

It doesn't work with Vcarve. What could be a problem? When it tries to change the z-axis I have to press unlock to continue. I used firmware.hex from the release section with STM32 mcu. Everything works when I switched back to the original firmware that I saved.

smaller controller

Hello,

great job with this firmware. Thank you.

Just an Information:
My most recent GRBL Offline Controller has no real STM Chip on it, but an GD32F103C8T6.
This chip has only 64k, so the verify step of the programmer fails because the code is too large to fit.

I plan to replace the chip by a STM32F103 with 128k, as soon as they are available again.

Impossible to flash GD32F103C8T6 chip

Hi,

When i flash the .hex firmware with a st link usb key v2, all seems to be OK but at the verification step , i have this error : Programming error @ 0x08010000!

Is it due to the problem of short memory of the GD32F103C8T6 chip ?

Do you have the same firmware but lighter ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.