Skip to content

Commit

Permalink
update to latest Klipper3d/klipper (2f6e94c) (#216)
Browse files Browse the repository at this point in the history
* stm32: fix support for USARTs on STM32G0B0

Signed-off-by: Robert Cambridge <[email protected]>

* makefile: Replace CFLAGS -I with -iquote

The -iquote tells GCC to only search that path when resolving a quoted
"include" (vs <angle brackets>) which by convention imples a include from
the projects own soruce tree. This prevents a conflict between Klippers
"sched.h" and "gpio.h" and <linux/gpio.h> and glibc <sched.h>.

Signed-off-by: Michael 'ASAP' Weinrich <[email protected]>

* linux: Don't use absolute paths for include

Not all systems (i.e. Nix) repect the standard Linux filesystem hierarchy,
instead relative paths should be used and allowing GCC to rely on it's
builtin search paths.

Signed-off-by: Michael 'ASAP' Weinrich <[email protected]>

* manual_stepper: Add basic status. (#6527)

Adding position and enabled in manual_stepper status. Enabled is already available through stepper_enable object. But this makes it more straightforward to access it.

Signed-off-by: Viesturs Zarins <[email protected]>

* klippy: remove a few unused variable assignments (#6504)

Signed-off-by: Kamil Domański <[email protected]>

* mcu: Separate trdispatch handling from MCU_endstop class

Create a new TriggerDispatch class to track the low-level handling of
the trdispatch mechanism.

Signed-off-by: Kevin O'Connor <[email protected]>

* probe: Add a probing_move() wrapper to low-level mcu_probe class

This allows the low-level probe class more control on the probing
implementation.

Signed-off-by: Kevin O'Connor <[email protected]>

* sensor_ldc1612: Initial support for bulk reading ldc1612 sensor

Signed-off-by: Alan.Ma from BigTreeTech <[email protected]>
Signed-off-by: Kevin O'Connor <[email protected]>

* ldc1612: Initial host support for reading ldc1612 bulk sensor data

Signed-off-by: Kevin O'Connor <[email protected]>

* ldc1612: Add LDC_CALIBRATE_DRIVE_CURRENT calibration command

Add a command to calibrate the sensor DRIVE_CURRENT0 register.

Signed-off-by: Kevin O'Connor <[email protected]>

* probe_eddy_current: Support calibrating Z height to sensor frequency

Add a calibration tool that can be used to correlate sensor frequency
to bed Z height.

Signed-off-by: Kevin O'Connor <[email protected]>

* probe_eddy_current: Initial support for PROBE command

Signed-off-by: Kevin O'Connor <[email protected]>

* probe_eddy_current: Use sensor value at halt position for "trigger" position

Calculate the sensor Z position after the probe halts and return that
as the "probed position".  This sensor position provides a more
accurate measurement.

Signed-off-by: Kevin O'Connor <[email protected]>

* docs: Add documentation for probe_eddy_current

Signed-off-by: Kevin O'Connor <[email protected]>

* docs: Add a new Eddy_Probe.md document

Signed-off-by: Kevin O'Connor <[email protected]>

* motan: Add support for graphing ldc1612 coil frequencies

Signed-off-by: Kevin O'Connor <[email protected]>

* manual_stepper: Revert "manual_stepper: Add basic status. (#6527)"

This reverts commit b029d04.

The MCU_Stepper class does not have a is_motor_enabled() method, so
the change above results in an internal exception.

Signed-off-by: Kevin O'Connor <[email protected]>

* homing_override: Adds rawparams support

Signed-off-by: Pedro Lamas <[email protected]>

* docs: Fix typo in Resonance_Compensation.md

Signed-off-by: Plynskiy Nikita <[email protected]>

* config: Artillery Sidewinder X3 (#6534)

Signed-off-by: Phil Timpson <[email protected]>

* virtual_sdcard: Define a default for on_gcode_error

If on_gcode_error is not specified, default to running the
TURN_OFF_HEATERS command.

Signed-off-by: Kevin O'Connor <[email protected]>

* docs: Recommend using "ip" instead of "ifconfig" in CANBUS.md

Some Linux systems do not install ifconfig, while ip should always be
available.  So, update the canbus documentation to recommend that.

Signed-off-by: Kevin O'Connor <[email protected]>

* docs: Add information on txqueuelen to CANBUS_Troubleshooting.md

Provide some background information on the Linux can interface
txqueuelen parameter, errors that it can cause, and considerations
when configuring it.

Signed-off-by: Kevin O'Connor <[email protected]>

* adxl345: Move sample timestamp calculation to reusable code

Add a new extract_samples() method to the ChipClockUpdater class that
calculates the sample timestamp for each sample in a list of bulk
sensor reports.

Update the adxl345 code to use that extract_samples() code.

Signed-off-by: Kevin O'Connor <[email protected]>

* lis2dw: Use extract_samples() for sample timestamp calculation

Signed-off-by: Kevin O'Connor <[email protected]>

* mpu9250: Use extract_samples() for sample timestamp calculation

Signed-off-by: Kevin O'Connor <[email protected]>

* ldc1612: Use extract_samples() for sample timestamp calculation

Signed-off-by: Kevin O'Connor <[email protected]>

* bulk_sensor: Refactor ChipClockUpdater constructor

Build the clock_sync and struct.Struct() in the ChipClockUpdater
constructor.

Signed-off-by: Kevin O'Connor <[email protected]>

* bulk_sensor: Rework ChipClockUpdater class into FixedFreqReader

Move the sensor_bulk_data message queuing into the class, and then
rename that class.  This simplifies the users of the code.

Signed-off-by: Kevin O'Connor <[email protected]>

* bulk_sensor: Rename BulkDataQueue methods

Rename pull_samples() to pull_queue() and rename clear_sample() to
clear_queue().  This avoids confusion between the queue of response
messages and the larger list of samples stored within those messages.

Signed-off-by: Kevin O'Connor <[email protected]>

* docs: Update CANBUS_Troubleshooting.md to avoid formatting error

Avoid starting a line with "128." as that confused markdown.

Signed-off-by: Kevin O'Connor <[email protected]>

* sht3x: Add sht31 support (#6560)

Signed-off-by: Timofey Titovets <[email protected]>

* docs: Fix typo in Bed_Mesh.md (#6572)

Signed-off-by: Maggi Alessandro <[email protected]>

* format

---------

Signed-off-by: Robert Cambridge <[email protected]>
Signed-off-by: Michael 'ASAP' Weinrich <[email protected]>
Signed-off-by: Viesturs Zarins <[email protected]>
Signed-off-by: Kamil Domański <[email protected]>
Signed-off-by: Kevin O'Connor <[email protected]>
Signed-off-by: Alan.Ma from BigTreeTech <[email protected]>
Signed-off-by: Pedro Lamas <[email protected]>
Signed-off-by: Plynskiy Nikita <[email protected]>
Signed-off-by: Phil Timpson <[email protected]>
Signed-off-by: Timofey Titovets <[email protected]>
Signed-off-by: Maggi Alessandro <[email protected]>
Co-authored-by: Robert Cambridge <[email protected]>
Co-authored-by: Michael 'ASAP' Weinrich <[email protected]>
Co-authored-by: Viesturs Zariņš <[email protected]>
Co-authored-by: Kamil Domański <[email protected]>
Co-authored-by: Kevin O'Connor <[email protected]>
Co-authored-by: Pedro Lamas <[email protected]>
Co-authored-by: trofen <[email protected]>
Co-authored-by: TheFeralEngineer <[email protected]>
Co-authored-by: Timofey Titovets <[email protected]>
Co-authored-by: Alessandro Maggi <[email protected]>
  • Loading branch information
11 people authored Apr 23, 2024
1 parent ca37123 commit b97b4bd
Show file tree
Hide file tree
Showing 47 changed files with 1,738 additions and 271 deletions.
1 change: 0 additions & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ _Enter a good description of whats being changed and WHY
- [ ] added a test case if possible
- [ ] if new feature, added to the readme
- [ ] ci is happy and green

5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ dirs-y = src
cc-option=$(shell if test -z "`$(1) $(2) -S -o /dev/null -xc /dev/null 2>&1`" \
; then echo "$(2)"; else echo "$(3)"; fi ;)

CFLAGS := -I$(OUT) -Isrc -I$(OUT)board-generic/ -std=gnu11 -O2 -MD \
-Wall -Wold-style-definition $(call cc-option,$(CC),-Wtype-limits,) \
CFLAGS := -iquote $(OUT) -iquote src -iquote $(OUT)board-generic/ \
-std=gnu11 -O2 -MD -Wall \
-Wold-style-definition $(call cc-option,$(CC),-Wtype-limits,) \
-ffunction-sections -fdata-sections -fno-delete-null-pointer-checks
CFLAGS += -flto=auto -fwhole-program -fno-use-linker-plugin -ggdb3

Expand Down
188 changes: 188 additions & 0 deletions config/printer-artillery-sidewinder-x3-plus-2024.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
# For the Artillery Sidewinder X3 Pro/Plus that came factory installed with V1.29 firmware, follow these steps.
# - Compile with the processor model STM32F401.
# - Select the 48KiB bootloader,
# - Select USB PA11/PA12 for USB communication interface.
# - Select USART2 PA3/PA2 for UART communication via the Wi-Fi Tx/Rx pins
# To set 48KiB bootloader, you need to make a change to make menuconfig Kconfig file
# Here is a link to a how-to video: https://youtu.be/dpc76zN7Dh0
# Rename klipper.bin to yuntu.bin
# Copy the file out/yuntu.bin to an SD card and then restart the printer with that SD card
#
# For models that did not come with V1.29 installed
# - Compile with the processor model STM32F401.
# - Select the NO BOOTLOADER
# - Select USB PA11/PA12 for USB communication interface.
# - Select USART2 PA3/PA2 for UART communication via the Wi-Fi Tx/Rx pins
# - quit, save, make
# - Connect your printer to a computer running Pronterface, Octoprint, Repetier, BedLeveler5000 (anything with Console capability)
# - Power on the machine and send M997 through console into Marlin, this will put the board into "DFU" mode
# - DO NOT TURN OFF THE PRINTER
# - Connect your Linux/Klipper device to the USB port
# - Run lsusb and verify that the STM32 DFU device is visible (Bus 001 Device 006: ID 0483:df11 STMicroelectronics STM Device in DFU Mode)
# - Run sudo make flash 0483:df11
# - Run lsusb again and there should be two devices:
# Bus 001 Device 007: ID 1d50:614e OpenMoko, Inc. stm32f401xc
# Bus 001 Device 003: ID 0cf3:e010 Qualcomm Atheros Communications stm32f401xc
# See docs/Config_Reference.md for a description of parameters.

[mcu]
serial: /dev/ttyACM0
restart_method: command

[printer]
kinematics: cartesian
max_velocity: 300
max_accel: 3000
max_z_velocity: 15
max_z_accel: 100
square_corner_velocity: 5

[led LED_Light]
white_pin: PC2
initial_white: 1.0

[neopixel hotend_neopixel]
pin: PD2
color_order: GRB
initial_RED: 1.0
initial_GREEN: 1.0
initial_BLUE: 1.0

[stepper_x]
step_pin: PA8
dir_pin: PC9
enable_pin: !PA15
microsteps: 16
rotation_distance: 40
endstop_pin: !PB9
position_min: 0
position_endstop: 0
position_max: 315
homing_speed: 50

[stepper_y]
step_pin: PC7
dir_pin: !PC6
enable_pin: !PC8
microsteps: 16
rotation_distance: 40
endstop_pin: !PB8
position_endstop: 0
position_max: 315
homing_speed: 50

[stepper_z]
step_pin: PB10
dir_pin: !PA4
enable_pin: !PC4
rotation_distance: 8
microsteps: 16
position_min: -1
position_max: 400
endstop_pin: probe:z_virtual_endstop # Use Z- as endstop
#homing_speed: 10.0

[extruder]
max_extrude_only_distance: 100.0
step_pin: PC11
dir_pin: !PC10
enable_pin: !PC12
microsteps: 64
nozzle_diameter: 0.400
filament_diameter: 1.750
heater_pin: PA6
sensor_type: EPCOS 100K B57560G104F #Generic 3950
sensor_pin: PC5
min_extrude_temp: 170
min_temp: 0
max_temp: 300
# Calibrate E-Steps https://www.klipper3d.org/Rotation_Distance.html#calibrating-rotation_distance-on-extruders
rotation_distance: 17.75
# Calibrate PID: https://www.klipper3d.org/Config_checks.html#calibrate-pid-settings
# - Example: PID_CALIBRATE HEATER=extruder TARGET=200
control: pid
pid_kp: 30.356
pid_ki: 1.857
pid_kd: 124.081
# Calibrate PA: https://www.klipper3d.org/Pressure_Advance.html

[heater_bed]
heater_pin: PA7
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PC0
max_temp: 100
min_temp: 0
# Calibrate PID: https://www.klipper3d.org/Config_checks.html#calibrate-pid-settings
# - Example: PID_CALIBRATE HEATER=heater_bed TARGET=60
control: pid
pid_kp: 64.230
pid_ki: 0.723
pid_kd: 1425.905

[heater_fan hotend_fan]
pin: PB1
heater: extruder
heater_temp: 50.0

[fan]
pin: PB0

[temperature_fan Artillery_MCU]
sensor_type: temperature_mcu
pin: PA5
max_temp: 60.0
target_temp: 40.0
min_temp: 0
shutdown_speed: 0.0
kick_start_time: 0.5
off_below: 0.19
max_speed: 1.0
min_speed: 0.0
control: watermark

[filament_switch_sensor filament_sensor]
pause_on_runout: true
switch_pin: PC1

[probe]
pin: PC14
x_offset:45.2
y_offset:11.6
speed:5
lift_speed:15
z_offset: 2.350

[safe_z_home]
home_xy_position: 110, 145 # X, Y coordinate (e.g. 100, 100) where the Z homing should be
speed: 300.0
z_hop: 10
z_hop_speed: 15.0

[bed_mesh]
speed: 300
horizontal_move_z: 6
mesh_min: 46,15
mesh_max: 300,300
probe_count: 10, 10
fade_start: 1.0
fade_end: 0.0
algorithm: bicubic

[screws_tilt_adjust]
screw1: 120, 153
screw1_name: center reference
screw2: 7, 45
screw2_name: front left
screw3: 210, 45
screw3_name: front right
screw4: 227, 145
screw4_name: right center
screw5: 210, 245
screw5_name: rear right
screw6: 7, 245
screw6_name: rear left
screw7: 7, 145
screw7_name: left center
horizontal_move_z: 8
speed: 300
screw_thread: CW-M4
7 changes: 3 additions & 4 deletions docs/Bed_Mesh.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,9 @@ probe_count: 5, 3

- `mesh_max: 240, 198`\
_Required_\
The probed coordinate farthest farthest from the origin. This is not
necessarily the last point probed, as the probing process occurs in a
zig-zag fashion. As with `mesh_min`, this coordinate is relative to
the probe's location.
The probed coordinate farthest from the origin. This is not necessarily
the last point probed, as the probing process occurs in a zig-zag fashion.
As with `mesh_min`, this coordinate is relative to the probe's location.

- `probe_count: 5, 3`\
_Default Value: 3, 3_\
Expand Down
4 changes: 2 additions & 2 deletions docs/CANBUS.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ adapter. This is typically done by creating a new file named
allow-hotplug can0
iface can0 can static
bitrate 1000000
up ifconfig $IFACE txqueuelen 128
up ip link set $IFACE txqueuelen 128
```

## Terminating Resistors
Expand Down Expand Up @@ -113,7 +113,7 @@ Some important notes when using this mode:
allow-hotplug can0
iface can0 can static
bitrate 1000000
up ifconfig $IFACE txqueuelen 128
up ip link set $IFACE txqueuelen 128
```

* The "bridge mcu" is not actually on the CAN bus. Messages to and
Expand Down
50 changes: 50 additions & 0 deletions docs/CANBUS_Troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,56 @@ Reordered messages is a severe problem that must be fixed. It will
result in unstable behavior and can lead to confusing errors at any
part of a print.

## Use an appropriate txqueuelen setting

The Klipper code uses the Linux kernel to manage CAN bus traffic. By
default, the kernel will only queue 10 CAN transmit packets. It is
recommended to [configure the can0 device](CANBUS.md#host-hardware)
with a `txqueuelen 128` to increase that size.

If Klipper transmits a packet and Linux has filled all of its transmit
queue space then Linux will drop that packet and messages like the
following will appear in the Klipper log:
```
Got error -1 in can write: (105)No buffer space available
```
Klipper will automatically retransmit the lost messages as part of its
normal application level message retransmit system. Thus, this log
message is a warning and it does not indicate an unrecoverable error.

If a complete CAN bus failure occurs (such as a CAN wire break) then
Linux will not be able to transmit any messages on the CAN bus and it
is common to find the above message in the Klipper log. In this case,
the log message is a symptom of a larger problem (the inability to
transmit any messages) and is not directly related to Linux
`txqueuelen`.

One may check the current queue size by running the Linux command `ip
link show can0`. It should report a bunch of text including the
snippet `qlen 128`. If one sees something like `qlen 10` then it
indicates the CAN device has not been properly configured.

It is not recommended to use a `txqueuelen` significantly larger
than 128. A CAN bus running at a frequency of 1000000 will typically
take around 120us to transmit a CAN packet. Thus a queue of 128
packets is likely to take around 15-20ms to drain. A substantially
larger queue could cause excessive spikes in message round-trip-time
which could lead to unrecoverable errors. Said another way, Klipper's
application retransmit system is more robust if it does not have to
wait for Linux to drain an excessively large queue of possibly stale
data. This is analogous to the problem of
[bufferbloat](https://en.wikipedia.org/wiki/Bufferbloat) on internet
routers.

Under normal circumstances Klipper may utilize ~25 queue slots per
MCU - typically only utilizing more slots during retransmits.
(Specifically, the Klipper host may transmit up to 192 bytes to each
Klipper MCU before receiving an acknowledgment from that MCU.) If a
single CAN bus has 5 or more Klipper MCUs on it, then it might be
necessary to increase the `txqueuelen` above the recommended value
of 128. However, as above, care should be taken when selecting a new
value to avoid excessive round-trip-time latency.

## Obtaining candump logs

The CAN bus messages sent to and from the micro-controller are handled
Expand Down
6 changes: 6 additions & 0 deletions docs/Config_Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ All dates in this document are approximate.

## Changes

20240415: The `on_error_gcode` parameter in the `[virtual_sdcard]`
config section now has a default. If this parameter is not specified
it now defaults to `TURN_OFF_HEATERS`. If the previous behavior is
desired (take no default action on an error during a virtual_sdcard
print) then define `on_error_gcode` with an empty value.

20240313: The `max_accel_to_decel` parameter in the `[printer]` config
section has been deprecated. The `ACCEL_TO_DECEL` parameter of the
`SET_VELOCITY_LIMIT` command has been deprecated. The
Expand Down
Loading

0 comments on commit b97b4bd

Please sign in to comment.