├── .gitattributes ├── README.md └── images ├── drawbot.png └── drawbot.xcf /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Klipper + DrawBot 2 | Note: I played enough with my drawing robot and disassembled it so I won't update this repository in case if something breaks in newer klipper versions. 3 | 4 | ## Related links 5 | 6 | [DrawBot on Thingiverse](https://www.thingiverse.com/thing:2349232) 7 | 8 | [Klipper firmware](https://www.klipper3d.org/) 9 | 10 | [KIAUH - Klipper install helper](https://github.com/th33xitus/kiauh) 11 | 12 | ## Why to use Klipper instead of GRBL? 13 | 1. I had connection problems with GRBL: sometimes commands or 'OK' responses were lost wholly or partially, especially when moving servo frequently. Although my Arduino Uno, servo and steppers had separate power supplies with connected grounds, and baud rate was set to 9600, that issue happened sometimes. Klipper is less demanding on connection quality because it can retransmit lost messages. 14 | 2. Klipper can run on a wider range of boards than GRBL, especially on the boards with TMC2209, although such boards may be too expensive for a $100 self-made drawing robot. 15 | 3. Because you can. 16 | 17 | ## Requirements 18 | You need a Linux computer that will act as a Klipper host. Usually Raspberry Pi is used for that purpose. 19 | 20 | ## Installing Klipper on a host 21 | The most easy way is to install via [KIAUH](https://github.com/th33xitus/kiauh). 22 | First, install Klipper, then Moonraker (HTTP API for Klipper), then fluidd (web interface for klipper that uses Moonraker). 23 | As a result you should open fluidd interface in a web browser that connects successfully to Moonraker. You will be able to edit `printer.cfg` from a web interface. 24 | 25 | Probably later there will be more detailed guide on that topic, but now use Google and read the manual if you encounter any problems. 26 | 27 | ## Building and flashing firmware 28 | Steps to build firmware if you are using KIAUH: 29 | 1. [Advanced] 30 | 2. [Build + Flash] 31 | 3. Configure: 32 | ``` 33 | Enable extra low level configuration options 34 | MCU Architecture: Atmega AVR 35 | Processor model: atmega328p 36 | Processor speed: 16 MHz 37 | Baud rate for serial port: 250000 38 | ``` 39 | 4. Build and flash 40 | 41 | ## Sample `printer.cfg` 42 | 43 | ### Description 44 | 45 | This sample is intended to be used on Arduino UNO with a CNC Shield V3. 46 | Klipper requires to use microcontroller pin names (like PB3) instead of Arduino ones (like D11). 47 | See [Arduino UNO Pinout](https://www.circuito.io/blog/arduino-uno-pinout/) and [CNC Shield V3 Pinout](https://wiki.keyestudio.com/File:KS0160_%E5%BC%95%E8%84%9A%E5%9B%BE.jpg) for reference. 48 | SG90 servo and NC endstops are used. 49 | 50 | ![alt text](images/drawbot.png "Title") 51 | 52 | **Although I use exactly the same configuraion, this sample is provided as is, without any warranty. I am not responsible for any possible damage. Remember, that incorrect output pin names may cause short-circuit and burn your mcu.** 53 | 54 | ### 55 | ```yaml 56 | [mcu] 57 | # You may need to change this. 58 | serial: /dev/serial/by-id/usb-1a86_USB_Serial-if00-port0 59 | # Has to be the same as in firmware 60 | baud: 250000 61 | 62 | [virtual_sdcard] 63 | path: ~/gcode_files 64 | 65 | [printer] 66 | kinematics: corexy 67 | # Current values are quite slow, you may try to find values that are the best for your drawbot 68 | # Units: mm/s and mm/s^2 69 | max_velocity: 10 70 | max_accel: 300 71 | 72 | [stepper_x] 73 | step_pin: PD2 74 | dir_pin: PD5 75 | enable_pin: !PB0 76 | microsteps: 16 77 | rotation_distance: 32 78 | # endstop_pin is required even if you don't use endstops. 79 | # Add ! after ^ if your use NO endstops instead of NC. 80 | endstop_pin: ^PB1 81 | position_endstop: 0 82 | position_max: 360 83 | homing_speed: 50 84 | 85 | [stepper_y] 86 | step_pin: PD3 87 | dir_pin: PD6 88 | enable_pin: !PB0 89 | microsteps: 16 90 | rotation_distance: 32 91 | # endstop_pin is required even if you don't use endstops. 92 | # Add ! after ^ if your use NO endstops instead of NC. 93 | endstop_pin: ^PB2 94 | # No need to set home direction manually: Klipper understands correct direction by seeing that position_endstop = position_max 95 | position_endstop: 220 96 | position_max: 220 97 | homing_speed: 50 98 | 99 | # Klipper requires stepper_z to be present 100 | [stepper_z] 101 | step_pin: PD4 102 | dir_pin: PD7 103 | enable_pin: !PB0 104 | microsteps: 16 105 | rotation_distance: 32 106 | # Warning: this is SpnEn on a CNC Shield V3. We must provide some value and we can't use correct PB3 here because Z+ pin has hardware PWM and is used to control a servo. Make sure your don't use PB4. 107 | endstop_pin: ^PB4 108 | position_endstop: 0 109 | position_max: 200 110 | homing_speed: 50 111 | 112 | # For the SG90 servo 113 | [servo pen] 114 | pin: PB3 115 | maximum_servo_angle: 180 116 | minimum_pulse_width: 0.001 117 | maximum_pulse_width: 0.002 118 | initial_angle: 0 119 | 120 | [gcode_macro PEN_UP] 121 | gcode: 122 | SET_SERVO SERVO=pen ANGLE=60 123 | 124 | [gcode_macro PEN_DOWN] 125 | gcode: 126 | SET_SERVO SERVO=pen ANGLE=0 127 | 128 | # Add support for G2 and G3 commands 129 | [gcode_arcs] 130 | resolution: 1.0 131 | 132 | [display_status] 133 | 134 | [pause_resume] 135 | 136 | # Cancelling drawing works without this macro, but fluidd will complain 137 | [gcode_macro CANCEL_PRINT] 138 | rename_existing: BASE_CANCEL_PRINT 139 | gcode: 140 | BASE_CANCEL_PRINT 141 | 142 | # Uncomment the following lines if you don't have endstops. 143 | # In that case homing will do nothing but reset position to (0, 0) 144 | # [homing_override] 145 | # set_position_x: 0 146 | # set_position_y: 0 147 | # set_position_z: 0 148 | # gcode: 149 | ``` 150 | 151 | ## Troubleshooting 152 | 1. Moves are performed in the wrong direction 153 | 154 | Use may try to invert dir_pin of stepper_x or stepper_y by prepending `!` before the value. 155 | 2. Moves are still performed in the wrong direction. One axis moves correctly, but another one is inverted. 156 | 157 | Reconnect X stepper to Y driver and vice versa. 158 | 159 | ## Software 160 | I suggest using [LaserWeb4](https://github.com/LaserWeb/LaserWeb4-Binaries/) for gcode generation. 161 | 162 | ### LaserWeb4 configuration 163 | Machine: 164 | - MACHINE WIDTH: 360mm 165 | - MACHINE HEIGHT: 220mm 166 | - SHOW MACHINE: enabled 167 | - TOOL HEAD -> BEAM: depends on a sharpness of your pen/pencil 168 | 169 | GCODE: 170 | - GCODE GENERATOR: Marlin 171 | - START GCODE 172 | ``` 173 | PEN_UP 174 | G28 X Y ; Home X and Y 175 | G21 ; Set units to mm 176 | G90 ; Absolute positioning 177 | ``` 178 | - END GCODE 179 | ``` 180 | PEN_DOWN ; don't burden a servo 181 | ``` 182 | - TOOL ON 183 | ``` 184 | PEN_DOWN 185 | ``` 186 | - TOOL OFF 187 | ``` 188 | PEN_UP 189 | ``` 190 | - LASER INTENSITY. `=` after `S` is important, otherwise Klipper doesn't understand macro call. Note that S parameter of PEN_DOWN is ignored, but it is impossible to instruct LaserWeb4 not to generate this parameter. 191 | ``` 192 | S= 193 | ``` 194 | - LASER INTENSITY SEPARATE LINE: disabled 195 | -------------------------------------------------------------------------------- /images/drawbot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gwisp2/klipper-drawbot/df23053f65ca751eed5e7e9af6c81e513fc973f9/images/drawbot.png -------------------------------------------------------------------------------- /images/drawbot.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gwisp2/klipper-drawbot/df23053f65ca751eed5e7e9af6c81e513fc973f9/images/drawbot.xcf --------------------------------------------------------------------------------