# Artillery SideWinder X2

1. [Klipper Configuration](#klipper-configuration)
2. [Octoprint backup archive](#octoprint-backup-archive)
3. [Ultimaker Cura configuration](#ultimaker-cura-configuration)
4. [Octoprint specific configuration](#octoprint-specific-configuration)
5. [Filament set up](#filament-set-up)
6. [Klipper firmware update](#klipper-firmware-update) (Printer & ADXL345 accelorometer)
7. [OctoKlipper: Auto-reconnect printer after power on](#octoklipper-auto-reconnect-printer-after-power-on)
8. [Resources / Links](#resources--links)

# Octoprint backup archive

[2025-01-02] [ASWX2-backup-20250102.zip](octoprint-cfg-bkp/ASWX2-backup-20250102.zip)

# Klipper Configuration

* Klipper [installation](https://www.klipper3d.org/Installation.html) documentation
* Klipper [printer.cfg](klipper-cfg-files/printer.cfg) file
* Klipper [macros.cfg](klipper-cfg-files/macros.cfg) file

# Ultimaker Cura configuration

## Cura Printer configuration

| Printer | Extruder |
|---------|----------|
| ![printer profile](images/aswx2-cura-profile-printer.png) | ![extruder profile](images/aswx2-cura-profile-extruder.png) |

## Start G-code
```
; Octolapse Plugin required parameters
; Script based on an original created by tjjfvi (https://github.com/tjjfvi)
; An up-to-date version of the tjjfvi's original script can be found
; here:  https://csi.t6.fyi/
; Note - This script will only work in Cura V4.2 and above!
; --- Global Settings
; layer_height = {layer_height}
; smooth_spiralized_contours = {smooth_spiralized_contours}
; magic_mesh_surface_mode = {magic_mesh_surface_mode}
; machine_extruder_count = {machine_extruder_count}
; --- Single Extruder Settings
; speed_z_hop = {speed_z_hop}
; retraction_amount = {retraction_amount}
; retraction_hop = {retraction_hop}
; retraction_hop_enabled = {retraction_hop_enabled}
; retraction_enable = {retraction_enable}
; retraction_speed = {retraction_speed}
; retraction_retract_speed = {retraction_retract_speed}
; retraction_prime_speed = {retraction_prime_speed}
; speed_travel = {speed_travel}

START_PRINT BED_TEMP={material_bed_temperature_layer_0} EXTRUDER_TEMP={material_print_temperature_layer_0}
```

## End G-code
```
END_PRINT
```

## Print profiles

* [Standard Quality](cura-profile/ASWX2%20-%20Standard%20Quality.curaprofile)
* [Dynamic Quality](cura-profile/ASWX2%20-%20Dynamic%20Quality.curaprofile)
* [Low Quality](cura-profile/ASWX2%20-%20Low%20Quality.curaprofile)
* [Super Quality](cura-profile/ASWX2%20-%20Super%20Quality.curaprofile)

# Octoprint specific configuration
## Bed Visualizer plugin configuration
![Bed Visualizer plugin configuration](images/bed-visualizer-plugin-configuration.png)

```
G28
BED_MESH_CALIBRATE
@BEDLEVELVISUALIZER
BED_MESH_OUTPUT
```

# Filament set up
## PLA

| Brand     | Filament desc | Printing temp | Build Plate temp | Retractation Distance |
|-----------|---------------|---------------|------------------|-----------------------|
| Geeetech  | Black         | 200°C         | 60°C             | 0.75mm                |
| Geeetech  | White         | 200°C         | 60°C             | 0.75mm                |
| Geeetech  | Silk Silver   | 205°C         | 60°C             | 0.75mm                |

## PETG

| Brand     | Filament desc | Printing temp | Build Plate temp | Retractation Distance |
|-----------|---------------|---------------|------------------|-----------------------|
| Geeetech  | --            | --            | --               | --                    |

# Klipper firmware update
## Last update
Last update done: 2024-09-04 \
Installed version: commit 08a1c9f12760ee6d89db2b82e76c7d93453212db
## Printer
### Printer preparation
1. Power off the printer

2. Unplug the electrical wall socket

3. Unplug the USB cable labelled `OPERATION` from printer

4. Set the top switch to `UPDATE` position \
![Switch in `UPDATE` position](images/aswx2-switch-in-update-position.jpg)

5. Plug the USB cable labelled `UPDATE` to the printer


### Firmware build and update
1. Access Octopi using ssh
```
ssh aswx2
```

2. Stop Klipper service
```
sudo service klipper stop
```

3. Browse to Klipper directory:
```
cd ~/klipper
```

4. Pull the last version of the Klipper firmware from Github:
```
git pull
```

5. Clean up working directory before building firmware
```
make clean
```

6. Check the firmware build configuration 
```
make menuconfig
```
![Klipper firmaware build configuration](images/aswx2-klipper-firmware-config.png)

7. Build the firmaware:
```
make
```

8. Check printer's Ruby board is in DFU mode and can be updated 
```
lsusb
```
![Ruby board in DFU mode](images/aswx2-ruby-board-DFU-mode-USB.png)

9. Note the Ruby board device ID. In example above: `ID: 0483:df11`

10. Flash the new firmware to the printer's Ruby board using the above device ID:
```
make flash FLASH_DEVICE=0483:df11
```
![Klipper firmware flash outputs](images/aswx2-klipper-flash-output.png)

11. Restart Klipper service
```
sudo service klipper start
```

12. Check Klipper service is properly restarted
```
sudo service klipper status
```
![Klipper service status check](images/awsx2-klipper-service-started.png)

### Switch back printer to operation mode
1. Unplug the USB cable labelled `UPDATE` from printer

2. Set the top switch to `OPERATION` position \
![Switch in `OPERATION` position](images/aswx2-switch-in-operation-position.jpg)

3. Plug the USB cable labelled `OPERATION` to the printer

4. Plug the electrical wall socket

## ADXL345 accelorometer

### Software prereqiusites
Note that resonance measurements and shaper auto-calibration require additional software dependencies not installed by default. First, run on your Raspberry Pi the following commands:
```
sudo apt update
sudo apt install python3-numpy python3-matplotlib libatlas-base-dev libopenblas-base
```

Details on Klipper [documentation](https://www.klipper3d.org/Measuring_Resonances.html#software-installation)

### Firmware configuration and build
1. Configure the firmaware:
```
cd ~/klipper
make clean
make menuconfig
```
![ADXL345 Firmare config](images/aswx2-adxl345-firmware-config.png)

2. Build the firmware:
```
make
```

### Firmware flash
1. Set the ADXL345 board in DFU mode by plugin it to the USB cable while maintaining the switch down

2. Check that the board is actually in DFU mode
```
lsusb
```
![ADXL345 board in DFU mode](images/aswx2-adxl345-dfu-mode.png)

3. Flash the firmware
```
make flash FLASH_DEVICE=2e8a:0003
```

Once flashed, the board will automatically reboot and goes back in operation mode.

# OctoKlipper: Auto-reconnect printer after power-on
[Source](https://arnav.jain.se/2020/auto-restart-klipper-when-ender3-connected-to-pi/) by Arnav Jain.

Start off by accessing Octopi using ssh. \
Then  create the `98-klipper.rules` file in the /etc/udev/rules.d/ folder:
```
ssh aswx2
sudo touch /etc/udev/rules.d/98-klipper.rules
```

Retreive `idVendor` and `idProduct` for the Klipper MCU:
1. Retrieve Klipper MCU ID
```
lusb
```
![Find Klipper MCU ID](images/aswx2-find-mcu-id.png)

2. Retrieve `idVendor` and `idProduct` using the Klipper MCU ID
```
lsusb -v -d 1d50:614e | grep id
```
![idVendor and idProduct](images/aswx2-klipper-mcu-idvendor-idproduct.png)

Then add the following text into the `98-klipper.rules` file just created:

1. Edit the `98-klipper.rules` file
```
sudo nano /etc/udev/rules.d/98-klipper.rules
```

2. Add text (remove the `0x` at the begining of the IDs)
```
## rule to restart klipper when the printer is connected via usb
SUBSYSTEM=="usb", ATTRS{idVendor}=="1d50", ATTRS{idProduct}=="614e", ACTION=="add", RUN+="/usr/bin/sudo -u pi /bin/sh -c '/bin/echo RESTART > /tmp/printer'"
```

Finally, re-load the udev rules:
```
sudo udevadm control --reload-rules
```

# Resources / Links

* [Runout sensor bracket SIDEWINDER X2 by LeLudoLAb - Thingiverse](https://www.thingiverse.com/thing:5027268)
* [Schéma pinout Artillery Ruby v1.2 (Genius Pro, Sidewinder X2, Hornet)](ruby-board-pinout-schema.md)
* [How to install Klipper on ASWX2 - List of links (Shaarli)](https://shaarli.igox.org/shaare/y5m3Bg)
* [[SW X2] Renforts axe Z - Tutoriels et améliorations pour Artillery - Forum pour les imprimantes 3D et l'impression 3D](https://www.lesimprimantes3d.fr/forum/topic/44553-sw-x2-renforts-axe-z/)
* [[Tuto] Remplacer 3DTouch Artillery par un vrai BLTouch - Tutoriels et améliorations pour Artillery - Forum pour les imprimantes 3D et l'impression 3D](https://www.lesimprimantes3d.fr/forum/topic/46506-tuto-remplacer-3dtouch-artillery-par-un-vrai-bltouch/#comment-484959)
* [Améliorations Sidewinder à imprimer](https://www.abrège.fr/post/ameliorations-sidewinder-x2-a-imprimer)
* [Aide et ressources en français pour imprimantes 3D Artillery](https://docarti.fr/)