Pimp My Snapmaker 2.0 - Mod No. 1: Add a Serial UART Connection to a Snapmaker 2.0 Controller

by seppomane in Circuits > Microcontrollers

316 Views, 2 Favorites, 0 Comments

Pimp My Snapmaker 2.0 - Mod No. 1: Add a Serial UART Connection to a Snapmaker 2.0 Controller

IMG_6207.jpg

You ask, why should I do this?

So you can control your Snapmaker 2.0 with G-Code via Arduino or other microcontrollers. Use joysticks, buttons, rotary controllers or what you prefer for customized actions.


Attention! 


Note that this modification will void your warranty. Your controller or your Snapmaker may be damaged.

Only recreate it at your own risk! I accept no liability for damage!

I bought a second controller for 80 euros so that I wouldn't destroy my original.

Supplies

IMG_6197.jpg

You need:

  • a good soldering station
  • 3D printer (you obviously have one)
  • 1.6 mm hex screw driver
  • Metal drill bits 1.6mm, 2.5mm
  • Thread cutter M2
  • pin header and sockets
  • experimental pcb
  • 2x M2 countersunk screws
  • Micro Controller like Arduino

Your skills:

  • you have to be very good at soldering
  • Arduino coding
  • Maker skills at all

Locate the UART Pins…

Snappi_2_UART_HACK_USB_IC_1.png
Snappi_2_UART_HACK_USB_IC_PINOUT.jpg
Snappi_2_UART_HACK_pin_locate2.png

Arduino RX -> CH340E RXD (Pin 9) -> R11 ->…-> GD32F307VGT6 TX

Arduino TX -> CH340E TXD (Pin 8) -> R12 -> … -> GD32F307VGT6 RX

Solder Wires to the Pins…

IMG_5986.jpg

I used silicone-coated wires because this insulation is heat-resistant.


YELLOW RXD -> R11

GREEN TXD -> R12

RED +5V

BLACK Ground

Drill Holes...

Snappi_2_UART_HACK_dril.jpg
IMG_5863.jpg
IMG_5988.jpg
IMG_5989.jpg

Drill the holes for the wires with the 2.5 mm drill and the holes for the attachment with the 1.6 mm drill. You then cut an M2 thread into the mounting holes.

Here you find a drilling template:


Create an UART Connector...

IMG_6087.jpg
IMG_6088.jpg
IMG_5864.jpg
Bildschirmfoto 2023-12-01 um 20.15.41.png
Bildschirmfoto 2023-12-02 um 19.12.34.png
IMG_6109.jpg

I chose 5 pins instead of the necessary 4 and melted the 2nd one so that the connector only fits in one direction.

I will give you the STL files for the plug and socket housing.


Arduino RX -> CH340E RXD (Pin 9) -> R11 ->…-> GD32F307VGT6 TX

Arduino TX -> CH340E TXD (Pin 8) -> R12 -> … -> GD32F307VGT6 RX


YELLOW -> Arduino RX Pin

GREEN -> Arduino TX Pin

RED -> Arduino +5V

BLACK -> Arduino GND

Arduino Coding…

Here is the simplest example.

When a button connects pin 3 to ground, all axes are homed.


const int buttonpin=3;                        // define pin 3 als button pin

void setup() {
Serial.begin(115200); // start serial connection to Snapmaker 115200 baud
pinMode(buttonpin, INPUT_PULLUP); // set button pin 3 as digital input with pullup resistor
}

void loop() {
if (digitalRead(buttonpin) == HIGH) { // if pin 3 to GND
Serial.println("G90"); // GCODE absolute positioning
Serial.println("G28"); // GCODE home all axes
Serial.flush(); // send GCODE to Snapmaker
delay(5000); // wait for 5 seconds
}

}



Test...

IMG_6108.jpg
IMG_6203.jpg
IMG_6204.jpg
IMG_6205.jpg
Pimp My Snapmaker 2.0 - Mod No. 1: Add a Serial UART Connection to a Snapmaker 2.0 Controller

To test it, I built a Pro Mini module into a WII Nunchuck controller. Works great.


/* Sebastian Austel 2022*/

#include <Wire.h>
#include <wiinunchuck.h>

int zbutton=0;
int cbutton=0;
int roll=0;
int tilt=0;

float stepdivid=10;

int joyxval=0;
int joyyval=0;
int joyzval=0;
int extr=0;
int mrot=0;
float xstep=0.0;
float ystep=0.0;
float zstep=0.0;
float xstepabs=0.0;
float ystepabs=0.0;
float zstepabs=0.0;
int xstepabsint=0;
int ystepabsint=0;
int zstepabsint=0;

bool zmodus=0;

int xyspeed=2000;
int zspeed=1000;
int xdelay=50;
int ydelay=50;
int zdelay=50;
float movedelay=500.00;
int movedelayint=500;
int movedelayintabs=500;


void setup() {
Serial.begin(115200);
nunchuk_init();
delay(100);
nunchuk_calibrate_joy();
delay(100);

}

void printnunvals() {
Serial.print("x: ");
Serial.println(joyxval);
Serial.print("y: ");
Serial.println(joyyval);
Serial.print("z: ");
Serial.println(joyzval);
Serial.print("z Button: ");
Serial.println(zbutton);
Serial.print("c Button: ");
Serial.println(cbutton);
Serial.print("roll: ");
Serial.println(roll);
Serial.print("tilt: ");
Serial.println(tilt);
Serial.print("stepdivid: ");
Serial.println(stepdivid);
Serial.print("zmodus: ");
Serial.println(zmodus);

}

void readnunvals() {
nunchuk_get_data();
joyxval=nunchuk_cjoy_x();
joyyval=nunchuk_cjoy_y();
zbutton=nunchuk_zbutton();
cbutton=nunchuk_cbutton();
roll=nunchuk_rollangle();
tilt=nunchuk_pitchangle();

//Joystick Range
joyxval = map(joyxval, 0, 255, -100, 100);
joyyval = map(joyyval, 0, 255, -100, 100);

//JoyStick Center Null
if (joyxval>=-5 && joyxval<=5) {
joyxval=0;
}
if (joyyval>=-5 && joyyval<=5) {
joyyval=0;
}

// roll range
roll = map(roll, -180, 180, -5, 5);

// tilt range
tilt = map(tilt, -180, 180, -5, 5);
}

void ButtonHold(){
while (nunchuk_zbutton()==1){nunchuk_get_data();delay(100);}
while (nunchuk_cbutton()==1){nunchuk_get_data();delay(100);}
}

void StepCount(){
//Step Count

if (roll<-2){
stepdivid = 10;
}
else{
stepdivid = 1;
}

xstep=joyxval/10.00/stepdivid;
ystep=joyyval/10.00/stepdivid;
zstep=ystep/10/stepdivid;
xstepabs=abs(xstep);
ystepabs=abs(ystep);
zstepabs=abs(zstep);
xstepabsint=abs(xstepabs);
ystepabsint=abs(ystepabs);
zstepabsint=abs(zstepabs);
}


void zmodeselect(){
if(zbutton==1){
zmodus=!zmodus;
ButtonHold();
delay(100);}
}

void setzero(){

if(cbutton==1){
//ZERO SET XYZ
Serial.println("G92 X0 Y0 Z0");
Serial.flush();
ButtonHold();
delay(100);
}
}


//MOVE START##################

void JoyMove(){
if (joyxval!=0 || joyyval!=0) {

switch (zmodus) {
case 0: //z mode not active = xy control ... Z Modus nicht aktiv = Steuerung XY

//delay depending on longer distance and speed ... abhängig von längerem Weg und speed
//calculate Movedelay ... Movedelay berechen
if (xstepabs>ystepabs){
movedelay=xstep*60000/xyspeed;
movedelayint=int(movedelay);
movedelayintabs=abs(movedelayint);
}
else{
movedelay=ystep*60000/xyspeed;
movedelayint=int(movedelay);
movedelayintabs=abs(movedelayint);
}
Serial.println("M211 S0");
Serial.println("G91");
Serial.print("G1 ");
Serial.print("X");
Serial.print(xstep);
Serial.print(" ");
Serial.print("Y");
Serial.print(ystep);
Serial.print(" ");
Serial.print("F");
Serial.println(xyspeed);
Serial.println("G90");
Serial.flush();

delay(movedelayintabs);
break;

case 1: //z mode active = z control ... Z Modus aktiv = Steuerung Z
//Z control ... Z Steuerung

movedelay=zstep*60000/zspeed;
movedelayint=int(movedelay);
movedelayintabs=abs(movedelayint);

Serial.println("M211 S0");
Serial.println("G91");
Serial.print("G1 ");
Serial.print("Z");
Serial.print(zstep);
Serial.print(" ");
Serial.print("F");
Serial.println(zspeed);
Serial.println("G90");
Serial.flush();

delay(movedelayintabs);
break;

default:
// default is optional
break;
}
}
}

//MOVE ENDE###################


//MAIN LOOP##########################################

void loop() {

readnunvals();

// do nothing for the first 5 seconds ... erste 5 Sek nichts tun
if (millis()<5000) {
joyxval=0;
joyyval=0;
zbutton=0;
cbutton=0;
roll=0;
tilt=0;
}

setzero();
zmodeselect();
StepCount();
JoyMove();
//printnunvals(); //uncomment for serial output nunchuck values = develope mode ... unkommentieren für serielle Ausgabe der Nunchuck-Werte = Entwicklungsmodus


delay(100);

}



Have Fun...

Feel free and be creative. 



More content of ...


MY MAKER STUFF

https://www.instructables.com/member/seppomane/


MY MUSIC STUFF

https://www.youtube.com/seppomane

https://soundcloud.com/austelmusic


MY GFX ARTIST STUFF

https://www.redbubble.com/de/people/Seppomane

https://seppomane.myspreadshop.de/