Select your language

This project is inspired by the interest in making something and not by the need to print. So .... 3D printer.
Budget € 200, unfortunately it must be said that the plans remained as plans, € 350 is a more realistic number.
Briefly parameters / snippets:
Operating voltage 24V.
Dimensions: 350x350x420 (X * Y * Z).
Print area 200 x 200 x 200 mm.
3 axles on MGN12H linear guides, - bearings.
X, Y axle transmission - GT2 6 mm timing belt (rubber)
Z axis screw transmission, 1 stepper, 2 screw transmissions, synchronized with GT2 closed loop belt at the top.
Power supply 24V, power 150W, 6.5A.
Base plate with heating MK3 220x220x3 12V 120W / base insulation / printing surface borosilicate glass,
MK3 hotbed thermistor 100k.
Print head MK8 direct extruder 1.75mm.
Printhead stepper: Nema 17 42BY45040-24D I = 1.5A
Extruder thermistor: NTC 3950 100k X, Y, Z
Steppers Nema 17 HS4401 I = 1.68A.
Control module MKS GEN V1.4, drivers TMC2209 V.1.2, Raspberry Octoprint, Klipper.
Desktop sensor LJ18A3-8-Z / BX-5V.
Construction of aluminum profiles 2020, 2040 + a wide range of fasteners.
------------------------------------
Software settings.
* Autocad / Fusion 360 -> 3D.stl * STL file fix -> Meshmixer (https://www.meshmixer.com/download.html)
* Slicing STL -> Gcode Cura.
* Raspberry Pi 3 Pi 3 cooling GPIO18 -> control pin through transistor.
   Configuration: add line to /boot/config.txt: dtoverlay = gpio-fan, gpio_pin = 18, temp = 55000 If the temp exceeds 55C - ON, 10C (55-10 = 45C) - OFF drops
* Octoprint Read: https://www.raspberrypi.org/blog/how-to-set-up-octoprint-on-your-raspberry-pi/
   The guide is simple and clear and I skip the installation description (on the SD card) - everything works.
   SSD is a good replacement for SD. -> write the image to the SSD and add a snippet to the file /boot/config.txt: program_usb_boot_mode = 1
* OctoKlipper pug-in, allows conf. file: printer.cfg to modify the Octoprint GUI.
* Klipper https://www.klipper3d.org Install https://www.klipper3d.org/Installation.html
   MKS GEN V1.4 (Atmega AVR, atmega2560, 16MHz)
* GCode https://marlinfw.org/docs/gcode/G002-G003.html
* MCU instruction manual: https://www.roboter-bausatz.de/media/pdf/0b/f0/a7/MKS-Gen-DataSheet.pdf
   MKS GEN V1.4 (Atmega AVR, atmega2560, 16MHz)
----------------------------------------------------------------
* Driver settings:
   Stepper Nema 17 HS4401, I= 1,68 A
   Stepper Nema 17 42BY45040-24D, I = 1,5 A
** Driver TMC2209 read: https://www.klipper3d.org/Config_Reference.html 
   https://mak3r.de/2020/04/03/stepper-driver-current-and-vref-calculator/ 
   Max run_current  1.2 A !!
   Klipper printer.cfg run_current: 0.95 (A)
** Driver DRV8825 settings:
   Stepper Nema 17 HS4401, I= 1,68 A
   VRF = (1,68/2) * 0,9 = 0,756 ~ 0,75 V
   Stepper Nema 17 42BY45040-24D, I = 1,5 A
   VRF = (1,5/2) * 0,9 = 0,675 ~ 0,67 V
* Clip extras: https://github.com/KevinOConnor/klipper/blob/9a92b346fd81386c54464b45d8310dab972b6bbd/config/example-extras.cfg#L1441
* Klipper macros: https://github.com/Desuuuu/klipper-macros
* Connection: https://github.com/KevinOConnor/klipper/issues/2828
* PID setting, Klipper, mackro
* Z-probe LJ18A3-8-Z / BX-5V -> 5V and 8mm response distance
* PETG cura settings see https://pupujuku.ddns.net/info/prindiklubi/petg-seadistus
* Detail cooling with 2 fans 4010 24V DC Fan 40x40x10mm Power consumption: 1.92W Current rating: 0.08A Noise: 24DBA
********************
Printer security solutions
********************
= Octoprint plugin Temperature Failsafe =
If the nozzle (280 C) or Bed (130 C) temp exceeds the set max. value:
  * Nozzle / Bed OFF
  * Stops printing
  * PI shell script starts: "gpio -g write 12 1" GPIO12 -> HIGH
     (... arduiono input vt = AC 220V = ...)
DIY optocoupler:
Raspberry: GPIO-R 1K-LED-GND
Arduino: VCC - LDR - analog PIN
                             - R 10K - GND
Arduino output see = AC 220V =

= AC 220V =
AC 220 input before power supplies: AC 220V fuse 3A
  * power supply 12V 180W / 220V / 0.8 = 1.02A
  * power supply 24V 150W / 220V / 0.8 = 0.85A
  * Sum 0.85 + 1.02 = 1.87 / 0.8 = 2.34A ~ 3A
Power supply AC-> DC 5V
Arduino nano <- MQ2 sensor
                    <- DS20B18 temperature sensor
                    <- Reset button
                    <- raspberry GPIO / Diy optocoupler
                    -> Buzzer
                    -> Red / Green LED
                    -> DC 5V- AC 220V relay (10A)
When energized:
* Output voltage 0V, Pause 30 sec (to stabilize MQ2) GreenLED ON, RedLED ON, Buzzer OFF
a. if MQ2 <150 and temp <50 Output 220V, GreenLED ON, RedLED OFF, Buzzer OFF
b. if MQ2> 150 or temp> 50 Output 0V, GreenLED OFF, RedLED ON, Buzzer ON // until the Reset button is pressed
* Reset When using the button, a new control and the corresponding scenario a. or b.


// 3D printer fire protect
// 13.06.2021

#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 2 // digi pin 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
int temp = 20;
int tempThres = 50;

int suits = 100;
int suitsThres = 150;

int ldrPin = A1; // raspberry input ldr
int ldrval=0;
int ldrThres = 300;

int redLed = 6;
int greenLed = 5;
int buzzer = 8;
int smokePin = A0;
int relay = 4;

bool f = false;

void setup() {
  sensors.begin();  // Start up the library
  pinMode(redLed, OUTPUT);
  pinMode(greenLed, OUTPUT);
  pinMode(buzzer, OUTPUT);
  pinMode(smokePin, INPUT);
  pinMode(ldrPin, INPUT);
  pinMode(relay, OUTPUT);
  Serial.begin(9600);
  Serial.println("GO");
  digitalWrite(redLed, HIGH);
  digitalWrite(greenLed, HIGH);
  digitalWrite(relay, HIGH);
  delay(10000); // oota 
  while (f == false){ 
    delay(1000);
    mq2_go(); 
  }
}

void mq2_go(){
  suits = analogRead(smokePin);
  delay(100);
  if (suits > suitsThres)
  {
    f = false;
  }
  else
  {
    f = true;
  }
}


void rpi() {
  ldrval = analogRead(ldrPin);
  delay(100);
  //Serial.print("ldrPin: ");
  //Serial.println(ldrval);
  if (ldrval > ldrThres)
  {
    alarm();
  }
  else
  {
    ok();
  }
}

void mq2x() {
  suits = analogRead(smokePin);
  delay(100);
  //Serial.print("Pin A0: ");
  //Serial.println(suits);
  if (suits > suitsThres)
  {
    alarm();
  }
  else
  {
    ok();
  }
}

void dallas() {
  sensors.requestTemperatures();
  delay(100);
  temp = sensors.getTempCByIndex(0);
  //Serial.print("Temperature: ");
  //Serial.print(temp);
  //Serial.println(" C");
  if (temp > tempThres)
  {
    alarm();
  }
  else
  {
    ok();
  }
}

void alarm() {
  digitalWrite(redLed, HIGH);
  digitalWrite(greenLed, LOW);
  digitalWrite(relay, HIGH);
  //Serial.println("Alarm");
  buttonWait(9);
  
}

void ok() {
  digitalWrite(redLed, LOW);
  digitalWrite(greenLed, HIGH);
  noTone(buzzer);
  //Serial.print("OK");
  digitalWrite(relay, LOW);
}

void buttonWait(int buttonPin){
  int buttonState = 0;
  while(1){
    tone(buzzer, 1000);
    buttonState = digitalRead(buttonPin);
    if (buttonState == HIGH) {
      return;
    }
  }
}

void loop() {
  dallas();
  delay(500);
  mq2x();
  delay(500);
  rpi();
  delay(500);
}​

Printeri Start Code:
CURA setting:
List of parameters: http://files.fieldofview.com/cura/Replacement_Patterns.html 
Start G-code

START_PRINT T_BED={material_bed_temperature_layer_0} T_EXTRUDER={material_print_temperature_layer_0}

End G-code

END_PRINT


Klipperi conf file printer.cfg
Uses only Cura temperature, other from Klipper macros:
Bed-Nozzle location offset edit last line: #*# z-offset = -0.3 (smaller: then the bed nozzle distance is smaller; larger: then the distance is large)

 

# This file contains common pin mappings for RAMPS (v1.3 and later)
# boards. RAMPS boards typically use a firmware compiled for the AVR
# atmega2560 (though other AVR chips are also possible).

# See docs/Config_Reference.md for a description of parameters.

[stepper_x]
step_pin: ar54
dir_pin: ar55
enable_pin: !ar38
microsteps: 64
rotation_distance: 40
endstop_pin: ^!ar3
#endstop_pin: ^ar2
position_endstop: 0
position_max: 200
homing_speed: 50

[tmc2209 stepper_x]
uart_pin: ar63
interpolate: True
run_current: 0.8
hold_current: 0.5
sense_resistor: 0.110
stealthchop_threshold: 60

[stepper_y]
step_pin: ar60
dir_pin: ar61
enable_pin: !ar56
microsteps: 64
rotation_distance: 40
endstop_pin: ^!ar14
#endstop_pin: ^ar15
position_endstop: 0
position_max: 200
homing_speed: 50

[tmc2209 stepper_y]
uart_pin: ar40
interpolate: True
run_current: 0.8
hold_current: 0.5
sense_resistor: 0.110
stealthchop_threshold: 60

[stepper_z]
step_pin: ar46
dir_pin: ar48
enable_pin: !ar62
microsteps: 64
rotation_distance: 8
endstop_pin: ^!ar18
#endstop_pin: ^ar19
position_endstop: 0
position_max: 191
#position_min: -1

[tmc2209 stepper_z]
uart_pin: ar42
interpolate: True
run_current: 0.90
hold_current: 0.5
sense_resistor: 0.110
stealthchop_threshold: 100

[probe]
pin: ^!ar19
x_offset: 5
y_offset: -45
#z_offset: 0.1


[bed_mesh]
speed: 150
horizontal_move_z: 5
mesh_min: 10,10
mesh_max: 190, 150
probe_count: 5,5

[extruder]
step_pin: ar26
dir_pin: ar28
enable_pin: !ar24
microsteps: 64
rotation_distance: 29.474
nozzle_diameter: 0.400
filament_diameter: 1.750
heater_pin: ar10
sensor_type: NTC 100K beta 3950
sensor_pin: analog13
#sensor_pin: ar67
control: pid
pid_Kp: 18.404
pid_Ki: 0.538
pid_Kd: 157.351
min_temp: 0
max_temp: 280
pressure_advance: 0.12
# pressure_advance: 0.15

[tmc2209 extruder]
uart_pin: ar44
interpolate: True
run_current: 0.7
hold_current: 0.4
sense_resistor: 0.110
stealthchop_threshold: 60

[heater_bed]
heater_pin: ar8
sensor_type: EPCOS 100K B57560G104F
sensor_pin: analog14
control = pid
pid_kp = 67.576
pid_ki = 0.994
pid_kd = 1147.945
min_temp: 0
max_temp: 130

[fan]
pin: ar7

[heater_fan my_nozzle_fan]
pin: ar9
heater: extruder
heater_temp: 50.0
fan_speed: 1.0

[mcu]
serial: /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A10JJR2O-if00-port0
pin_map: arduino
restart_method = command

[printer]
kinematics: cartesian
max_velocity: 300
max_accel: 3000
max_z_velocity: 10
max_z_accel: 50
square_corner_velocity: 1

[pause_resume]
recover_velocity: 50

###########################################################################
[gcode_macro M600]
default_parameter_X: 0
default_parameter_Y: 0
default_parameter_Z: 30
gcode:
    SAVE_GCODE_STATE NAME=M600_state
    PAUSE
    G91
    G1 E-.8 F2700
    G1 Z{Z}
    G90
    #G1 X{X} Y{Y} F3000
    G91
    #G1 E-50 F1000
    RESTORE_GCODE_STATE NAME=M600_state

#####################
[gcode_macro m205] ; hide M205 error
gcode:

#####################
[gcode_macro PREHEAT]
gcode:
	M140 S70 	; start bed temp.
	M190 S70 	; wait bed temp.
	M104 S240 	; set nozzle temp.
	M140 S80 	; start bed temp.
	M109 S240 	; wait nozzle temp.
	M190 S80 	; wait bed temp.
	{% if printer.toolhead.homed_axes != "xyz" %}
		G28
	{% endif %}
	G0 Z30		; Z = 20 mm
	
######################	
[gcode_macro POSITION]
gcode:
    M114

######################	
[gcode_macro CENTER_Z30]
gcode:
	{% if printer.toolhead.homed_axes != "xyz" %}
		G28
	{% endif %}
    G0 X100 Y100 Z30

[gcode_macro CENTER_Z0]
gcode:
	{% if printer.toolhead.homed_axes != "xyz" %}
		G28
	{% endif %}
    G0 X100 Y100 Z0
    
	
######################	
[gcode_macro HOME]
gcode:
    G28
    
[gcode_macro BED_CAL_AUTO]
gcode:
	{% if printer.toolhead.homed_axes != "xyz" %}
		G28
	{% endif %}
    BED_MESH_CALIBRATE METHOD=automatic
    
#####################################################
[gcode_macro START_PRINT T_BED T_EXTRUDER]
#variable_parameter_T_BED: 60
#variable_parameter_T_EXTRUDER: 190
gcode:
    G90 ; set to absolute positioning - this line was added in case Cura doesn't include it by default
    M82 ; set extruder to absolute mode - this line was added in case Cura doesn't include it by default (may not be needed)
    G28 ; home all axe
    # Move the nozzle near the bed
    G1 X15 Y20 Z5 F6000
    
    M117 Waiting for temperature
    # Start bed heating and continue
    M140 S{T_BED}
    {% if printer.heater_bed.temperature < params.T_BED|float*0.84 %}
        M190 S{params.T_BED|float*0.84} # wait till 0.85 of bed temp is reached, then continue  
    {% endif %}   
    M140 S{T_BED} 
    M109 S{T_EXTRUDER}
    M190 S{T_BED}
    
    ; The lines below are to prep the nozzle before a print begins
    G1 Z0.2 F1200 ; raise nozzle 0.2mm
    G92 E0 ; reset extrusion distance
    G1 Y1 ; move Y-Axis (bed) 1mm to prep for purge
    G1 X100 E12 F600 ; move X-carriage 100mm while purging 12mm of filament
    G92 E0 ; reset extrusion distance
    G1 F200 E3
    G92 E0
   
[gcode_macro END_PRINT]
gcode:    
    M104 S0
    M140 S0
    G92 E1
    G1 E-1 F300
    G28 X0 Y190
    M84    
 
 
[respond]
[pause_resume] 

#####################################################
#https://klipper.discourse.group/t/macro-creation-tutorial/30/2
#######################################################

[gcode_macro scan_start]
gcode:
	{% set x_s = 10 %} 		# set x startpoint
	{% set y_s = 50 %} 		# set y startpoint
	{% set z_s = 30 %} 		# set z startpoint
	{% if printer.toolhead.homed_axes != "xyz" %}
		G28
	{% endif %}
	G90 						#absolut pos
	G0 X{x_s} Y{y_s} Z{z_s}
	M400
	M118 INSERT OBJECT 		# Insert scanning object !	
    M118 Run macro SCAN_RUN 	# resume !
###############################################################
[gcode_macro scan_run]
gcode:
    {% set scan_max = 21 %} 	# set scan lenght
	{% set scan_step = 5 %} 	# set scan step lenght mm
	{% set r = scan_max // scan_step %} 	# set scan steps

    {% for x in range(0,r,1) %}
        RUN_SHELL_COMMAND CMD=ledon
	    G91
        G0 Y-{scan_step}
	    M400
        G4 P2000
        RUN_SHELL_COMMAND CMD=ledoff
        M400
    {% endfor %}  
##############################################################
[gcode_shell_command ledon]
command: node /home/pi/scripts/ledon.js
#timeout: 5.
#verbose: True
[gcode_shell_command ledoff]
command: python /home/pi/scripts/ledoff.py
timeout: 2.
verbose: True
##############################################################
######################	
[gcode_macro CENTER_lilscan]
gcode:
	{% if printer.toolhead.homed_axes != "xyz" %}
		G28
	{% endif %}
    G0 X32 Y80 Z140
################################################################

#*# <---------------------- SAVE_CONFIG ---------------------->
#*# DO NOT EDIT THIS BLOCK OR BELOW. The contents are auto-generated.
#*#
#*# [probe]
#*# z_offset = -0.35
#*#
#*# [bed_mesh default]
#*# version = 1
#*# points =
#*# 	  0.556875, 0.534375, 0.510625, 0.513750, 0.598750
#*# 	  0.450000, 0.455000, 0.451875, 0.453125, 0.463750
#*# 	  0.411875, 0.417500, 0.416875, 0.410625, 0.416875
#*# 	  0.403750, 0.413750, 0.414375, 0.404375, 0.401875
#*# 	  0.420625, 0.442500, 0.440000, 0.425000, 0.411875
#*# tension = 0.2
#*# min_x = 10.0
#*# algo = lagrange
#*# y_count = 5
#*# mesh_y_pps = 2
#*# min_y = 10.0
#*# x_count = 5
#*# max_y = 150.0
#*# mesh_x_pps = 2
#*# max_x = 190.0
​


RAMPS 1.4 pinmapping
// For RAMPS 1.4
#define X_STEP_PIN         54
#define X_DIR_PIN          55
#define X_ENABLE_PIN       38
#define X_MIN_PIN           3
#define X_MAX_PIN           2
#define Y_STEP_PIN         60
#define Y_DIR_PIN          61
#define Y_ENABLE_PIN       56
#define Y_MIN_PIN          14
#define Y_MAX_PIN          15
#define Z_STEP_PIN         46
#define Z_DIR_PIN          48
#define Z_ENABLE_PIN       62
#define Z_MIN_PIN          18
#define Z_MAX_PIN          19
#define E_STEP_PIN         26
#define E_DIR_PIN          28
#define E_ENABLE_PIN       24
#define SDPOWER            -1
#define SDSS               53
#define LED_PIN            13
#define FAN_PIN            9
#define PS_ON_PIN          12
#define KILL_PIN           -1
#define HEATER_0_PIN       10
#define HEATER_1_PIN       8
#define TEMP_0_PIN          13   // ANALOG NUMBERING
#define TEMP_1_PIN          14   // ANALOG NUMBERING

A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 A13 A14 A15
54 55 56 57 58 59 60 61 61 63 64  65  66  67  68  69 
​