Merge remote-tracking branch 'upstream/master' into dgus-display

This commit is contained in:
Desuuuu 2022-05-22 18:04:09 +02:00
commit 0b8d84d5d4
No known key found for this signature in database
GPG Key ID: 85943F4B2C2CE0DC
337 changed files with 88248 additions and 3263 deletions

View File

@ -8,9 +8,8 @@ jobs:
if: github.repository == 'Klipper3d/klipper'
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v3
- uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
if (context.payload.label.name != "not on github")
return;
@ -36,7 +35,7 @@ jobs:
+ "~ Your friendly GitIssueBot"
+ "\n\n"
+ "PS: I'm just an automated script, not a human being.";
github.issues.createComment({
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,

View File

@ -1,5 +1,7 @@
name: klipper3d deploy
on:
schedule:
- cron: "0 0 * * *"
push:
branches:
- master
@ -24,6 +26,10 @@ jobs:
${{ runner.os }}-pip-
- name: Install dependencies
run: pip install -r docs/_klipper3d/mkdocs-requirements.txt
- name: Build and deploy klipper3d
run: |
mkdocs gh-deploy --config-file docs/_klipper3d/mkdocs.yml --remote-branch gh-pages --force --verbose
- name: Build MkDocs Pages
run: docs/_klipper3d/build-translations.sh
- name: Deploy
uses: JamesIves/github-pages-deploy-action@v4.2.5
with:
branch: gh-pages # The branch the action should deploy to.
folder: site # The folder the action should deploy.

View File

@ -0,0 +1,66 @@
# Add a comment to github PRs marked with the "reviewer needed" label
name: "Add comment to PRs marked 'reviewer needed'"
on:
pull_request_target:
types: [labeled]
jobs:
add_comment:
if: github.repository == 'Klipper3d/klipper'
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
with:
script: |
if (context.payload.label.name != "reviewer needed")
return;
if (context.payload.pull_request.assignees.length > 0)
return;
msg = "Thank you for your contribution to Klipper."
+ " Unfortunately, a reviewer has not assigned themselves to"
+ " this GitHub Pull Request. All Pull Requests are reviewed"
+ " before merging, and a reviewer will need to volunteer."
+ " Further information is available at:"
+ " https://www.klipper3d.org/CONTRIBUTING.html"
+ "\n\n"
+ "There are some steps that you can take now:"
+ "\n"
+ "1. Perform a self-review of your Pull Request by following"
+ " the steps at:"
+ " https://www.klipper3d.org/CONTRIBUTING.html#what-to-expect-in-a-review"
+ "\n"
+ " If you have completed a self-review, be sure to state the"
+ " results of that self-review explicitly in the Pull Request"
+ " comments. A reviewer is more likely to participate if the"
+ " bulk of a review has already been completed."
+ "\n"
+ "2. Consider opening a topic on the [Klipper Discourse]"
+ "(https://www.klipper3d.org/Contact.html#community-forum)"
+ " server to discuss this work. The Discourse server is a good"
+ " place to discuss development ideas and to engage users"
+ " interested in testing. Reviewers are more likely to"
+ " prioritize Pull Requests with an active community of users."
+ "\n"
+ "3. Consider helping out reviewers by reviewing other Klipper"
+ " Pull Requests. Taking the time to perform a careful and"
+ " detailed review of others work is appreciated. Regular"
+ " contributors are more likely to prioritize the"
+ " contributions of other regular contributors."
+ "\n\n"
+ "Unfortunately, if a reviewer does not assign themselves to"
+ " this GitHub Pull Request then it will be automatically"
+ " closed. If this happens, then it is a good idea to move"
+ " further discussion to the [Klipper Discourse]"
+ "(https://www.klipper3d.org/Contact.html#community-forum)"
+ " server. Reviewers can reach out on that forum to let you"
+ " know if they are interested and when they are available."
+ "\n\n"
+ "Best regards,\n"
+ "~ Your friendly GitIssueBot"
+ "\n\n"
+ "PS: I'm just an automated script, not a human being.";
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: msg
})

View File

@ -36,10 +36,12 @@ jobs:
if: github.repository == 'Klipper3d/klipper'
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v3
- uses: actions/github-script@v6
with:
script: |
const issues = await github.issues.listForRepo({
const expireMillis = 1000 * 60 * 60 * 36;
const curtime = new Date().getTime();
const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
@ -47,41 +49,157 @@ jobs:
per_page: 100,
page: 1
});
const expireMillis = 1000 * 60 * 60 * 36;
const curtime = new Date().getTime();
for (var issue of issues.data.values()) {
for (const issue of issues.data.values()) {
const updatetime = new Date(issue.updated_at).getTime();
if (curtime < updatetime + expireMillis)
continue;
await github.issues.update({
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
state: 'closed'
});
}
# Close tickets marked with "reviewer needed" label for 2+ weeks
close_reviewer_needed:
if: github.repository == 'Klipper3d/klipper'
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
with:
script: |
const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: 'reviewer needed',
assignee: 'none',
per_page: 100,
page: 1
});
msg = "Unfortunately a reviewer has not assigned themselves to"
+ " this GitHub Pull Request and it is therefore being"
+ " closed. It is a good idea to move"
+ " further discussion to the [Klipper Discourse]"
+ "(https://www.klipper3d.org/Contact.html#community-forum)"
+ " server. Reviewers can reach out on that forum to let you"
+ " know if they are interested and when they are available."
+ "\n\n"
+ "Best regards,\n"
+ "~ Your friendly GitIssueBot"
+ "\n\n"
+ "PS: I'm just an automated script, not a human being.";
const expireMillis = 1000 * 60 * 60 * 24 * 14;
const curtime = new Date().getTime();
for (const issue of issues.data.values()) {
const updatetime = new Date(issue.updated_at).getTime();
if (curtime < updatetime + expireMillis)
continue;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
body: msg
});
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
state: 'closed'
});
}
# Mark unassigned PRs that are idle for 2 weeks
mark_reviewer_needed:
if: github.repository == 'Klipper3d/klipper'
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
with:
script: |
msg = "Thank you for your contribution to Klipper."
+ " Unfortunately, a reviewer has not assigned themselves to"
+ " this GitHub Pull Request. All Pull Requests are reviewed"
+ " before merging, and a reviewer will need to volunteer."
+ " Further information is available at:"
+ " https://www.klipper3d.org/CONTRIBUTING.html"
+ "\n\n"
+ "There are some steps that you can take now:"
+ "\n"
+ "1. Perform a self-review of your Pull Request by following"
+ " the steps at:"
+ " https://www.klipper3d.org/CONTRIBUTING.html#what-to-expect-in-a-review"
+ "\n"
+ " If you have completed a self-review, be sure to state the"
+ " results of that self-review explicitly in the Pull Request"
+ " comments. A reviewer is more likely to participate if the"
+ " bulk of a review has already been completed."
+ "\n"
+ "2. Consider opening a topic on the [Klipper Discourse]"
+ "(https://www.klipper3d.org/Contact.html#community-forum)"
+ " server to discuss this work. The Discourse server is a good"
+ " place to discuss development ideas and to engage users"
+ " interested in testing. Reviewers are more likely to"
+ " prioritize Pull Requests with an active community of users."
+ "\n"
+ "3. Consider helping out reviewers by reviewing other Klipper"
+ " Pull Requests. Taking the time to perform a careful and"
+ " detailed review of others work is appreciated. Regular"
+ " contributors are more likely to prioritize the"
+ " contributions of other regular contributors."
+ "\n\n"
+ "Unfortunately, if a reviewer does not assign themselves to"
+ " this GitHub Pull Request then it will be automatically"
+ " closed. If this happens, then it is a good idea to move"
+ " further discussion to the [Klipper Discourse]"
+ "(https://www.klipper3d.org/Contact.html#community-forum)"
+ " server. Reviewers can reach out on that forum to let you"
+ " know if they are interested and when they are available."
+ "\n\n"
+ "Best regards,\n"
+ "~ Your friendly GitIssueBot"
+ "\n\n"
+ "PS: I'm just an automated script, not a human being.";
const create_check = new Date("2022-03-01T00:00:00Z").getTime();
const expireMillis = 1000 * 60 * 60 * 24 * 14;
const curtime = new Date().getTime();
const pulls_req = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
per_page: 100,
page: 1
});
for (const pr of pulls_req.data.values()) {
const createtime = new Date(pr.created_at).getTime();
if (createtime < create_check)
continue;
const updatetime = new Date(pr.updated_at).getTime();
if (curtime < updatetime + expireMillis)
continue;
if (pr.labels.length > 0)
continue;
if (pr.assignees.length > 0)
continue;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
body: msg
});
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
labels: ['reviewer needed']
});
}
# Close tickets marked with "resolved" label
close_resolved:
if: github.repository == 'Klipper3d/klipper'
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v3
- uses: actions/github-script@v6
with:
script: |
const issues = await github.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: 'resolved',
per_page: 100,
page: 1
});
const expireMillis = 1000 * 60 * 60 * 24 * 7;
const curtime = new Date().getTime();
for (var issue of issues.data.values()) {
const updatetime = new Date(issue.updated_at).getTime();
if (curtime < updatetime + expireMillis)
continue;
msg = "This ticket is being closed because the underlying issue"
+ " is now thought to be resolved."
+ "\n\n"
@ -89,13 +207,27 @@ jobs:
+ "~ Your friendly GitIssueBot"
+ "\n\n"
+ "PS: I'm just an automated script, not a human being.";
await github.issues.createComment({
const expireMillis = 1000 * 60 * 60 * 24 * 7;
const curtime = new Date().getTime();
const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: 'resolved',
per_page: 100,
page: 1
});
for (const issue of issues.data.values()) {
const updatetime = new Date(issue.updated_at).getTime();
if (curtime < updatetime + expireMillis)
continue;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
body: msg
});
await github.issues.update({
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
@ -107,23 +239,9 @@ jobs:
if: github.repository == 'Klipper3d/klipper'
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v3
- uses: actions/github-script@v6
with:
script: |
const issues = await github.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: 'not mainline',
per_page: 100,
page: 1
});
const expireMillis = 1000 * 60 * 60 * 24 * 7;
const curtime = new Date().getTime();
for (var issue of issues.data.values()) {
const updatetime = new Date(issue.updated_at).getTime();
if (curtime < updatetime + expireMillis)
continue;
msg = "This PR is being closed because it is currently not"
+ " considered a good match for the master Klipper"
+ " repository."
@ -132,13 +250,27 @@ jobs:
+ "~ Your friendly GitIssueBot"
+ "\n\n"
+ "PS: I'm just an automated script, not a human being.";
await github.issues.createComment({
const expireMillis = 1000 * 60 * 60 * 24 * 7;
const curtime = new Date().getTime();
const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: 'not mainline',
per_page: 100,
page: 1
});
for (const issue of issues.data.values()) {
const updatetime = new Date(issue.updated_at).getTime();
if (curtime < updatetime + expireMillis)
continue;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
body: msg
});
await github.issues.update({
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
@ -150,23 +282,9 @@ jobs:
if: github.repository == 'Klipper3d/klipper'
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v3
- uses: actions/github-script@v6
with:
script: |
const issues = await github.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: 'pending feedback',
per_page: 100,
page: 1
});
const expireMillis = 1000 * 60 * 60 * 24 * 21;
const curtime = new Date().getTime();
for (var issue of issues.data.values()) {
const updatetime = new Date(issue.updated_at).getTime();
if (curtime < updatetime + expireMillis)
continue;
msg = "It looks like this GitHub Pull Request has become"
+ " inactive. If there are any further updates, you can"
+ " add a comment here or open a new ticket."
@ -175,19 +293,33 @@ jobs:
+ "~ Your friendly GitIssueBot"
+ "\n\n"
+ "PS: I'm just an automated script, not a human being.";
await github.issues.addLabels({
const expireMillis = 1000 * 60 * 60 * 24 * 21;
const curtime = new Date().getTime();
const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: 'pending feedback',
per_page: 100,
page: 1
});
for (const issue of issues.data.values()) {
const updatetime = new Date(issue.updated_at).getTime();
if (curtime < updatetime + expireMillis)
continue;
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
labels: ['inactive']
});
await github.issues.createComment({
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
body: msg
});
await github.issues.update({
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,

View File

@ -19,7 +19,7 @@ OBJCOPY=$(CROSS_PREFIX)objcopy
OBJDUMP=$(CROSS_PREFIX)objdump
STRIP=$(CROSS_PREFIX)strip
CPP=cpp
PYTHON=python2
PYTHON=python3
# Source files
src-y =
@ -85,17 +85,21 @@ $(OUT)compile_time_request.o: $(patsubst %.c, $(OUT)src/%.o.ctr,$(src-y)) ./scri
################ Auto generation of "board/" include file link
$(OUT)board-link: $(KCONFIG_CONFIG)
create-board-link:
@echo " Creating symbolic link $(OUT)board"
$(Q)mkdir -p $(addprefix $(OUT), $(dirs-y))
$(Q)echo "#$(CONFIG_BOARD_DIRECTORY)" > $@.temp
$(Q)if ! cmp -s $@.temp $@; then rm -f $(OUT)*.d $(patsubst %,$(OUT)%/*.d,$(dirs-y)) ; mv $@.temp $@ ; fi
$(Q)rm -f $(OUT)*.d $(patsubst %,$(OUT)%/*.d,$(dirs-y))
$(Q)rm -f $(OUT)board
$(Q)ln -sf $(CURDIR)/src/$(CONFIG_BOARD_DIRECTORY) $(OUT)board
$(Q)mkdir -p $(OUT)board-generic
$(Q)rm -f $(OUT)board-generic/board
$(Q)ln -sf $(CURDIR)/src/generic $(OUT)board-generic/board
# Hack to rebuild OUT directory and reload make dependencies on Kconfig change
$(OUT)board-link: $(KCONFIG_CONFIG)
$(Q)mkdir -p $(OUT)
$(Q)echo "# Makefile board-link rule" > $@
$(Q)$(MAKE) create-board-link
include $(OUT)board-link
################ Kconfig rules
@ -114,7 +118,7 @@ menuconfig:
################ Generic rules
# Make definitions
.PHONY : all clean distclean olddefconfig menuconfig FORCE
.PHONY : all clean distclean olddefconfig menuconfig create-board-link FORCE
.DELETE_ON_ERROR:
all: $(target-y)

View File

@ -0,0 +1,147 @@
# This file contains common pin mappings for Alligator (Rev.2) board.
# To use this config, the firmware should be compiled for the Arduino
# Due.
# Remember flash procedure:
# sudo /etc/init.d/alligator-manager --erase
# sudo bossac -e -w -v -b -R -i -p ttyAMA0 klipper.bin
# See alligator github for alligator manager:
# https://github.com/3Dartists/alligator-manager
# See docs/Config_Reference.md for a description of parameters.
[static_digital_output DRV8825_microstepping]
pins:PC10
pins:PC29
pins:PC19
pins:PC18
[dac084S085 stepper_digipot]
enable_pin: PB14
spi_bus: spi0
# Scale the config so that the channel value can be specified in amps.
# (For Alligator v2.0 boards, use 2.50)
scale: 2.50
# Channel A in this example is X, B is Y, C is Z, D is E0,1,2,3.
channel_A: 1.5
channel_B: 1.5
channel_C: 1.5
channel_D: 1.0
# channel D will be the current used by all extruders if> 1
[stepper_x]
step_pin: PB24
dir_pin: !PB25
enable_pin: !PA15
microsteps: 32 # number of microstep 16, 32
rotation_distance: 16
endstop_pin: ^!PC5
position_endstop: -30
position_max: 220
position_min: -30
homing_speed: 50
[stepper_y]
step_pin: PB22
dir_pin: !PB23
enable_pin: !PA15
microsteps: 32
rotation_distance: 16
endstop_pin: ^!PC3
position_endstop: -8
position_min: -8
position_max: 220
homing_speed: 50
[stepper_z]
step_pin: PC27
dir_pin: PC28
enable_pin: !PA15
microsteps: 32
rotation_distance: 4
endstop_pin: ^!PC2
position_endstop: 0
position_max: 240
position_min: -1
[extruder]
step_pin: PC25
dir_pin: PC26
enable_pin: !PA15
microsteps: 32
rotation_distance: 7
nozzle_diameter: 0.400
filament_diameter: 1.750
heater_pin: PA1
sensor_pin: PA16 # PA16(near mcu) or PA24(near ethernet)
sensor_type: ATC Semitec 104NT-4-R025H42G
control: pid
pid_kp: 15.572
pid_ki: 0.446
pid_kd: 136.064
min_temp: 0
max_temp: 270
#[extruder1]
#step_pin: PD3
#dir_pin: !PD2
#enable_pin: !PA15
#microsteps: 32
#heater_pin: PC22
#sensor_pin: PB25
#[extruder2]
#step_pin: PD7
#dir_pin: !PD6
#enable_pin: !PA15
#microsteps: 32
#heater_pin: PC21
#sensor_pin: PC28
#[extruder3]
#step_pin: PD9
#dir_pin: !PD8
#enable_pin: !PA15
#microsteps: 32
#heater_pin: PA29
#sensor_pin: PC5
[heater_bed]
heater_pin: PA0
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PA24 # PA16(near mcu) or PA24(near ethernet)
control: pid
pid_kp: 73.517
pid_ki: 1.132
pid_kd: 1193.728
min_temp: 0
max_temp: 130
[fan]
pin: PA7
#[heater_fan fan1]
#pin: PA5
#heater: extruder
[output_pin BEEPER_pin]
pin: PB19
pwm: True
value: 0
shutdown_value: 0
cycle_time: 0.1
scale: 1000
[mcu]
serial: /dev/ttyAMA0
[printer]
kinematics: cartesian
max_velocity: 300
max_accel: 1000
max_z_velocity: 20
max_z_accel: 100
#[bltouch]
#sensor_pin: ^PC6
#control_pin: PC4

View File

@ -0,0 +1,135 @@
# This file contains common pin mappings for Alligator (Rev.3) board.
# To use this config, the firmware should be compiled for the Arduino
# Due.
# Remember flash procedure:
# sudo /etc/init.d/alligator-manager --erase
# sudo bossac -e -w -v -b -R -i -p ttyAMA0 klipper.bin
# See alligator github for alligator manager:
# https://github.com/3Dartists/alligator-manager
# See docs/Config_Reference.md for a description of parameters.
[static_digital_output DRV8825_microstepping]
pins:PC10
pins:PC29
pins:PC19
pins:PC18
[dac084S085 stepper_digipot]
enable_pin: PD2
spi_bus: spi0
# Scale the config so that the channel value can be specified in amps.
# (For Alligator v3.0 boards, use 2.50)
scale: 2.50
# Channel A in this example is X, B is Y, C is Z, D is E0,1,2,3.
channel_A: 1.5
channel_B: 1.5
channel_C: 1.5
channel_D: 1.0
# channel D will be the current used by all extruders if> 1
[stepper_x]
step_pin: PB24
dir_pin: !PB25
enable_pin: !PA15
microsteps: 32 # number of microstep 16, 32
rotation_distance: 16
endstop_pin: ^!PC5
position_endstop: -30
position_max: 220
position_min: -30
homing_speed: 50
[stepper_y]
step_pin: PB22
dir_pin: !PB23
enable_pin: !PC28
microsteps: 32
rotation_distance: 16
endstop_pin: ^!PC3
position_endstop: -8
position_min: -8
position_max: 220
homing_speed: 50
[stepper_z]
step_pin: PB20
dir_pin: PB21
enable_pin: !PA29
microsteps: 32
rotation_distance: 4
endstop_pin: ^!PC2
position_endstop: 0
position_max: 240
position_min: -1
[extruder]
step_pin: PB18
dir_pin: PB19
enable_pin: !PC27
microsteps: 32
rotation_distance: 7
nozzle_diameter: 0.400
filament_diameter: 1.750
heater_pin: PA19
sensor_pin: PC25
sensor_type: ATC Semitec 104NT-4-R025H42G
control: pid
pid_kp: 15.572
pid_ki: 0.446
pid_kd: 136.064
min_temp: 0
max_temp: 270
#[extruder1]
#step_pin: PB17
#dir_pin: !PB14
#enable_pin: !PD6
#microsteps: 32
#heater_pin: PC22
#sensor_pin: PA29
#[extruder2]
#step_pin: PB12
#dir_pin: !PB13
#enable_pin: !PD8
#microsteps: 32
#heater_pin: PC21
#sensor_pin: PC28
#[extruder3]
#step_pin: PB15
#dir_pin: !PB16
#enable_pin: !PD9
#microsteps: 32
#heater_pin: PA29
#sensor_pin: PB25
[heater_bed]
heater_pin: PA0
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PA8
control: pid
pid_kp: 73.517
pid_ki: 1.132
pid_kd: 1193.728
min_temp: 0
max_temp: 130
[fan]
pin: PA7
#[heater_fan fan1]
#pin: PA5
#heater: extruder
[mcu]
serial: /dev/ttyAMA0
[printer]
kinematics: cartesian
max_velocity: 300
max_accel: 1000
max_z_velocity: 20
max_z_accel: 100

View File

@ -0,0 +1,132 @@
# This file contains common pin mappings for the BIGTREETECH SKR Pico V1.0
# To use this config, the firmware should be compiled for the RP2040 with
# USB communication.
# The "make flash" command does not work on the SKR Pico V1.0. Instead,
# after running "make", copy the generated "out/klipper.uf2" file
# to the mass storage device in RP2040 boot mode
# See docs/Config_Reference.md for a description of parameters.
[stepper_x]
step_pin: gpio11
dir_pin: !gpio10
enable_pin: !gpio12
microsteps: 16
rotation_distance: 40
endstop_pin: ^gpio4
position_endstop: 0
position_max: 235
homing_speed: 50
[tmc2209 stepper_x]
uart_pin: gpio9
tx_pin: gpio8
uart_address: 0
run_current: 0.580
stealthchop_threshold: 999999
[stepper_y]
step_pin: gpio6
dir_pin: !gpio5
enable_pin: !gpio7
microsteps: 16
rotation_distance: 40
endstop_pin: ^gpio3
position_endstop: 0
position_max: 235
homing_speed: 50
[tmc2209 stepper_y]
uart_pin: gpio9
tx_pin: gpio8
uart_address: 2
run_current: 0.580
stealthchop_threshold: 999999
[stepper_z]
step_pin: gpio19
dir_pin: gpio28
enable_pin: !gpio2
microsteps: 16
rotation_distance: 8
endstop_pin: ^gpio25
position_endstop: 0.0
position_max: 250
[tmc2209 stepper_z]
uart_pin: gpio9
tx_pin: gpio8
uart_address: 1
run_current: 0.580
stealthchop_threshold: 999999
[extruder]
step_pin: gpio14
dir_pin: !gpio13
enable_pin: !gpio15
microsteps: 16
rotation_distance: 33.500
nozzle_diameter: 0.400
filament_diameter: 1.750
heater_pin: gpio23
sensor_type: EPCOS 100K B57560G104F
sensor_pin: gpio27
control: pid
pid_Kp: 21.527
pid_Ki: 1.063
pid_Kd: 108.982
min_temp: 0
max_temp: 250
[tmc2209 extruder]
uart_pin: gpio9
tx_pin: gpio8
uart_address: 3
run_current: 0.650
stealthchop_threshold: 999999
[heater_bed]
heater_pin: gpio21
sensor_type: ATC Semitec 104GT-2
sensor_pin: gpio26
control: pid
pid_Kp: 54.027
pid_Ki: 0.770
pid_Kd: 948.182
min_temp: 0
max_temp: 130
[fan]
pin: gpio17
[heater_fan nozzle_cooling_fan]
pin: gpio18
[heater_fan controller_fan]
pin: gpio20
[mcu]
serial: /dev/serial/by-id/usb-Klipper_Klipper_firmware_12345-if00
[printer]
kinematics: cartesian
max_velocity: 300
max_accel: 3000
max_z_velocity: 5
max_z_accel: 100
[neopixel board_neopixel]
pin: gpio24
chain_count: 1
color_order: GRB
initial_RED: 0.3
initial_GREEN: 0.3
initial_BLUE: 0.3
#[bltouch]
#sensor_pin: gpio22
#control_pin: gpio29
#[filament_switch_sensor runout_sensor]
#switch_pin: ^gpio16

View File

@ -11,7 +11,7 @@ dir_pin: PE10
enable_pin: !PE9
microsteps: 16
rotation_distance: 40
endstop_pin: PB14 # PA1 for X-max
endstop_pin: ^PB14 # PA1 for X-max
position_endstop: 0
position_max: 200
@ -21,7 +21,7 @@ dir_pin: PB12
enable_pin: !PD9
microsteps: 16
rotation_distance: 40
endstop_pin: PB13 # PA2 for Y-max
endstop_pin: ^PB13 # PA2 for Y-max
position_endstop: 0
position_max: 200
@ -31,7 +31,7 @@ dir_pin: PD13
enable_pin: !PD15
microsteps: 16
rotation_distance: 8
endstop_pin: PA0 # PA3 for Z-max
endstop_pin: ^PA0 # PA3 for Z-max
position_endstop: 0
position_max: 400

View File

@ -11,7 +11,7 @@ dir_pin: PE10
enable_pin: !PE12
microsteps: 16
rotation_distance: 40
endstop_pin: PB14 # PA1 for X-max
endstop_pin: ^PB14 # PA1 for X-max
position_endstop: 0
position_max: 200
@ -21,7 +21,7 @@ dir_pin: PB12
enable_pin: !PD9
microsteps: 16
rotation_distance: 40
endstop_pin: PB13 # PA2 for Y-max
endstop_pin: ^PB13 # PA2 for Y-max
position_endstop: 0
position_max: 200
@ -31,7 +31,7 @@ dir_pin: PD13
enable_pin: !PD15
microsteps: 16
rotation_distance: 8
endstop_pin: PA0 # PA3 for Z-max (and servo)
endstop_pin: ^PA0 # PA3 for Z-max (and servo)
position_endstop: 0
position_max: 400

View File

@ -12,7 +12,7 @@ dir_pin: PE10
enable_pin: !PE9
microsteps: 16
rotation_distance: 40
endstop_pin: PB14 # PA1 for X-max
endstop_pin: ^PB14 # PA1 for X-max
position_endstop: 0
position_max: 200
@ -32,7 +32,7 @@ dir_pin: PD13
enable_pin: !PD15
microsteps: 16
rotation_distance: 8
endstop_pin: PA0 # PA3 for Z-max
endstop_pin: ^PA0 # PA3 for Z-max
position_endstop: 0
position_max: 400

View File

@ -0,0 +1,216 @@
# This file contains common pin mappings for the Mellow Fly-CDY-v3.
# To use this config, the firmware should be compiled for the
# STM32F407 with a "32KiB bootloader".
# The "make flash" command does not work on the Fly-CDY-v3. Instead,
# after running "make", copy the generated "out/klipper.bin" file to a
# file named "firmware.bin" on an SD card and then restart the Fly-CDY-v3
# with that SD card.
# See docs/Config_Reference.md for a description of parameters.
[stepper_x]
step_pin: PE5
dir_pin: PC0
enable_pin: !PC1
microsteps: 16
rotation_distance: 40
endstop_pin: ^PC7 # X-MAX PC6
position_endstop: 0
position_max: 200
homing_speed: 50
[stepper_y]
step_pin: PE4
dir_pin: !PC13
enable_pin: !PC14
microsteps: 16
rotation_distance: 40
endstop_pin: ^PD11 # Y-MAX PD10
position_endstop: 0
position_max: 200
homing_speed: 50
[stepper_z]
step_pin: PE3
dir_pin: PB7
enable_pin: !PB8
microsteps: 16
rotation_distance: 40
endstop_pin: ^PB10 # Z-MAX PB11
position_endstop: 0.5
position_max: 200
[extruder]
step_pin: PE2
dir_pin: PD6
enable_pin: !PD7
microsteps: 16
rotation_distance: 33.500
nozzle_diameter: 0.400
filament_diameter: 1.750
heater_pin: PD12
sensor_pin: PA3
sensor_type: EPCOS 100K B57560G104F
control: pid
pid_Kp: 22.2
pid_Ki: 1.08
pid_Kd: 114
min_temp: 0
max_temp: 250
#[extruder1]
#step_pin: PE1
#dir_pin: !PD3
#enable_pin: !PD4
#heater_pin: PD13
#sensor_pin: PC4
#[extruder2]
#step_pin: PE0
#dir_pin: !PA15
#enable_pin: !PD0
#heater_pin: PD14
#sensor_pin: PC5
[heater_bed]
heater_pin: PB0
sensor_type: Generic 3950
sensor_pin: PB1
control: watermark
min_temp: 0
max_temp: 130
#FAN0
[fan]
pin: PA0
#FAN1
#[heater_fan fan1]
#pin: PA1
#FAN2
#[heater_fan fan2]
#pin: PA2
[mcu]
serial: /dev/serial/by-id/usb-Klipper_Klipper_firmware_12345-if00
[printer]
kinematics: cartesian
max_velocity: 300
max_accel: 3000
max_z_velocity: 5
max_z_accel: 100
########################################
# TMC2209 configuration
########################################
#[tmc2209 stepper_x]
#uart_pin: PC15
#run_current: 0.800
#diag_pin: PC7
#stealthchop_threshold: 999999
#[tmc2209 stepper_y]
#uart_pin: PA8
#run_current: 0.800
#diag_pin: PC6
#stealthchop_threshold: 999999
#[tmc2209 stepper_z]
#uart_pin: PB6
#run_current: 0.800
#diag_pin: PD11
#stealthchop_threshold: 999999
#[tmc2209 extruder]
#uart_pin: PD5
#run_current: 0.600
#diag_pin: PD10
#stealthchop_threshold: 999999
#[tmc2209 extruder1]
#uart_pin: PD1
#run_current: 0.600
#diag_pin: PB10
#stealthchop_threshold: 999999
#[tmc2209 extruder2]
#uart_pin: PE9
#run_current: 0.600
#diag_pin: PB11
#stealthchop_threshold: 999999
########################################
# TMC5160 configuration
########################################
#[tmc5160 stepper_x]
#cs_pin: PC15
#spi_bus: spi3
#run_current: 0.800
#diag1_pin: PC7
#stealthchop_threshold: 999999
#[tmc5160 stepper_y]
#cs_pin: PA8
#spi_bus: spi3
#run_current: 0.800
#diag1_pin: PC6
#stealthchop_threshold: 999999
#[tmc5160 stepper_z]
#cs_pin: PB6
#spi_bus: spi3
#run_current: 0.800
#diag1_pin: PD11
#stealthchop_threshold: 999999
#[tmc5160 extruder]
#cs_pin: PD5
#spi_bus: spi3
#run_current: 0.800
#diag1_pin: PD10
#stealthchop_threshold: 999999
#[tmc5160 extruder1]
#cs_pin: PD1
#spi_bus: spi3
#run_current: 0.800
#diag1_pin: PB10
#stealthchop_threshold: 999999
#[tmc5160 extruder2]
#cs_pin: PE9
#spi_bus: spi3
#run_current: 0.800
#diag1_pin: PB11
#stealthchop_threshold: 999999
########################################
# Accelerometer (ADXL345) pins
########################################
## SCK=PA5, MISO=PA6, MOSI=PA7
#[adxl345]
#cs_pin: PE7
#spi_bus: spi1
########################################
# EXP1 / EXP2 (display) pins
########################################
[board_pins]
aliases:
# EXP1 header
EXP1_1=<NC>, EXP1_3=PB2, EXP1_5=PE15, EXP1_7=PA13, EXP1_9=<GND>,
EXP1_2=PA9, EXP1_4=PA10, EXP1_6=PE14, EXP1_8=PA14, EXP1_10=<5V>,
# EXP2 header
EXP2_1=PA6, EXP2_3=PD8, EXP2_5=PD9, EXP2_7=PE13, EXP2_9=<GND>,
EXP2_2=PA5, EXP2_4=PA4, EXP2_6=PA7, EXP2_8=<RST>, EXP2_10=<NC>,
# See the sample-lcd.cfg file for definitions of common LCD displays.

View File

@ -0,0 +1,157 @@
# This file contains common pin mappings for the Mellow Fly-Gemini-v1.
# To use this config, the firmware should be compiled for the
# STM32F405 with a "32KiB bootloader".
# The "make flash" command does not work on the Fly-Gemini-v1. Instead,
# after running "make", copy the generated "out/klipper.bin" file to a
# file named "firmware.bin" or "klipper.bin" on an SD card and then restart the Fly-Gemini-v1
# with that SD card.
# See docs/Config_Reference.md for a description of parameters.
[stepper_x]
step_pin: PC13
dir_pin: PC1
enable_pin: !PB2
microsteps: 16
rotation_distance: 40
endstop_pin: ^PA3
position_endstop: 0
position_max: 200
homing_speed: 50
[stepper_y]
step_pin: PC14
dir_pin: !PC4
enable_pin: !PB6
microsteps: 16
rotation_distance: 40
endstop_pin: ^PB1
position_endstop: 0
position_max: 200
homing_speed: 50
[stepper_z]
step_pin: PC15
dir_pin: PC5
enable_pin: !PB5
microsteps: 16
rotation_distance: 40
endstop_pin: ^PB10
position_endstop: 0.5
position_max: 200
[extruder]
step_pin: PC3
dir_pin: PC7
enable_pin: !PB4
microsteps: 16
rotation_distance: 33.500
nozzle_diameter: 0.400
filament_diameter: 1.750
heater_pin: PA0
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PC0
control: pid
pid_Kp: 22.2
pid_Ki: 1.08
pid_Kd: 114
min_temp: 0
max_temp: 250
[heater_bed]
heater_pin: PA2
sensor_type: Generic 3950
sensor_pin: PC2
control: watermark
min_temp: 0
max_temp: 130
[fan]
pin: PC6
[mcu]
serial: /dev/serial/by-id/usb-Klipper_Klipper_firmware_12345-if00
[printer]
kinematics: cartesian
max_velocity: 300
max_accel: 3000
max_z_velocity: 5
max_z_accel: 100
########################################
# TMC2209 configuration
########################################
#[tmc2209 stepper_x]
#uart_pin: PB11
#run_current: 0.800
#diag_pin: PA3
#stealthchop_threshold: 999999
#[tmc2209 stepper_y]
#uart_pin: PB9
#run_current: 0.800
#diag_pin: PB1
#stealthchop_threshold: 999999
#[tmc2209 stepper_z]
#uart_pin: PB8
#run_current: 0.800
#diag_pin: PB10
#stealthchop_threshold: 999999
#[tmc2209 extruder]
#uart_pin: PB7
#run_current: 0.600
#diag_pin:
#stealthchop_threshold: 999999
########################################
# TMC5160 configuration
########################################
#[tmc5160 stepper_x]
#cs_pin: PB11
#spi_bus: spi1
#run_current: 0.800
#diag1_pin: PA3
#stealthchop_threshold: 999999
#[tmc5160 stepper_y]
#cs_pin: PB9
#spi_bus: spi1
#run_current: 0.800
#diag1_pin: PB1
#stealthchop_threshold: 999999
#[tmc5160 stepper_z]
#cs_pin: PB8
#spi_bus: spi1
#run_current: 0.800
#diag1_pin: PB10
#stealthchop_threshold: 999999
#[tmc5160 extruder]
#cs_pin: PB7
#spi_bus: spi1
#run_current: 0.800
#diag1_pin:
#stealthchop_threshold: 999999
########################################
# EXP1 / EXP2 (display) pins
########################################
[board_pins]
aliases:
# EXP1 header
EXP1_1=<NC>, EXP1_3=PA13, EXP1_5=PA9, EXP1_7=<NC>, EXP1_9=<GND>,
EXP1_2=PA4, EXP1_4=PA10, EXP1_6=PA8, EXP1_8=<NC>, EXP1_10=<5V>,
# EXP2 header
EXP2_1=PB14, EXP2_3=PA15, EXP2_5=PA14, EXP2_7=PB3, EXP2_9=<GND>,
EXP2_2=PB13, EXP2_4=PB12, EXP2_6=PB15, EXP2_8=<RST>, EXP2_10=<NC>,
# See the sample-lcd.cfg file for definitions of common LCD displays.

View File

@ -0,0 +1,161 @@
# This file contains common pin mappings for the Mellow Fly-Gemini-v2.
# To use this config, the firmware should be compiled for the
# STM32F405 with a "32KiB bootloader".
# The "make flash" command does not work on the Fly-Gemini-v2. Instead,
# after running "make", copy the generated "out/klipper.bin" file to a
# file named "firmware.bin" or "klipper.bin" on an SD card and then restart the Fly-Gemini-v2
# with that SD card.
# See docs/Config_Reference.md for a description of parameters.
[stepper_x]
step_pin: PC13
dir_pin: PC1
enable_pin: !PB2
microsteps: 16
rotation_distance: 40
endstop_pin: ^PA3
position_endstop: 0
position_max: 200
homing_speed: 50
[stepper_y]
step_pin: PC14
dir_pin: !PC4
enable_pin: !PD2
microsteps: 16
rotation_distance: 40
endstop_pin: ^PB1
position_endstop: 0
position_max: 200
homing_speed: 50
[stepper_z]
step_pin: PC15
dir_pin: PC5
enable_pin: !PC12
microsteps: 16
rotation_distance: 40
endstop_pin: ^PB10
position_endstop: 0.5
position_max: 200
[extruder]
step_pin: PC3
dir_pin: PC8
enable_pin: !PC11
microsteps: 16
rotation_distance: 33.500
nozzle_diameter: 0.400
filament_diameter: 1.750
heater_pin: PA0
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PC0
control: pid
pid_Kp: 22.2
pid_Ki: 1.08
pid_Kd: 114
min_temp: 0
max_temp: 250
[heater_bed]
heater_pin: PA2
sensor_type: Generic 3950
sensor_pin: PC2
control: watermark
min_temp: 0
max_temp: 130
[fan]
pin: PC6
#FAN1
#[heater_fan fan1]
#pin: PC7
[mcu]
serial: /dev/serial/by-id/usb-Klipper_Klipper_firmware_12345-if00
[printer]
kinematics: cartesian
max_velocity: 300
max_accel: 3000
max_z_velocity: 5
max_z_accel: 100
########################################
# TMC2209 configuration
########################################
#[tmc2209 stepper_x]
#uart_pin: PB11
#run_current: 0.800
#diag_pin: PA3
#stealthchop_threshold: 999999
#[tmc2209 stepper_y]
#uart_pin: PB9
#run_current: 0.800
#diag_pin: PB1
#stealthchop_threshold: 999999
#[tmc2209 stepper_z]
#uart_pin: PB8
#run_current: 0.800
#diag_pin: PB10
#stealthchop_threshold: 999999
#[tmc2209 extruder]
#uart_pin: PB7
#run_current: 0.600
#diag_pin:
#stealthchop_threshold: 999999
########################################
# TMC5160 configuration
########################################
#[tmc5160 stepper_x]
#cs_pin: PB11
#spi_bus: spi1
#run_current: 0.800
#diag1_pin: PA3
#stealthchop_threshold: 999999
#[tmc5160 stepper_y]
#cs_pin: PB9
#spi_bus: spi1
#run_current: 0.800
#diag1_pin: PB1
#stealthchop_threshold: 999999
#[tmc5160 stepper_z]
#cs_pin: PB8
#spi_bus: spi1
#run_current: 0.800
#diag1_pin: PB10
#stealthchop_threshold: 999999
#[tmc5160 extruder]
#cs_pin: PB7
#spi_bus: spi1
#run_current: 0.800
#diag1_pin:
#stealthchop_threshold: 999999
########################################
# EXP1 / EXP2 (display) pins
########################################
[board_pins]
aliases:
# EXP1 header
EXP1_1=PC9, EXP1_3=PA13, EXP1_5=PA9, EXP1_7=<NC>, EXP1_9=<GND>,
EXP1_2=PB6, EXP1_4=PA10, EXP1_6=PA8, EXP1_8=<NC>, EXP1_10=<5V>,
# EXP2 header
EXP2_1=PB14, EXP2_3=PA15, EXP2_5=PA14, EXP2_7=PC10, EXP2_9=<GND>,
EXP2_2=PB13, EXP2_4=PB12, EXP2_6=PB15, EXP2_8=<RST>, EXP2_10=<NC>,
# See the sample-lcd.cfg file for definitions of common LCD displays.

View File

@ -53,7 +53,7 @@ microsteps: 16
rotation_distance: 33.500
nozzle_diameter: 0.400
filament_diameter: 1.750
heater_pin: PC7 # Heat0
heater_pin: PB0 # Heat0
sensor_pin: PF4 # ADC_0
sensor_type: EPCOS 100K B57560G104F
control: pid
@ -240,72 +240,56 @@ max_z_accel: 100
#[tmc5160 stepper_x]
#cs_pin: PC4
#spi_software_miso_pin: PB5
#spi_software_mosi_pin: PB4
#spi_software_sclk_pin: PB3
#spi_bus: spi3
##diag1_pin: PG12
#run_current: 0.800
#stealthchop_threshold: 999999
#[tmc5160 stepper_y]
#cs_pin: PF12
#spi_software_miso_pin: PB5
#spi_software_mosi_pin: PB4
#spi_software_sclk_pin: PB3
#spi_bus: spi3
##diag1_pin: PG11
#run_current: 0.800
#stealthchop_threshold: 999999
#[tmc5160 stepper_z]
#cs_pin: PF15
#spi_software_miso_pin: PB5
#spi_software_mosi_pin: PB4
#spi_software_sclk_pin: PB3
#spi_bus: spi3
##diag1_pin: PG10
#run_current: 0.650
#stealthchop_threshold: 999999
#[tmc5160 extruder]
#cs_pin: PE7
#spi_software_miso_pin: PB5
#spi_software_mosi_pin: PB4
#spi_software_sclk_pin: PB3
#spi_bus: spi3
##diag1_pin: PG9
#run_current: 0.800
#stealthchop_threshold: 999999
#[tmc5160 extruder1]
#cs_pin: PE10
#spi_software_miso_pin: PB5
#spi_software_mosi_pin: PB4
#spi_software_sclk_pin: PB3
#spi_bus: spi3
##diag1_pin: PD7
#run_current: 0.800
#stealthchop_threshold: 999999
#[tmc5160 extruder2]
#cs_pin: PF1
#spi_software_miso_pin: PB5
#spi_software_mosi_pin: PB4
#spi_software_sclk_pin: PB3
#spi_bus: spi3
##diag1_pin: PD6
#run_current: 0.800
#stealthchop_threshold: 999999
#[tmc5160 extruder3]
#cs_pin: PG2
#spi_software_miso_pin: PB5
#spi_software_mosi_pin: PB4
#spi_software_sclk_pin: PB3
#spi_bus: spi3
##diag1_pin: PA8
#run_current: 0.800
#stealthchop_threshold: 999999
#[tmc5160 extruder4]
#cs_pin: PG5
#spi_software_miso_pin: PB5
#spi_software_mosi_pin: PB4
#spi_software_sclk_pin: PB3
#spi_bus: spi3
##diag1_pin: PF3
#run_current: 0.800
#stealthchop_threshold: 999999

View File

@ -0,0 +1,128 @@
# This file contains common pin mappings for the TH3D EZBoard Lite v2.
# To use this config, the firmware should be compiled for the
# STM32F407 with 12mhz Crystal, 48KiB Bootloader, and USB communication.
# The "make flash" command does not work on this board. Instead,
# after running "make", copy the generated "out/klipper.bin" file to a
# file named "firmware.bin" on an SD card and then restart the board
# with that SD card.
# See docs/Config_Reference.md for a description of parameters.
[mcu]
serial: /dev/serial/by-id/usb-Klipper_stm32f407xx_0000000000000000-if00
[printer]
kinematics: cartesian
max_velocity: 300
max_accel: 3000
max_z_velocity: 5
max_z_accel: 100
[stepper_x]
step_pin: PB3
dir_pin: PD2
enable_pin: !PB5
microsteps: 16
rotation_distance: 40
endstop_pin: ^!PC1
position_endstop: 0
position_max: 235
homing_speed: 50
[tmc2209 stepper_x]
uart_pin: PC11
tx_pin: PC10
run_current: 0.600
uart_address: 0
[stepper_y]
step_pin: PB8
dir_pin: PC13
enable_pin: !PC12
microsteps: 16
rotation_distance: 40
endstop_pin: ^!PC2
position_endstop: 0
position_max: 235
homing_speed: 50
[tmc2209 stepper_y]
uart_pin: PC11
tx_pin: PC10
run_current: 0.600
uart_address: 1
[stepper_z]
step_pin: PA3
dir_pin: PB1
enable_pin: !PC14
microsteps: 16
rotation_distance: 8
endstop_pin: ^!PC3
position_endstop: 0.5
position_max: 250
[tmc2209 stepper_z]
uart_pin: PC11
tx_pin: PC10
run_current: 0.700
uart_address: 2
[extruder]
step_pin: PA15
dir_pin: PB11
enable_pin: !PB2
microsteps: 16
rotation_distance: 34.406
nozzle_diameter: 0.400
filament_diameter: 1.750
heater_pin: PC8
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PA1
control: pid
pid_Kp: 22.2
pid_Ki: 1.08
pid_Kd: 114
min_temp: 0
max_temp: 250
[tmc2209 extruder]
uart_pin: PC11
tx_pin: PC10
run_current: 0.800
stealthchop_threshold: 999999
uart_address: 3
[heater_bed]
heater_pin: PC9
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PA0
control: pid
pid_Kp: 54.027
pid_Ki: 0.770
pid_Kd: 948.182
min_temp: 0
max_temp: 130
[fan]
pin: PC6
#[bltouch]
#sensor_pin: ^PC3
#control_pin: PA2
#[filament_switch_sensor my_sensor]
#switch_pin: PC0
########################################
# EXP1 / EXP2 (display) pins
########################################
[board_pins]
aliases:
# EXP1 header
EXP1_1=PA14, EXP1_3=PC4, EXP1_5=PC5, EXP1_7=PB12, EXP1_9=<GND>,
EXP1_2=PB0, EXP1_4=<RST>, EXP1_6=PB13, EXP1_8=PB15, EXP1_10=<5V>
# See the sample-lcd.cfg file for definitions of common LCD displays.

View File

@ -0,0 +1,317 @@
# This file contains common pin mappings for the BigTreeTech SKR SE BX.
# To use this config, the firmware should be compiled for the
# STM32H743 with a "128KiB bootloader". Additionally, GPIO pins PB5
# and PE5 need to be set at microcontroller startup.
######################################################################
# NOTE: In order enable the TFT70-BX display when the printer first
# starts, add PB5 and PE5 to the `GPIO pins to set at micro-controller
# startup` section when running "make menuconfig"
######################################################################
# The "make flash" command does not work on the SKR SE BX. Instead,
# after running "make", copy the generated "out/klipper.bin" file to a
# file named "firmware.bin" on an SD card and then restart the SKR SE BX
# with that SD card. After klipper has been flashed once to the board,
# you can update klipper by leaving a microSD inserted and running the
# scripts/flash-sd.sh script.
# See docs/Config_Reference.md for a description of parameters.
########################################
# Steppers
########################################
[stepper_x]
step_pin: PG13
dir_pin: !PG12
enable_pin: !PG14
microsteps: 16
rotation_distance: 40
full_steps_per_rotation: 400
endstop_pin: tmc2209_stepper_x:virtual_endstop
position_endstop: -13
position_min: -13
position_max: 250
homing_speed: 30
homing_retract_dist: 0
[stepper_y]
step_pin: PB3
dir_pin: !PD3
enable_pin: !PB4
microsteps: 16
rotation_distance: 40
full_steps_per_rotation: 400
endstop_pin: tmc2209_stepper_y:virtual_endstop
position_endstop: -7
position_min: -7
position_max: 250
homing_speed: 30
homing_retract_dist: 0
[stepper_z]
step_pin: PD7
dir_pin: PD6
enable_pin: !PG9
microsteps: 16
rotation_distance: 8
full_steps_per_rotation: 400
endstop_pin: probe:z_virtual_endstop
position_min: -2
position_max: 250
[stepper_z1]
step_pin: PA8
dir_pin: PC9
enable_pin: !PD2
microsteps: 16
rotation_distance: 8
full_steps_per_rotation: 400
[extruder]
step_pin: PC14
dir_pin: !PC13
enable_pin: !PC15
microsteps: 16
rotation_distance: 24.031
gear_ratio: 7:1
full_steps_per_rotation: 200
nozzle_diameter: 0.400
filament_diameter: 1.750
heater_pin: PC4
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PH4
control: pid
pid_Kp: 22.2
pid_Ki: 1.08
pid_Kd: 114
min_temp: 0
max_temp: 350
[safe_z_home]
home_xy_position: 125,125
speed: 200
z_hop: 10
z_hop_speed: 25
########################################
# TMC2209 configuration
########################################
[tmc2209 stepper_x]
uart_pin: PG10
diag_pin: ^PB11
run_current: 0.800
sense_resistor: 0.150
driver_SGTHRS: 127
stealthchop_threshold: 999999
[tmc2209 stepper_y]
uart_pin: PD4
diag_pin: ^PB12
run_current: 0.800
sense_resistor: 0.150
driver_SGTHRS: 137
stealthchop_threshold: 999999
[tmc2209 stepper_z]
uart_pin: PD5
run_current: 1.000
sense_resistor: 0.150
stealthchop_threshold: 999999
[tmc2209 stepper_z1]
uart_pin: PC8
run_current: 1.000
sense_resistor: 0.150
stealthchop_threshold: 999999
[tmc2209 extruder]
uart_pin: PI8
run_current: 0.800
sense_resistor: 0.150
stealthchop_threshold: 0
########################################
# PRINTER
########################################
[mcu]
serial: /dev/ttyAMA0
restart_method: command
[printer]
kinematics: cartesian
max_velocity: 200
max_accel: 1000
max_z_velocity: 10
max_z_accel: 1000
[fan]
pin: PA5
[heater_fan extruder_fan]
pin: PA6
heater: extruder
[controller_fan controller_fan]
pin: PA7
idle_timeout: 300 # 5 minute timeout
[output_pin motor_power]
pin: PI11
value: 1
[idle_timeout]
gcode:
TURN_OFF_HEATERS
M84
SET_PIN PIN=screen VALUE=0
SET_LED LED=led BLUE=0.0 RED=0.0 GREEN=0.0
[pause_resume]
########################################
# DISPLAY
########################################
[output_pin screen]
pin: PB5
value: 1
[display_status]
[gcode_button lcd_button]
pin: PH8
press_gcode:
SET_PIN PIN=screen VALUE=1
SET_LED LED=led BLUE=1.0 RED=1.0 GREEN=1.0
[output_pin beeper]
pin: PA14
pwm: True
cycle_time: 0.001
########################################
# LEDS
########################################
[neopixel led]
pin: PH3
chain_count: 15
[neopixel knob]
pin: PB1
chain_count: 2
[delayed_gcode welcome]
initial_duration: 0.1
gcode:
SET_LED LED=knob RED=0.0 BLUE=1.0 GREEN=0.0
SET_LED LED=led RED=0.0 BLUE=1.0 GREEN=0.0
G4 P1000
SET_LED LED=led RED=1.0 BLUE=0.0 GREEN=0.0
G4 P1000
SET_LED LED=led RED=0.0 BLUE=0.0 GREEN=1.0
G4 P1000
SET_LED LED=led RED=1.0 BLUE=1.0 GREEN=1.0
########################################
# BED
########################################
[heater_bed]
heater_pin: PA4
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PH5
control: watermark
min_temp: 0
max_temp: 250
[probe]
pin: PH2
x_offset: -30.1
y_offset: 26.78
z_offset: 0
speed: 5
samples: 3
samples_result: median
sample_retract_dist: 3.0
samples_tolerance: 0.006
samples_tolerance_retries: 5
[bed_mesh]
speed: 120
mesh_min: 10,19.78
mesh_max: 219.9,230
probe_count: 4,4
[screws_tilt_adjust]
screw1: 58,-7
screw1_name: front left
screw2: 245,-7
screw2_name: front right
screw3: 245,179
screw3_name: rear right
screw4: 58,179
screw4_name: rear left
speed: 100
screw_thread: CCW-M3
########################################
## MACROS
########################################
# Slicer setup: "print_start NOZZLE=<temp> BED=<temp>
# This macro does a preheat on the probe for better accuracy and needs
# the temps passed in. examples:
# Cura: PRINT_START BED={material_bed_temperature_layer_0} NOZZLE={material_print_temperature_layer_0}
# PrusaSlicer: PRINT_START NOZZLE=[first_layer_temperature] BED=[bed_temperature]
# Use PRINT_END for the slicer ending script
[gcode_macro PRINT_START]
gcode:
# Turn on screen if it's not on
SET_PIN PIN=screen VALUE=1
G28
G0 Z1
# Warm up nozzle, not to full temps yet
M104 S150
# Set LED to Purple for bed heating
SET_LED LED=led BLUE=0.94 RED=0.63 GREEN=0.13
M117 Heating Bed
# Allow probe to warm up, then re-home Z
M190 S60
M105
G4 P90000
G28 Z
M190 S{params.BED}
M105
G90 # Ensure we are in absolute mode
G21
M83 # Set the extruder to relative mode
G92 E0
# Set LED to Red for nozzle heating
SET_LED LED=led BLUE=0.0 RED=1.0 GREEN=0.0
M117 Heating Nozzle
G0 X2 Y0 F6000
G0 Z0.4
M109 S{params.NOZZLE}
M105
# Set LED to white for printing
SET_LED LED=led BLUE=1.0 RED=1.0 GREEN=1.0
M117 Printing
# Purge Line
G1 X120 E30 F1200
G1 Y1
G1 X2 E30 F1200
G92 E0
G1 Z1.0 F600
G92 E0
G0 F9000
G90 # Set back to Absolute mode

View File

@ -0,0 +1,161 @@
# This file contains pin mappings for the Creality CR-10 Smart Pro
# with a CR-FDM-v2.5.S1 board.
#
# To use this config, during "make menuconfig" select the STM32F103
# with a "64KiB bootloader" and serial (on USART1 PA10/PA9)
# communication. Enable PA0 GPIO pin on startup.
#
# Flash this firmware on the MCU by copying "out/klipper.bin" to an SD
# card and turning the printer on with the card inserted. The firmware
# filename must end in ".bin" and must not match the last filename
# that was flashed.
#
# The machine itself includes a small router that can run a Klipper
# frontend. You don't need to buy a single-board computer.
#
# See docs/Config_Reference.md for a description of parameters.
[stepper_x]
step_pin: PB8
dir_pin: !PB7
enable_pin: !PC3
rotation_distance: 40
microsteps: 16
endstop_pin: PC4
position_min: -5
position_endstop: -5
position_max: 305
homing_speed: 50
[stepper_y]
step_pin: PB6
dir_pin: PB5
enable_pin: !PC3
rotation_distance: 40
microsteps: 16
endstop_pin: PC5
position_min: -2
position_endstop: -2
position_max: 302
homing_speed: 50
[stepper_z]
step_pin: PB4
dir_pin: !PB3
enable_pin: !PC3
rotation_distance: 8
microsteps: 16
endstop_pin: probe:z_virtual_endstop
position_min: -1.5
position_max: 400
homing_speed: 4
second_homing_speed: 1
homing_retract_dist: 2.0
[extruder]
step_pin: PC2
dir_pin: !PB9
enable_pin: !PC3
rotation_distance: 7.640
microsteps: 16
nozzle_diameter: 0.400
filament_diameter: 1.750
heater_pin: PB14
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PB1
control: pid
pid_Kp: 22.865
pid_Ki: 1.292
pid_Kd: 101.178
min_temp: 0
max_temp: 250
[filament_switch_sensor runout_sensor]
pause_on_runout: false
runout_gcode: PAUSE
insert_gcode: RESUME
switch_pin: !PA15
[heater_bed]
heater_pin: PB13
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PB0
control: pid
pid_Kp: 72.49
pid_Ki: 0.844
pid_Kd: 1542.189
min_temp: 0
max_temp: 120
[heater_fan hotend_fan]
pin: PC13
heater: extruder
heater_temp: 50.0
[fan]
pin: PB15
kick_start_time: 0.5
[mcu]
serial: /dev/ttyPrinter
restart_method: command
[temperature_sensor Board_MCU]
sensor_type: temperature_mcu
min_temp: 0
max_temp: 100
[bltouch]
sensor_pin: ^PC15
control_pin: PC14
x_offset: -32.5
y_offset: -40.6
z_offset: 2.60 # initial safe value, get correct value by PROBE_CALIBRATE
[safe_z_home]
home_xy_position: 150,150
speed: 50
z_hop: 3
z_hop_speed: 5
[screws_tilt_adjust]
screw1: 60, 80
screw1_name: front left screw
screw2: 300, 80
screw2_name: front right screw
# The rear screws are actually mechanically not reachable for the
# probe, but that is ok, adjustments will still converge.
screw3: 300, 300
screw3_name: rear right screw
screw4: 60, 300
screw4_name: rear left screw
horizontal_move_z: 10.
speed: 50.
screw_thread: CW-M3
# Main light bar
[output_pin lights]
pin: PA7
value: 1
# Do not use PB12. PB12 resets the Wifi board.
#[output_pin factory_reset]
#pin: PB12
#value: 0
# Turns off the printer
[output_pin power]
pin: PA0
value: 1
shutdown_value: 1
# Conservative default values that mimic the behaviour of the
# stock firmware for easy results. It can go faster.
[printer]
kinematics: cartesian
max_velocity: 500
max_accel: 2000
square_corner_velocity: 5.0
max_z_velocity: 10
max_z_accel: 100

View File

@ -80,7 +80,7 @@ min_temp: 0
max_temp: 120
[fan]
pin: PA0
pin: PB15
kick_start_time: 0.5
[mcu]

View File

@ -0,0 +1,106 @@
# This file contains pin mappings for the stock 2021 Creality
# Ender2 Pro. To use this config, during "make menuconfig" select
# the STM32F103 with a "28KiB bootloader" and serial
# (on USART1 PA10/PA9) communication.
# If you prefer a direct serial connection, in "make menuconfig"
# select "Enable extra low-level configuration options" and select
# serial (on USART3 PB11/PB10), which is broken out on the 10 pin IDC
# cable used for the LCD module as follows:
# 3: Tx, 4: Rx, 9: GND, 10: VCC
# Flash this firmware by copying "out/klipper.bin" to a SD card and
# turning on the printer with the card inserted. The firmware
# filename must end in ".bin" and must not match the last filename
# that was flashed.
# See docs/Config_Reference.md for a description of parameters.
[stepper_x]
step_pin: PC2
dir_pin: PB9
enable_pin: !PC3
microsteps: 16
rotation_distance: 40
endstop_pin: ^PA5
position_min: -20
position_endstop: -20
position_max: 165
homing_speed: 50
[stepper_y]
step_pin: PB8
dir_pin: PB7
enable_pin: !PC3
microsteps: 16
rotation_distance: 40
endstop_pin: ^PA6
position_min: -5
position_endstop: -5
position_max: 165
homing_speed: 50
[stepper_z]
step_pin: PB6
dir_pin: !PB5
enable_pin: !PC3
microsteps: 16
rotation_distance: 8
endstop_pin: ^PA7
position_endstop: 0.0
position_max: 180
[extruder]
max_extrude_only_distance: 100.0
step_pin: PB4
dir_pin: PB3
enable_pin: !PC3
microsteps: 16
rotation_distance: 27.53480577
nozzle_diameter: 0.400
filament_diameter: 1.750
heater_pin: PA1
sensor_pin: PC5
sensor_type: EPCOS 100K B57560G104F
control: pid
pid_Kp: 29.634
pid_Ki: 2.102
pid_Kd: 104.459
min_temp: 0
max_temp: 260
[heater_bed]
heater_pin: PB10
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PC4
control: pid
pid_Kp: 72.921
pid_Ki: 1.594
pid_Kd: 834.031
min_temp: 0
max_temp: 80
[fan]
pin: PA0
[mcu]
serial: /dev/serial/by-id/usb-1a86_USB_Serial-if00-port0
restart_method: command
[printer]
kinematics: cartesian
max_velocity: 300
max_accel: 3000
max_z_velocity: 5
max_z_accel: 100
[display]
lcd_type: st7920
cs_pin: PB12
sclk_pin: PB13
sid_pin: PB15
encoder_pins: ^PB14, ^PA2
click_pin: ^!PB2
[output_pin beeper]
pin: PC6

View File

@ -88,6 +88,12 @@ max_accel: 3000
max_z_velocity: 5
max_z_accel: 100
[bed_screws]
screw1: 30.5, 37
screw2: 30.5, 207
screw3: 204.5, 207
screw4: 204.5, 37
[display]
lcd_type: st7920
cs_pin: PA3

View File

@ -3,6 +3,12 @@
# "make menuconfig" select the STM32F103 with a "28KiB bootloader" and
# serial (on USART1 PA10/PA9) communication.
# It should be noted that newer variations of this printer shipping in
# 2022 may have GD32F103 chips installed and not STM32F103. You may
# have to inspect the mainboard to ascertain which one you have. If it
# is the GD32F103 then please select Disable SWD at startup in the
# "make menuconfig" along with the same settings for STM32F103.
# If you prefer a direct serial connection, in "make menuconfig"
# select "Enable extra low-level configuration options" and select
# serial (on USART3 PB11/PB10), which is broken out on the 10 pin IDC

View File

@ -0,0 +1,101 @@
# This file contains pin mappings for the stock 2020 Creality Ender 5
# Pro with the 32-bit Creality 4.2.2 board. To use this config, during
# "make menuconfig" select the STM32F103 with a "28KiB bootloader" and
# with "Use USB for communication" disabled.
# If you prefer a direct serial connection, in "make menuconfig"
# select "Enable extra low-level configuration options" and select the
# USART3 serial port, which is broken out on the 10 pin IDC cable used
# for the LCD module as follows:
# 3: Tx, 4: Rx, 9: GND, 10: VCC
# Flash this firmware by copying "out/klipper.bin" to a SD card and
# turning on the printer with the card inserted. The firmware
# filename must end in ".bin" and must not match the last filename
# that was flashed.
# See docs/Config_Reference.md for a description of parameters.
[stepper_x]
step_pin: PC2
dir_pin: PB9
enable_pin: !PC3
microsteps: 16
rotation_distance: 40
endstop_pin: ^PA5
position_endstop: 220
position_max: 220
homing_speed: 50
[stepper_y]
step_pin: PB8
dir_pin: PB7
enable_pin: !PC3
microsteps: 16
rotation_distance: 40
endstop_pin: ^PA6
position_endstop: 220
position_max: 220
homing_speed: 50
[stepper_z]
step_pin: PB6
dir_pin: PB5
enable_pin: !PC3
microsteps: 16
rotation_distance: 4
endstop_pin: ^PA7
position_max: 300
position_endstop: 0.0
[extruder]
max_extrude_only_distance: 100.0
step_pin: PB4
dir_pin: PB3
enable_pin: !PC3
microsteps: 16
rotation_distance: 32.342
nozzle_diameter: 0.400
filament_diameter: 1.750
heater_pin: PA1
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PC5
control: pid
pid_kp: 24.831
pid_ki: 1.346
pid_kd: 114.532
min_temp: 0
max_temp: 260
[heater_bed]
heater_pin: PA2
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PC4
control: pid
pid_kp: 66.429
pid_ki: 1.197
pid_kd: 921.707
min_temp: 0
max_temp: 135
[fan]
pin: PA0
[mcu]
serial: /dev/serial/by-id/usb-1a86_USB_Serial-if00-port0
restart_method: command
[printer]
kinematics: cartesian
max_velocity: 300
max_accel: 3000
max_z_velocity: 5
max_z_accel: 100
[display]
lcd_type: st7920
cs_pin: PB12
sclk_pin: PB13
sid_pin: PB15
encoder_pins: ^PB14, ^PB10
click_pin: ^!PB2

View File

@ -1,16 +1,25 @@
# This file contains common pin mappings for the stock Elegoo
# Neptune 2 with a MKS Robin Nano (v1.2.004) board. To use this
# config, the firmware should be compiled for the STM32F103. When
# running "make menuconfig", enable "extra low-level configuration
# setup", select the 28KiB bootloader, and serial (on # USART3
# PB11/PB10) communication.
# Note that the "make flash" command does not work with MKS Robin
# boards. After running "make", run the following command:
# This file contains standard pin mappings for the stock Elegoo Neptune 2 with a
# ZNP Robin Nano (v 1.2 and v1.3) board.
# For the 1.2 board:
# - Compile with the processor model STM32F103.
# - Enable "extra low-level configuration options"
# - Select the 28KiB bootloader,
# - Select (Serial (on # USART3 PB11/PB10) for the communication interface.
# Note that the "make flash" command does not work with ZNP Robin boards. After
# running "make", run the following command:
# ./scripts/update_mks_robin.py out/klipper.bin out/elegoo.bin
# Copy the file out/elegoo.bin to an SD card and then restart the
# printer with that SD card.
#
# For the 1.3 board:
# - Compile with the processor model STM32F407.
# - Enable "extra low-level configuration options"
# - Select the 32KiB bootloader,
# - Select (Serial (on # USART3 PB11/PB10) for the communication interface.
# Note that the "make flash" command does not work with ZNP Robin boards. After
# running "make", run the following command:
# cp out/klipper.bin out/elegoo.bin
#
# Copy the file out/elegoo.bin to an SD card and then restart the printer with
# that SD card.
# See docs/Config_Reference.md for a description of parameters.
[stepper_x]
@ -51,7 +60,7 @@ step_pin: PD6
dir_pin: PD3
enable_pin: !PB3
microsteps: 16
rotation_distance: 34.406
rotation_distance: 34.406 # use 23.809 as a base before calibration for a 2s
nozzle_diameter: 0.400
filament_diameter: 1.750
heater_pin: PC3
@ -79,7 +88,7 @@ pid_Kp: 70.857
pid_Ki: 1.221
pid_Kd: 1028.316
min_temp: 0
max_temp: 130
max_temp: 110
[heater_fan hotend_fan]
pin: PB0
@ -93,6 +102,12 @@ pin: PB1
serial: /dev/ttyUSB0
restart_method: command
[bed_screws]
screw1: 32.5, 32.5
screw2: 32.5, 202.5
screw3: 202.5, 32.5
screw4: 202.5, 202.5
[printer]
kinematics: cartesian
max_velocity: 300

View File

@ -0,0 +1,141 @@
# This file contains common pin mappings for the Monoprice
# Select Mini v1. To use this config, the firmware should be compiled for the
# STM32F103 microcontroller with an 8MHz crystal and USB for communication.
#
# Use the following settings in make menuconfig:
#
# * Enable extra low-level configuration options: Enable
# * Microcontroller architecture: STM32
# * Processor: STM32F103
# * Bootloader offset: 8KiB bootloader
# * Clockspeed: 8 Mhz crystal
# * Communication interface: USB (on PA11/PA12)
# * GPIO pins to set: PA8, PB1, PB11, PB9
#
# IMPORTANT: A bootloader offset of 8KiB will preserver the stock bootloader
# and allows easy flashing via SDCard without additional hardware.
#
# IMPORTANT: Setting PB9 in the the GPIO pins to set at micro-controller
# startup is required for the USB port to function.
#
# PA8, PB1, PB11 in the GPIO pins deactivates the steppers until klippy
# takes over.
#
# Note 1: Prior to flashing klipper, if possible, make a copy of the default
# or current configuration values for the printer. Running an M503 command
# will output these values.
#
# Note 2: Klipper can be flashed by copying out/klipper.bin to the MPSMv1's
# SDCard, renaming it to update.bin, and creating an empty file on the SD card
# named fcupdate.flg. Insert the SDCard while the printer is off it on. After
# klipper is flashed, remove the SDCard and delete update.bin and fcupdate.flg
# to prevent the firmware from flashing on every subsequent power-on.
# Returning to stock firmware without a programmer is possible as long as the
# bootloader is not overwritten.
#
# Note 3: Stepper directions are not consistent in MSPMv1 printers. Check the
# directions of the printer with M503 in the stock firmware and adjust the
# dir_pins below accordingly.
#
# Note 4: Klipper currently does not support the LCD-UI of this
# printer, which is connected via serial interface and controlled by an
# esp8266 using a custom protocol.
#
# See ../docs/Config_Reference.md file for a description of all parameters.
[stepper_x]
homing_speed: 15
step_pin: PB14
dir_pin: !PB15 # modify stepper direction if necessary
enable_pin: !PA8
# rotation_distance varies in the printer model. Check the correct
# step-rate of the Select Mini in the original firmware (with M503)
# and calculate the appropriate value for rotation_distance. This has
# to be done for all axes.
microsteps: 16
rotation_distance: 34.510 # 17 teeth on pulley; MXL belt (2.03 pitch)
endstop_pin: ^!PB4
position_endstop: 0
position_max: 120 # default bed width
position_min: 0
[stepper_y]
homing_speed: 15
step_pin: PB12
dir_pin: PB13 # modify stepper direction if necessary
enable_pin: !PA8
microsteps: 16
rotation_distance: 34.510 # check comment in [stepper_x] section
endstop_pin: ^!PA15
position_endstop: 0
position_max: 120 # default bed length
position_min: 0
[stepper_z]
homing_speed: 10
step_pin: PB10
dir_pin: PB2 # modify stepper direction if necessary
enable_pin: !PB11
microsteps: 16
full_steps_per_rotation: 48
rotation_distance: 0.7 # M4 rod. check comment in [stepper_x] section
endstop_pin: ^!PB5
position_endstop: 0.5
position_max: 120 # default height
[extruder]
# extruder stepper
step_pin: PB0
dir_pin: !PC13 # modify stepper direction if necessary
enable_pin: !PB1
microsteps: 16
rotation_distance: 32.990 # 97 steps/mm. check comment in [stepper_x] section
nozzle_diameter: 0.400
filament_diameter: 1.750
# heater
heater_pin: PB6
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PA0
control: pid
pid_kp: 20.00
pid_ki: 0.02
pid_kd: 250.00
# temperatures
min_temp: 0
max_temp: 250
max_extrude_only_distance: 425 #for (un-)loading
[heater_bed]
heater_pin: PB7
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PA1
control: pid
pid_kp: 70.00
pid_ki: 1.50
pid_kd: 812.00
min_temp: 0
max_temp: 85
# Print cooling fan
[heater_fan hotend_fan]
pin: PB8
heater: extruder
heater_temp: 45.0
[mcu]
serial: /dev/ttyACM0
restart_method: command
[printer]
kinematics: cartesian
max_velocity: 150
max_accel: 800
max_z_velocity: 1.5
max_z_accel: 20
# Positions for BED_SCREWS_ADJUST levelling with bed screws still accessible
[bed_screws]
screw1: 22, 10
screw2: 22, 90
screw3: 98, 90
screw4: 98, 10

View File

@ -15,7 +15,7 @@
# Also make sure to use the following string in the low-level configuration
# options to set a couple of GPIOs to high when the MCU boots:
#
# PA8, PB5, PB1
# PA8, PB11, PB1
#
# This will deactivate the steppers until klippy takes over.
#

View File

@ -91,11 +91,9 @@ pid_Kd: 898.279
[heater_fan hotend_fan]
pin: PG14
fan_speed: 0.5
[fan]
pin: PG13
max_power: 0.5
[controller_fan drivers_fan]
pin: PD6

View File

@ -1,18 +1,20 @@
# This file contains common pin mappings for the Two Trees Sapphire
# Plus printer from 2020 (revision 2 with dual Z axis).
# Plus V1 (SP-5) printer (Robin Nano 1.2, 2208 drivers for X,Y and A4988 for Zs,E).
# INSTRUCTIONS FOR COMPILING
# To use this config, the firmware should be compiled for the STM32F103.
# When running "make menuconfig" you have to:
# - enable "extra low-level configuration setup",
# - select the 28KiB bootloader,
# - select serial (on USART3 PB11/PB10) communication
# - set "GPIO pins to set at micro-controller startup" to "!PC6,!PD13"
# When running "make menuconfig", enable "extra low-level configuration setup",
# select the 28KiB bootloader, serial (on USART3 PB11/PB10) to use USB communication
# or serial (on USART1 PA10/PA9) to use direct UART connection with Raspberry trough wifi pins.
# Set "GPIO pins to set at micro-controller startup" to "!PC6,!PD13" to turn off display at startup.
# Note that the "make flash" command does not work with the Sapphire
# Pro. After running "make", run the following command:
# INSTRUCTIONS FOR FLASHING, THE SCRIPT IS COMPULSORY OR IT WON'T WORK!!!
# Note that the "make flash" command does not work with the Robin Nano!
# After running "make", run the following command in one row FROM THE KLIPPER FOLDER:
# ./scripts/update_mks_robin.py out/klipper.bin out/Robin_nano35.bin
# Copy the file out/Robin_nano35.bin to an SD card and then restart the
# printer with that SD card.
# Copy the file out/Robin_nano35.bin (if you can't find the file the script was not executed)
# to an SD card and then restart the printer with that SD card.
# If you removed the LCD screen rename the file to "Robin_nano43.bin" for correct flashing.
# See docs/Config_Reference.md for a description of parameters.
@ -54,12 +56,11 @@ dir_pin: PA1
enable_pin: !PA3
microsteps: 16
rotation_distance: 8
endstop_pin: !PC4
[extruder]
step_pin: PD6
dir_pin: !PD3
enable_pin: !PB3
enable_pin: PB3
microsteps: 16
gear_ratio: 50:17
rotation_distance: 23.52
@ -86,6 +87,9 @@ pid_Kp: 325.10
pid_Ki: 63.35
pid_Kd: 417.10
[heater_fan extruder]
pin: PB0
[fan]
pin: PB1
@ -97,8 +101,14 @@ restart_method: command
kinematics: corexy
max_velocity: 250
max_accel: 4500
max_z_velocity: 25
max_z_velocity: 15
max_z_accel: 100
[bed_screws]
screw1: 35,35
screw2: 275,35
screw3: 275,275
screw4: 35,275
[static_digital_output reset_display]
pins: !PC6, !PD13

View File

@ -0,0 +1,114 @@
# This file contains common pin mappings for the Two Trees Sapphire
# Plus V1.1 (SP-5) printer (Robin Nano 1.2, all 2225 drivers at 32 microsteps).
# INSTRUCTIONS FOR COMPILING
# To use this config, the firmware should be compiled for the STM32F103.
# When running "make menuconfig", enable "extra low-level configuration setup",
# select the 28KiB bootloader, serial (on USART3 PB11/PB10) to use USB communication
# or serial (on USART1 PA10/PA9) to use direct UART connection with Raspberry trough wifi pins.
# Set "GPIO pins to set at micro-controller startup" to "!PC6,!PD13" to turn off display at startup.
# INSTRUCTIONS FOR FLASHING, THE SCRIPT IS COMPULSORY OR IT WON'T WORK!!!
# Note that the "make flash" command does not work with the Robin Nano!
# After running "make", run the following command in one row FROM THE KLIPPER FOLDER:
# ./scripts/update_mks_robin.py out/klipper.bin out/Robin_nano35.bin
# Copy the file out/Robin_nano35.bin (if you can't find the file the script was not executed)
# to an SD card and then restart the printer with that SD card.
# If you removed the LCD screen rename the file to "Robin_nano43.bin" for correct flashing.
# See docs/Config_Reference.md for a description of parameters.
[stepper_x]
step_pin: PE3
dir_pin: !PE2
enable_pin: !PE4
microsteps: 32
rotation_distance: 40
endstop_pin: !PA15
position_endstop: 0
position_max: 300
homing_speed: 50
[stepper_y]
step_pin: PE0
dir_pin: !PB9
enable_pin: !PE1
microsteps: 32
rotation_distance: 40
endstop_pin: !PA12
position_endstop: 300
position_max: 300
homing_speed: 50
[stepper_z]
step_pin: PB5
dir_pin: !PB4
enable_pin: !PB8
microsteps: 32
rotation_distance: 8
endstop_pin: !PA11
position_endstop: 0
position_max: 340
[stepper_z1]
step_pin: PA6
dir_pin: !PA1
enable_pin: !PA3
microsteps: 32
rotation_distance: 8
[extruder]
step_pin: PD6
dir_pin: !PD3
enable_pin: !PB3
microsteps: 32
gear_ratio: 50:17
rotation_distance: 23.52
nozzle_diameter: 0.400
filament_diameter: 1.750
heater_pin: PC3
sensor_type: EPCOS 100K B57560G104F # Stock
sensor_pin: PC1
min_temp: 0
max_temp: 250
control: pid
pid_Kp: 17.48
pid_Ki: 1.32
pid_Kd: 57.81
[heater_bed]
heater_pin: PA0
sensor_type: EPCOS 100K B57560G104F # Stock
sensor_pin: PC0
min_temp: 0
max_temp: 130
control: pid
pid_Kp: 325.10
pid_Ki: 63.35
pid_Kd: 417.10
[heater_fan extruder]
pin: PB0
[fan]
pin: PB1
[mcu]
serial: /dev/ttyUSB0
restart_method: command
[printer]
kinematics: corexy
max_velocity: 250
max_accel: 4500
max_z_velocity: 15
max_z_accel: 100
[bed_screws]
screw1: 35,35
screw2: 275,35
screw3: 275,275
screw4: 35,275
[static_digital_output reset_display]
pins: !PC6, !PD13

View File

@ -1,92 +0,0 @@
# This file contains common pin mappings for the Two Trees Sapphire
# Pro printer from 2020. To use this config, the firmware should be
# compiled for the STM32F103. When running "make menuconfig", enable
# "extra low-level configuration setup", select the 28KiB bootloader,
# serial (on USART3 PB11/PB10) communication, and set "GPIO pins to
# set at micro-controller startup" to "!PC6,!PD13".
# Note that the "make flash" command does not work with the Sapphire
# Pro. After running "make", run the following command:
# ./scripts/update_mks_robin.py out/klipper.bin out/Robin_nano35.bin
# Copy the file out/Robin_nano35.bin to an SD card and then restart the
# printer with that SD card.
# See docs/Config_Reference.md for a description of parameters.
[stepper_x]
step_pin: PE3
dir_pin: !PE2
enable_pin: !PE4
microsteps: 16
rotation_distance: 32
endstop_pin: !PA15
position_endstop: 0
position_max: 230
homing_speed: 50
[stepper_y]
step_pin: PE0
dir_pin: !PB9
enable_pin: !PE1
microsteps: 16
rotation_distance: 32
endstop_pin: !PA12
position_endstop: 230
position_max: 230
homing_speed: 50
[stepper_z]
step_pin: PB5
dir_pin: PB4
enable_pin: !PB8
microsteps: 16
rotation_distance: 8
endstop_pin: !PA11
position_endstop: 0.5
position_max: 230
[extruder]
step_pin: PD6
dir_pin: !PD3
enable_pin: !PB3
microsteps: 16
rotation_distance: 6.720
nozzle_diameter: 0.400
filament_diameter: 1.750
heater_pin: PC3
sensor_type: ATC Semitec 104GT-2
sensor_pin: PC1
control: pid
pid_Kp: 14.669
pid_Ki: 0.572
pid_Kd: 94.068
min_temp: 0
max_temp: 250
[heater_bed]
heater_pin: PA0
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PC0
control: pid
pid_Kp: 325.10
pid_Ki: 63.35
pid_Kd: 417.10
min_temp: 0
max_temp: 130
[fan]
pin: PB1
[mcu]
serial: /dev/ttyUSB0
restart_method: command
[printer]
kinematics: corexy
max_velocity: 250
max_accel: 4500
max_z_velocity: 25
max_z_accel: 100
[static_digital_output reset_display]
pins: !PC6, !PD13

View File

@ -0,0 +1,107 @@
# This file contains common pin mappings for the Two Trees Sapphire
# Pro (SP-3) printer (Robin Nano 1.2, 2208 drivers for X,Y and A4988 for Z,E).
# INSTRUCTIONS FOR COMPILING
# To use this config, the firmware should be compiled for the STM32F103.
# When running "make menuconfig", enable "extra low-level configuration setup",
# select the 28KiB bootloader, serial (on USART3 PB11/PB10) to use USB communication
# or serial (on USART1 PA10/PA9) to use direct UART connection with Raspberry trough wifi pins.
# Set "GPIO pins to set at micro-controller startup" to "!PC6,!PD13" to turn off display at startup.
# INSTRUCTIONS FOR FLASHING, THE SCRIPT IS COMPULSORY OR IT WON'T WORK!!!
# Note that the "make flash" command does not work with the Robin Nano!
# After running "make", run the following command in one row FROM THE KLIPPER FOLDER:
# ./scripts/update_mks_robin.py out/klipper.bin out/Robin_nano35.bin
# Copy the file out/Robin_nano35.bin (if you can't find the file the script was not executed)
# to an SD card and then restart the printer with that SD card.
# If you removed the LCD screen rename the file to "Robin_nano43.bin" for correct flashing.
# See docs/Config_Reference.md for a description of parameters.
[stepper_x]
step_pin: PE3
dir_pin: !PE2
enable_pin: !PE4
microsteps: 16
rotation_distance: 40
endstop_pin: !PA15
position_endstop: 0
position_max: 230
homing_speed: 50
[stepper_y]
step_pin: PE0
dir_pin: !PB9
enable_pin: !PE1
microsteps: 16
rotation_distance: 40
endstop_pin: !PA12
position_endstop: 230
position_max: 230
homing_speed: 50
[stepper_z]
step_pin: PB5
dir_pin: PB4
enable_pin: !PB8
microsteps: 16
rotation_distance: 2
endstop_pin: !PA11
position_endstop: 0.5
position_max: 230
[extruder]
step_pin: PD6
dir_pin: !PD3
enable_pin: !PB3
microsteps: 16
gear_ratio: 50:17
rotation_distance: 23.52
nozzle_diameter: 0.400
filament_diameter: 1.750
heater_pin: PC3
sensor_type: ATC Semitec 104GT-2
sensor_pin: PC1
control: pid
pid_Kp: 14.669
pid_Ki: 0.572
pid_Kd: 94.068
min_temp: 0
max_temp: 250
[heater_bed]
heater_pin: PA0
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PC0
control: pid
pid_Kp: 325.10
pid_Ki: 63.35
pid_Kd: 417.10
min_temp: 0
max_temp: 130
[heater_fan extruder]
pin: PB0
[fan]
pin: PB1
[mcu]
serial: /dev/ttyUSB0
restart_method: command
[printer]
kinematics: corexy
max_velocity: 250
max_accel: 4500
max_z_velocity: 10
max_z_accel: 80
[bed_screws]
screw1: 15,15
screw2: 210,15
screw3: 210,210
screw4: 15,210
[static_digital_output reset_display]
pins: !PC6, !PD13

View File

@ -168,3 +168,4 @@ sclk_pin: PD3
sid_pin: PC0
encoder_pins: ^PA2, ^PA1
click_pin: ^!PA3
kill_pin: ^!PD2

View File

@ -16,6 +16,10 @@ This causes the host software to create a Unix Domain Socket. A client
can then open a connection on that socket and send commands to
Klipper.
See the [Moonraker](https://github.com/Arksine/moonraker) project for
a popular tool that can forward HTTP requests to Klipper's API Server
Unix Domain Socket.
## Request format
Messages sent and received on the socket are JSON encoded strings
@ -341,6 +345,25 @@ and might later produce asynchronous messages such as:
The "header" field in the initial query response is used to describe
the fields found in later "data" responses.
### angle/dump_angle
This endpoint is used to subscribe to
[angle sensor data](Config_Reference.md#angle). Obtaining these
low-level motion updates may be useful for diagnostic and debugging
purposes. Using this endpoint may increase Klipper's system load.
A request may look like:
`{"id": 123, "method":"angle/dump_angle",
"params": {"sensor": "my_angle_sensor", "response_template": {}}}`
and might return:
`{"id": 123,"result":{"header":["time","angle"]}}`
and might later produce asynchronous messages such as:
`{"params":{"position_offset":3.151562,"errors":0,
"data":[[1290.951905,-5063],[1290.952321,-5065]]}}`
The "header" field in the initial query response is used to describe
the fields found in later "data" responses.
### pause_resume/cancel
This endpoint is similar to running the "PRINT_CANCEL" G-Code command.

View File

@ -64,9 +64,10 @@ run `BLTOUCH_DEBUG COMMAND=touch_mode`, run `QUERY_PROBE`, and verify
that command reports "probe: open". Then while gently pushing the pin
up slightly with the nail of your finger run `QUERY_PROBE` again.
Verify the command reports "probe: TRIGGERED". If either query does
not report the correct message then check your wiring and
configuration again. At the completion of this test run `BLTOUCH_DEBUG
COMMAND=pin_up` and verify that the pin moves up.
not report the correct message then it usually indicates an incorrect
wiring or configuration (though some [clones](#bl-touch-clones) may
require special handling). At the completion of this test run
`BLTOUCH_DEBUG COMMAND=pin_up` and verify that the pin moves up.
After completing the BL-Touch control pin and sensor pin tests, it is
now time to test probing, but with a twist. Instead of letting the
@ -106,7 +107,8 @@ commands to achieve this.
## BL-Touch "clones"
Many BL-Touch "clone" devices work correctly with Klipper using the
default configuration. However, some "clone" devices may require
default configuration. However, some "clone" devices may not support
the `QUERY_PROBE` command and some "clone" devices may require
configuration of `pin_up_reports_not_triggered` or
`pin_up_touch_mode_reports_triggered`.
@ -116,6 +118,16 @@ these directions. Do not configure either of these to False on a
genuine BL-Touch. Incorrectly setting these to False can increase
probing time and can increase the risk of damaging the printer.
Some "clone" devices do not support `touch_mode` and as a result the
`QUERY_PROBE` command does not work. Despite this, it may still be
possible to perform probing and homing with these devices. On these
devices the `QUERY_PROBE` command during the
[initial tests](#initial-tests) will not succeed, however the
subsequent `G28` (or `PROBE`) test does succeed. It may be possible to
use these "clone" devices with Klipper if one does not utilize the
`QUERY_PROBE` command and one does not enable the
`probe_with_touch_mode` feature.
Some "clone" devices are unable to perform Klipper's internal sensor
verification test. On these devices, attempts to home or probe can
result in Klipper reporting a "BLTouch failed to verify sensor state"

View File

@ -63,7 +63,7 @@ test".
In order to perform the paper test, cut a small rectangular piece of
paper using a pair of scissors (eg, 5x3 cm). The paper generally has a
width of around 100 microns (0.100mm). (The exact width of the paper
thickness of around 100 microns (0.100mm). (The exact thickness of the paper
isn't crucial.)
The first step of the paper test is to inspect the printer's nozzle
@ -74,7 +74,7 @@ or bed.
If one always prints on a particular tape or printing surface then one
may perform the paper test with that tape/surface in place. However,
note that tape itself has a width and different tapes (or any other
note that tape itself has a thickness and different tapes (or any other
printing surface) will impact Z measurements. Be sure to rerun the
paper test to measure each type of surface that is in use.
@ -89,11 +89,11 @@ temperature!**
When the nozzle is heated, its position (relative to the bed) changes
due to thermal expansion. This thermal expansion is typically around a
100 microns, which is about the same width as a typical piece of
100 microns, which is about the same thickness as a typical piece of
printer paper. The exact amount of thermal expansion isn't crucial,
just as the exact width of the paper isn't crucial. Start with the
just as the exact thickness of the paper isn't crucial. Start with the
assumption that the two are equal (see below for a method of
determining the difference between the two widths).
determining the difference between the two distances).
It may seem odd to calibrate the distance at room temperature when the
goal is to have a consistent distance when heated. However, if one
@ -180,7 +180,7 @@ command to exit the calibration tool.
After successfully performing bed leveling, one may go on to calculate
a more precise value for the combined impact of "thermal expansion",
"width of the paper", and "amount of friction felt during the paper
"thickness of the paper", and "amount of friction felt during the paper
test".
This type of calculation is generally not needed as most users find

View File

@ -51,7 +51,7 @@ probe_count: 5,3
- `probe_count: 5, 3`\
_Default Value: 3, 3_\
The number of points to probe on each axis, specified as x,y integer
The number of points to probe on each axis, specified as X, Y integer
values. In this example 5 points will be probed along the X axis, with
3 points along the Y axis, for a total of 15 probed points. Note that
if you wanted a square grid, for example 3x3, this could be specified
@ -137,8 +137,8 @@ bicubic_tension: 0.2
_Default Value: 2, 2_\
The `mesh_pps` option is shorthand for Mesh Points Per Segment. This
option specifies how many points to interpolate for each segment along
the x and y axes. Consider a 'segment' to be the space between each
probed point. Like `probe_count`, `mesh_pps` is specified as an x,y
the X and Y axes. Consider a 'segment' to be the space between each
probed point. Like `probe_count`, `mesh_pps` is specified as an X, Y
integer pair, and also may be specified a single integer that is applied
to both axes. In this example there are 4 segments along the X axis
and 2 segments along the Y axis. This evaluates to 8 interpolated

View File

@ -248,6 +248,25 @@ results were obtained by running an STM32F407 binary on an STM32F446
| 1 stepper | 46 |
| 3 stepper | 205 |
### STM32G0B1 step rate benchmark
The following configuration sequence is used on the STM32G0B1:
```
allocate_oids count=3
config_stepper oid=0 step_pin=PB13 dir_pin=PB12 invert_step=-1 step_pulse_ticks=0
config_stepper oid=1 step_pin=PB10 dir_pin=PB2 invert_step=-1 step_pulse_ticks=0
config_stepper oid=2 step_pin=PB0 dir_pin=PC5 invert_step=-1 step_pulse_ticks=0
finalize_config crc=0
```
The test was last run on commit `247cd753` with gcc version
`arm-none-eabi-gcc (Fedora 10.2.0-4.fc34) 10.2.0`.
| stm32g0b1 | ticks |
| ---------------- | ----- |
| 1 stepper | 58 |
| 3 stepper | 243 |
### LPC176x step rate benchmark
The following configuration sequence is used on the LPC176x:

View File

@ -254,10 +254,11 @@ bossac -U -p /dev/ttyACM0 --offset=0x4000 -w out/klipper.bin -v -b -R
## STM32F103 micro-controllers (Blue Pill devices)
The STM32F103 devices have a ROM that can flash a bootloader or
application via 3.3V serial. To access this ROM, one should connect
the "boot 0" pin to high and "boot 1" pin to low, and then reset the
device. The "stm32flash" package can then be used to flash the device
using something like:
application via 3.3V serial. Typically one would wire the PA10 (MCU
Rx) and PA9 (MCU Tx) pins to a 3.3V UART adapter. To access the ROM,
one should connect the "boot 0" pin to high and "boot 1" pin to low,
and then reset the device. The "stm32flash" package can then be used
to flash the device using something like:
```
stm32flash -w out/klipper.bin -v -g 0 /dev/ttyAMA0
```
@ -385,6 +386,66 @@ not available, so it may be done by setting pin PA2 low if you flashed
the SKR Mini E3's "PIN" document. There is a ground pin next to PA2
which you can use to pull PA2 low.
### STM32F103/STM32F072 with MSC bootloader
The [MSC bootloader](https://github.com/Telekatz/MSC-stm32f103-bootloader) is a driverless bootloader capable of flashing over USB.
It is possible to flash the bootloader via 3.3v serial using stm32flash as noted
in the stm32duino section above, substituting the file name for the desired
MSC bootloader binary (ie: MSCboot-Bluepill.bin for the blue pill).
For STM32F072 boards it is also possible to flash the bootloader over USB (via DFU)
with something like:
```
dfu-util -d 0483:df11 -a 0 -R -D MSCboot-STM32F072.bin -s0x08000000:leave
```
This bootloader uses 8KiB or 16KiB of flash space, see description of the bootloader
(the application must be compiled with with the corresponding starting address).
The bootloader can be activated by pressing the reset button of the board twice.
As soon as the bootloader is activated, the board appears as a USB flash drive
onto which the klipper.bin file can be copied.
### STM32F103/STM32F0x2 with CanBoot bootloader
The [CanBoot](https://github.com/Arksine/CanBoot) bootloader provides an option
for uploading Klipper firmware over the CANBUS. The bootloader itself is
derived from Klipper's source code. Currently CanBoot supports the STM32F103,
STM32F042, and STM32F072 models.
It is recommended to use a ST-Link Programmer to flash CanBoot, however it
should be possible to flash using `stm32flash` on STM32F103 devices, and
`dfu-util` on STM32F042/STM32F072 devices. See the previous sections in this
document for instructions on these flashing methods, substituting `canboot.bin`
for the file name where appropriate. The CanBoot repo linked above provides
instructions for building the bootloader.
The first time CanBoot has been flashed it should detect that no application
is present and enter the bootloader. If this doesn't occur it is possible to
enter the bootloader by pressing the reset button twice in succession.
The `flash_can.py` utility supplied in the `lib/canboot` folder may be used to
upload Klipper firmware. The device UUID is necessary to flash. If you do not
have a UUID it is possible to query nodes currently running the bootloader:
```
python3 flash_can.py -q
```
This will return UUIDs for all connected nodes not currently assigned a UUID.
This should include all nodes currently in the bootloader.
Once you have a UUID, you may upload firmware with following command:
```
python3 flash_can.py -i can0 -f ~/klipper/out/klipper.bin -u aabbccddeeff
```
Where `aabbccddeeff` is replaced by your UUID. Note that the `-i` and `-f`
options may be omitted, they default to `can0` and `~/klipper/out/klipper.bin`
respectively.
When building Klipper for use with CanBoot, select the 8 KiB Bootloader option.
## STM32F4 micro-controllers (SKR Pro 1.1)
STM32F4 microcontrollers come equipped with a built-in system bootloader

View File

@ -8,7 +8,7 @@ Klipper currently only supports CAN on stm32 chips. In addition, the
micro-controller chip must support CAN and it must be on a board that
has a CAN transceiver.
To compile for CAN, run "make menuconfig" and select "CAN bus" as the
To compile for CAN, run `make menuconfig` and select "CAN bus" as the
communication interface. Finally, compile the micro-controller code
and flash it to the target board.

View File

@ -73,7 +73,60 @@ Common things a reviewer will look for:
Updates to documentation should not declare that they are a "work
in progress".
2. Is the copyright of the submission clear, non-gratuitous, and
2. Does the submission provide a "high impact" benefit to real-world
users performing real-world tasks?
Reviewers need to identify, at least in their own minds, roughly
"who the target audience is", a rough scale of "the size of that
audience", the "benefit" they will obtain, how the "benefit is
measured", and the "results of those measurement tests". In most
cases this will be obvious to both the submitter and the reviewer,
and it is not explicitly stated during a review.
Submissions to the master Klipper branch are expected to have a
noteworthy target audience. As a general "rule of thumb",
submissions should target a user base of at least a 100 real-world
users.
If a reviewer asks for details on the "benefit" of a submission,
please don't consider it criticism. Being able to understand the
real-world benefits of a change is a natural part of a review.
When discussing benefits it is preferable to discuss "facts and
measurements". In general, reviewers are not looking for responses
of the form "someone may find option X useful", nor are they
looking for responses of the form "this submission adds a feature
that firmware X implements". Instead, it is generally preferable to
discuss details on how the quality improvement was measured and
what were the results of those measurements - for example, "tests
on Acme X1000 printers show improved corners as seen in picture
...", or for example "print time of real-world object X on a
Foomatic X900 printer went from 4 hours to 3.5 hours". It is
understood that testing of this type can take significant time and
effort. Some of Klipper's most notable features took months of
discussion, rework, testing, and documentation prior to being
merged into the master branch.
All new modules, config options, commands, command parameters, and
documents should have "high impact". We do not want to burden users
with options that they can not reasonably configure nor do we want
to burden them with options that don't provide a notable benefit.
A reviewer may ask for clarification on how a user is to configure
an option - an ideal response will contain details on the process -
for example, "users of the MegaX500 are expected to set option X to
99.3 while users of the Elite100Y are expected to calibrate option
X using procedure ...".
If the goal of an option is to make the code more modular then
prefer using code constants instead of user facing config options.
New modules, new options, and new parameters should not provide
similar functionality to existing modules - if the differences are
arbitrary than it's preferable to utilize the existing system or
refactor the existing code.
3. Is the copyright of the submission clear, non-gratuitous, and
compatible?
New C files and Python files should have an unambiguous copyright
@ -91,14 +144,14 @@ Common things a reviewer will look for:
real name. It indicates the submitter agrees with the
[developer certificate of origin](developer-certificate-of-origin).
3. Does the submission follow guidelines specified in the Klipper
4. Does the submission follow guidelines specified in the Klipper
documentation?
In particular, code should follow the guidelines in
[Code_Overview.md](Code_Overview.md) and config files should follow
the guidelines in [Example_Configs.md](Example_Configs.md).
4. Is the Klipper documentation updated to reflect new changes?
5. Is the Klipper documentation updated to reflect new changes?
At a minimum, the reference documentation must be updated with
corresponding changes to the code:
@ -118,7 +171,7 @@ Common things a reviewer will look for:
added to the website index
[docs/_klipper3d/mkdocs.yml](../docs/_klipper3d/mkdocs.yml).
5. Are commits well formed, address a single topic per commit, and
6. Are commits well formed, address a single topic per commit, and
independent?
Commit messages should follow the
@ -140,61 +193,6 @@ Common things a reviewer will look for:
general, gratuitous whitespace changes are not accepted unless they
are from the established "owner" of the code being modified.
6. Does the submission provide a "high impact" benefit to real-world
users performing real-world tasks?
Reviewers need to identify, at least in their own minds, roughly
"who the target audience is", a rough scale of "the size of that
audience", the "benefit" they will obtain, how the "benefit is
measured", and the "results of those measurement tests". In most
cases this will be obvious to both the submitter and the reviewer,
and it is not explicitly stated during a review.
Submissions to the master Klipper branch are expected to have a
noteworthy target audience. As a general "rule of thumb",
submissions should target a user base of at least a 100 real-world
users.
If a reviewer asks for details on the "benefit" of a submission,
please don't consider it criticism. Being able to understand the
real-world benefits of a change is a natural part of a review.
When discussing benefits it is preferable to discuss "facts and
measurements" instead of "opinions and theories". In general,
reviewers are not looking for responses of the form "this
submission may improve quality because of ...", nor are they
looking for responses of the form "someone may find option X
useful", nor are they looking for responses of the form "this
submission adds a feature that firmware X implements". Instead, it
is generally preferable to discuss details on how the quality
improvement was measured and what were the results of those
measurements - for example, "tests on Acme X1000 printers show
improved corners as seen in picture ...", or for example "print
time of real-world object X on a Foomatic X900 printer went from 4
hours to 3.5 hours". It is understood that testing of this type can
take significant time and effort. Some of Klipper's most notable
features took years of discussion, rework, testing, and
documentation prior to being merged into the master branch.
All new modules, config options, commands, command parameters, and
documents should have "high impact". We do not want to burden users
with options that they can not reasonably configure nor do we want
to burden them with options that don't provide a notable benefit.
A reviewer may ask for clarification on how a user is to configure
an option - an ideal response will contain details on the process -
for example, "users of the MegaX500 are expected to set option X to
99.3 while users of the Elite100Y are expected to calibrate option
X using procedure ...".
If the goal of an option is to make the code more modular then
prefer using code constants instead of user facing config options.
New modules, new options, and new parameters should not provide
similar functionality to existing modules - if the differences are
arbitrary than it's preferable to utilize the existing system or
refactor the existing code.
Klipper does not implement a strict "coding style guide", but
modifications to existing code should follow the high-level code flow,
code indentation style, and format of that existing code. Submissions
@ -301,15 +299,13 @@ contributions) and contain a current email address.
[Klipper-translations Project](https://github.com/Klipper3d/klipper-translations)
is a project dedicated to translating Klipper to different languages.
[Weblate](https://hosted.weblate.org/projects/klipper/) hosts all the
Gettext strings for translating and reviewing. Locales can merge into
the Klipper project once they satisfy the following requirements:
Gettext strings for translating and reviewing. Locales can be displayed on
[klipper3d.org](https://www.klipper3d.org) once they satisfy the following requirements:
- [ ] 75% Total coverage
- [ ] All titles (H1) are covered
- [ ] All titles (H1) are translated
- [ ] An updated navigation hierarchy PR in klipper-translations.
The navigation hierarchy is in `docs\_klipper3d\mkdocs.yml`.
To reduce the frustration of translating domain-specific terms and
gain awareness of the ongoing translations, you can submit a PR
modifying the
@ -321,15 +317,15 @@ If a translation already exists in the Klipper repository and no
longer meets the checklist above, it will be marked out-of-date after
a month without updates.
Please follow the following format for `mkdocs.yml` navigation
hierarchy:
Once the requirements are met, you need to:
```yml
nav:
- existing hierachy
- <language>:
- locales/<language code>/md file
```
1. update klipper-tranlations repository
[active_translations](https://github.com/Klipper3d/klipper-translations/blob/translations/active_translations)
2. Optional: add a manual-index.md file in klipper-translations repository's
`docs\locals\<lang>` folder to replace the language specific index.md (generated
index.md does not render correctly).
Note: Currently, there isn't a method for correctly translating
pictures in the documentation.
Known Issues:
1. Currently, there isn't a method for correctly translating pictures in
the documentation
2. It is impossible to translate titles in mkdocs.yml.

View File

@ -58,9 +58,12 @@ functions are declared using the DECL_COMMAND() macro (see the
Task, init, and command functions always run with interrupts enabled
(however, they can temporarily disable interrupts if needed). These
functions should never pause, delay, or do any work that lasts more
than a few micro-seconds. These functions schedule work at specific
times by scheduling timers.
functions should avoid long pauses, delays, or do work that lasts a
significant time. (Long delays in these "task" functions result in
scheduling jitter for other "tasks" - delays over 100us may become
noticeable, delays over 500us may result in command retransmissions,
delays over 100ms may result in watchdog reboots.) These functions
schedule work at specific times by scheduling timers.
Timer functions are scheduled by calling sched_add_timer() (located in
**src/sched.c**). The scheduler code will arrange for the given

View File

@ -45,8 +45,7 @@ gcode:
SET_PIN PIN=my_led VALUE=0
```
This will be showing is you use the `HELP` command or use the autocomplete
function.
The terminal will display the description when you use the `HELP` command or the autocomplete function.
## Save/Restore state for G-Code moves

View File

@ -8,6 +8,55 @@ All dates in this document are approximate.
## Changes
20220407: The temperature_fan `pid_integral_max` config option has
been removed (it was deprecated on 20210612).
20220407: The default color order for pca9632 LEDs is now "RGBW". Add
an explicit `color_order: RBGW` setting to the pca9632 config section
to obtain the previous behavior.
20220330: The format of the `printer.neopixel.color_data` status
information for neopixel and dotstar modules has changed. The
information is now stored as a list of color lists (instead of a list
of dictionaries). See the [status reference](Status_Reference.md#led)
for details.
20220307: `M73` will no longer set print progress to 0 if `P` is missing.
20220304: There is no longer a default for the `extruder` parameter of
[extruder_stepper](Config_Reference.md#extruder_stepper) config
sections. If desired, specify `extruder: extruder` explicitly to
associate the stepper motor with the "extruder" motion queue at
startup.
20220210: The `SYNC_STEPPER_TO_EXTRUDER` command is deprecated; the
`SET_EXTRUDER_STEP_DISTANCE` command is deprecated; the
[extruder](Config_Reference.md#extruder) `shared_heater` config option
is deprecated. These features will be removed in the near future.
Replace `SET_EXTRUDER_STEP_DISTANCE` with
`SET_EXTRUDER_ROTATION_DISTANCE`. Replace `SYNC_STEPPER_TO_EXTRUDER`
with `SYNC_EXTRUDER_MOTION`. Replace extruder config sections using
`shared_heater` with
[extruder_stepper](Config_Reference.md#extruder_stepper) config
sections and update any activation macros to use
[SYNC_EXTRUDER_MOTION](G-Codes.md#sync_extruder_motion).
20220116: The tmc2130, tmc2208, tmc2209, and tmc2660 `run_current`
calculation code has changed. For some `run_current` settings the
drivers may now be configured differently. This new configuration
should be more accurate, but it may invalidate previous tmc driver
tuning.
20211230: Scripts to tune input shaper (`scripts/calibrate_shaper.py`
and `scripts/graph_accelerometer.py`) were migrated to use Python3
by default. As a result, users must install Python3 versions of certain
packages (e.g. `sudo apt install python3-numpy python3-matplotlib`) to
continue using these scripts. For more details, refer to
[Software installation](Measuring_Resonances.md#software-installation).
Alternatively, users can temporarily force the execution of these scripts
under Python 2 by explicitly calling Python2 interpretor in the console:
`python2 ~/klipper/scripts/calibrate_shaper.py ...`
20211110: The "NTC 100K beta 3950" temperature sensor is deprecated.
This sensor will be removed in the near future. Most users will find
the "Generic 3950" temperature sensor more accurate. To continue to

View File

@ -84,7 +84,7 @@ The printer section controls high level printer settings.
[printer]
kinematics:
# The type of printer in use. This option may be one of: cartesian,
# corexy, corexz, hybrid-corexy, hybrid-corexz, rotary_delta, delta,
# corexy, corexz, hybrid_corexy, hybrid_corexz, rotary_delta, delta,
# polar, winch, or none. This
# parameter must be specified.
max_velocity:
@ -462,21 +462,12 @@ Only parameters specific to polar printers are described here - see
[common kinematic settings](#common-kinematic-settings) for available
parameters.
POLAR KINEMATICS ARE A WORK IN PROGRESS. Moves around the `0,0`
POLAR KINEMATICS ARE A WORK IN PROGRESS. Moves around the 0, 0
position are known to not work properly.
```
[printer]
kinematics: polar
# The stepper_bed section is used to describe the stepper controlling
# the bed.
[stepper_bed]
gear_ratio:
# A gear_ratio must be specified and rotation_distance may not be
# specified. For example, if the bed has an 80 toothed pulley driven
# by a stepper with a 16 toothed pulley then one would specify a
# gear ratio of "80:16". This parameter must be provided.
max_z_velocity:
# This sets the maximum velocity (in mm/s) of movement along the z
# axis. This setting can be used to restrict the maximum speed of
@ -487,6 +478,15 @@ max_z_accel:
# the z axis. It limits the acceleration of the z stepper motor. The
# default is to use max_accel for max_z_accel.
# The stepper_bed section is used to describe the stepper controlling
# the bed.
[stepper_bed]
gear_ratio:
# A gear_ratio must be specified and rotation_distance may not be
# specified. For example, if the bed has an 80 toothed pulley driven
# by a stepper with a 16 toothed pulley then one would specify a
# gear ratio of "80:16". This parameter must be provided.
# The stepper_arm section is used to describe the stepper controlling
# the carriage on the arm.
[stepper_arm]
@ -615,7 +615,7 @@ rotation_distance:
anchor_x:
anchor_y:
anchor_z:
# The x, y, and z position of the cable winch in cartesian space.
# The X, Y, and Z position of the cable winch in cartesian space.
# These parameters must be provided.
```
@ -638,10 +638,11 @@ max_accel: 1
### [extruder]
The extruder section is used to describe both the stepper controlling
the printer extruder and the heater parameters for the nozzle. See the
[pressure advance guide](Pressure_Advance.md) for information on
tuning pressure advance.
The extruder section is used to describe the heater parameters for the
nozzle hotend along with the stepper controlling the extruder. See the
[command reference](G-Codes.md#extruder) for additional information.
See the [pressure advance guide](Pressure_Advance.md) for information
on tuning pressure advance.
```
[extruder]
@ -652,7 +653,10 @@ microsteps:
rotation_distance:
#full_steps_per_rotation:
#gear_ratio:
# See the "stepper" section for a description of the above parameters.
# See the "stepper" section for a description of the above
# parameters. If none of the above parameters are specified then no
# stepper will be associated with the nozzle hotend (though a
# SYNC_EXTRUDER_MOTION command may associate one at run-time).
nozzle_diameter:
# Diameter of the nozzle orifice (in mm). This parameter must be
# provided.
@ -728,14 +732,17 @@ control:
# Control algorithm (either pid or watermark). This parameter must
# be provided.
pid_Kp:
# Kp is the "proportional" constant for the pid. This parameter must
# be provided for PID heaters.
pid_Ki:
# Ki is the "integral" constant for the pid. This parameter must be
# provided for PID heaters.
pid_Kd:
# Kd is the "derivative" constant for the pid. This parameter must
# be provided for PID heaters.
# The proportional (pid_Kp), integral (pid_Ki), and derivative
# (pid_Kd) settings for the PID feedback control system. Klipper
# evaluates the PID settings with the following general formula:
# heater_pwm = (Kp*error + Ki*integral(error) - Kd*derivative(error)) / 255
# Where "error" is "requested_temperature - measured_temperature"
# and "heater_pwm" is the requested heating rate with 0.0 being full
# off and 1.0 being full on. Consider using the PID_CALIBRATE
# command to obtain these parameters. The pid_Kp, pid_Ki, and pid_Kd
# parameters must be provided for PID heaters.
#max_delta: 2.0
# On 'watermark' controlled heaters this is the number of degrees in
# Celsius above the target temperature before disabling the heater
@ -788,8 +795,7 @@ recommended to define a safe_z_home section in printer.cfg to home
toward the center of the print area.
See the [bed mesh guide](Bed_Mesh.md) and
[command reference](G-Codes.md#mesh-bed-leveling) for additional
information.
[command reference](G-Codes.md#bed_mesh) for additional information.
Visual Examples:
```
@ -826,24 +832,24 @@ Visual Examples:
# mesh_origin option. This parameter must be provided for round beds
# and omitted for rectangular beds.
#mesh_origin:
# Defines the center x,y coordinate of the mesh for round beds. This
# Defines the center X, Y coordinate of the mesh for round beds. This
# coordinate is relative to the probe's location. It may be useful
# to adjust the mesh_origin in an effort to maximize the size of the
# mesh radius. Default is 0, 0. This parameter must be omitted for
# rectangular beds.
#mesh_min:
# Defines the minimum x,y coordinate of the mesh for rectangular
# Defines the minimum X, Y coordinate of the mesh for rectangular
# beds. This coordinate is relative to the probe's location. This
# will be the first point probed, nearest to the origin. This
# parameter must be provided for rectangular beds.
#mesh_max:
# Defines the maximum x,y coordinate of the mesh for rectangular
# Defines the maximum X, Y coordinate of the mesh for rectangular
# beds. Adheres to the same principle as mesh_min, however this will
# be the furthest point probed from the bed's origin. This parameter
# must be provided for rectangular beds.
#probe_count: 3, 3
# For rectangular beds, this is a comma separate pair of integer
# values (X,Y) defining the number of points to probe along each
# values X, Y defining the number of points to probe along each
# axis. A single value is also valid, in which case that value will
# be applied to both axes. Default is 3, 3.
#round_probe_count: 5
@ -872,7 +878,7 @@ Visual Examples:
# This is also the minimum length that a move can be split. Default
# is 5.0.
#mesh_pps: 2, 2
# A comma separated pair of integers (X,Y) defining the number of
# A comma separated pair of integers X, Y defining the number of
# points per segment to interpolate in the mesh along each axis. A
# "segment" can be defined as the space between each probed point.
# The user may enter a single value which will be applied to both
@ -903,7 +909,7 @@ Bed tilt compensation. One may define a bed_tilt config section to
enable move transformations that account for a tilted bed. Note that
bed_mesh and bed_tilt are incompatible; both cannot be defined.
See the [command reference](G-Codes.md#bed-tilt) for additional
See the [command reference](G-Codes.md#bed_tilt) for additional
information.
```
@ -941,8 +947,7 @@ config section to enable a BED_SCREWS_ADJUST g-code command.
See the
[leveling guide](Manual_Level.md#adjusting-bed-leveling-screws) and
[command reference](G-Codes.md#bed-screws-helper) for additional
information.
[command reference](G-Codes.md#bed_screws) for additional information.
```
[bed_screws]
@ -987,17 +992,17 @@ g-code command.
See the
[leveling guide](Manual_Level.md#adjusting-bed-leveling-screws-using-the-bed-probe)
and [command reference](G-Codes.md#bed-screws-tilt-adjust-helper) for
additional information.
and [command reference](G-Codes.md#screws_tilt_adjust) for additional
information.
```
[screws_tilt_adjust]
#screw1:
# The X,Y coordinate of the first bed leveling screw. This is a
# position to command the nozzle to that is directly above the bed
# screw (or as close as possible while still being above the bed).
# This is the base screw used in calculations. This parameter must
# be provided.
# The (X, Y) coordinate of the first bed leveling screw. This is a
# position to command the nozzle to so that the probe is directly
# above the bed screw (or as close as possible while still being
# above the bed). This is the base screw used in calculations. This
# parameter must be provided.
#screw1_name:
# An arbitrary name for the given screw. This name is displayed when
# the helper script runs. The default is to use a name based upon
@ -1027,7 +1032,7 @@ additional information.
Multiple Z stepper tilt adjustment. This feature enables independent
adjustment of multiple z steppers (see the "stepper_z1" section) to
adjust for tilt. If this section is present then a Z_TILT_ADJUST
extended [G-Code command](G-Codes.md#z-tilt) becomes available.
extended [G-Code command](G-Codes.md#z_tilt) becomes available.
```
[z_tilt]
@ -1035,7 +1040,7 @@ extended [G-Code command](G-Codes.md#z-tilt) becomes available.
# A list of X, Y coordinates (one per line; subsequent lines
# indented) describing the location of each bed "pivot point". The
# "pivot point" is the point where the bed attaches to the given Z
# stepper. It is described using nozzle coordinates (the XY position
# stepper. It is described using nozzle coordinates (the X, Y position
# of the nozzle if it could move directly above the point). The
# first entry corresponds to stepper_z, the second to stepper_z1,
# the third to stepper_z2, etc. This parameter must be provided.
@ -1082,7 +1087,7 @@ configuration:
|Z Z3|
----------------
```
Where x is the (0,0) point on the bed
Where x is the 0, 0 point on the bed
```
[quad_gantry_level]
@ -1120,7 +1125,7 @@ printer skew across 3 planes, xy, xz, yz. This is done by printing a
calibration model along a plane and measuring three lengths. Due to
the nature of skew correction these lengths are set via gcode. See
[Skew Correction](Skew_Correction.md) and
[Command Reference](G-Codes.md#skew-correction) for details.
[Command Reference](G-Codes.md#skew_correction) for details.
```
[skew_correction]
@ -1131,7 +1136,7 @@ the nature of skew correction these lengths are set via gcode. See
### [safe_z_home]
Safe Z homing. One may use this mechanism to home the Z axis at a
specific XY coordinate. This is useful if the toolhead, for example
specific X, Y coordinate. This is useful if the toolhead, for example
has to move to the center of the bed before Z can be homed.
```
@ -1153,8 +1158,8 @@ home_xy_position:
# Speed (in mm/s) at which the Z axis is lifted prior to homing. The
# default is 20mm/s.
#move_to_previous: False
# When set to True, xy are reset to their previous positions after z
# homing. The default is False.
# When set to True, the X and Y axes are reset to their previous
# positions after Z axis homing. The default is False.
```
### [homing_override]
@ -1199,8 +1204,8 @@ endstop switches. Add a bare "[endstop_phase]" declaration to enable
the ENDSTOP_PHASE_CALIBRATE command.
See the [endstop phases guide](Endstop_Phase.md) and
[command reference](G-Codes.md#endstop-adjustments-by-stepper-phase)
for additional information.
[command reference](G-Codes.md#endstop_phase) for additional
information.
```
[endstop_phase stepper_z]
@ -1265,7 +1270,7 @@ G-Code macros (one may define any number of sections with a
Execute a gcode on a set delay. See the
[command template guide](Command_Templates.md#delayed-gcodes) and
[command reference](G-Codes.md#delayed-gcode) for more information.
[command reference](G-Codes.md#delayed_gcode) for more information.
```
[delayed_gcode my_delayed_gcode]
@ -1287,7 +1292,7 @@ gcode:
Support saving variables to disk so that they are retained across
restarts. See
[command templates](Command_Templates.md#save-variables-to-disk) and
[G-Code reference](G-Codes.md#save-variables) for further information.
[G-Code reference](G-Codes.md#save_variables) for further information.
```
[save_variables]
@ -1338,7 +1343,7 @@ a belt printer, can find use in looping sections of the sdcard file.
(For example, to print the same part over and over, or repeat the
a section of a part for a chain or other repeated pattern).
See the [command reference](G-Codes.md#sdcard-loop) for supported
See the [command reference](G-Codes.md#sdcard_loop) for supported
commands. See the [sample-macros.cfg](../config/sample-macros.cfg)
file for a Marlin compatible M808 G-Code macro.
@ -1350,7 +1355,7 @@ file for a Marlin compatible M808 G-Code macro.
Support manually moving stepper motors for diagnostic purposes. Note,
using this feature may place the printer in an invalid state - see the
[command reference](G-Codes.md#force-movement) for important details.
[command reference](G-Codes.md#force_move) for important details.
```
[force_move]
@ -1362,7 +1367,7 @@ using this feature may place the printer in an invalid state - see the
### [pause_resume]
Pause/Resume functionality with support of position capture and
restore. See the [command reference](G-Codes.md#pause-resume) for more
restore. See the [command reference](G-Codes.md#pause_resume) for more
information.
```
@ -1377,7 +1382,7 @@ information.
Firmware filament retraction. This enables G10 (retract) and G11
(unretract) GCODE commands issued by many slicers. The parameters
below provide startup defaults, although the values can be adjusted
via the SET_RETRACTION [command](G-Codes.md#firmware-retraction)),
via the SET_RETRACTION [command](G-Codes.md#firmware_retraction)),
allowing per-filament settings and runtime tuning.
```
@ -1412,7 +1417,7 @@ Support for gcode arc (G2/G3) commands.
### [respond]
Enable the "M118" and "RESPOND" extended
[commands](G-Codes.md#send-message-respond-to-host).
[commands](G-Codes.md#respond).
```
[respond]
@ -1432,7 +1437,7 @@ Enable the "M118" and "RESPOND" extended
### [input_shaper]
Enables [resonance compensation](Resonance_Compensation.md). Also see
the [command reference](G-Codes.md#resonance-compensation).
the [command reference](G-Codes.md#input_shaper).
```
[input_shaper]
@ -1471,10 +1476,9 @@ the [command reference](G-Codes.md#resonance-compensation).
Support for ADXL345 accelerometers. This support allows one to query
accelerometer measurements from the sensor. This enables an
ACCELEROMETER_MEASURE command (see
[G-Codes](G-Codes.md#adxl345-accelerometer-commands) for more
information). The default chip name is "default", but one may specify
an explicit name (eg, [adxl345 my_chip_name]).
ACCELEROMETER_MEASURE command (see [G-Codes](G-Codes.md#adxl345) for
more information). The default chip name is "default", but one may
specify an explicit name (eg, [adxl345 my_chip_name]).
```
[adxl345]
@ -1490,10 +1494,10 @@ cs_pin:
# See the "common SPI settings" section for a description of the
# above parameters.
#axes_map: x, y, z
# The accelerometer axis for each of the printer's x, y, and z axes.
# The accelerometer axis for each of the printer's X, Y, and Z axes.
# This may be useful if the accelerometer is mounted in an
# orientation that does not match the printer orientation. For
# example, one could set this to "y,x,z" to swap the x and y axes.
# example, one could set this to "y, x, z" to swap the X and Y axes.
# It is also possible to negate an axis if the accelerometer
# direction is reversed (eg, "x, z, -y"). The default is "x, y, z".
#rate: 3200
@ -1510,7 +1514,7 @@ Support for resonance testing and automatic input shaper calibration.
In order to use most of the functionality of this module, additional
software dependencies must be installed; refer to
[Measuring Resonances](Measuring_Resonances.md) and the
[command reference](G-Codes.md#resonance-testing-commands) for more
[command reference](G-Codes.md#resonance_tester) for more
information. See the [Max smoothing](Measuring_Resonances.md#max-smoothing)
section of the measuring resonances guide for more information on
`max_smoothing` parameter and its use.
@ -1544,8 +1548,8 @@ section of the measuring resonances guide for more information on
# for more details on using this feature.
#min_freq: 5
# Minimum frequency to test for resonances. The default is 5 Hz.
#max_freq: 120
# Maximum frequency to test for resonances. The default is 120 Hz.
#max_freq: 133.33
# Maximum frequency to test for resonances. The default is 133.33 Hz.
#accel_per_hz: 75
# This parameter is used to determine which acceleration to use to
# test a specific frequency: accel = accel_per_hz * freq. Higher the
@ -1733,6 +1737,7 @@ control_pin:
#y_offset:
#z_offset:
#speed:
#lift_speed:
#samples:
#sample_retract_dist:
#samples_result:
@ -1741,6 +1746,60 @@ control_pin:
# See the "probe" section for information on these parameters.
```
### [smart_effector]
The "Smart Effector" from Duet3d implements a Z probe using a force
sensor. One may define this section instead of `[probe]` to enable the
Smart Effector specific features. This also enables
[runtime commands](G-Codes.md#smart_effector) to adjust the parameters
of the Smart Effector at run time.
```
[smart_effector]
pin:
# Pin connected to the Smart Effector Z Probe output pin (pin 5). Note that
# pullup resistor on the board is generally not required. However, if the
# output pin is connected to the board pin with a pullup resistor, that
# resistor must be high value (e.g. 10K Ohm or more). Some boards have a low
# value pullup resistor on the Z probe input, which will likely result in an
# always-triggered probe state. In this case, connect the Smart Effector to
# a different pin on the board. This parameter is required.
#control_pin:
# Pin connected to the Smart Effector control input pin (pin 7). If provided,
# Smart Effector sensitivity programming commands become available.
#probe_accel:
# If set, limits the acceleration of the probing moves (in mm/sec^2).
# A sudden large acceleration at the beginning of the probing move may
# cause spurious probe triggering, especially if the hotend is heavy.
# To prevent that, it may be necessary to reduce the acceleration of
# the probing moves via this parameter.
#recovery_time: 0.4
# A delay between the travel moves and the probing moves in seconds. A fast
# travel move prior to probing may result in a spurious probe triggering.
# This may cause 'Probe triggered prior to movement' errors if no delay
# is set. Value 0 disables the recovery delay.
# Default value is 0.4.
#x_offset:
#y_offset:
# Should be left unset (or set to 0).
z_offset:
# Trigger height of the probe. Start with -0.1 (mm), and adjust later using
# `PROBE_CALIBRATE` command. This parameter must be provided.
#speed:
# Speed (in mm/s) of the Z axis when probing. It is recommended to start
# with the probing speed of 20 mm/s and adjust it as necessary to improve
# the accuracy and repeatability of the probe triggering.
#samples:
#sample_retract_dist:
#samples_result:
#samples_tolerance:
#samples_tolerance_retries:
#activate_gcode:
#deactivate_gcode:
#deactivate_on_each_sample:
# See the "probe" section for more information on the parameters above.
```
## Additional stepper motors and extruders
### [stepper_z1]
@ -1784,12 +1843,7 @@ for an example configuration.
# See the "extruder" section for available stepper and heater
# parameters.
#shared_heater:
# If this extruder uses the same heater already defined for another
# extruder then place the name of that extruder here. For example,
# should extruder3 and extruder4 share a heater then the extruder3
# config section should define the heater and the extruder4 section
# should specify "shared_heater: extruder3". The default is to not
# reuse an existing heater.
# This option is deprecated and should no longer be specified.
```
### [dual_carriage]
@ -1829,14 +1883,14 @@ Support for additional steppers synchronized to the movement of an
extruder (one may define any number of sections with an
"extruder_stepper" prefix).
See the [command reference](G-Codes.md#extruder-stepper-commands) for
more information.
See the [command reference](G-Codes.md#extruder) for more information.
```
[extruder_stepper my_extra_stepper]
#extruder: extruder
# The extruder this stepper is synchronized to. The default is
# "extruder".
extruder:
# The extruder this stepper is synchronized to. If this is set to an
# empty string then the stepper will not be synchronized to an
# extruder. This parameter must be provided.
#step_pin:
#dir_pin:
#enable_pin:
@ -1852,9 +1906,9 @@ Manual steppers (one may define any number of sections with a
"manual_stepper" prefix). These are steppers that are controlled by
the MANUAL_STEPPER g-code command. For example: "MANUAL_STEPPER
STEPPER=my_stepper MOVE=10 SPEED=5". See
[G-Codes](G-Codes.md#manual-stepper-commands) file for a description
of the MANUAL_STEPPER command. The steppers are not connected to the
normal printer kinematics.
[G-Codes](G-Codes.md#manual_stepper) file for a description of the
MANUAL_STEPPER command. The steppers are not connected to the normal
printer kinematics.
```
[manual_stepper my_stepper]
@ -2009,8 +2063,8 @@ section.
Generic heaters (one may define any number of sections with a
"heater_generic" prefix). These heaters behave similarly to standard
heaters (extruders, heated beds). Use the SET_HEATER_TEMPERATURE
command (see [G-Codes](G-Codes.md) for details) to set the target
temperature.
command (see [G-Codes](G-Codes.md#heaters) for details) to set the
target temperature.
```
[heater_generic my_generic_heater]
@ -2210,7 +2264,7 @@ sensor_type:
### LM75 temperature sensor
LM75/LM75A two wire (I2C) connected temperature sensors. These sensors
have range up to 125 C, so are usable for e.g. chamber temperature
have a range of -55~125 C, so are usable for e.g. chamber temperature
monitoring. They can also function as simple fan/heater controllers.
```
@ -2444,8 +2498,8 @@ fan that will be enabled whenever its associated sensor is above a set
temperature. By default, a temperature_fan has a shutdown_speed equal
to max_power.
See the [command reference](G-Codes.md#temperature-fan-commands) for
additional information.
See the [command reference](G-Codes.md#temperature_fan) for additional
information.
```
[temperature_fan my_temp_fan]
@ -2463,14 +2517,25 @@ additional information.
#sensor_type:
#sensor_pin:
#control:
#pid_Kp:
#pid_Ki:
#pid_Kd:
#pid_deriv_time:
#max_delta:
#min_temp:
#max_temp:
# See the "extruder" section for a description of the above parameters.
#pid_Kp:
#pid_Ki:
#pid_Kd:
# The proportional (pid_Kp), integral (pid_Ki), and derivative
# (pid_Kd) settings for the PID feedback control system. Klipper
# evaluates the PID settings with the following general formula:
# fan_pwm = max_power - (Kp*e + Ki*integral(e) - Kd*derivative(e)) / 255
# Where "e" is "target_temperature - measured_temperature" and
# "fan_pwm" is the requested fan rate with 0.0 being full off and
# 1.0 being full on. The pid_Kp, pid_Ki, and pid_Kd parameters must
# be provided when the PID control algorithm is enabled.
#pid_deriv_time: 2.0
# A time value (in seconds) over which temperature measurements will
# be smoothed when using the PID control algorithm. This may reduce
# the impact of measurement noise. The default is 2 seconds.
#target_temp: 40.0
# A temperature (in Celsius) that will be the target temperature.
# The default is 40 degrees.
@ -2491,8 +2556,7 @@ additional information.
Manually controlled fan (one may define any number of sections with a
"fan_generic" prefix). The speed of a manually controlled fan is set
with the SET_FAN_SPEED
[gcode command](G-Codes.md#manually-controlled-fans-commands).
with the SET_FAN_SPEED [gcode command](G-Codes.md#fan_generic).
```
[fan_generic extruder_partfan]
@ -2509,13 +2573,151 @@ with the SET_FAN_SPEED
# See the "fan" section for a description of the above parameters.
```
## Additional servos, LEDs, buttons, and other pins
## LEDs
### [led]
Support for LEDs (and LED strips) controlled via micro-controller PWM
pins (one may define any number of sections with an "led" prefix). See
the [command reference](G-Codes.md#led) for more information.
```
[led my_led]
#red_pin:
#green_pin:
#blue_pin:
#white_pin:
# The pin controlling the given LED color. At least one of the above
# parameters must be provided.
#cycle_time: 0.010
# The amount of time (in seconds) per PWM cycle. It is recommended
# this be 10 milliseconds or greater when using software based PWM.
# The default is 0.010 seconds.
#hardware_pwm: False
# Enable this to use hardware PWM instead of software PWM. When
# using hardware PWM the actual cycle time is constrained by the
# implementation and may be significantly different than the
# requested cycle_time. The default is False.
#initial_RED: 0.0
#initial_GREEN: 0.0
#initial_BLUE: 0.0
#initial_WHITE: 0.0
# Sets the initial LED color. Each value should be between 0.0 and
# 1.0. The default for each color is 0.
```
### [neopixel]
Neopixel (aka WS2812) LED support (one may define any number of
sections with a "neopixel" prefix). See the
[command reference](G-Codes.md#led) for more information.
Note that the [linux mcu](RPi_microcontroller.md) implementation does
not currently support directly connected neopixels. The current design
using the Linux kernel interface does not allow this scenario because
the kernel GPIO interface is not fast enough to provide the required
pulse rates.
```
[neopixel my_neopixel]
pin:
# The pin connected to the neopixel. This parameter must be
# provided.
#chain_count:
# The number of Neopixel chips that are "daisy chained" to the
# provided pin. The default is 1 (which indicates only a single
# Neopixel is connected to the pin).
#color_order: GRB
# Set the pixel order required by the LED hardware (using a string
# containing the letters R, G, B, W with W optional). Alternatively,
# this may be a comma separated list of pixel orders - one for each
# LED in the chain. The default is GRB.
#initial_RED: 0.0
#initial_GREEN: 0.0
#initial_BLUE: 0.0
#initial_WHITE: 0.0
# See the "led" section for information on these parameters.
```
### [dotstar]
Dotstar (aka APA102) LED support (one may define any number of
sections with a "dotstar" prefix). See the
[command reference](G-Codes.md#led) for more information.
```
[dotstar my_dotstar]
data_pin:
# The pin connected to the data line of the dotstar. This parameter
# must be provided.
clock_pin:
# The pin connected to the clock line of the dotstar. This parameter
# must be provided.
#chain_count:
# See the "neopixel" section for information on this parameter.
#initial_RED: 0.0
#initial_GREEN: 0.0
#initial_BLUE: 0.0
# See the "led" section for information on these parameters.
```
### [pca9533]
PCA9533 LED support. The PCA9533 is used on the mightyboard.
```
[pca9533 my_pca9533]
#i2c_address: 98
# The i2c address that the chip is using on the i2c bus. Use 98 for
# the PCA9533/1, 99 for the PCA9533/2. The default is 98.
#i2c_mcu:
#i2c_bus:
#i2c_speed:
# See the "common I2C settings" section for a description of the
# above parameters.
#initial_RED: 0.0
#initial_GREEN: 0.0
#initial_BLUE: 0.0
#initial_WHITE: 0.0
# See the "led" section for information on these parameters.
```
### [pca9632]
PCA9632 LED support. The PCA9632 is used on the FlashForge Dreamer.
```
[pca9632 my_pca9632]
#i2c_address: 98
# The i2c address that the chip is using on the i2c bus. This may be
# 96, 97, 98, or 99. The default is 98.
#i2c_mcu:
#i2c_bus:
#i2c_speed:
# See the "common I2C settings" section for a description of the
# above parameters.
#scl_pin:
#sda_pin:
# Alternatively, if the pca9632 is not connected to a hardware I2C
# bus, then one may specify the "clock" (scl_pin) and "data"
# (sda_pin) pins. The default is to use hardware I2C.
#color_order: RGBW
# Set the pixel order of the LED (using a string containing the
# letters R, G, B, W). The default is RGBW.
#initial_RED: 0.0
#initial_GREEN: 0.0
#initial_BLUE: 0.0
#initial_WHITE: 0.0
# See the "led" section for information on these parameters.
```
## Additional servos, buttons, and other pins
### [servo]
Servos (one may define any number of sections with a "servo"
prefix). The servos may be controlled using the SET_SERVO
[g-code command](G-Codes.md#servo-commands). For example: SET_SERVO
[g-code command](G-Codes.md#servo). For example: SET_SERVO
SERVO=my_servo ANGLE=180
```
@ -2542,80 +2744,6 @@ pin:
# send any signal at startup.
```
### [neopixel]
Neopixel (aka WS2812) LED support (one may define any number of
sections with a "neopixel" prefix). One may set the LED color via
"SET_LED LED=my_neopixel RED=0.1 GREEN=0.1 BLUE=0.1" type extended
[g-code commands](G-Codes.md#neopixel-and-dotstar-commands).
```
[neopixel my_neopixel]
pin:
# The pin connected to the neopixel. This parameter must be
# provided.
#chain_count:
# The number of Neopixel chips that are "daisy chained" to the
# provided pin. The default is 1 (which indicates only a single
# Neopixel is connected to the pin).
#color_order: GRB
# Set the pixel order required by the LED hardware. Options are GRB,
# RGB, GRBW, or RGBW. The default is GRB.
#initial_RED: 0.0
#initial_GREEN: 0.0
#initial_BLUE: 0.0
#initial_WHITE: 0.0
# Sets the initial LED color of the Neopixel. Each value should be
# between 0.0 and 1.0. The WHITE option is only available on RGBW
# LEDs. The default for each color is 0.
```
### [dotstar]
Dotstar (aka APA102) LED support (one may define any number of
sections with a "dotstar" prefix). One may set the LED color via
"SET_LED LED=my_dotstar RED=0.1 GREEN=0.1 BLUE=0.1" type extended
[g-code commands](G-Codes.md#neopixel-and-dotstar-commands).
```
[dotstar my_dotstar]
data_pin:
# The pin connected to the data line of the dotstar. This parameter
# must be provided.
clock_pin:
# The pin connected to the clock line of the dotstar. This parameter
# must be provided.
#chain_count:
#initial_RED: 0.0
#initial_GREEN: 0.0
#initial_BLUE: 0.0
# See the "neopixel" section for information on these parameters.
```
### [PCA9533]
PCA9533 LED support. The PCA9533 is used on the mightyboard.
```
[pca9533 my_pca9533]
#i2c_address: 98
# The i2c address that the chip is using on the i2c bus. Use 98 for
# the PCA9533/1, 99 for the PCA9533/2. The default is 98.
#i2c_mcu:
#i2c_bus:
#i2c_speed:
# See the "common I2C settings" section for a description of the
# above parameters.
#initial_RED: 0
#initial_GREEN: 0
#initial_BLUE: 0
#initial_WHITE: 0
# The PCA9533 only supports 1 or 0. The default is 0. On the
# mightyboard, the white led is not populated.
# Use GCODE to modify led values after startup.
# set_led led=my_pca9533 red=1 green=1 blue=1
```
### [gcode_button]
Execute gcode when a button is pressed or released (or when a pin
@ -2650,7 +2778,7 @@ Run-time configurable output pins (one may define any number of
sections with an "output_pin" prefix). Pins configured here will be
setup as output pins and one may modify them at run-time using
"SET_PIN PIN=my_pin VALUE=.1" type extended
[g-code commands](G-Codes.md#custom-pin-commands).
[g-code commands](G-Codes.md#output_pin).
```
[output_pin my_pin]
@ -2737,7 +2865,7 @@ pins:
Configuration of Trinamic stepper motor drivers in UART/SPI mode.
Additional information is in the [TMC Drivers guide](TMC_Drivers.md)
and in the [command reference](G-Codes.md#tmc-stepper-drivers).
and in the [command reference](G-Codes.md#tmcxxxx).
### [tmc2130]
@ -3314,7 +3442,7 @@ lcd_type:
# button.
```
### hd44780 display
#### hd44780 display
Information on configuring hd44780 displays (which is used in
"RepRapDiscount 2004 Smart Controller" type displays).
@ -3342,7 +3470,7 @@ d7_pin:
...
```
### hd44780_spi display
#### hd44780_spi display
Information on configuring an hd44780_spi display - a 20x04 display
controlled via a hardware "shift register" (which is used in
@ -3372,7 +3500,7 @@ spi_software_miso_pin:
...
```
### st7920 display
#### st7920 display
Information on configuring st7920 displays (which is used in
"RepRapDiscount 12864 Full Graphic Smart Controller" type displays).
@ -3389,7 +3517,7 @@ sid_pin:
...
```
### emulated_st7920 display
#### emulated_st7920 display
Information on configuring an emulated st7920 display - found in some
"2.4 inch touchscreen devices" and similar.
@ -3412,7 +3540,7 @@ spi_software_miso_pin:
...
```
### uc1701 display
#### uc1701 display
Information on configuring uc1701 displays (which is used in "MKS Mini
12864" type displays).
@ -3435,7 +3563,7 @@ a0_pin:
...
```
### ssd1306 and sh1106 displays
#### ssd1306 and sh1106 displays
Information on configuring ssd1306 and sh1106 displays.
@ -3480,7 +3608,7 @@ lcd_type:
...
```
## [display_data]
### [display_data]
Support for displaying custom data on an lcd screen. One may create
any number of display groups and any number of data items under those
@ -3506,15 +3634,21 @@ text:
# parameter must be provided.
```
## [display_template]
### [display_template]
Display data text "macros" (one may define any number of sections with
a display_template prefix). This feature allows one to reduce
repetitive definitions in display_data sections. One may use the
builtin render() function in display_data sections to evaluate a
template. For example, if one were to define `[display_template
my_template]` then one could use `{ render('my_template') }` in a
display_data section.
a display_template prefix). See the
[command templates](Command_Templates.md) document for information on
template evaluation.
This feature allows one to reduce repetitive definitions in
display_data sections. One may use the builtin `render()` function in
display_data sections to evaluate a template. For example, if one were
to define `[display_template my_template]` then one could use `{
render('my_template') }` in a display_data section.
This feature can also be used for continuous LED updates using the
[SET_LED_TEMPLATE](G-Codes.md#set_led_template) command.
```
[display_template my_template_name]
@ -3527,13 +3661,13 @@ display_data section.
# "param_speed = 75" might have a caller with
# "render('my_template_name', param_speed=80)". Parameter names may
# not use upper case characters.
#text:
# The text to return when the render() function is called for this
# template. This field is evaluated using command templates (see
text:
# The text to return when the this template is rendered. This field
# is evaluated using command templates (see
# docs/Command_Templates.md). This parameter must be provided.
```
## [display_glyph]
### [display_glyph]
Display a custom glyph on displays that support it. The given name
will be assigned the given display data which can then be referenced
@ -3563,7 +3697,7 @@ examples.
# required if hd44780_data is specified.
```
## [display my_extra_display]
### [display my_extra_display]
If a primary [display] section has been defined in printer.cfg as
shown above it is possible to define multiple auxiliary displays. Note
@ -3575,7 +3709,7 @@ thus they do not support the "menu" options or button configuration.
# See the "display" section for available parameters.
```
## [menu]
### [menu]
Customizable lcd display menus.
@ -3693,7 +3827,7 @@ type:
### T5UID1 Display
Information on configuring a T5UID1 display. Also see the
[command reference](G-Codes.md#dgus-display-commands).
[command reference](G-Codes.md#dgus_display).
```
[dgus_display]
@ -3716,7 +3850,7 @@ implementation:
The DGUSPrinterMenu T5UID1 implementation supports dynamic menus. It is
designed to work with the
[DGUSPrinterMenu](https://github.com/Desuuuu/DGUSPrinterMenu) touchscreen
firmware. Also see the [command reference](G-Codes.md#dgus-display-commands).
firmware. Also see the [command reference](G-Codes.md#dgus_display).
```
[dgus_display]
@ -3926,7 +4060,7 @@ title:
The debug T5UID1 implementation provides low-level commands for interacting
with the display.
See the [command reference](G-Codes.md#dgus-display-commands) for more
See the [command reference](G-Codes.md#dgus_display) for more
information.
```
@ -3943,8 +4077,8 @@ implementation: debug
Filament Switch Sensor. Support for filament insert and runout
detection using a switch sensor, such as an endstop switch.
See the [command reference](G-Codes.md#filament-sensor) for more
information.
See the [command reference](G-Codes.md#filament_switch_sensor) for
more information.
```
[filament_switch_sensor my_sensor]
@ -3983,8 +4117,8 @@ Filament Motion Sensor. Support for filament insert and runout
detection using an encoder that toggles the output pin during filament
movement through the sensor.
See the [command reference](G-Codes.md#filament-sensor) for more
information.
See the [command reference](G-Codes.md#filament_switch_sensor) for
more information.
```
[filament_motion_sensor my_sensor]
@ -4172,7 +4306,7 @@ example.
```
# The "replicape" config section adds "replicape:stepper_x_enable"
# virtual stepper enable pins (for steppers x, y, z, e, and h) and
# virtual stepper enable pins (for steppers X, Y, Z, E, and H) and
# "replicape:power_x" PWM output pins (for hotbed, e, h, fan0, fan1,
# fan2, and fan3) that may then be used elsewhere in the config file.
[replicape]
@ -4266,6 +4400,40 @@ serial:
# Auto cancel print when ping varation is above this threshold
```
### [angle]
Magnetic hall angle sensor support for reading stepper motor angle
shaft measurements using a1333, as5047d, or tle5012b SPI chips. The
measurements are available via the [API Server](API_Server.md) and
[motion analysis tool](Debugging.md#motion-analysis-and-data-logging).
See the [G-Code reference](G-Codes.md#angle) for available commands.
```
[angle my_angle_sensor]
sensor_type:
# The type of the magnetic hall sensor chip. Available choices are
# "a1333", "as5047d", and "tle5012b". This parameter must be
# specified.
#sample_period: 0.000400
# The query period (in seconds) to use during measurements. The
# default is 0.000400 (which is 2500 samples per second).
#stepper:
# The name of the stepper that the angle sensor is attached to (eg,
# "stepper_x"). Setting this value enables an angle calibration
# tool. To use this feature, the Python "numpy" package must be
# installed. The default is to not enable angle calibration for the
# angle sensor.
cs_pin:
# The SPI enable pin for the sensor. This parameter must be provided.
#spi_speed:
#spi_bus:
#spi_software_sclk_pin:
#spi_software_mosi_pin:
#spi_software_miso_pin:
# See the "common SPI settings" section for a description of the
# above parameters.
```
## Common bus parameters
### Common SPI settings

View File

@ -132,10 +132,10 @@ troubleshooting tips in the previous section to confirm the
Klipper supports
[PID control](https://en.wikipedia.org/wiki/PID_controller) for the
extruder and bed heaters. In order to use this control mechanism it is
necessary to calibrate the PID settings on each printer. (PID settings
extruder and bed heaters. In order to use this control mechanism, it is
necessary to calibrate the PID settings on each printer (PID settings
found in other firmwares or in the example configuration files often
work poorly.)
work poorly).
To calibrate the extruder, navigate to the OctoPrint terminal tab and
run the PID_CALIBRATE command. For example: `PID_CALIBRATE

View File

@ -202,20 +202,33 @@ run this on a desktop class machine (not a Raspberry Pi) as it does
require significant cpu to run efficiently.
To use simulavr, download the simulavr package and compile with python
support:
support. Note that the build system may need to have some packages (such as
swig) installed in order to build the python module.
```
git clone git://git.savannah.nongnu.org/simulavr.git
cd simulavr
./bootstrap
./configure --enable-python
make
make python
make build
```
Make sure a file like **./build/pysimulavr/_pysimulavr.*.so** is present
after the above compilation:
```
ls ./build/pysimulavr/_pysimulavr.*.so
```
This commmand should report a specific file (e.g.
**./build/pysimulavr/_pysimulavr.cpython-39-x86_64-linux-gnu.so**) and
not an error.
Note that the build system may need to have some packages (such as
swig) installed in order to build the python module. Make sure the
file **src/python/_pysimulavr.so** is present after the above
compilation.
If you are on a Debian-based system (Debian, Ubuntu, etc.) you can
install the following packages and generate *.deb files for system-wide
installation of simulavr:
```
sudo apt update
sudo apt install g++ make cmake swig rst2pdf help2man texinfo
make cfgclean python debian
sudo dpkg -i build/debian/python3-simulavr*.deb
```
To compile Klipper for use in simulavr, run:
@ -229,7 +242,12 @@ select SIMULAVR software emulation support. Then one can compile
Klipper (run `make`) and then start the simulation with:
```
PYTHONPATH=/path/to/simulavr/src/python/ ./scripts/avrsim.py out/klipper.elf
PYTHONPATH=/path/to/simulavr/build/pysimulavr/ ./scripts/avrsim.py out/klipper.elf
```
Note that if you have installed python3-simulavr system-wide, you do
not need to set `PYTHONPATH`, and can simply run the simulator as
```
./scripts/avrsim.py out/klipper.elf
```
Then, with simulavr running in another window, one can run the

View File

@ -97,7 +97,11 @@ measuring parts of that test object with digital calipers.
Prior to running an enhanced delta calibration one must run the basic
delta calibration (via the DELTA_CALIBRATE command) and save the
results (via the SAVE_CONFIG command).
results (via the SAVE_CONFIG command). Make sure there hasn't been any
notable change to the printer configuration nor hardware since last
performing a basic delta calibration (if unsure, rerun the
[basic delta calibration](#basic-delta-calibration), including
SAVE_CONFIG, just prior to printing the test object described below.)
Use a slicer to generate G-Code from the
[docs/prints/calibrate_size.stl](prints/calibrate_size.stl) file.

View File

@ -10,7 +10,7 @@ is also a useful resource for finding and sharing config files.
## Guidelines
1. Select the appropriate config filename prefix.
1. Select the appropriate config filename prefix:
1. The `printer` prefix is used for stock printers sold by a
mainstream manufacturer.
2. The `generic` prefix is used for a 3d printer board that may be
@ -24,17 +24,20 @@ is also a useful resource for finding and sharing config files.
5. The `example` prefix is used to describe printer kinematics.
This type of config is typically only added along with code for
a new type of printer kinematics.
2. Use the appropriate filename suffix. The `printer` config files
must end in a year followed by `.cfg` (eg, `-2019.cfg`). In this
case, the year is an approximate year the given printer was
sold. All example configuration files must end in `.cfg`.
3. Klipper must be able to start `printer`, `generic`, and `kit`
2. All configuration files must end in a `.cfg` suffix. The `printer`
config files must end in a year followed by `.cfg` (eg,
`-2019.cfg`). In this case, the year is an approximate year the
given printer was sold.
3. Do not use spaces or special characters in the config filename. The
filename should contain only characters `A-Z`, `a-z`, `0-9`, `-`,
and `.`.
4. Klipper must be able to start `printer`, `generic`, and `kit`
example config file without error. These config files should be
added to the
[test/klippy/printers.test](../test/klippy/printers.test)
regression test case. Add new config files to that test case in the
appropriate section and in alphabetical order within that section.
4. The example configuration should be for the "stock" configuration
5. The example configuration should be for the "stock" configuration
of the printer. (There are too many "customized" configurations to
track in the main Klipper repository.) Similarly, we only add
example config files for printers, kits, and boards that have
@ -42,7 +45,7 @@ is also a useful resource for finding and sharing config files.
in active use). Consider using the
[Klipper Community Discourse server](https://community.klipper3d.org)
for other configs.
5. Only specify those devices present on the given printer or board.
6. Only specify those devices present on the given printer or board.
Do not specify settings specific to your particular setup.
1. For `generic` config files, only those devices on the mainboard
should be described. For example, it would not make sense to add
@ -61,7 +64,7 @@ is also a useful resource for finding and sharing config files.
4. Only define macros that utilize functionality specific to the
given printer or to define g-codes that are commonly emitted by
slicers configured for the given printer.
6. Where possible, it is best to use the same wording, phrasing,
7. Where possible, it is best to use the same wording, phrasing,
indentation, and section ordering as the existing config files.
1. The top of each config file should list the type of
micro-controller the user should select during "make
@ -82,7 +85,9 @@ is also a useful resource for finding and sharing config files.
extruder - it is normally in the range of 20 to 35mm. When
specifying a `gear_ratio` it is preferable to specify the actual
gears on the mechanism (eg, prefer `gear_ratio: 80:20` over
`gear_ratio: 4:1`).
`gear_ratio: 4:1`). See the
[rotation distance document](Rotation_Distance.md#using-a-gear_ratio)
for more information.
6. Avoid defining field values that are set to their default
value. For example, one should not specify `min_extrude_temp:
170` as that is already the default value.
@ -91,13 +96,14 @@ is also a useful resource for finding and sharing config files.
files. (For example, avoid adding lines like "this file was
created by ...".) Place attribution and change history in the
git commit message.
7. Do not use any deprecated features in the example config file. The
`step_distance` and `pin_map` parameters are deprecated and should
not be in any example config file.
8. Do not disable a default safety system in an example config file.
8. Do not use any deprecated features in the example config file.
9. Do not disable a default safety system in an example config file.
For example, a config should not specify a custom
`max_extrude_cross_section`. Do not enable debugging features. For
example there should not be a `force_move` config section.
10. All known boards that Klipper supports can use the default serial
baud rate of 250000. Do not recommend a different baud rate in an
example config file.
Example config files are submitted by creating a github "pull
request". Please also follow the directions in the

View File

@ -15,7 +15,7 @@
13. [My TMC motor driver turns off in the middle of a print](#my-tmc-motor-driver-turns-off-in-the-middle-of-a-print)
14. [I keep getting random "Lost communication with MCU" errors](#i-keep-getting-random-lost-communication-with-mcu-errors)
15. [My Raspberry Pi keeps rebooting during prints](#my-raspberry-pi-keeps-rebooting-during-prints)
16. [When I set "restart_method=command" my AVR device just hangs on a restart](#when-i-set-restart_methodcommand-my-avr-device-just-hangs-on-a-restart)
16. [When I set `restart_method=command` my AVR device just hangs on a restart](#when-i-set-restart_methodcommand-my-avr-device-just-hangs-on-a-restart)
17. [Will the heaters be left on if the Raspberry Pi crashes?](#will-the-heaters-be-left-on-if-the-raspberry-pi-crashes)
18. [How do I convert a Marlin pin number to a Klipper pin name?](#how-do-i-convert-a-marlin-pin-number-to-a-klipper-pin-name)
19. [Do I have to wire my device to a specific type of micro-controller pin?](#do-i-have-to-wire-my-device-to-a-specific-type-of-micro-controller-pin)
@ -293,7 +293,7 @@ troubleshooting steps for a
["Lost communication with MCU"](#i-keep-getting-random-lost-communication-with-mcu-errors)
error.
## When I set "restart_method=command" my AVR device just hangs on a restart
## When I set `restart_method=command` my AVR device just hangs on a restart
Some old versions of the AVR bootloader have a known bug in watchdog
event handling. This typically manifests when the printer.cfg file has

View File

@ -161,19 +161,24 @@ represent total number of steps per second on the micro-controller.
| ------------------------------- | ----------------- | ----------------- |
| 16Mhz AVR | 157K | 99K |
| 20Mhz AVR | 196K | 123K |
| Arduino Zero (SAMD21) | 686K | 471K |
| SAMD21 | 686K | 471K |
| STM32F042 | 814K | 578K |
| Beaglebone PRU | 866K | 708K |
| "Blue Pill" (STM32F103) | 1180K | 818K |
| Arduino Due (SAM3X8E) | 1273K | 981K |
| Duet2 Maestro (SAM4S8C) | 1690K | 1385K |
| Smoothieboard (LPC1768) | 1923K | 1351K |
| Smoothieboard (LPC1769) | 2353K | 1622K |
| Raspberry Pi Pico (RP2040) | 2400K | 1636K |
| Duet2 Wifi/Eth (SAM4E8E) | 2500K | 1674K |
| Adafruit Metro M4 (SAMD51) | 3077K | 1885K |
| BigTreeTech SKR Pro (STM32F407) | 3652K | 2459K |
| Fysetc Spider (STM32F446) | 3913K | 2634K |
| STM32G0B1 | 1103K | 790K |
| STM32F103 | 1180K | 818K |
| SAM3X8E | 1273K | 981K |
| SAM4S8C | 1690K | 1385K |
| LPC1768 | 1923K | 1351K |
| LPC1769 | 2353K | 1622K |
| RP2040 | 2400K | 1636K |
| SAM4E8E | 2500K | 1674K |
| SAMD51 | 3077K | 1885K |
| STM32F407 | 3652K | 2459K |
| STM32F446 | 3913K | 2634K |
If unsure of the micro-controller on a particular board, find the
appropriate [config file](../config/), and look for the
micro-controller name in the comments at the top of that file.
Further details on the benchmarks are available in the
[Benchmarks document](Benchmarks.md).

File diff suppressed because it is too large Load Diff

View File

@ -1,100 +1,26 @@
# Hall filament width sensor
This document describes Filament Width Sensor host module. Hardware used for developing this host module is based on Two Hall liniar sensors (ss49e for example). Sensors in the body are located opposite sides. Principle of operation : two hall sensors work in differential mode, temperature drift same for sensor. Special temperature compensation not needed. You can find designs at [Thingiverse](https://www.thingiverse.com/thing:4138933)
This document describes Filament Width Sensor host module. Hardware used for
developing this host module is based on two Hall linear sensors (ss49e for
example). Sensors in the body are located opposite sides. Principle of operation:
two hall sensors work in differential mode, temperature drift same for sensor.
Special temperature compensation not needed.
You can find designs at [Thingiverse](https://www.thingiverse.com/thing:4138933),
an assembly video is also available on [Youtube](https://www.youtube.com/watch?v=TDO9tME8vp4)
To use Hall filament width sensor, read
[Config Reference](Config_Reference.md#hall_filament_width_sensor) and
[G-Code documentation](G-Codes.md#hall_filament_width_sensor).
[Hall based filament width sensor assembly video](https://www.youtube.com/watch?v=TDO9tME8vp4)
## How does it work?
Sensor generates two analog output based on calculated filament width. Sum of output voltage always equals to detected filament width . Host module monitors voltage changes and adjusts extrusion multiplier. I use aux2 connector on ramps-like board analog11 and analog12 pins. You can use different pins and differenr boards
## Configuration
```
[hall_filament_width_sensor]
adc1: analog11
adc2: analog12
# adc1 and adc2 channels select own pins Analog input pins on 3d printer board
# Sensor power supply can be 3.3v or 5v
Cal_dia1: 1.50 # Reference diameter point 1 (mm)
Cal_dia2: 2.00 # Reference diameter point 2 (mm)
# The measurement principle provides for two-point calibration
# In calibration process you must use rods of known diameter
# I use drill rods as the base diameter.
# nominal filament diameter must be between Cal_dia1 and Cal_dia2
# Your size may differ from the indicated ones, for example 2.05
Raw_dia1:10630 # Raw sensor value for reference point 1
Raw_dia2:8300 # Raw sensor value for reference point 2
# Raw value of sensor in units
# can be readed by command QUERY_RAW_FILAMENT_WIDTH
default_nominal_filament_diameter: 1.75 # This parameter is in millimeters (mm)
max_difference: 0.15
# Maximum allowed filament diameter difference in millimeters (mm)
# If difference between nominal filament diameter and sensor output is more
# than +- max_difference, extrusion multiplier set back to %100
measurement_delay: 70
# The distance from sensor to the melting chamber/hot-end in millimeters (mm).
# The filament between the sensor and the hot-end will be treated as the default_nominal_filament_diameter.
# Host module works with FIFO logic. It keeps each sensor value and position in
# an array and POP them back in correct position.
#enable:False
# Sensor enabled or disabled after power on. Disabled by default
# measurement_interval:10
# Sensor readings done with 10 mm intervals by default. If necessary you are free to change this setting
#logging: False
# Out diameter to terminal and klipper.log
# can be turn on|of by command
#Virtual filament_switch_sensor suppurt. Create sensor named hall_filament_width_sensor.
#
#min_diameter:1.0
#Minimal diameter for trigger virtual filament_switch_sensor.
#use_current_dia_while_delay: False
# Use the current diameter instead of the nominal diamenter while the measurement delay has not run through.
#
#Values from filament_switch_sensor. See the "filament_switch_sensor" section for information on these parameters.
#
#pause_on_runout: True
#runout_gcode:
#insert_gcode:
#event_delay: 3.0
#pause_delay: 0.5
```
## G-Code Commands
**QUERY_FILAMENT_WIDTH** - Return the current measured filament width as result
**RESET_FILAMENT_WIDTH_SENSOR** - Clear all sensor readings. Can be used after filament change.
**DISABLE_FILAMENT_WIDTH_SENSOR** - Turn off the filament width sensor and stop using it to do flow control
**ENABLE_FILAMENT_WIDTH_SENSOR** - Turn on the filament width sensor and start using it to do flow control
**QUERY_RAW_FILAMENT_WIDTH** Return the current ADC channel values and RAW sensor value for calibration points
**ENABLE_FILAMENT_WIDTH_LOG** - Turn on diameter logging
**DISABLE_FILAMENT_WIDTH_LOG** - Turn off diameter logging
## Menu variables
**hall_filament_width_sensor.Diameter** current measured filament width in mm
**hall_filament_width_sensor.Raw** current raw measured filament width in units
**hall_filament_width_sensor.is_active** Sensor on or off
Sensor generates two analog output based on calculated filament width. Sum of
output voltage always equals to detected filament width. Host module monitors
voltage changes and adjusts extrusion multiplier. I use aux2 connector on
ramps-like board analog11 and analog12 pins. You can use different pins and
differenr boards.
## Template for menu variables
@ -114,7 +40,8 @@ index: 1
## Calibration procedure
To get raw sensor value you can use menu item or **QUERY_RAW_FILAMENT_WIDTH** command in terminal
To get raw sensor value you can use menu item or **QUERY_RAW_FILAMENT_WIDTH**
command in terminal.
1. Insert first calibration rod (1.5 mm size) get first raw sensor value
@ -126,12 +53,15 @@ To get raw sensor value you can use menu item or **QUERY_RAW_FILAMENT_WIDTH** co
By default, the sensor is disabled at power-on.
To enable the sensor, issue **ENABLE_FILAMENT_WIDTH_SENSOR** command or set the `enable` parameter to `true.`
To enable the sensor, issue **ENABLE_FILAMENT_WIDTH_SENSOR** command or
set the `enable` parameter to `true`.
## Logging
By default, diameter logging is disabled at power-on.
Issue **ENABLE_FILAMENT_WIDTH_LOG** command to start logging and issue **DISABLE_FILAMENT_WIDTH_LOG** command to stop logging. To enable logging at power-on, set the `logging` parameter to `true`.
Issue **ENABLE_FILAMENT_WIDTH_LOG** command to start logging and issue
**DISABLE_FILAMENT_WIDTH_LOG** command to stop logging. To enable logging
at power-on, set the `logging` parameter to `true`.
Filament diameter is logged on every measurement interval (10 mm by default).

View File

@ -6,10 +6,34 @@ Raspberry Pi 2, 3, or 4 computer be used as the host machine (see the
[FAQ](FAQ.md#can-i-run-klipper-on-something-other-than-a-raspberry-pi-3)
for other machines).
Klipper currently supports a number of Atmel ATmega based
micro-controllers,
[ARM based micro-controllers](Features.md#step-benchmarks), and
[Beaglebone PRU](Beaglebone.md) based printers.
## Obtain a Klipper Configuration File
Most Klipper settings are determined by a "printer configuration file"
that will be stored on the Raspberry Pi. An appropriate configuration
file can often be found by looking in the Klipper
[config directory](../config/) for a file starting with a "printer-"
prefix that corresponds to the target printer. The Klipper
configuration file contains technical information about the printer
that will be needed during the installation.
If there isn't an appropriate printer configuration file in the
Klipper config directory then try searching the printer manufacturer's
website to see if they have an appropriate Klipper configuration file.
If no configuration file for the printer can be found, but the type of
printer control board is known, then look for an appropriate
[config file](../config/) starting with a "generic-" prefix. These
example printer board files should allow one to successfully complete
the initial installation, but will require some customization to
obtain full printer functionality.
It is also possible to define a new printer configuration from
scratch. However, this requires significant technical knowledge about
the printer and its electronics. It is recommended that most users
start with an appropriate configuration file. If creating a new custom
printer configuration file, then start with the closest example
[config file](../config/) and use the Klipper
[config reference](Config_Reference.md) for further information.
## Prepping an OS image
@ -49,16 +73,27 @@ cd ~/klipper/
make menuconfig
```
Select the appropriate micro-controller and review any other options
provided. Once configured, run:
The comments at the top of the
[printer configuration file](#obtain-a-klipper-configuration-file)
should describe the settings that need to be set during "make
menuconfig". Open the file in a web browser or text editor and look
for these instructions near the top of the file. Once the appropriate
"menuconfig" settings have been configured, press "Q" to exit, and
then "Y" to save. Then run:
```
make
```
It is necessary to determine the serial port connected to the
micro-controller. For micro-controllers that connect via USB, run the
following:
If the comments at the top of the
[printer configuration file](#obtain-a-klipper-configuration-file)
describe custom steps for "flashing" the final image to the printer
control board then follow those steps and then proceed to
[configuring OctoPrint](#configuring-octoprint-to-use-klipper).
Otherwise, the following steps are often used to "flash" the printer
control board. First, it is necessary to determine the serial port
connected to the micro-controller. Run the following:
```
ls /dev/serial/by-id/*
@ -122,36 +157,43 @@ Klipper. Proceed to the next section.
## Configuring Klipper
The Klipper configuration is stored in a text file on the Raspberry
Pi. Take a look at the example config files in the
[config directory](../config/). The
[Config Reference](Config_Reference.md) contains documentation on
config parameters.
The next step is to copy the
[printer configuration file](#obtain-a-klipper-configuration-file) to
the Raspberry Pi.
Arguably the easiest way to update the Klipper configuration file is
to use a desktop editor that supports editing files over the "scp"
and/or "sftp" protocols. There are freely available tools that support
this (eg, Notepad++, WinSCP, and Cyberduck). Use one of the example
config files as a starting point and save it as a file named
"printer.cfg" in the home directory of the pi user (ie,
/home/pi/printer.cfg).
Arguably the easiest way to set the Klipper configuration file is to
use a desktop editor that supports editing files over the "scp" and/or
"sftp" protocols. There are freely available tools that support this
(eg, Notepad++, WinSCP, and Cyberduck). Load the printer config file
in the editor and then save it as a file named "printer.cfg" in the
home directory of the pi user (ie, /home/pi/printer.cfg).
Alternatively, one can also copy and edit the file directly on the
Raspberry Pi via ssh - for example:
Raspberry Pi via ssh. That may look something like the following (be
sure to update the command to use the appropriate printer config
filename):
```
cp ~/klipper/config/example-cartesian.cfg ~/printer.cfg
nano ~/printer.cfg
```
Make sure to review and update each setting that is appropriate for
the hardware.
It's common for each printer to have its own unique name for the
micro-controller. The name may change after flashing Klipper, so rerun
the `ls /dev/serial/by-id/*` command and then update the config file
with the unique name. For example, update the `[mcu]` section to look
something similar to:
these steps again even if they were already done when flashing. Run:
```
ls /dev/serial/by-id/*
```
It should report something similar to the following:
```
/dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0
```
Then update the config file with the unique name. For example, update
the `[mcu]` section to look something similar to:
```
[mcu]
@ -162,26 +204,19 @@ After creating and editing the file it will be necessary to issue a
"restart" command in the OctoPrint web terminal to load the config. A
"status" command will report the printer is ready if the Klipper
config file is successfully read and the micro-controller is
successfully found and configured. It is not unusual to have
configuration errors during the initial setup - update the printer
config file and issue "restart" until "status" reports the printer is
ready.
successfully found and configured.
When customizing the printer config file, it is not uncommon for
Klipper to report a configuration error. If an error occurs, make any
necessary corrections to the printer config file and issue "restart"
until "status" reports the printer is ready.
Klipper reports error messages via the OctoPrint terminal tab. The
"status" command can be used to re-report error messages. The default
Klipper startup script also places a log in **/tmp/klippy.log** which
provides more detailed information.
In addition to common g-code commands, Klipper supports a few extended
commands - "status" and "restart" are examples of these commands. Use
the "help" command to get a list of other extended commands.
After Klipper reports that the printer is ready go on to the
After Klipper reports that the printer is ready, proceed to the
[config check document](Config_checks.md) to perform some basic checks
on the pin definitions in the config file.
## Contacting the developers
Be sure to see the [FAQ](FAQ.md) for answers to some common questions.
See the [contact page](Contact.md) to report a bug or to contact the
developers.
on the definitions in the config file. See the main
[documentation reference](Overview.md) for other information.

View File

@ -79,8 +79,8 @@ then one can start the tool by running:
BED_SCREWS_ADJUST
```
This tool will move the printer's nozzle to each screw XY location and
then move the nozzle to a Z=0 height. At this point one can use the
This tool will move the printer's nozzle to each screw XY location
and then move the nozzle to a Z=0 height. At this point one can use the
"paper test" to adjust the bed screw directly under the nozzle. See
the information described in
["the paper test"](Bed_Level.md#the-paper-test), but adjust the bed
@ -179,12 +179,15 @@ Recv: // rear right screw : y=155.0, y=190.0, z=2.71500 : adjust CCW 00:50
Recv: // read left screw : x=-5.0, y=190.0, z=2.47250 : adjust CW 00:02
Recv: ok
```
This means that:
This means that:
- front left screw is the reference point you must not change it.
- front right screw must be turned clockwise 1 full turn and a quarter turn
- rear right screw must be turned counter-clockwise 50 minutes
- read left screw must be turned clockwise 2 minutes (not need it's ok)
- rear left screw must be turned clockwise 2 minutes (not need it's ok)
Note that "minutes" refers to "minutes of a clock face". So, for
example, 15 minutes is a quarter of a full turn.
Repeat the process several times until you get a good level bed -
normally when all adjustments are below 6 minutes.

View File

@ -77,7 +77,7 @@ too little RAM, the installation may fail and you will need to enable swap.
Next, run the following commands to install the additional dependencies:
```
sudo apt update
sudo apt install python-numpy python-matplotlib
sudo apt install python3-numpy python3-matplotlib
```
Afterwards, check and follow the instructions in the
@ -163,7 +163,7 @@ TEST_RESONANCES AXIS=Y
```
This will generate 2 CSV files (`/tmp/resonances_x_*.csv` and
`/tmp/resonances_y_*.csv`). These files can be processed with the stand-alone
script on a Raspberry Pi. To do that, run running the following commands:
script on a Raspberry Pi. To do that, run the following commands:
```
~/klipper/scripts/calibrate_shaper.py /tmp/resonances_x_*.csv -o /tmp/shaper_calibrate_x.png
~/klipper/scripts/calibrate_shaper.py /tmp/resonances_y_*.csv -o /tmp/shaper_calibrate_y.png
@ -473,10 +473,11 @@ ignoring any errors for `SET_INPUT_SHAPER` command. For `TEST_RESONANCES`
command, specify the desired test axis. The raw data will be written into
`/tmp` directory on the RPi.
The raw data can also be obtained by running the command `ACCELEROMETER_MEASURE`
command twice during some normal printer activity - first to start the
measurements, and then to stop them and write the output file. Refer to
[G-Codes](G-Codes.md#adxl345-accelerometer-commands) for more details.
The raw data can also be obtained by running the command
`ACCELEROMETER_MEASURE` command twice during some normal printer
activity - first to start the measurements, and then to stop them and
write the output file. Refer to [G-Codes](G-Codes.md#adxl345) for more
details.
The data can be processed later by the following scripts:
`scripts/graph_accelerometer.py` and `scripts/calibrate_shaper.py`. Both

View File

@ -1,6 +1,6 @@
# Probe calibration
This document describes the method for calibrating the x, y, and z
This document describes the method for calibrating the X, Y, and Z
offsets of an "automatic z probe" in Klipper. This is useful for users
that have a `[probe]` or `[bltouch]` section in their config file.
@ -129,12 +129,12 @@ typical bed leveling procedures. It may be possible to tune the probe
speed and/or probe start height to improve the repeatability of the
probe. The `PROBE_ACCURACY` command allows one to run tests with
different parameters to see their impact - see the
[G-Codes document](G-Codes.md) for further details. If the probe
generally obtains repeatable results but has an occasional outlier,
then it may be possible to account for that by using multiple samples
on each probe - read the description of the probe `samples` config
parameters in the [config reference](Config_Reference.md#probe) for
more details.
[G-Codes document](G-Codes.md#probe_accuracy) for further details. If
the probe generally obtains repeatable results but has an occasional
outlier, then it may be possible to account for that by using multiple
samples on each probe - read the description of the probe `samples`
config parameters in the [config reference](Config_Reference.md#probe)
for more details.
If new probe speed, samples count, or other settings are needed, then
update the printer.cfg file and issue a `RESTART` command. If so, it

View File

@ -1,23 +1,26 @@
# RPi microcontroller
This document describes the process of running Klipper on a RPi
and use the same RPi as secondary mcu.
This document describes the process of running Klipper on a RPi and
use the same RPi as secondary mcu.
## Why use RPi as a secondary MCU?
Often the MCUs dedicated to controlling 3D printers have a limited and
pre-configured number of exposed pins to manage the main printing
functions (thermal resistors, extruders, steppers ...).
Using the RPi where Klipper is installed as a secondary MCU gives the
possibility to directly use the GPIOs and the buses (i2c, spi) of the RPi
inside klipper without using Octoprint plugins (if used) or external
programs giving the ability to control everything within the print GCODE.
functions (thermal resistors, extruders, steppers ...). Using the RPi
where Klipper is installed as a secondary MCU gives the possibility to
directly use the GPIOs and the buses (i2c, spi) of the RPi inside
klipper without using Octoprint plugins (if used) or external programs
giving the ability to control everything within the print GCODE.
**Warning**: If your platform is a _Beaglebone_ and you have correctly followed the installation steps, the linux mcu is already installed and configured for your system.
**Warning**: If your platform is a _Beaglebone_ and you have correctly
followed the installation steps, the linux mcu is already installed
and configured for your system.
## Install the rc script
If you want to use the host as a secondary MCU the klipper_mcu process must run before the klippy process.
If you want to use the host as a secondary MCU the klipper_mcu process
must run before the klippy process.
After installing Klipper, install the script. run:
```
@ -26,10 +29,6 @@ sudo cp "./scripts/klipper-mcu-start.sh" /etc/init.d/klipper_mcu
sudo update-rc.d klipper_mcu defaults
```
## Enabling SPI
Make sure the Linux SPI driver is enabled by running sudo raspi-config and enabling SPI under the "Interfacing options" menu.
## Building the micro-controller code
To compile the Klipper micro-controller code, start by configuring it
@ -38,7 +37,9 @@ for the "Linux process":
cd ~/klipper/
make menuconfig
```
In the menu, set "Microcontroller Architecture" to "Linux process," then save and exit.
In the menu, set "Microcontroller Architecture" to "Linux process,"
then save and exit.
To build and install the new micro-controller code, run:
```
@ -47,9 +48,10 @@ make flash
sudo service klipper start
```
If klippy.log reports a "Permission denied" error when attempting to connect
to `/tmp/klipper_host_mcu` then you need to add your user to the tty group.
The following command will add the "pi" user to the tty group:
If klippy.log reports a "Permission denied" error when attempting to
connect to `/tmp/klipper_host_mcu` then you need to add your user to
the tty group. The following command will add the "pi" user to the
tty group:
```
sudo usermod -a -G tty pi
```
@ -61,12 +63,24 @@ following the instructions in
[RaspberryPi sample config](../config/sample-raspberry-pi.cfg) and
[Multi MCU sample config](../config/sample-multi-mcu.cfg).
## Optional: Enabling SPI
Make sure the Linux SPI driver is enabled by running
`sudo raspi-config` and enabling SPI under the "Interfacing options"
menu.
## Optional: Identify the correct gpiochip
On Rasperry and on many clones the pins exposed on the GPIO belong to the first gpiochip. They can therefore be used on klipper simply by referring them with the name `gpio0..n`.
However, there are cases in which the exposed pins belong to gpiochips other than the first. For example in the case of some OrangePi models or if a Port Expander is used. In these cases it is useful to use the commands to access the _Linux GPIO character device_ to verify the configuration.
On Raspberry Pi and on many clones the pins exposed on the GPIO belong
to the first gpiochip. They can therefore be used on klipper simply by
referring them with the name `gpio0..n`. However, there are cases in
which the exposed pins belong to gpiochips other than the first. For
example in the case of some OrangePi models or if a Port Expander is
used. In these cases it is useful to use the commands to access the
_Linux GPIO character device_ to verify the configuration.
To install the _Linux GPIO character device - binary_ on a debian based distro like octopi run:
To install the _Linux GPIO character device - binary_ on a debian
based distro like octopi run:
```
sudo apt-get install gpiod
```
@ -81,9 +95,13 @@ To check the pin number and the pin availability tun:
gpioinfo
```
The chosen pin can thus be used within the configuration as `gpiochip<n>/gpio<o>` where **n** is the chip number as seen by the `gpiodetect` command and **o** is the line number seen by the` gpioinfo` command.
The chosen pin can thus be used within the configuration as
`gpiochip<n>/gpio<o>` where **n** is the chip number as seen by the
`gpiodetect` command and **o** is the line number seen by the`
gpioinfo` command.
***Warning:*** only gpio marked as `unused` can be used. It is not possible for a _line_ to be used by multiple processes simultaneously.
***Warning:*** only gpio marked as `unused` can be used. It is not
possible for a _line_ to be used by multiple processes simultaneously.
For example on a RPi 3B+ where klipper use the GPIO20 for a switch:
```
@ -160,23 +178,32 @@ gpiochip1 - 8 lines:
## Optional: Hardware PWM
Raspberry Pi's have two PWM channels (PWM0 and PWM1) which are exposed on the header or if not, can be routed to existing gpio pins.
The Linux mcu daemon uses the pwmchip sysfs interface to control hardware pwm devices on Linux hosts.
The pwm sysfs interface is not exposed by default on a Raspberry and can be activated by adding a line to ```/boot/config.txt```:
Raspberry Pi's have two PWM channels (PWM0 and PWM1) which are exposed
on the header or if not, can be routed to existing gpio pins. The
Linux mcu daemon uses the pwmchip sysfs interface to control hardware
pwm devices on Linux hosts. The pwm sysfs interface is not exposed by
default on a Raspberry and can be activated by adding a line to
`/boot/config.txt`:
```
# Enable pwmchip sysfs interface
dtoverlay=pwm,pin=12,func=4
```
This example enables only PWM0 and routes it to gpio12. If both PWM channels need to be enabled you can use ```pwm-2chan```.
This example enables only PWM0 and routes it to gpio12. If both PWM
channels need to be enabled you can use `pwm-2chan`.
The overlay does not expose the pwm line on sysfs on boot and needs to be exported by echo'ing the number of the pwm channel to ```/sys/class/pwm/pwmchip0/export```:
The overlay does not expose the pwm line on sysfs on boot and needs to
be exported by echo'ing the number of the pwm channel to
`/sys/class/pwm/pwmchip0/export`:
```
echo 0 > /sys/class/pwm/pwmchip0/export
```
This will create device ```/sys/class/pwm/pwmchip0/pwm0``` in the filesystem.
The easiest way to do this is by adding this to ```/etc/rc.local``` before the ```exit 0``` line.
With the sysfs in place, you can now use either the pwm channel(s) by adding the following piece of configuration to your ```printer.cfg```:
This will create device `/sys/class/pwm/pwmchip0/pwm0` in the
filesystem. The easiest way to do this is by adding this to
`/etc/rc.local` before the `exit 0` line.
With the sysfs in place, you can now use either the pwm channel(s) by
adding the following piece of configuration to your `printer.cfg`:
```
[output_pin caselight]
pin: host:pwmchip0/pwm0
@ -184,7 +211,8 @@ pwm: True
hardware_pwm: True
cycle_time: 0.000001
```
This will add hardware pwm control to gpio12 on the Pi (because the overlay was configured to route pwm0 to pin=12).
This will add hardware pwm control to gpio12 on the Pi (because the
overlay was configured to route pwm0 to pin=12).
PWM0 can be routed to gpio12 and gpio18, PWM1 can be routed to gpio13
and gpio19:

View File

@ -23,9 +23,8 @@ of the stealthChop mode of Trinamic stepper drivers.
## Tuning
Basic tuning requires measuring the ringing frequencies of the printer and
adding a few parameters to `printer.cfg` file.
Basic tuning requires measuring the ringing frequencies of the printer
by printing a test model.
Slice the ringing test model, which can be found in
[docs/prints/ringing_tower.stl](prints/ringing_tower.stl), in the slicer:
@ -45,31 +44,28 @@ Slice the ringing test model, which can be found in
First, measure the **ringing frequency**.
1. Increase `max_accel` and `max_accel_to_decel` parameters in your
`printer.cfg` to 7000. Note that this is only needed for tuning, and more
proper value will be selected in the corresponding
[section](#selecting-max_accel).
2. If `square_corner_velocity` parameter was changed, revert it back to 5.0.
It is not advised to increase it when using the input shaper because it can
cause more smoothing in parts - it is better to use higher acceleration
value instead.
3. Restart the firmware: `RESTART`.
4. Disable Pressure Advance: `SET_PRESSURE_ADVANCE ADVANCE=0`.
5. If you have already added `[input_shaper]` section to the printer.cfg,
1. If `square_corner_velocity` parameter was changed, revert it back
to 5.0. It is not advised to increase it when using input shaper
because it can cause more smoothing in parts - it is better to use
higher acceleration value instead.
2. Increase `max_accel_to_decel` by issuing the following command:
`SET_VELOCITY_LIMIT ACCEL_TO_DECEL=7000`
3. Disable Pressure Advance: `SET_PRESSURE_ADVANCE ADVANCE=0`
4. If you have already added `[input_shaper]` section to the printer.cfg,
execute `SET_INPUT_SHAPER SHAPER_FREQ_X=0 SHAPER_FREQ_Y=0` command. If you
get "Unknown command" error, you can safely ignore it at this point and
continue with the measurements.
6. Execute the command
`TUNING_TOWER COMMAND=SET_VELOCITY_LIMIT PARAMETER=ACCEL START=1250 FACTOR=100 BAND=5`.
5. Execute the command:
`TUNING_TOWER COMMAND=SET_VELOCITY_LIMIT PARAMETER=ACCEL START=1500 STEP_DELTA=500 STEP_HEIGHT=5`
Basically, we try to make ringing more pronounced by setting different large
values for acceleration. This command will increase the acceleration every
5 mm starting from 1500 mm/sec^2: 1500 mm/sec^2, 2000 mm/sec^2, 2500 mm/sec^2
and so forth up until 7000 mm/sec^2 at the last band.
7. Print the test model sliced with the suggested parameters.
8. You can stop the print earlier if the ringing is clearly visible and you see
6. Print the test model sliced with the suggested parameters.
7. You can stop the print earlier if the ringing is clearly visible and you see
that acceleration gets too high for your printer (e.g. printer shakes too
much or starts skipping steps).
9. Use X and Y marks at the back of the model for reference. The measurements
8. Use X and Y marks at the back of the model for reference. The measurements
from the side with X mark should be used for X axis *configuration*, and
Y mark - for Y axis configuration. Measure the distance *D* (in mm) between
several oscillations on the part with X mark, near the notches, preferably
@ -79,14 +75,14 @@ First, measure the **ringing frequency**.
|![Mark ringing](img/ringing-mark.jpg)|![Measure ringing](img/ringing-measure.jpg)|
10. Count how many oscillations *N* the measured distance *D* corresponds to.
9. Count how many oscillations *N* the measured distance *D* corresponds to.
If you are unsure how to count the oscillations, refer to the picture
above, which shows *N* = 6 oscillations.
11. Compute the ringing frequency of X axis as *V* &middot; *N* / *D* (Hz),
10. Compute the ringing frequency of X axis as *V* &middot; *N* / *D* (Hz),
where *V* is the velocity for outer perimeters (mm/sec). For the example
above, we marked 6 oscillations, and the test was printed at 100 mm/sec
velocity, so the frequency is 100 * 6 / 12.14 ≈ 49.4 Hz.
12. Do (9) - (11) for Y mark as well.
11. Do (8) - (10) for Y mark as well.
Note that ringing on the test print should follow the pattern of the curved
notches, as in the picture above. If it doesn't, then this defect is not really
@ -150,16 +146,15 @@ For most of the printers, either MZV or EI shapers can be recommended. This
section describes a testing process to choose between them, and figure out
a few other related parameters.
Print the ringing test model as follows (assuming you already have
shaper_freq_x/y set and max_accel/max_accel_to_decel increased to 7000 in
printer.cfg file):
Print the ringing test model as follows:
1. Restart the firmware: `RESTART`.
2. Disable Pressure Advance: `SET_PRESSURE_ADVANCE ADVANCE=0`.
3. Execute `SET_INPUT_SHAPER SHAPER_TYPE=MZV`.
4. Execute the command
`TUNING_TOWER COMMAND=SET_VELOCITY_LIMIT PARAMETER=ACCEL START=1250 FACTOR=100 BAND=5`.
5. Print the test model sliced with the suggested parameters.
1. Restart the firmware: `RESTART`
2. Prepare for test: `SET_VELOCITY_LIMIT ACCEL_TO_DECEL=7000`
3. Disable Pressure Advance: `SET_PRESSURE_ADVANCE ADVANCE=0`
4. Execute: `SET_INPUT_SHAPER SHAPER_TYPE=MZV`
5. Execute the command:
`TUNING_TOWER COMMAND=SET_VELOCITY_LIMIT PARAMETER=ACCEL START=1500 STEP_DELTA=500 STEP_HEIGHT=5`
6. Print the test model sliced with the suggested parameters.
If you see no ringing at this point, then MZV shaper can be recommended for use.
@ -169,8 +164,8 @@ differ significantly from the values you obtained earlier, a more complex input
shaper configuration is needed. You can refer to Technical details of
[Input shapers](#input-shapers) section. Otherwise, proceed to the next step.
Now try EI input shaper. To try it, repeat steps (1)-(5) from above, but
executing at step 3 the following command instead:
Now try EI input shaper. To try it, repeat steps (1)-(6) from above, but
executing at step 4 the following command instead:
`SET_INPUT_SHAPER SHAPER_TYPE=EI`.
Compare two prints with MZV and EI input shaper. If EI shows noticeably better
@ -207,7 +202,7 @@ You should have a printed test for the shaper you chose from the previous step
(if you don't, print the test model sliced with the
[suggested parameters](#tuning) with the pressure advance disabled
`SET_PRESSURE_ADVANCE ADVANCE=0` and with the tuning tower enabled as
`TUNING_TOWER COMMAND=SET_VELOCITY_LIMIT PARAMETER=ACCEL START=1250 FACTOR=100 BAND=5`).
`TUNING_TOWER COMMAND=SET_VELOCITY_LIMIT PARAMETER=ACCEL START=1500 STEP_DELTA=500 STEP_HEIGHT=5`).
Note that at very high accelerations, depending on the resonance frequency and
the input shaper you chose (e.g. EI shaper creates more smoothing than MZV),
input shaping may cause too much smoothing and rounding of the parts. So,
@ -242,8 +237,7 @@ It may also be a result of a miscalibrated (too high) filament flow, so it is
a good idea to check that too.
Choose the minimum out of the two acceleration values (from ringing and
smoothing), and put it as max_accel into printer.cfg (you can delete
max_accel_to_decel or revert it to the old value).
smoothing), and put it as `max_accel` into printer.cfg.
As a note, it may happen - especially at low ringing frequencies - that EI
@ -273,28 +267,28 @@ your choice with the same frequencies as you have measured earlier), you can
follow the steps in this section. Note that if you see ringing at different
frequencies after enabling [input_shaper], this section will not help with that.
Assuming that you have sliced the ringing model with suggested parameters and
increased `max_accel` and `max_accel_to_decel` parameters in the `printer.cfg`
to 7000 already, complete the following steps for each of the axes X and Y:
Assuming that you have sliced the ringing model with suggested
parameters, complete the following steps for each of the axes X and Y:
1. Make sure Pressure Advance is disabled: `SET_PRESSURE_ADVANCE ADVANCE=0`.
2. Execute `SET_INPUT_SHAPER SHAPER_TYPE=ZV`.
3. From the existing ringing test model with your chosen input shaper select
1. Prepare for test: `SET_VELOCITY_LIMIT ACCEL_TO_DECEL=7000`
2. Make sure Pressure Advance is disabled: `SET_PRESSURE_ADVANCE ADVANCE=0`
3. Execute: `SET_INPUT_SHAPER SHAPER_TYPE=ZV`
4. From the existing ringing test model with your chosen input shaper select
the acceleration that shows ringing sufficiently well, and set it with:
`SET_VELOCITY_LIMIT ACCEL=...`.
4. Calculate the necessary parameters for the `TUNING_TOWER` command to tune
`SET_VELOCITY_LIMIT ACCEL=...`
5. Calculate the necessary parameters for the `TUNING_TOWER` command to tune
`shaper_freq_x` parameter as follows: start = shaper_freq_x * 83 / 132 and
factor = shaper_freq_x / 66, where `shaper_freq_x` here is the current value
in `printer.cfg`.
5. Execute the command
6. Execute the command:
`TUNING_TOWER COMMAND=SET_INPUT_SHAPER PARAMETER=SHAPER_FREQ_X START=start FACTOR=factor BAND=5`
using `start` and `factor` values calculated at step (4).
6. Print the test model.
7. Reset the original frequency value:
using `start` and `factor` values calculated at step (5).
7. Print the test model.
8. Reset the original frequency value:
`SET_INPUT_SHAPER SHAPER_FREQ_X=...`.
8. Find the band which shows ringing the least and count its number from the
9. Find the band which shows ringing the least and count its number from the
bottom starting at 1.
9. Calculate the new shaper_freq_x value via old
10. Calculate the new shaper_freq_x value via old
shaper_freq_x * (39 + 5 * #band-number) / 66.
Repeat these steps for the Y axis in the same manner, replacing references to X
@ -312,16 +306,12 @@ After both new `shaper_freq_x` and `shaper_freq_y` parameters have been
calculated, you can update `[input_shaper]` section in `printer.cfg` with the
new `shaper_freq_x` and `shaper_freq_y` values.
Do not forget to revert the changes to `max_accel` and `max_accel_to_decel`
parameters in the `printer.cfg` after finishing this section.
### Pressure Advance
If you use Pressure Advance, it may need to be re-tuned. Follow the
[instructions](Pressure_Advance.md#tuning-pressure-advance) to find the
new value, if it differs from the previous one. Make sure to restore the
original values of `max_accel` and `max_accel_to_decel` parameters in the
`printer.cfg` and restart Klipper before tuning Pressure Advance.
[instructions](Pressure_Advance.md#tuning-pressure-advance) to find
the new value, if it differs from the previous one. Make sure to
restart Klipper before tuning Pressure Advance.
### Unreliable measurements of ringing frequencies
@ -335,26 +325,26 @@ accelerometer and measure the resonances with it (refer to the
process) - but this option requires some crimping and soldering.
For tuning, add empty `[input_shaper]` section to your `printer.cfg`. Then,
assuming that you have sliced the ringing model with suggested parameters and
increased `max_accel` and `max_accel_to_decel` parameters in the `printer.cfg`
to 7000 already, print the test model 3 times as follows. First time, prior to
printing, run
For tuning, add empty `[input_shaper]` section to your
`printer.cfg`. Then, assuming that you have sliced the ringing model
with suggested parameters, print the test model 3 times as
follows. First time, prior to printing, run
1. `RESTART`
2. `SET_PRESSURE_ADVANCE ADVANCE=0`.
3. `SET_INPUT_SHAPER SHAPER_TYPE=2HUMP_EI SHAPER_FREQ_X=60 SHAPER_FREQ_Y=60`.
4. `TUNING_TOWER COMMAND=SET_VELOCITY_LIMIT PARAMETER=ACCEL START=1250 FACTOR=100 BAND=5`.
2. `SET_VELOCITY_LIMIT ACCEL_TO_DECEL=7000`
3. `SET_PRESSURE_ADVANCE ADVANCE=0`
4. `SET_INPUT_SHAPER SHAPER_TYPE=2HUMP_EI SHAPER_FREQ_X=60 SHAPER_FREQ_Y=60`
5. `TUNING_TOWER COMMAND=SET_VELOCITY_LIMIT PARAMETER=ACCEL START=1500 STEP_DELTA=500 STEP_HEIGHT=5`
and print the model. Then print the model again, but before printing run instead
1. `SET_INPUT_SHAPER SHAPER_TYPE=2HUMP_EI SHAPER_FREQ_X=50 SHAPER_FREQ_Y=50`.
2. `TUNING_TOWER COMMAND=SET_VELOCITY_LIMIT PARAMETER=ACCEL START=1250 FACTOR=100 BAND=5`.
1. `SET_INPUT_SHAPER SHAPER_TYPE=2HUMP_EI SHAPER_FREQ_X=50 SHAPER_FREQ_Y=50`
2. `TUNING_TOWER COMMAND=SET_VELOCITY_LIMIT PARAMETER=ACCEL START=1500 STEP_DELTA=500 STEP_HEIGHT=5`
Then print the model for the 3rd time, but now run
1. `SET_INPUT_SHAPER SHAPER_TYPE=2HUMP_EI SHAPER_FREQ_X=40 SHAPER_FREQ_Y=40`.
2. `TUNING_TOWER COMMAND=SET_VELOCITY_LIMIT PARAMETER=ACCEL START=1250 FACTOR=100 BAND=5`.
1. `SET_INPUT_SHAPER SHAPER_TYPE=2HUMP_EI SHAPER_FREQ_X=40 SHAPER_FREQ_Y=40`
2. `TUNING_TOWER COMMAND=SET_VELOCITY_LIMIT PARAMETER=ACCEL START=1500 STEP_DELTA=500 STEP_HEIGHT=5`
Essentially, we are printing the ringing test model with TUNING_TOWER using
2HUMP_EI shaper with shaper_freq = 60 Hz, 50 Hz, and 40 Hz.
@ -377,8 +367,8 @@ frequency based on the frequency of 2HUMP_EI shaper you chose:
Now print the test model one more time, running
1. `SET_INPUT_SHAPER SHAPER_TYPE=EI SHAPER_FREQ_X=... SHAPER_FREQ_Y=...`.
2. `TUNING_TOWER COMMAND=SET_VELOCITY_LIMIT PARAMETER=ACCEL START=1250 FACTOR=100 BAND=5`.
1. `SET_INPUT_SHAPER SHAPER_TYPE=EI SHAPER_FREQ_X=... SHAPER_FREQ_Y=...`
2. `TUNING_TOWER COMMAND=SET_VELOCITY_LIMIT PARAMETER=ACCEL START=1500 STEP_DELTA=500 STEP_HEIGHT=5`
providing the shaper_freq_x=... and shaper_freq_y=... as determined previously.

View File

@ -36,7 +36,7 @@ Most drivers use 16 microsteps. If unsure, set `microsteps: 16` in the
config and use 16 in the formula above.
Almost all printers should have a whole number for `rotation_distance`
on x, y, and z type axes. If the above formula results in a
on X, Y, and Z type axes. If the above formula results in a
rotation_distance that is within .01 of a whole number then round the
final value to that whole_number.

View File

@ -10,12 +10,23 @@ attribute be sure to review the
[Config Changes document](Config_Changes.md) when upgrading the
Klipper software.
## angle
The following information is available in
[angle some_name](Config_Reference.md#angle) objects:
- `temperature`: The last temperature reading (in Celsius) from a
tle5012b magnetic hall sensor. This value is only available if the
angle sensor is a tle5012b chip and if measurements are in progress
(otherwise it reports `None`).
## bed_mesh
The following information is available in the
[bed_mesh](Config_Reference.md#bed_mesh) object:
- `profile_name`, `mesh_min`, `mesh_max`, `probed_matrix`,
`mesh_matrix`: Information on the currently active bed_mesh.
- `profiles`: The set of currently defined profiles as setup
using BED_MESH_PROFILE.
## configfile
@ -138,7 +149,8 @@ The following information is available in the
[hall_filament_width_sensor](Config_Reference.md#hall_filament_width_sensor)
object:
- `is_active`: Returns True if the sensor is currently active.
- `Diameter`, `Raw`: The last read values from the sensor.
- `Diameter`: The last reading from the sensor in mm.
- `Raw`: The last raw ADC reading from the sensor.
## heater
@ -179,6 +191,19 @@ is always available):
been in the "Printing" state (as tracked by the idle_timeout
module).
## led
The following information is available for each `[led led_name]`,
`[neopixel led_name]`, `[dotstar led_name]`, `[pca9533 led_name]`, and
`[pca9632 led_name]` config section defined in printer.cfg:
- `color_data`: A list of color lists containing the RGBW values for a
led in the chain. Each value is represented as a float from 0.0 to
1.0. Each color list contains 4 items (red, green, blue, white) even
if the underyling LED supports fewer color channels. For example,
the blue value (3rd item in color list) of the second neopixel in a
chain could be accessed at
`printer["neopixel <config_name>"].color_data[1][2]`.
## mcu
The following information is available in
@ -395,16 +420,6 @@ object is available if z_tilt is defined):
- `applied`: True if the z-tilt leveling process has been run and completed
successfully.
## neopixel / dotstar
The following information is available for each `[neopixel led_name]` and
`[dotstar led_name]` defined in printer.cfg:
- `color_data`: An array of objects, with each object containing the RGBW
values for a led in the chain. Note that not all configurations will contain
a white value. Each value is represented as a float from 0 to 1. For
example, the blue value of the second neopixel in a chain could be accessed
at `printer["neopixel <config_name>"].color_data[1].B`.
## dgus_status
The following information is available in the `dgus_status` object

View File

@ -45,7 +45,7 @@ leave a stepper idle sufficiently long.
If one wishes to reduce current to motors during print start routines,
then consider issuing
[SET_TMC_CURRENT](G-Codes.md#tmc-stepper-drivers) commands in a
[SET_TMC_CURRENT](G-Codes.md#set_tmc_current) commands in a
[START_PRINT macro](Slicers.md#klipper-gcode_macro) to adjust the
current before and after normal printing moves.
@ -410,10 +410,10 @@ restrictions:
## Querying and diagnosing driver settings
The `[DUMP_TMC command](G-Codes.md#tmc-stepper-drivers) is a useful
tool when configuring and diagnosing the drivers. It will report all
fields configured by Klipper as well as all fields that can be queried
from the driver.
The `[DUMP_TMC command](G-Codes.md#dump_tmc) is a useful tool when
configuring and diagnosing the drivers. It will report all fields
configured by Klipper as well as all fields that can be queried from
the driver.
All of the reported fields are defined in the Trinamic datasheet for
each driver. These datasheets can be found on the
@ -429,7 +429,7 @@ Klipper supports configuring many low-level driver fields using
has the full list of fields available for each type of driver.
In addition, almost all fields can be modified at run-time using the
[SET_TMC_FIELD command](G-Codes.md#tmc-stepper-drivers).
[SET_TMC_FIELD command](G-Codes.md#set_tmc_field).
Each of these fields is defined in the Trinamic datasheet for each
driver. These datasheets can be found on the

View File

@ -1,36 +1,22 @@
# TSL1401CL filament width sensor
This document describes Filament Width Sensor host module. Hardware used for developing this host module is based on TSL1401CL linear sensor array but it can work with any sensor array that has analog output. You can find designs at [thingiverse.com](https://www.thingiverse.com/search?q=filament%20width%20sensor)
This document describes Filament Width Sensor host module. Hardware used
for developing this host module is based on TSL1401CL linear sensor array
but it can work with any sensor array that has analog output. You can find
designs at [Thingiverse](https://www.thingiverse.com/search?q=filament%20width%20sensor).
To use a sensor array as a filament width sensor, read
[Config Reference](Config_Reference.md#tsl1401cl_filament_width_sensor) and
[G-Code documentation](G-Codes.md#hall_filament_width_sensor).
## How does it work?
Sensor generates analog output based on calculated filament width. Output voltage always equals to detected filament width (Ex. 1.65v, 1.70v, 3.0v). Host module monitors voltage changes and adjusts extrusion multiplier.
Sensor generates analog output based on calculated filament width. Output
voltage always equals to detected filament width (Ex. 1.65v, 1.70v, 3.0v).
Host module monitors voltage changes and adjusts extrusion multiplier.
## Configuration
## Note:
[tsl1401cl_filament_width_sensor]
pin: analog5
# Analog input pin for sensor output on Ramps board
default_nominal_filament_diameter: 1.75
# This parameter is in millimeters (mm)
max_difference: 0.2
# Maximum allowed filament diameter difference in millimeters (mm)
# If difference between nominal filament diameter and sensor output is more
# than +- max_difference, extrusion multiplier set back to %100
measurement_delay 100
# The distance from sensor to the melting chamber/hot-end in millimeters (mm).
# The filament between the sensor and the hot-end will be treated as the default_nominal_filament_diameter.
# Host module works with FIFO logic. It keeps each sensor value and position in
# an array and POP them back in correct position.
Sensor readings done with 10 mm intervals by default. If necessary you are free to change this setting by editing ***MEASUREMENT_INTERVAL_MM*** parameter in **filament_width_sensor.py** file.
## Commands
**QUERY_FILAMENT_WIDTH** - Return the current measured filament width as result
**RESET_FILAMENT_WIDTH_SENSOR** Clear all sensor readings. Can be used after filament change.
**DISABLE_FILAMENT_WIDTH_SENSOR** Turn off the filament width sensor and stop using it to do flow control
**ENABLE_FILAMENT_WIDTH_SENSOR** - Turn on the filament width sensor and start using it to do flow control
Sensor readings done with 10 mm intervals by default. If necessary you are
free to change this setting by editing ***MEASUREMENT_INTERVAL_MM*** parameter
in **filament_width_sensor.py** file.

View File

@ -4,3 +4,17 @@ site is hosted using "github pages". The
https://www.mkdocs.org/ ) to automatically convert the markdown files
in the docs/ directory to html. In addition to the files in this
directory, the docs/CNAME file also controls the website generation.
To test deploy the main English site locally one can use commands
similar to the following:
virtualenv ~/mkdocs-env && ~/python-env/bin/pip install -r ~/klipper/docs/_klipper3d/mkdocs-requirements.txt
cd ~/klipper && ~/mkdocs-env/bin/mkdocs serve --config-file ~/klipper/docs/_klipper3d/mkdocs.yml -a 0.0.0.0:8000
To test deploy the multi-language site locally one can use commands
similar to the following:
virtualenv ~/mkdocs-env && ~/python-env/bin/pip install -r ~/klipper/docs/_klipper3d/mkdocs-requirements.txt
source ~/mkdocs-env/bin/activate
cd ~/klipper && ./docs/_klipper3d/build-translations.sh
cd ~/klipper/site/ && python3 -m http.server 8000

View File

@ -0,0 +1,64 @@
#!/bin/bash
# This script extracts the Klipper translations and builds multiple
# mdocs sites - one for each supported language. See the README file
# for additional details.
MKDOCS_DIR="docs/_klipper3d/"
WORK_DIR="work/"
TRANS_DIR="${WORK_DIR}klipper-translations/"
TRANS_FILE="${TRANS_DIR}active_translations"
MKDOCS_MAIN="${MKDOCS_DIR}mkdocs-main.yml"
# Fetch translations
git clone --depth 1 https://github.com/Klipper3d/klipper-translations ${TRANS_DIR}
# Create new mkdocs-main.yml with language links
cp ${MKDOCS_DIR}mkdocs.yml ${MKDOCS_MAIN}
while IFS="," read dirname langsite langdesc langsearch; do
sed -i "s%^.*# Alternate language links automatically added here$% - name: ${langdesc}\n link: /${langsite}/\n lang: ${langsite}\n\0%" ${MKDOCS_MAIN}
done < <(egrep -v '^ *(#|$)' ${TRANS_FILE})
# Build main English website
echo "building site for en"
mkdocs build -f ${MKDOCS_MAIN}
# Build each additional language website
while IFS="," read dirname langsite langdesc langsearch; do
new_docs_dir="${WORK_DIR}lang/${langsite}/docs/"
locale_dir="${TRANS_DIR}/docs/locales/${dirname}"
# Copy markdown files to new_docs_dir
echo "Copying $dirname to $langsite"
mkdir -p "${new_docs_dir}"
cp "${locale_dir}"/*.md "${new_docs_dir}"
echo "copy resources"
cp -r docs/img "${new_docs_dir}"
cp -r docs/prints "${new_docs_dir}"
cp -r docs/_klipper3d "${new_docs_dir}"
# manually replace index.md if a manual-index.md exist
manual_index="${new_docs_dir}manual-index.md"
if [[ -f "${manual_index}" ]]; then
mv -f "${manual_index}" "${new_docs_dir}index.md"
echo "replaced index.md with manual_index.md for $langsite"
else
echo "Manually translated index file for $langsite not found!"
fi
# Create language specific mkdocs-lang-xxx.yml file
echo "create language specific mkdocs configurations for ${langsite}"
new_mkdocs_file="${new_docs_dir}_klipper3d/mkdocs-lang-${langsite}.yml"
cp "${MKDOCS_MAIN}" "${new_mkdocs_file}"
echo "replace search language"
sed -i "s%^ lang: en$% lang: ${langsearch}%" "${new_mkdocs_file}"
echo "replace site language"
sed -i "s%^ language: en$% language: ${langsite}%" "${new_mkdocs_file}"
# Build site
echo "building site for ${langsite}"
mkdir -p "${PWD}/site/${langsite}/"
ln -sf "${PWD}/site/${langsite}/" "${WORK_DIR}lang/${langsite}/site"
mkdocs build -f "${new_mkdocs_file}"
done < <(egrep -v '^ *(#|$)' ${TRANS_FILE})

View File

@ -1,7 +1,7 @@
# Python virtualenv module requirements for mkdocs
jinja2==3.0.3
mkdocs==1.2.3
mkdocs-material==7.2.0
mkdocs-section-index==0.3.1
mkdocs-material==8.1.3
mkdocs-simple-hooks==0.1.3
mkdocs-exclude==1.0.2
mdx-truly-sane-lists==1.2

View File

@ -1,5 +1,8 @@
# Main configuration file for mkdocs generation of klipper3d.org website
# Note that the build-translations.sh script expects a certain file
# layout. See that script and the README file for more details.
# Site and directory configuration
site_name: Klipper documentation
repo_url: https://github.com/Klipper3d/klipper
@ -9,7 +12,7 @@ use_directory_urls: False
docs_dir: '../'
site_dir: '../../site/'
# Markdown document translation settings
# Custom markdown dialect settings
markdown_extensions:
- toc:
permalink: True
@ -19,13 +22,13 @@ markdown_extensions:
- mdx_truly_sane_lists
- mdx_breakless_lists
plugins:
- search
- mkdocs-simple-hooks:
search:
lang: en
mkdocs-simple-hooks:
hooks:
on_page_markdown: "docs._klipper3d.mkdocs_hooks:transform"
- exclude:
glob:
- README.md
exclude:
glob: "README.md"
# Website layout configuration (using mkdocs-material theme)
theme:
@ -49,6 +52,7 @@ theme:
favicon: img/favicon.ico
icon:
repo: fontawesome/brands/github
alternate: material/web
features:
#- navigation.tabs
#- navigation.expand
@ -58,6 +62,7 @@ theme:
- search.suggest
- search.highlight
- search.share
language: en
extra_css:
- _klipper3d/css/extra.css
@ -67,6 +72,12 @@ extra:
analytics:
provider: google
property: UA-138371409-1
# Language Selection
alternate:
- name: English
link: /
lang: en
# Alternate language links automatically added here
# Navigation hierarchy (this should mimic the layout of Overview.md)
nav:

View File

@ -38,8 +38,9 @@ defs_stepcompress = """
struct stepcompress *stepcompress_alloc(uint32_t oid);
void stepcompress_fill(struct stepcompress *sc, uint32_t max_error
, uint32_t invert_sdir, int32_t queue_step_msgtag
, int32_t set_next_step_dir_msgtag);
, int32_t queue_step_msgtag, int32_t set_next_step_dir_msgtag);
void stepcompress_set_invert_sdir(struct stepcompress *sc
, uint32_t invert_sdir);
void stepcompress_free(struct stepcompress *sc);
int stepcompress_reset(struct stepcompress *sc, uint64_t last_step_clock);
int stepcompress_set_last_position(struct stepcompress *sc
@ -133,8 +134,8 @@ defs_kin_winch = """
defs_kin_extruder = """
struct stepper_kinematics *extruder_stepper_alloc(void);
void extruder_set_smooth_time(struct stepper_kinematics *sk
, double smooth_time);
void extruder_set_pressure_advance(struct stepper_kinematics *sk
, double pressure_advance, double smooth_time);
"""
defs_kin_shaper = """

View File

@ -52,15 +52,17 @@ extruder_integrate_time(double base, double start_v, double half_accel
// Calculate the definitive integral of extruder for a given move
static double
pa_move_integrate(struct move *m, double base, double start, double end,
double time_offset)
pa_move_integrate(struct move *m, double pressure_advance
, double base, double start, double end, double time_offset)
{
if (start < 0.)
start = 0.;
if (end > m->move_t)
end = m->move_t;
// Calculate base position and velocity with pressure advance
double pressure_advance = m->axes_r.y;
int can_pressure_advance = m->axes_r.y != 0.;
if (!can_pressure_advance)
pressure_advance = 0.;
base += pressure_advance * m->start_v;
double start_v = m->start_v + pressure_advance * 2. * m->half_accel;
// Calculate definitive integral
@ -72,34 +74,36 @@ pa_move_integrate(struct move *m, double base, double start, double end,
// Calculate the definitive integral of the extruder over a range of moves
static double
pa_range_integrate(struct move *m, double move_time, double hst)
pa_range_integrate(struct move *m, double move_time
, double pressure_advance, double hst)
{
// Calculate integral for the current move
double res = 0., start = move_time - hst, end = move_time + hst;
double start_base = m->start_pos.x;
res += pa_move_integrate(m, 0., start, move_time, start);
res -= pa_move_integrate(m, 0., move_time, end, end);
res += pa_move_integrate(m, pressure_advance, 0., start, move_time, start);
res -= pa_move_integrate(m, pressure_advance, 0., move_time, end, end);
// Integrate over previous moves
struct move *prev = m;
while (unlikely(start < 0.)) {
prev = list_prev_entry(prev, node);
start += prev->move_t;
double base = prev->start_pos.x - start_base;
res += pa_move_integrate(prev, base, start, prev->move_t, start);
res += pa_move_integrate(prev, pressure_advance, base, start
, prev->move_t, start);
}
// Integrate over future moves
while (unlikely(end > m->move_t)) {
end -= m->move_t;
m = list_next_entry(m, node);
double base = m->start_pos.x - start_base;
res -= pa_move_integrate(m, base, 0., end, end);
res -= pa_move_integrate(m, pressure_advance, base, 0., end, end);
}
return res;
}
struct extruder_stepper {
struct stepper_kinematics sk;
double half_smooth_time, inv_half_smooth_time2;
double pressure_advance, half_smooth_time, inv_half_smooth_time2;
};
static double
@ -112,12 +116,13 @@ extruder_calc_position(struct stepper_kinematics *sk, struct move *m
// Pressure advance not enabled
return m->start_pos.x + move_get_distance(m, move_time);
// Apply pressure advance and average over smooth_time
double area = pa_range_integrate(m, move_time, hst);
double area = pa_range_integrate(m, move_time, es->pressure_advance, hst);
return m->start_pos.x + area * es->inv_half_smooth_time2;
}
void __visible
extruder_set_smooth_time(struct stepper_kinematics *sk, double smooth_time)
extruder_set_pressure_advance(struct stepper_kinematics *sk
, double pressure_advance, double smooth_time)
{
struct extruder_stepper *es = container_of(sk, struct extruder_stepper, sk);
double hst = smooth_time * .5;
@ -126,6 +131,7 @@ extruder_set_smooth_time(struct stepper_kinematics *sk, double smooth_time)
if (! hst)
return;
es->inv_half_smooth_time2 = 1. / (hst * hst);
es->pressure_advance = pressure_advance;
}
struct stepper_kinematics * __visible

View File

@ -259,15 +259,25 @@ stepcompress_alloc(uint32_t oid)
// Fill message id information
void __visible
stepcompress_fill(struct stepcompress *sc, uint32_t max_error
, uint32_t invert_sdir, int32_t queue_step_msgtag
, int32_t set_next_step_dir_msgtag)
, int32_t queue_step_msgtag, int32_t set_next_step_dir_msgtag)
{
sc->max_error = max_error;
sc->invert_sdir = !!invert_sdir;
sc->queue_step_msgtag = queue_step_msgtag;
sc->set_next_step_dir_msgtag = set_next_step_dir_msgtag;
}
// Set the inverted stepper direction flag
void __visible
stepcompress_set_invert_sdir(struct stepcompress *sc, uint32_t invert_sdir)
{
invert_sdir = !!invert_sdir;
if (invert_sdir != sc->invert_sdir) {
sc->invert_sdir = invert_sdir;
if (sc->sdir >= 0)
sc->sdir ^= 1;
}
}
// Helper to free items from the history_list
static void
free_history(struct stepcompress *sc, uint64_t end_clock)

View File

@ -13,8 +13,10 @@ struct pull_history_steps {
struct stepcompress *stepcompress_alloc(uint32_t oid);
void stepcompress_fill(struct stepcompress *sc, uint32_t max_error
, uint32_t invert_sdir, int32_t queue_step_msgtag
, int32_t queue_step_msgtag
, int32_t set_next_step_dir_msgtag);
void stepcompress_set_invert_sdir(struct stepcompress *sc
, uint32_t invert_sdir);
void stepcompress_free(struct stepcompress *sc);
uint32_t stepcompress_get_oid(struct stepcompress *sc);
int stepcompress_get_step_dir(struct stepcompress *sc);

578
klippy/extras/angle.py Normal file
View File

@ -0,0 +1,578 @@
# Support for reading SPI magnetic angle sensors
#
# Copyright (C) 2021,2022 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging, math, threading
from . import bus, motion_report
MIN_MSG_TIME = 0.100
TCODE_ERROR = 0xff
TRINAMIC_DRIVERS = ["tmc2130", "tmc2208", "tmc2209", "tmc2660", "tmc5160"]
CALIBRATION_BITS = 6 # 64 entries
ANGLE_BITS = 16 # angles range from 0..65535
class AngleCalibration:
def __init__(self, config):
self.printer = config.get_printer()
self.name = config.get_name()
self.stepper_name = config.get('stepper', None)
if self.stepper_name is None:
# No calibration
return
try:
import numpy
except:
raise config.error("Angle calibration requires numpy module")
sconfig = config.getsection(self.stepper_name)
sconfig.getint('microsteps', note_valid=False)
self.tmc_module = self.mcu_stepper = None
# Current calibration data
self.mcu_pos_offset = None
self.angle_phase_offset = 0.
self.calibration_reversed = False
self.calibration = []
cal = config.get('calibrate', None)
if cal is not None:
data = [d.strip() for d in cal.split(',')]
angles = [float(d) for d in data if d]
self.load_calibration(angles)
# Register commands
self.printer.register_event_handler("stepper:sync_mcu_position",
self.handle_sync_mcu_pos)
self.printer.register_event_handler("klippy:connect", self.connect)
cname = self.name.split()[-1]
gcode = self.printer.lookup_object('gcode')
gcode.register_mux_command("ANGLE_CALIBRATE", "CHIP",
cname, self.cmd_ANGLE_CALIBRATE,
desc=self.cmd_ANGLE_CALIBRATE_help)
def handle_sync_mcu_pos(self, mcu_stepper):
if mcu_stepper.get_name() == self.stepper_name:
self.mcu_pos_offset = None
def calc_mcu_pos_offset(self, sample):
# Lookup phase information
mcu_phase_offset, phases = self.tmc_module.get_phase_offset()
if mcu_phase_offset is None:
return
# Find mcu position at time of sample
angle_time, angle_pos = sample
mcu_pos = self.mcu_stepper.get_past_mcu_position(angle_time)
# Convert angle_pos to mcu_pos units
microsteps, full_steps = self.get_microsteps()
angle_to_mcu_pos = full_steps * microsteps / float(1<<ANGLE_BITS)
angle_mpos = angle_pos * angle_to_mcu_pos
# Calculate adjustment for stepper phases
phase_diff = ((angle_mpos + self.angle_phase_offset * angle_to_mcu_pos)
- (mcu_pos + mcu_phase_offset)) % phases
if phase_diff > phases//2:
phase_diff -= phases
# Store final offset
self.mcu_pos_offset = mcu_pos - (angle_mpos - phase_diff)
def apply_calibration(self, samples):
calibration = self.calibration
if not calibration:
return None
calibration_reversed = self.calibration_reversed
interp_bits = ANGLE_BITS - CALIBRATION_BITS
interp_mask = (1 << interp_bits) - 1
interp_round = 1 << (interp_bits - 1)
for i, (samp_time, angle) in enumerate(samples):
bucket = (angle & 0xffff) >> interp_bits
cal1 = calibration[bucket]
cal2 = calibration[bucket + 1]
adj = (angle & interp_mask) * (cal2 - cal1)
adj = cal1 + ((adj + interp_round) >> interp_bits)
angle_diff = (angle - adj) & 0xffff
angle_diff -= (angle_diff & 0x8000) << 1
new_angle = angle - angle_diff
if calibration_reversed:
new_angle = -new_angle
samples[i] = (samp_time, new_angle)
if self.mcu_pos_offset is None:
self.calc_mcu_pos_offset(samples[0])
if self.mcu_pos_offset is None:
return None
return self.mcu_stepper.mcu_to_commanded_position(self.mcu_pos_offset)
def load_calibration(self, angles):
# Calculate linear intepolation calibration buckets by solving
# linear equations
angle_max = 1 << ANGLE_BITS
calibration_count = 1 << CALIBRATION_BITS
bucket_size = angle_max // calibration_count
full_steps = len(angles)
nominal_step = float(angle_max) / full_steps
self.angle_phase_offset = (angles.index(min(angles)) & 3) * nominal_step
self.calibration_reversed = angles[-2] > angles[-1]
if self.calibration_reversed:
angles = list(reversed(angles))
first_step = angles.index(min(angles))
angles = angles[first_step:] + angles[:first_step]
import numpy
eqs = numpy.zeros((full_steps, calibration_count))
ans = numpy.zeros((full_steps,))
for step, angle in enumerate(angles):
int_angle = int(angle + .5) % angle_max
bucket = int(int_angle / bucket_size)
bucket_start = bucket * bucket_size
ang_diff = angle - bucket_start
ang_diff_per = ang_diff / bucket_size
eq = eqs[step]
eq[bucket] = 1. - ang_diff_per
eq[(bucket + 1) % calibration_count] = ang_diff_per
ans[step] = float(step * nominal_step)
if bucket + 1 >= calibration_count:
ans[step] -= ang_diff_per * angle_max
sol = numpy.linalg.lstsq(eqs, ans, rcond=None)[0]
isol = [int(s + .5) for s in sol]
self.calibration = isol + [isol[0] + angle_max]
def lookup_tmc(self):
for driver in TRINAMIC_DRIVERS:
driver_name = "%s %s" % (driver, self.stepper_name)
module = self.printer.lookup_object(driver_name, None)
if module is not None:
return module
raise self.printer.command_error("Unable to find TMC driver for %s"
% (self.stepper_name,))
def connect(self):
self.tmc_module = self.lookup_tmc()
fmove = self.printer.lookup_object('force_move')
self.mcu_stepper = fmove.lookup_stepper(self.stepper_name)
def get_microsteps(self):
configfile = self.printer.lookup_object('configfile')
sconfig = configfile.get_status(None)['settings']
stconfig = sconfig.get(self.stepper_name, {})
microsteps = stconfig['microsteps']
full_steps = stconfig['full_steps_per_rotation']
return microsteps, full_steps
def get_stepper_phase(self):
mcu_phase_offset, phases = self.tmc_module.get_phase_offset()
if mcu_phase_offset is None:
raise self.printer.command_error("Driver phase not known for %s"
% (self.stepper_name,))
mcu_pos = self.mcu_stepper.get_mcu_position()
return (mcu_pos + mcu_phase_offset) % phases
def do_calibration_moves(self):
move = self.printer.lookup_object('force_move').manual_move
# Start data collection
angle_sensor = self.printer.lookup_object(self.name)
cconn = angle_sensor.start_internal_client()
# Move stepper several turns (to allow internal sensor calibration)
microsteps, full_steps = self.get_microsteps()
mcu_stepper = self.mcu_stepper
step_dist = mcu_stepper.get_step_dist()
full_step_dist = step_dist * microsteps
rotation_dist = full_steps * full_step_dist
align_dist = step_dist * self.get_stepper_phase()
move_time = 0.010
move_speed = full_step_dist / move_time
move(mcu_stepper, -(rotation_dist+align_dist), move_speed)
move(mcu_stepper, 2. * rotation_dist, move_speed)
move(mcu_stepper, -2. * rotation_dist, move_speed)
move(mcu_stepper, .5 * rotation_dist - full_step_dist, move_speed)
# Move to each full step position
toolhead = self.printer.lookup_object('toolhead')
times = []
samp_dist = full_step_dist
for i in range(2 * full_steps):
move(mcu_stepper, samp_dist, move_speed)
start_query_time = toolhead.get_last_move_time() + 0.050
end_query_time = start_query_time + 0.050
times.append((start_query_time, end_query_time))
toolhead.dwell(0.150)
if i == full_steps-1:
# Reverse direction and test each full step again
move(mcu_stepper, .5 * rotation_dist, move_speed)
move(mcu_stepper, -.5 * rotation_dist + samp_dist, move_speed)
samp_dist = -samp_dist
move(mcu_stepper, .5*rotation_dist + align_dist, move_speed)
toolhead.wait_moves()
# Finish data collection
cconn.finalize()
msgs = cconn.get_messages()
# Correlate query responses
cal = {}
step = 0
for msg in msgs:
for query_time, pos in msg['params']['data']:
# Add to step tracking
while step < len(times) and query_time > times[step][1]:
step += 1
if step < len(times) and query_time >= times[step][0]:
cal.setdefault(step, []).append(pos)
if len(cal) != len(times):
raise self.printer.command_error(
"Failed calibration - incomplete sensor data")
fcal = { i: cal[i] for i in range(full_steps) }
rcal = { full_steps-i-1: cal[i+full_steps] for i in range(full_steps) }
return fcal, rcal
def calc_angles(self, meas):
total_count = total_variance = 0
angles = {}
for step, data in meas.items():
count = len(data)
angle_avg = float(sum(data)) / count
angles[step] = angle_avg
total_count += count
total_variance += sum([(d - angle_avg)**2 for d in data])
return angles, math.sqrt(total_variance / total_count), total_count
cmd_ANGLE_CALIBRATE_help = "Calibrate angle sensor to stepper motor"
def cmd_ANGLE_CALIBRATE(self, gcmd):
# Perform calibration movement and capture
old_calibration = self.calibration
self.calibration = []
try:
fcal, rcal = self.do_calibration_moves()
finally:
self.calibration = old_calibration
# Calculate each step position average and variance
microsteps, full_steps = self.get_microsteps()
fangles, fstd, ftotal = self.calc_angles(fcal)
rangles, rstd, rtotal = self.calc_angles(rcal)
if (len({a: i for i, a in fangles.items()}) != len(fangles)
or len({a: i for i, a in rangles.items()}) != len(rangles)):
raise self.printer.command_error(
"Failed calibration - sensor not updating for each step")
merged = { i: fcal[i] + rcal[i] for i in range(full_steps) }
angles, std, total = self.calc_angles(merged)
gcmd.respond_info("angle: stddev=%.3f (%.3f forward / %.3f reverse)"
" in %d queries" % (std, fstd, rstd, total))
# Order data with lowest/highest magnet position first
anglist = [angles[i] % 0xffff for i in range(full_steps)]
if angles[0] > angles[1]:
first_ang = max(anglist)
else:
first_ang = min(anglist)
first_phase = anglist.index(first_ang) & ~3
anglist = anglist[first_phase:] + anglist[:first_phase]
# Save results
cal_contents = []
for i, angle in enumerate(anglist):
if not i % 8:
cal_contents.append('\n')
cal_contents.append("%.1f" % (angle,))
cal_contents.append(',')
cal_contents.pop()
configfile = self.printer.lookup_object('configfile')
configfile.remove_section(self.name)
configfile.set(self.name, 'calibrate', ''.join(cal_contents))
class HelperA1333:
SPI_MODE = 3
SPI_SPEED = 10000000
def __init__(self, config, spi, oid):
self.spi = spi
self.is_tcode_absolute = False
self.last_temperature = None
def get_static_delay(self):
return .000001
def start(self):
# Setup for angle query
self.spi.spi_transfer([0x32, 0x00])
class HelperAS5047D:
SPI_MODE = 1
SPI_SPEED = int(1. / .000000350)
def __init__(self, config, spi, oid):
self.spi = spi
self.is_tcode_absolute = False
self.last_temperature = None
def get_static_delay(self):
return .000100
def start(self):
# Clear any errors from device
self.spi.spi_transfer([0xff, 0xfc]) # Read DIAAGC
self.spi.spi_transfer([0x40, 0x01]) # Read ERRFL
self.spi.spi_transfer([0xc0, 0x00]) # Read NOP
class HelperTLE5012B:
SPI_MODE = 1
SPI_SPEED = 4000000
def __init__(self, config, spi, oid):
self.printer = config.get_printer()
self.spi = spi
self.oid = oid
self.is_tcode_absolute = True
self.last_temperature = None
self.mcu = spi.get_mcu()
self.mcu.register_config_callback(self._build_config)
self.spi_angle_transfer_cmd = None
self.last_chip_mcu_clock = self.last_chip_clock = 0
self.chip_freq = 0.
name = config.get_name().split()[-1]
gcode = self.printer.lookup_object("gcode")
gcode.register_mux_command("ANGLE_DEBUG_READ", "CHIP", name,
self.cmd_ANGLE_DEBUG_READ,
desc=self.cmd_ANGLE_DEBUG_READ_help)
gcode.register_mux_command("ANGLE_DEBUG_WRITE", "CHIP", name,
self.cmd_ANGLE_DEBUG_WRITE,
desc=self.cmd_ANGLE_DEBUG_WRITE_help)
def _build_config(self):
cmdqueue = self.spi.get_command_queue()
self.spi_angle_transfer_cmd = self.mcu.lookup_query_command(
"spi_angle_transfer oid=%c data=%*s",
"spi_angle_transfer_response oid=%c clock=%u response=%*s",
oid=self.oid, cq=cmdqueue)
def get_tcode_params(self):
return self.last_chip_mcu_clock, self.last_chip_clock, self.chip_freq
def _calc_crc(self, data):
crc = 0xff
for d in data:
crc ^= d
for i in range(8):
if crc & 0x80:
crc = (crc << 1) ^ 0x1d
else:
crc <<= 1
return (~crc) & 0xff
def _send_spi(self, msg):
for retry in range(5):
if msg[0] & 0x04:
params = self.spi_angle_transfer_cmd.send([self.oid, msg])
else:
params = self.spi.spi_transfer(msg)
resp = bytearray(params['response'])
crc = self._calc_crc(bytearray(msg[:2]) + resp[2:-2])
if crc == resp[-1]:
return params
raise self.printer.command_error("Unable to query tle5012b chip")
def _read_reg(self, reg):
cw = 0x8000 | ((reg & 0x3f) << 4) | 0x01
if reg >= 0x05 and reg <= 0x11:
cw |= 0x5000
msg = [cw >> 8, cw & 0xff, 0, 0, 0, 0]
params = self._send_spi(msg)
resp = bytearray(params['response'])
return (resp[2] << 8) | resp[3]
def _write_reg(self, reg, val):
cw = ((reg & 0x3f) << 4) | 0x01
if reg >= 0x05 and reg <= 0x11:
cw |= 0x5000
msg = [cw >> 8, cw & 0xff, (val >> 8) & 0xff, val & 0xff, 0, 0]
for retry in range(5):
self._send_spi(msg)
rval = self._read_reg(reg)
if rval == val:
return
raise self.printer.command_error("Unable to write to tle5012b chip")
def _mask_reg(self, reg, off, on):
rval = self._read_reg(reg)
self._write_reg(reg, (rval & ~off) | on)
def _query_clock(self):
# Read frame counter (and normalize to a 16bit counter)
msg = [0x84, 0x42, 0, 0, 0, 0, 0, 0] # Read with latch, AREV and FSYNC
params = self._send_spi(msg)
resp = bytearray(params['response'])
mcu_clock = self.mcu.clock32_to_clock64(params['clock'])
chip_clock = ((resp[2] & 0x7e) << 9) | ((resp[4] & 0x3e) << 4)
# Calculate temperature
temper = resp[5] - ((resp[4] & 0x01) << 8)
self.last_temperature = (temper + 152) / 2.776
return mcu_clock, chip_clock
def update_clock(self):
mcu_clock, chip_clock = self._query_clock()
mdiff = mcu_clock - self.last_chip_mcu_clock
chip_mclock = self.last_chip_clock + int(mdiff * self.chip_freq + .5)
cdiff = (chip_mclock - chip_clock) & 0xffff
cdiff -= (cdiff & 0x8000) << 1
new_chip_clock = chip_mclock - cdiff
self.chip_freq = float(new_chip_clock - self.last_chip_clock) / mdiff
self.last_chip_clock = new_chip_clock
self.last_chip_mcu_clock = mcu_clock
def start(self):
# Clear any errors from device
self._read_reg(0x00) # Read STAT
# Initialize chip (so different chip variants work the same way)
self._mask_reg(0x06, 0xc003, 0x4000) # MOD1: 42.7us, IIF disable
self._mask_reg(0x08, 0x0007, 0x0001) # MOD2: Predict off, autocal=1
self._mask_reg(0x0e, 0x0003, 0x0000) # MOD4: IIF mode
# Setup starting clock values
mcu_clock, chip_clock = self._query_clock()
self.last_chip_clock = chip_clock
self.last_chip_mcu_clock = mcu_clock
self.chip_freq = float(1<<5) / self.mcu.seconds_to_clock(1. / 750000.)
self.update_clock()
cmd_ANGLE_DEBUG_READ_help = "Query low-level angle sensor register"
def cmd_ANGLE_DEBUG_READ(self, gcmd):
reg = gcmd.get("REG", minval=0, maxval=0x30, parser=lambda x: int(x, 0))
val = self._read_reg(reg)
gcmd.respond_info("ANGLE REG[0x%02x] = 0x%04x" % (reg, val))
cmd_ANGLE_DEBUG_WRITE_help = "Set low-level angle sensor register"
def cmd_ANGLE_DEBUG_WRITE(self, gcmd):
reg = gcmd.get("REG", minval=0, maxval=0x30, parser=lambda x: int(x, 0))
val = gcmd.get("VAL", minval=0, maxval=0xffff,
parser=lambda x: int(x, 0))
self._write_reg(reg, val)
SAMPLE_PERIOD = 0.000400
class Angle:
def __init__(self, config):
self.printer = config.get_printer()
self.sample_period = config.getfloat('sample_period', SAMPLE_PERIOD,
above=0.)
self.calibration = AngleCalibration(config)
# Measurement conversion
self.start_clock = self.time_shift = self.sample_ticks = 0
self.last_sequence = self.last_angle = 0
# Measurement storage (accessed from background thread)
self.lock = threading.Lock()
self.raw_samples = []
# Sensor type
sensors = { "a1333": HelperA1333, "as5047d": HelperAS5047D,
"tle5012b": HelperTLE5012B }
sensor_type = config.getchoice('sensor_type', {s: s for s in sensors})
sensor_class = sensors[sensor_type]
self.spi = bus.MCU_SPI_from_config(config, sensor_class.SPI_MODE,
default_speed=sensor_class.SPI_SPEED)
self.mcu = mcu = self.spi.get_mcu()
self.oid = oid = mcu.create_oid()
self.sensor_helper = sensor_class(config, self.spi, oid)
# Setup mcu sensor_spi_angle bulk query code
self.query_spi_angle_cmd = self.query_spi_angle_end_cmd = None
mcu.add_config_cmd(
"config_spi_angle oid=%d spi_oid=%d spi_angle_type=%s"
% (oid, self.spi.get_oid(), sensor_type))
mcu.add_config_cmd(
"query_spi_angle oid=%d clock=0 rest_ticks=0 time_shift=0"
% (oid,), on_restart=True)
mcu.register_config_callback(self._build_config)
mcu.register_response(self._handle_spi_angle_data,
"spi_angle_data", oid)
# API server endpoints
self.api_dump = motion_report.APIDumpHelper(
self.printer, self._api_update, self._api_startstop, 0.100)
self.name = config.get_name().split()[1]
wh = self.printer.lookup_object('webhooks')
wh.register_mux_endpoint("angle/dump_angle", "sensor", self.name,
self._handle_dump_angle)
def _build_config(self):
freq = self.mcu.seconds_to_clock(1.)
while float(TCODE_ERROR << self.time_shift) / freq < 0.002:
self.time_shift += 1
cmdqueue = self.spi.get_command_queue()
self.query_spi_angle_cmd = self.mcu.lookup_command(
"query_spi_angle oid=%c clock=%u rest_ticks=%u time_shift=%c",
cq=cmdqueue)
self.query_spi_angle_end_cmd = self.mcu.lookup_query_command(
"query_spi_angle oid=%c clock=%u rest_ticks=%u time_shift=%c",
"spi_angle_end oid=%c sequence=%hu", oid=self.oid, cq=cmdqueue)
def get_status(self, eventtime=None):
return {'temperature': self.sensor_helper.last_temperature}
# Measurement collection
def is_measuring(self):
return self.start_clock != 0
def _handle_spi_angle_data(self, params):
with self.lock:
self.raw_samples.append(params)
def _extract_samples(self, raw_samples):
# Load variables to optimize inner loop below
sample_ticks = self.sample_ticks
start_clock = self.start_clock
clock_to_print_time = self.mcu.clock_to_print_time
last_sequence = self.last_sequence
last_angle = self.last_angle
time_shift = 0
static_delay = 0.
last_chip_mcu_clock = last_chip_clock = chip_freq = inv_chip_freq = 0.
is_tcode_absolute = self.sensor_helper.is_tcode_absolute
if is_tcode_absolute:
tparams = self.sensor_helper.get_tcode_params()
last_chip_mcu_clock, last_chip_clock, chip_freq = tparams
inv_chip_freq = 1. / chip_freq
else:
time_shift = self.time_shift
static_delay = self.sensor_helper.get_static_delay()
# Process every message in raw_samples
count = error_count = 0
samples = [None] * (len(raw_samples) * 16)
for params in raw_samples:
seq = (last_sequence & ~0xffff) | params['sequence']
if seq < last_sequence:
seq += 0x10000
last_sequence = seq
d = bytearray(params['data'])
msg_mclock = start_clock + seq*16*sample_ticks
for i in range(len(d) // 3):
tcode = d[i*3]
if tcode == TCODE_ERROR:
error_count += 1
continue
raw_angle = d[i*3 + 1] | (d[i*3 + 2] << 8)
angle_diff = (last_angle - raw_angle) & 0xffff
angle_diff -= (angle_diff & 0x8000) << 1
last_angle -= angle_diff
mclock = msg_mclock + i*sample_ticks
if is_tcode_absolute:
# tcode is tle5012b frame counter
mdiff = mclock - last_chip_mcu_clock
chip_mclock = last_chip_clock + int(mdiff * chip_freq + .5)
cdiff = ((tcode << 10) - chip_mclock) & 0xffff
cdiff -= (cdiff & 0x8000) << 1
sclock = mclock + (cdiff - 0x800) * inv_chip_freq
else:
# tcode is mcu clock offset shifted by time_shift
sclock = mclock + (tcode<<time_shift)
ptime = round(clock_to_print_time(sclock) - static_delay, 6)
samples[count] = (ptime, last_angle)
count += 1
self.last_sequence = last_sequence
self.last_angle = last_angle
del samples[count:]
return samples, error_count
# API interface
def _api_update(self, eventtime):
if self.sensor_helper.is_tcode_absolute:
self.sensor_helper.update_clock()
with self.lock:
raw_samples = self.raw_samples
self.raw_samples = []
if not raw_samples:
return {}
samples, error_count = self._extract_samples(raw_samples)
if not samples:
return {}
offset = self.calibration.apply_calibration(samples)
return {'data': samples, 'errors': error_count,
'position_offset': offset}
def _start_measurements(self):
if self.is_measuring():
return
logging.info("Starting angle '%s' measurements", self.name)
self.sensor_helper.start()
# Start bulk reading
with self.lock:
self.raw_samples = []
self.last_sequence = 0
systime = self.printer.get_reactor().monotonic()
print_time = self.mcu.estimated_print_time(systime) + MIN_MSG_TIME
self.start_clock = reqclock = self.mcu.print_time_to_clock(print_time)
rest_ticks = self.mcu.seconds_to_clock(self.sample_period)
self.sample_ticks = rest_ticks
self.query_spi_angle_cmd.send([self.oid, reqclock, rest_ticks,
self.time_shift], reqclock=reqclock)
def _finish_measurements(self):
if not self.is_measuring():
return
# Halt bulk reading
params = self.query_spi_angle_end_cmd.send([self.oid, 0, 0, 0])
self.start_clock = 0
with self.lock:
self.raw_samples = []
self.sensor_helper.last_temperature = None
logging.info("Stopped angle '%s' measurements", self.name)
def _api_startstop(self, is_start):
if is_start:
self._start_measurements()
else:
self._finish_measurements()
def _handle_dump_angle(self, web_request):
self.api_dump.add_client(web_request)
hdr = ('time', 'angle')
web_request.send({'header': hdr})
def start_internal_client(self):
return self.api_dump.add_internal_client()
def load_config_prefix(config):
return Angle(config)

View File

@ -221,7 +221,8 @@ class BedMesh:
"mesh_min": (0., 0.),
"mesh_max": (0., 0.),
"probed_matrix": [[]],
"mesh_matrix": [[]]
"mesh_matrix": [[]],
"profiles": self.pmgr.get_profiles()
}
if self.z_mesh is not None:
params = self.z_mesh.get_mesh_params()
@ -316,7 +317,7 @@ class BedMeshCalibrate:
if self.radius is not None:
# round bed, min/max needs to be recalculated
y_dist = x_dist
new_r = (x_cnt / 2) * x_dist
new_r = (x_cnt // 2) * x_dist
min_x = min_y = -new_r
max_x = max_y = new_r
else:
@ -1134,6 +1135,8 @@ class ProfileManager:
self._check_incompatible_profiles()
if "default" in self.profiles:
self.load_profile("default")
def get_profiles(self):
return self.profiles
def get_current_profile(self):
return self.current_profile
def _check_incompatible_profiles(self):
@ -1170,9 +1173,12 @@ class ProfileManager:
for key, value in mesh_params.items():
configfile.set(cfg_name, key, value)
# save copy in local storage
self.profiles[prof_name] = profile = {}
# ensure any self.profiles returned as status remains immutable
profiles = dict(self.profiles)
profiles[prof_name] = profile = {}
profile['points'] = probed_matrix
profile['mesh_params'] = collections.OrderedDict(mesh_params)
self.profiles = profiles
self.current_profile = prof_name
self.gcode.respond_info(
"Bed Mesh state has been saved to profile [%s]\n"
@ -1197,7 +1203,9 @@ class ProfileManager:
if prof_name in self.profiles:
configfile = self.printer.lookup_object('configfile')
configfile.remove_section('bed_mesh ' + prof_name)
del self.profiles[prof_name]
profiles = dict(self.profiles)
del profiles[prof_name]
self.profiles = profiles
self.gcode.respond_info(
"Profile [%s] removed from storage for this session.\n"
"The SAVE_CONFIG command will update the printer\n"

View File

@ -437,7 +437,7 @@ class BME280:
else:
factor = 0
while duration_ms > 0x3F:
duration_ms /= 4
duration_ms //= 4
factor += 1
duration_reg = duration_ms + (factor * 64)

View File

@ -48,7 +48,8 @@ def resolve_bus_name(mcu, param, bus):
# Helper code for working with devices connected to an MCU via an SPI bus
class MCU_SPI:
def __init__(self, mcu, bus, pin, mode, speed, sw_pins=None):
def __init__(self, mcu, bus, pin, mode, speed, sw_pins=None,
cs_active_high=False):
self.mcu = mcu
self.bus = bus
# Config SPI object (set all CS pins high before spi_set_bus commands)
@ -56,7 +57,8 @@ class MCU_SPI:
if pin is None:
mcu.add_config_cmd("config_spi_without_cs oid=%d" % (self.oid,))
else:
mcu.add_config_cmd("config_spi oid=%d pin=%s" % (self.oid, pin))
mcu.add_config_cmd("config_spi oid=%d pin=%s cs_active_high=%d"
% (self.oid, pin, cs_active_high))
# Generate SPI bus config message
if sw_pins is not None:
self.config_fmt = (
@ -112,7 +114,8 @@ class MCU_SPI:
# Helper to setup an spi bus from settings in a config section
def MCU_SPI_from_config(config, mode, pin_option="cs_pin",
default_speed=100000, share_type=None):
default_speed=100000, share_type=None,
cs_active_high=False):
# Determine pin from config
ppins = config.get_printer().lookup_object("pins")
cs_pin = config.get(pin_option)
@ -139,7 +142,7 @@ def MCU_SPI_from_config(config, mode, pin_option="cs_pin",
bus = config.get('spi_bus', None)
sw_pins = None
# Create MCU_SPI object
return MCU_SPI(mcu, bus, pin, mode, speed, sw_pins)
return MCU_SPI(mcu, bus, pin, mode, speed, sw_pins, cs_active_high)
######################################################################

View File

@ -0,0 +1,25 @@
# SPI DAC DAC084S085 implementation
#
# Copyright (C) 2021 Lorenzo Franco <lorenzo.franco@lorenzing.com>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
from . import bus
class dac084S085:
def __init__(self, config):
self.spi = bus.MCU_SPI_from_config(
config, 1, pin_option="enable_pin", default_speed=10000000)
scale = config.getfloat('scale', 1., above=0.)
for chan, name in enumerate("ABCD"):
val = config.getfloat('channel_%s' % (name,), None,
minval=0., maxval=scale)
if val is not None:
self.set_register(chan, int(val * 255. / scale))
def set_register(self, chan, value):
b1 = (chan << 6) | (1 << 4) | ((value >> 4) & 0x0f)
b2 = (value << 4) & 0xf0
self.spi.spi_send([b1, b2])
def load_config_prefix(config):
return dac084S085(config)

View File

@ -76,7 +76,9 @@ class DGUSStatus:
if self.finish_at is not None:
self.finish_at += pause_duration
if self.finish_at_naive is not None:
self.finish_at_naive = (self.finish_at_naive[0], self.finish_at_naive[1] + pause_duration)
self.finish_at_naive = (self.finish_at_naive[0],
self.finish_at_naive[1]
+ pause_duration)
self.pause_at = None
return eventtime + 5.

View File

@ -1,6 +1,6 @@
# Basic LCD display support
#
# Copyright (C) 2018-2020 Kevin O'Connor <kevin@koconnor.net>
# Copyright (C) 2018-2022 Kevin O'Connor <kevin@koconnor.net>
# Copyright (C) 2018 Aleph Objects, Inc <marcio@alephobjects.com>
# Copyright (C) 2018 Eric Callahan <arksine.code@gmail.com>
#
@ -39,6 +39,8 @@ class DisplayTemplate:
option, config.get_name()))
gcode_macro = self.printer.load_object(config, 'gcode_macro')
self.template = gcode_macro.load_template(config, 'text')
def get_params(self):
return self.params
def render(self, context, **kwargs):
params = dict(self.params)
params.update(**kwargs)
@ -83,47 +85,20 @@ class DisplayGroup:
display.draw_text(row, col, text.replace('\n', ''), eventtime)
context.clear() # Remove circular references for better gc
class PrinterLCD:
# Global cache of DisplayTemplate, DisplayGroup, and glyphs
class PrinterDisplayTemplate:
def __init__(self, config):
self.printer = config.get_printer()
self.reactor = self.printer.get_reactor()
# Load low-level lcd handler
self.lcd_chip = config.getchoice('lcd_type', LCD_chips)(config)
# Load menu and display_status
self.menu = None
name = config.get_name()
if name == 'display':
# only load menu for primary display
self.menu = menu.MenuManager(config, self)
self.printer.load_object(config, "display_status")
# Configurable display
self.display_templates = {}
self.display_data_groups = {}
self.display_glyphs = {}
self.load_config(config)
dgroup = "_default_16x4"
if self.lcd_chip.get_dimensions()[0] == 20:
dgroup = "_default_20x4"
dgroup = config.get('display_group', dgroup)
self.show_data_group = self.display_data_groups.get(dgroup)
if self.show_data_group is None:
raise config.error("Unknown display_data group '%s'" % (dgroup,))
# Screen updating
self.printer.register_event_handler("klippy:ready", self.handle_ready)
self.screen_update_timer = self.reactor.register_timer(
self.screen_update_event)
self.redraw_request_pending = False
self.redraw_time = 0.
# Register g-code commands
gcode = self.printer.lookup_object("gcode")
gcode.register_mux_command('SET_DISPLAY_GROUP', 'DISPLAY', name,
self.cmd_SET_DISPLAY_GROUP,
desc=self.cmd_SET_DISPLAY_GROUP_help)
if name == 'display':
gcode.register_mux_command('SET_DISPLAY_GROUP', 'DISPLAY', None,
self.cmd_SET_DISPLAY_GROUP)
def get_dimensions(self):
return self.lcd_chip.get_dimensions()
# Configurable display
def get_display_templates(self):
return self.display_templates
def get_display_data_groups(self):
return self.display_data_groups
def get_display_glyphs(self):
return self.display_glyphs
def _parse_glyph(self, config, glyph_name, data, width, height):
glyph_data = []
for line in data.split('\n'):
@ -170,7 +145,7 @@ class PrinterLCD:
self.display_data_groups[group_name] = dg
# Load display glyphs
dg_prefix = 'display_glyph '
icons = {}
self.display_glyphs = icons = {}
dg_main = config.get_prefix_sections(dg_prefix)
dg_main_names = {c.get_name(): 1 for c in dg_main}
dg_def = [c for c in dconfig.get_prefix_sections(dg_prefix)
@ -188,8 +163,56 @@ class PrinterLCD:
slot = dg.getint('hd44780_slot', minval=0, maxval=7)
idata = self._parse_glyph(config, glyph_name, data, 5, 8)
icons.setdefault(glyph_name, {})['icon5x8'] = (slot, idata)
self.lcd_chip.set_glyphs(icons)
# Initialization
def lookup_display_templates(config):
printer = config.get_printer()
dt = printer.lookup_object("display_template", None)
if dt is None:
dt = PrinterDisplayTemplate(config)
printer.add_object("display_template", dt)
return dt
class PrinterLCD:
def __init__(self, config):
self.printer = config.get_printer()
self.reactor = self.printer.get_reactor()
# Load low-level lcd handler
self.lcd_chip = config.getchoice('lcd_type', LCD_chips)(config)
# Load menu and display_status
self.menu = None
name = config.get_name()
if name == 'display':
# only load menu for primary display
self.menu = menu.MenuManager(config, self)
self.printer.load_object(config, "display_status")
# Configurable display
templates = lookup_display_templates(config)
self.display_templates = templates.get_display_templates()
self.display_data_groups = templates.get_display_data_groups()
self.lcd_chip.set_glyphs(templates.get_display_glyphs())
dgroup = "_default_16x4"
if self.lcd_chip.get_dimensions()[0] == 20:
dgroup = "_default_20x4"
dgroup = config.get('display_group', dgroup)
self.show_data_group = self.display_data_groups.get(dgroup)
if self.show_data_group is None:
raise config.error("Unknown display_data group '%s'" % (dgroup,))
# Screen updating
self.printer.register_event_handler("klippy:ready", self.handle_ready)
self.screen_update_timer = self.reactor.register_timer(
self.screen_update_event)
self.redraw_request_pending = False
self.redraw_time = 0.
# Register g-code commands
gcode = self.printer.lookup_object("gcode")
gcode.register_mux_command('SET_DISPLAY_GROUP', 'DISPLAY', name,
self.cmd_SET_DISPLAY_GROUP,
desc=self.cmd_SET_DISPLAY_GROUP_help)
if name == 'display':
gcode.register_mux_command('SET_DISPLAY_GROUP', 'DISPLAY', None,
self.cmd_SET_DISPLAY_GROUP)
def get_dimensions(self):
return self.lcd_chip.get_dimensions()
def handle_ready(self):
self.lcd_chip.init()
# Start screen update timer

View File

@ -30,7 +30,9 @@ class DisplayStatus:
progress = sdcard.get_status(eventtime)['progress']
return { 'progress': progress, 'message': self.message }
def cmd_M73(self, gcmd):
progress = gcmd.get_float('P', 0.) / 100.
progress = gcmd.get_float('P', None)
if progress is not None:
progress = progress / 100.
self.progress = min(1., max(0., progress))
curtime = self.printer.get_reactor().monotonic()
self.expire_progress = curtime + M73_TIMEOUT

View File

@ -1,6 +1,6 @@
# Support for "dotstar" leds
#
# Copyright (C) 2019-2020 Kevin O'Connor <kevin@koconnor.net>
# Copyright (C) 2019-2022 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
from . import bus
@ -9,11 +9,10 @@ BACKGROUND_PRIORITY_CLOCK = 0x7fffffff00000000
class PrinterDotstar:
def __init__(self, config):
self.printer = config.get_printer()
self.printer = printer = config.get_printer()
name = config.get_name().split()[1]
self.mutex = self.printer.get_reactor().mutex()
# Configure a software spi bus
ppins = self.printer.lookup_object('pins')
ppins = printer.lookup_object('pins')
data_pin_params = ppins.lookup_pin(config.get('data_pin'))
clock_pin_params = ppins.lookup_pin(config.get('clock_pin'))
mcu = data_pin_params['chip']
@ -22,75 +21,38 @@ class PrinterDotstar:
sw_spi_pins = (data_pin_params['pin'], data_pin_params['pin'],
clock_pin_params['pin'])
self.spi = bus.MCU_SPI(mcu, None, None, 0, 500000, sw_spi_pins)
# Initial color
# Initialize color data
self.chain_count = config.getint('chain_count', 1, minval=1)
red = config.getfloat('initial_RED', 0., minval=0., maxval=1.)
green = config.getfloat('initial_GREEN', 0., minval=0., maxval=1.)
blue = config.getfloat('initial_BLUE', 0., minval=0., maxval=1.)
color_data = [0xff, blue, green, red] * self.chain_count
self.color_data = [0, 0, 0, 0] + color_data + [0xff, 0xff, 0xff, 0xff]
self.update_color_data(red, green, blue)
self.old_color_data = bytearray([d ^ 1 for d in self.color_data])
pled = printer.load_object(config, "led")
self.led_helper = pled.setup_helper(config, self.update_leds,
self.chain_count)
self.prev_data = None
# Register commands
self.printer.register_event_handler("klippy:connect", self.send_data)
gcode = self.printer.lookup_object('gcode')
gcode.register_mux_command("SET_LED", "LED", name, self.cmd_SET_LED,
desc=self.cmd_SET_LED_help)
def update_color_data(self, red, green, blue, white=None, index=None):
red = int(red * 255. + .5)
blue = int(blue * 255. + .5)
green = int(green * 255. + .5)
color_data = [0xff, blue, green, red]
if index is not None:
self.color_data[index*4:(index+1)*4] = color_data
else:
self.color_data[4:-4] = color_data * self.chain_count
def send_data(self, print_time=None):
old_data, new_data = self.old_color_data, self.color_data
if new_data == old_data:
printer.register_event_handler("klippy:connect", self.handle_connect)
def handle_connect(self):
self.update_leds(self.led_helper.get_status()['color_data'], None)
def update_leds(self, led_state, print_time):
if led_state == self.prev_data:
return
self.prev_data = led_state
# Build data to send
data = [0] * ((len(led_state) + 2) * 4)
for i, (red, green, blue, white) in enumerate(led_state):
idx = (i + 1) * 4
data[idx] = 0xff
data[idx+1] = int(blue * 255. + .5)
data[idx+2] = int(green * 255. + .5)
data[idx+3] = int(red * 255. + .5)
data[-4] = data[-3] = data[-2] = data[-1] = 0xff
# Transmit update
minclock = 0
if print_time is not None:
minclock = self.spi.get_mcu().print_time_to_clock(print_time)
data = self.color_data
for d in [data[i:i+20] for i in range(0, len(data), 20)]:
self.spi.spi_send(d, minclock=minclock,
reqclock=BACKGROUND_PRIORITY_CLOCK)
cmd_SET_LED_help = "Set the color of an LED"
def cmd_SET_LED(self, gcmd):
# Parse parameters
red = gcmd.get_float('RED', 0., minval=0., maxval=1.)
green = gcmd.get_float('GREEN', 0., minval=0., maxval=1.)
blue = gcmd.get_float('BLUE', 0., minval=0., maxval=1.)
white = 0.0 #dotstar's dont have white yet
index = gcmd.get_int('INDEX', None, minval=1, maxval=self.chain_count)
transmit = gcmd.get_int('TRANSMIT', 1)
sync = gcmd.get_int('SYNC', 1)
def reactor_bgfunc(print_time):
with self.mutex:
self.update_color_data(red, green, blue, index=index)
if transmit:
self.send_data(print_time)
def lookahead_bgfunc(print_time):
reactor = self.printer.get_reactor()
reactor.register_callback(lambda et: reactor_bgfunc(print_time))
if sync:
#Sync LED Update with print time and send
toolhead = self.printer.lookup_object('toolhead')
toolhead.register_lookahead_callback(lookahead_bgfunc)
else:
#Send update now (so as not to wake toolhead and reset idle_timeout)
lookahead_bgfunc(None)
def get_status(self, eventtime):
cdata = []
for i in range(self.chain_count):
idx = (i + 1) * 4
cdata.append(
{k: round(v / 255., 4) for k, v in
zip("BGR", self.color_data[idx+1:idx+4])}
)
return {'color_data': cdata}
return self.led_helper.get_status(eventtime)
def load_config_prefix(config):
return PrinterDotstar(config)

View File

@ -54,7 +54,8 @@ class EndstopPhase:
self.name = config.get_name().split()[1]
# Obtain step_distance and microsteps from stepper config section
sconfig = config.getsection(self.name)
self.step_dist = stepper.parse_step_distance(sconfig)
rotation_dist, steps_per_rotation = stepper.parse_step_distance(sconfig)
self.step_dist = rotation_dist / steps_per_rotation
self.phases = sconfig.getint("microsteps", note_valid=False) * 4
self.phase_calc = PhaseCalc(self.printer, self.name, self.phases)
# Register event handlers

View File

@ -4,36 +4,17 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
import stepper
from kinematics import extruder
class ExtruderStepper:
class PrinterExtruderStepper:
def __init__(self, config):
self.printer = config.get_printer()
stepper_name = config.get_name().split()[1]
self.extruder_name = config.get('extruder', 'extruder')
self.stepper = stepper.PrinterStepper(config)
self.stepper.setup_itersolve('extruder_stepper_alloc')
self.extruder_stepper = extruder.ExtruderStepper(config)
self.extruder_name = config.get('extruder')
self.printer.register_event_handler("klippy:connect",
self.handle_connect)
gcode = self.printer.lookup_object('gcode')
gcode.register_mux_command("SYNC_STEPPER_TO_EXTRUDER", "STEPPER",
stepper_name,
self.cmd_SYNC_STEPPER_TO_EXTRUDER,
desc=self.cmd_SYNC_STEPPER_TO_EXTRUDER_help)
def handle_connect(self):
extruder = self.printer.lookup_object(self.extruder_name)
extruder.sync_stepper(self.stepper)
toolhead = self.printer.lookup_object('toolhead')
toolhead.register_step_generator(self.stepper.generate_steps)
cmd_SYNC_STEPPER_TO_EXTRUDER_help = "Set extruder stepper"
def cmd_SYNC_STEPPER_TO_EXTRUDER(self, gcmd):
ename = gcmd.get('EXTRUDER')
extruder = self.printer.lookup_object(ename, None)
if extruder is None:
raise gcmd.error("'%s' is not a valid extruder." % (ename,))
extruder.sync_stepper(self.stepper)
self.extruder_name = ename
gcmd.respond_info("Extruder stepper now syncing with '%s'" % (ename,))
self.extruder_stepper.sync_to_extruder(self.extruder_name)
def load_config_prefix(config):
return ExtruderStepper(config)
return PrinterExtruderStepper(config)

View File

@ -20,9 +20,15 @@ class ArcSupport:
self.gcode_move = self.printer.load_object(config, 'gcode_move')
self.gcode = self.printer.lookup_object('gcode')
self.gcode.register_command("G2", self.cmd_G2)
self.gcode.register_command("G3", self.cmd_G2)
self.gcode.register_command("G3", self.cmd_G3)
def cmd_G2(self, gcmd):
self._cmd_inner(gcmd, True)
def cmd_G3(self, gcmd):
self._cmd_inner(gcmd, False)
def _cmd_inner(self, gcmd, clockwise):
gcodestatus = self.gcode_move.get_status()
if not gcodestatus['absolute_coordinates']:
raise gcmd.error("G2/G3 does not support relative move mode")
@ -40,7 +46,6 @@ class ArcSupport:
raise gcmd.error("G2/G3 neither I nor J given")
asE = gcmd.get_float("E", None)
asF = gcmd.get_float("F", None)
clockwise = (gcmd.get_command() == 'G2')
# Build list of linear coordinates to move to
coords = self.planArc(currentPos, [asX, asY, asZ], [asI, asJ],

View File

@ -18,7 +18,8 @@ def multi_complete(printer, completions):
cp = reactor.register_callback(lambda e: [c.wait() for c in completions])
# If any completion indicates an error, then exit main completion early
for c in completions:
reactor.register_callback(lambda e: cp.complete(1) if c.wait() else 0)
reactor.register_callback(
lambda e, c=c: cp.complete(1) if c.wait() else 0)
return cp
# Tracking of stepper positions during a homing/probing move

View File

@ -14,7 +14,7 @@ from . import bus
# HTU21D - Tested on Linux MCU.
# Si7013 - Untested
# Si7020 - Untested
# Si7021 - Untested
# Si7021 - Tested on Pico MCU
# SHT21 - Untested
#
######################################################################
@ -56,7 +56,7 @@ HTU21D_DEVICES = {
'TEMP13_HUM10':[ .7, .5],
'TEMP12_HUM08':[ .4, .4],
'TEMP11_HUM11':[ .3, .7]},
'SI7021':{'id':0x14,
'SI7021':{'id':0x15,
'TEMP14_HUM12':[.11,.12],
'TEMP13_HUM10':[ .7, .5],
'TEMP12_HUM08':[ .4, .4],

232
klippy/extras/led.py Normal file
View File

@ -0,0 +1,232 @@
# Support for PWM driven LEDs
#
# Copyright (C) 2019-2022 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging, ast
from .display import display
# Time between each led template update
RENDER_TIME = 0.500
# Helper code for common LED initialization and control
class LEDHelper:
def __init__(self, config, update_func, led_count=1):
self.printer = config.get_printer()
self.update_func = update_func
self.led_count = led_count
self.need_transmit = False
# Initial color
red = config.getfloat('initial_RED', 0., minval=0., maxval=1.)
green = config.getfloat('initial_GREEN', 0., minval=0., maxval=1.)
blue = config.getfloat('initial_BLUE', 0., minval=0., maxval=1.)
white = config.getfloat('initial_WHITE', 0., minval=0., maxval=1.)
self.led_state = [(red, green, blue, white)] * led_count
# Register commands
name = config.get_name().split()[-1]
gcode = self.printer.lookup_object('gcode')
gcode.register_mux_command("SET_LED", "LED", name, self.cmd_SET_LED,
desc=self.cmd_SET_LED_help)
def get_led_count(self):
return self.led_count
def set_color(self, index, color):
if index is None:
new_led_state = [color] * self.led_count
if self.led_state == new_led_state:
return
else:
if self.led_state[index - 1] == color:
return
new_led_state = list(self.led_state)
new_led_state[index - 1] = color
self.led_state = new_led_state
self.need_transmit = True
def check_transmit(self, print_time):
if not self.need_transmit:
return
self.need_transmit = False
try:
self.update_func(self.led_state, print_time)
except self.printer.command_error as e:
logging.exception("led update transmit error")
cmd_SET_LED_help = "Set the color of an LED"
def cmd_SET_LED(self, gcmd):
# Parse parameters
red = gcmd.get_float('RED', 0., minval=0., maxval=1.)
green = gcmd.get_float('GREEN', 0., minval=0., maxval=1.)
blue = gcmd.get_float('BLUE', 0., minval=0., maxval=1.)
white = gcmd.get_float('WHITE', 0., minval=0., maxval=1.)
index = gcmd.get_int('INDEX', None, minval=1, maxval=self.led_count)
transmit = gcmd.get_int('TRANSMIT', 1)
sync = gcmd.get_int('SYNC', 1)
color = (red, green, blue, white)
# Update and transmit data
def lookahead_bgfunc(print_time):
self.set_color(index, color)
if transmit:
self.check_transmit(print_time)
if sync:
#Sync LED Update with print time and send
toolhead = self.printer.lookup_object('toolhead')
toolhead.register_lookahead_callback(lookahead_bgfunc)
else:
#Send update now (so as not to wake toolhead and reset idle_timeout)
lookahead_bgfunc(None)
def get_status(self, eventtime=None):
return {'color_data': self.led_state}
# Main LED tracking code
class PrinterLED:
def __init__(self, config):
self.printer = config.get_printer()
self.led_helpers = {}
self.active_templates = {}
self.render_timer = None
# Load templates
dtemplates = display.lookup_display_templates(config)
self.templates = dtemplates.get_display_templates()
gcode_macro = self.printer.lookup_object("gcode_macro")
self.create_template_context = gcode_macro.create_template_context
# Register handlers
gcode = self.printer.lookup_object('gcode')
gcode.register_command("SET_LED_TEMPLATE", self.cmd_SET_LED_TEMPLATE,
desc=self.cmd_SET_LED_TEMPLATE_help)
def setup_helper(self, config, update_func, led_count=1):
led_helper = LEDHelper(config, update_func, led_count)
name = config.get_name().split()[-1]
self.led_helpers[name] = led_helper
return led_helper
def _activate_timer(self):
if self.render_timer is not None or not self.active_templates:
return
reactor = self.printer.get_reactor()
self.render_timer = reactor.register_timer(self._render, reactor.NOW)
def _activate_template(self, led_helper, index, template, lparams):
key = (led_helper, index)
if template is not None:
uid = (template,) + tuple(sorted(lparams.items()))
self.active_templates[key] = (uid, template, lparams)
return
if key in self.active_templates:
del self.active_templates[key]
def _render(self, eventtime):
if not self.active_templates:
# Nothing to do - unregister timer
reactor = self.printer.get_reactor()
reactor.register_timer(self.render_timer)
self.render_timer = None
return reactor.NEVER
# Setup gcode_macro template context
context = self.create_template_context(eventtime)
def render(name, **kwargs):
return self.templates[name].render(context, **kwargs)
context['render'] = render
# Render all templates
need_transmit = {}
rendered = {}
template_info = self.active_templates.items()
for (led_helper, index), (uid, template, lparams) in template_info:
color = rendered.get(uid)
if color is None:
try:
text = template.render(context, **lparams)
parts = [max(0., min(1., float(f)))
for f in text.split(',', 4)]
except Exception as e:
logging.exception("led template render error")
parts = []
if len(parts) < 4:
parts += [0.] * (4 - len(parts))
rendered[uid] = color = tuple(parts)
need_transmit[led_helper] = 1
led_helper.set_color(index, color)
context.clear() # Remove circular references for better gc
# Transmit pending changes
for led_helper in need_transmit.keys():
led_helper.check_transmit(None)
return eventtime + RENDER_TIME
cmd_SET_LED_TEMPLATE_help = "Assign a display_template to an LED"
def cmd_SET_LED_TEMPLATE(self, gcmd):
led_name = gcmd.get("LED")
led_helper = self.led_helpers.get(led_name)
if led_helper is None:
raise gcmd.error("Unknown LED '%s'" % (led_name,))
led_count = led_helper.get_led_count()
index = gcmd.get_int("INDEX", None, minval=1, maxval=led_count)
template = None
lparams = {}
tpl_name = gcmd.get("TEMPLATE")
if tpl_name:
template = self.templates.get(tpl_name)
if template is None:
raise gcmd.error("Unknown display_template '%s'" % (tpl_name,))
tparams = template.get_params()
for p, v in gcmd.get_command_parameters().items():
if not p.startswith("PARAM_"):
continue
p = p.lower()
if p not in tparams:
raise gcmd.error("Invalid display_template parameter: %s"
% (p,))
try:
lparams[p] = ast.literal_eval(v)
except ValueError as e:
raise gcmd.error("Unable to parse '%s' as a literal" % (v,))
if index is not None:
self._activate_template(led_helper, index, template, lparams)
else:
for i in range(led_count):
self._activate_template(led_helper, i+1, template, lparams)
self._activate_timer()
PIN_MIN_TIME = 0.100
MAX_SCHEDULE_TIME = 5.0
# Handler for PWM controlled LEDs
class PrinterPWMLED:
def __init__(self, config):
self.printer = printer = config.get_printer()
# Configure pwm pins
ppins = printer.lookup_object('pins')
cycle_time = config.getfloat('cycle_time', 0.010, above=0.,
maxval=MAX_SCHEDULE_TIME)
hardware_pwm = config.getboolean('hardware_pwm', False)
self.pins = []
for i, name in enumerate(("red", "green", "blue", "white")):
pin_name = config.get(name + '_pin', None)
if pin_name is None:
continue
mcu_pin = ppins.setup_pin('pwm', pin_name)
mcu_pin.setup_max_duration(0.)
mcu_pin.setup_cycle_time(cycle_time, hardware_pwm)
self.pins.append((i, mcu_pin))
if not self.pins:
raise config.error("No LED pin definitions found in '%s'"
% (config.get_name(),))
self.last_print_time = 0.
# Initialize color data
pled = printer.load_object(config, "led")
self.led_helper = pled.setup_helper(config, self.update_leds, 1)
self.prev_color = color = self.led_helper.get_status()['color_data'][0]
for idx, mcu_pin in self.pins:
mcu_pin.setup_start_value(color[idx], 0.)
def update_leds(self, led_state, print_time):
if print_time is None:
eventtime = self.printer.get_reactor().monotonic()
mcu = self.pins[0][1].get_mcu()
print_time = mcu.estimated_print_time(eventtime) + PIN_MIN_TIME
print_time = max(print_time, self.last_print_time + PIN_MIN_TIME)
color = led_state[0]
for idx, mcu_pin in self.pins:
if self.prev_color[idx] != color[idx]:
mcu_pin.set_pwm(print_time, color[idx])
self.last_print_time = print_time
self.prev_color = color
def get_status(self, eventtime=None):
return self.led_helper.get_status(eventtime)
def load_config(config):
return PrinterLED(config)
def load_config_prefix(config):
return PrinterPWMLED(config)

View File

@ -31,18 +31,20 @@ class SoftwareI2C:
self.mcu.add_config_cmd("config_digital_out oid=%d pin=%s"
" value=%d default_value=%d max_duration=%d" % (
self.sda_oid, sda_params['pin'], 1, 1, 0))
def get_mcu(self):
return self.mcu
def build_config(self):
self.mcu.add_config_cmd("config_digital_out oid=%d pin=%s value=%d"
" default_value=%d max_duration=%d" % (
self.scl_oid, self.scl_pin, 1, 1, 0))
self.update_pin_cmd = self.mcu.lookup_command(
"update_digital_out oid=%c value=%c", cq=self.cmd_queue)
def i2c_write(self, msg):
def i2c_write(self, msg, minclock=0, reqclock=0):
msg = [self.addr] + msg
send = self.scl_main.update_pin_cmd.send
# Send ack
send([self.sda_oid, 0])
send([self.scl_oid, 0])
send([self.sda_oid, 0], minclock=minclock, reqclock=reqclock)
send([self.scl_oid, 0], minclock=minclock, reqclock=reqclock)
# Send bytes
sda_last = 0
for data in msg:
@ -51,17 +53,18 @@ class SoftwareI2C:
sda_next = not not (data & (0x80 >> i))
if sda_last != sda_next:
sda_last = sda_next
send([self.sda_oid, sda_last])
send([self.scl_oid, 1])
send([self.scl_oid, 0])
send([self.sda_oid, sda_last],
minclock=minclock, reqclock=reqclock)
send([self.scl_oid, 1], minclock=minclock, reqclock=reqclock)
send([self.scl_oid, 0], minclock=minclock, reqclock=reqclock)
# Transmit clock for ack
send([self.scl_oid, 1])
send([self.scl_oid, 0])
send([self.scl_oid, 1], minclock=minclock, reqclock=reqclock)
send([self.scl_oid, 0], minclock=minclock, reqclock=reqclock)
# Send stop
if sda_last:
send([self.sda_oid, 0])
send([self.scl_oid, 1])
send([self.sda_oid, 1])
send([self.sda_oid, 0], minclock=minclock, reqclock=reqclock)
send([self.scl_oid, 1], minclock=minclock, reqclock=reqclock)
send([self.sda_oid, 1], minclock=minclock, reqclock=reqclock)
class mcp4018:
def __init__(self, config):

View File

@ -17,29 +17,37 @@ class APIDumpHelper:
if startstop_cb is None:
startstop_cb = (lambda is_start: None)
self.startstop_cb = startstop_cb
self.is_started = False
self.update_interval = update_interval
self.update_timer = None
self.clients = {}
def _stop(self):
self.clients.clear()
if self.update_timer is None:
return
reactor = self.printer.get_reactor()
reactor.unregister_timer(self.update_timer)
self.update_timer = None
if not self.is_started:
return reactor.NEVER
try:
self.startstop_cb(False)
except self.printer.command_error as e:
logging.exception("API Dump Helper stop callback error")
self.clients.clear()
self.is_started = False
if self.clients:
# New client started while in process of stopping
self._start()
return reactor.NEVER
def _start(self):
if self.update_timer is not None:
if self.is_started:
return
self.is_started = True
try:
self.startstop_cb(True)
except self.printer.command_error as e:
logging.exception("API Dump Helper start callback error")
self._stop()
self.is_started = False
self.clients.clear()
raise
reactor = self.printer.get_reactor()
systime = reactor.monotonic()
@ -139,7 +147,7 @@ class DumpStepper:
mcu_pos = first.start_position
start_position = self.mcu_stepper.mcu_to_commanded_position(mcu_pos)
step_dist = self.mcu_stepper.get_step_dist()
if self.mcu_stepper.is_dir_inverted():
if self.mcu_stepper.get_dir_inverted()[0]:
step_dist = -step_dist
d = [(s.interval, s.step_count, s.add) for s in data]
return {"data": d, "start_position": start_position,

View File

@ -1,6 +1,6 @@
# Support for "neopixel" leds
#
# Copyright (C) 2019-2020 Kevin O'Connor <kevin@koconnor.net>
# Copyright (C) 2019-2022 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
@ -14,37 +14,40 @@ MAX_MCU_SIZE = 500 # Sanity check on LED chain length
class PrinterNeoPixel:
def __init__(self, config):
self.printer = config.get_printer()
name = config.get_name().split()[1]
self.mutex = self.printer.get_reactor().mutex()
self.printer = printer = config.get_printer()
self.mutex = printer.get_reactor().mutex()
# Configure neopixel
ppins = self.printer.lookup_object('pins')
ppins = printer.lookup_object('pins')
pin_params = ppins.lookup_pin(config.get('pin'))
self.mcu = pin_params['chip']
self.oid = self.mcu.create_oid()
self.pin = pin_params['pin']
self.mcu.register_config_callback(self.build_config)
formats = {v: v for v in ["RGB", "GRB", "RGBW", "GRBW"]}
self.color_order = config.getchoice("color_order", formats, "GRB")
elem_size = len(self.color_order)
self.chain_count = config.getint('chain_count', 1, minval=1,
maxval=MAX_MCU_SIZE//elem_size)
self.neopixel_update_cmd = self.neopixel_send_cmd = None
# Initial color
self.color_data = bytearray(self.chain_count * elem_size)
red = config.getfloat('initial_RED', 0., minval=0., maxval=1.)
green = config.getfloat('initial_GREEN', 0., minval=0., maxval=1.)
blue = config.getfloat('initial_BLUE', 0., minval=0., maxval=1.)
white = 0
if elem_size == 4:
white = config.getfloat('initial_WHITE', 0., minval=0., maxval=1.)
self.update_color_data(red, green, blue, white)
# Build color map
chain_count = config.getint('chain_count', 1, minval=1)
color_order = config.getlist("color_order", ["GRB"])
if len(color_order) == 1:
color_order = [color_order[0]] * chain_count
if len(color_order) != chain_count:
raise config.error("color_order does not match chain_count")
color_indexes = []
for lidx, co in enumerate(color_order):
if sorted(co) not in (sorted("RGB"), sorted("RGBW")):
raise config.error("Invalid color_order '%s'" % (co,))
color_indexes.extend([(lidx, "RGBW".index(c)) for c in co])
self.color_map = list(enumerate(color_indexes))
if len(self.color_map) > MAX_MCU_SIZE:
raise config.error("neopixel chain too long")
# Initialize color data
pled = printer.load_object(config, "led")
self.led_helper = pled.setup_helper(config, self.update_leds,
chain_count)
self.color_data = bytearray(len(self.color_map))
self.update_color_data(self.led_helper.get_status()['color_data'])
self.old_color_data = bytearray([d ^ 1 for d in self.color_data])
# Register commands
self.printer.register_event_handler("klippy:connect", self.send_data)
gcode = self.printer.lookup_object('gcode')
gcode.register_mux_command("SET_LED", "LED", name, self.cmd_SET_LED,
desc=self.cmd_SET_LED_help)
# Register callbacks
printer.register_event_handler("klippy:connect", self.send_data)
def build_config(self):
bmt = self.mcu.seconds_to_clock(BIT_MAX_TIME)
rmt = self.mcu.seconds_to_clock(RESET_MIN_TIME)
@ -58,24 +61,10 @@ class PrinterNeoPixel:
self.neopixel_send_cmd = self.mcu.lookup_query_command(
"neopixel_send oid=%c", "neopixel_result oid=%c success=%c",
oid=self.oid, cq=cmd_queue)
def update_color_data(self, red, green, blue, white, index=None):
red = int(red * 255. + .5)
blue = int(blue * 255. + .5)
green = int(green * 255. + .5)
white = int(white * 255. + .5)
if self.color_order == "GRB":
color_data = [green, red, blue]
elif self.color_order == "RGB":
color_data = [red, green, blue]
elif self.color_order == "GRBW":
color_data = [green, red, blue, white]
else:
color_data = [red, green, blue, white]
if index is None:
self.color_data[:] = color_data * self.chain_count
else:
elem_size = len(color_data)
self.color_data[(index-1)*elem_size:index*elem_size] = color_data
def update_color_data(self, led_state):
color_data = self.color_data
for cdidx, (lidx, cidx) in self.color_map:
color_data[cdidx] = int(led_state[lidx][cidx] * 255. + .5)
def send_data(self, print_time=None):
old_data, new_data = self.old_color_data, self.color_data
if new_data == old_data:
@ -110,42 +99,14 @@ class PrinterNeoPixel:
break
else:
logging.info("Neopixel update did not succeed")
cmd_SET_LED_help = "Set the color of an LED"
def cmd_SET_LED(self, gcmd):
# Parse parameters
red = gcmd.get_float('RED', 0., minval=0., maxval=1.)
green = gcmd.get_float('GREEN', 0., minval=0., maxval=1.)
blue = gcmd.get_float('BLUE', 0., minval=0., maxval=1.)
white = gcmd.get_float('WHITE', 0., minval=0., maxval=1.)
index = gcmd.get_int('INDEX', None, minval=1, maxval=self.chain_count)
transmit = gcmd.get_int('TRANSMIT', 1)
sync = gcmd.get_int('SYNC', 1)
# Update and transmit data
def reactor_bgfunc(print_time):
def update_leds(self, led_state, print_time):
def reactor_bgfunc(eventtime):
with self.mutex:
self.update_color_data(red, green, blue, white, index)
if transmit:
self.update_color_data(led_state)
self.send_data(print_time)
def lookahead_bgfunc(print_time):
reactor = self.printer.get_reactor()
reactor.register_callback(lambda et: reactor_bgfunc(print_time))
if sync:
#Sync LED Update with print time and send
toolhead = self.printer.lookup_object('toolhead')
toolhead.register_lookahead_callback(lookahead_bgfunc)
else:
#Send update now (so as not to wake toolhead and reset idle_timeout)
lookahead_bgfunc(None)
def get_status(self, eventtime):
cdata = []
elem_size = len(self.color_order)
for i in range(self.chain_count):
idx = i * elem_size
cdata.append(
{k: round(v / 255., 4) for k, v in
zip(self.color_order, self.color_data[idx:idx+elem_size])}
)
return {'color_data': cdata}
self.printer.get_reactor().register_callback(reactor_bgfunc)
def get_status(self, eventtime=None):
return self.led_helper.get_status(eventtime)
def load_config_prefix(config):
return PrinterNeoPixel(config)

View File

@ -174,7 +174,7 @@ class Palette2:
cmd_Disconnect_Help = ("Disconnect from the Palette 2")
def cmd_Disconnect(self, gmcd=None):
def cmd_Disconnect(self, gcmd=None):
self.gcode.respond_info("Disconnecting from Palette 2")
if self.serial:
self.serial.close()
@ -305,7 +305,7 @@ class Palette2:
param_drive = gcmd.get_commandline()[5:6]
param_distance = gcmd.get_commandline()[8:]
except IndexError:
gmcd.respond_info(
gcmd.respond_info(
"Incorrect number of arguments for splice command")
try:
self.omega_splices.append((int(param_drive), param_distance))

View File

@ -63,7 +63,7 @@ class PauseResume:
gcmd.respond_info("Print already paused")
return
self.send_pause_command()
self.gcode.run_script_from_command("SAVE_GCODE_STATE STATE=PAUSE_STATE")
self.gcode.run_script_from_command("SAVE_GCODE_STATE NAME=PAUSE_STATE")
self.is_paused = True
def send_resume_command(self):
if self.sd_paused:
@ -80,7 +80,7 @@ class PauseResume:
return
velocity = gcmd.get_float('VELOCITY', self.recover_velocity)
self.gcode.run_script_from_command(
"RESTORE_GCODE_STATE STATE=PAUSE_STATE MOVE=1 MOVE_SPEED=%.4f"
"RESTORE_GCODE_STATE NAME=PAUSE_STATE MOVE=1 MOVE_SPEED=%.4f"
% (velocity))
self.send_resume_command()
self.is_paused = False

View File

@ -6,48 +6,32 @@
import logging
from . import bus
BACKGROUND_PRIORITY_CLOCK = 0x7fffffff00000000
PCA9533_PWM0=0b010
PCA9533_PWM1=0b100
PCA9533_PLS0=0b101
class PCA9533:
def __init__(self, config):
self.printer = config.get_printer()
self.i2c = bus.MCU_I2C_from_config(config, default_addr=98)
#i2c_addr = self.i2c.get_i2c_address()
name = config.get_name().split()[1]
self.gcode = self.printer.lookup_object('gcode')
self.gcode.register_mux_command("SET_LED","LED",name,self.set_led,
desc="Set the color of an LED")
self.led0 = config.getint("initial_RED",0,0,1)
self.led1 = config.getint("initial_GREEN",0,0,1)
self.led2 = config.getint("initial_BLUE",0,0,1)
self.led3 = config.getint("initial_WHITE",0,0,1)
ls0 = (self.led3<<6) | (self.led2<<4) | (self.led1<<2) | (self.led0)
self.i2c.i2c_write([PCA9533_PLS0,ls0])
def set_led(self, gcmd):
if gcmd.get_float("RED",self.led0,0,1) != 0:
self.led0 = 1
else:
self.led0 = 0
if gcmd.get_float("GREEN",self.led1,0,1) != 0:
self.led1 = 1
else:
self.led1 = 0
if gcmd.get_float("BLUE",self.led2,0,1) != 0:
self.led2 = 1
else:
self.led2 = 0
if gcmd.get_float("WHITE",self.led3,0,1) != 0:
self.led3 = 1
else:
self.led3 = 0
ls0 = (self.led3<<6) | (self.led2<<4) | (self.led1<<2) | (self.led0)
self.i2c.i2c_write([PCA9533_PLS0,ls0])
pled = self.printer.load_object(config, "led")
self.led_helper = pled.setup_helper(config, self.update_leds, 1)
self.i2c.i2c_write([PCA9533_PWM0, 85])
self.i2c.i2c_write([PCA9533_PWM1, 170])
self.update_leds(self.led_helper.get_status()['color_data'], None)
def update_leds(self, led_state, print_time):
rmap = [0, 2, 3, 1, 1]
red, green, blue, white = [rmap[int(v * 4.)] for v in led_state[0]]
ls0 = (white<<6) | (blue<<4) | (green<<2) | red
minclock = 0
if print_time is not None:
minclock = self.i2c.get_mcu().print_time_to_clock(print_time)
self.i2c.i2c_write([PCA9533_PLS0, ls0], minclock=minclock,
reqclock=BACKGROUND_PRIORITY_CLOCK)
def get_status(self, eventtime):
return self.led_helper.get_status(eventtime)
def load_config_prefix(config):
return PCA9533(config)

74
klippy/extras/pca9632.py Normal file
View File

@ -0,0 +1,74 @@
# Support for the PCA9632 LED driver ic
#
# Copyright (C) 2022 Ricardo Alcantara <ricardo@vulcanolabs.com>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
from . import bus, mcp4018
BACKGROUND_PRIORITY_CLOCK = 0x7fffffff00000000
# Register addresses
PCA9632_MODE1 = 0x00
PCA9632_MODE2 = 0x01
PCA9632_PWM0 = 0x02
PCA9632_PWM1 = 0x03
PCA9632_PWM2 = 0x04
PCA9632_PWM3 = 0x05
PCA9632_LEDOUT = 0x08
LED_PWM = 0x02
PCA9632_LED0 = 0x00
PCA9632_LED1 = 0x02
PCA9632_LED2 = 0x04
PCA9632_LED3 = 0x06
class PCA9632:
def __init__(self, config):
self.printer = printer = config.get_printer()
if config.get("scl_pin", None) is not None:
self.i2c = mcp4018.SoftwareI2C(config, 98)
else:
self.i2c = bus.MCU_I2C_from_config(config, default_addr=98)
color_order = config.get("color_order", "RGBW")
if sorted(color_order) != sorted("RGBW"):
raise config.error("Invalid color_order '%s'" % (color_order,))
self.color_map = ["RGBW".index(c) for c in color_order]
self.prev_regs = {}
pled = printer.load_object(config, "led")
self.led_helper = pled.setup_helper(config, self.update_leds, 1)
printer.register_event_handler("klippy:connect", self.handle_connect)
def reg_write(self, reg, val, minclock=0):
if self.prev_regs.get(reg) == val:
return
self.prev_regs[reg] = val
self.i2c.i2c_write([reg, val], minclock=minclock,
reqclock=BACKGROUND_PRIORITY_CLOCK)
def handle_connect(self):
#Configure MODE1
self.reg_write(PCA9632_MODE1, 0x00)
#Configure MODE2 (DIMMING, INVERT, CHANGE ON STOP,TOTEM)
self.reg_write(PCA9632_MODE2, 0x15)
self.update_leds(self.led_helper.get_status()['color_data'], None)
def update_leds(self, led_state, print_time):
minclock = 0
if print_time is not None:
minclock = self.i2c.get_mcu().print_time_to_clock(print_time)
color = [int(v * 255. + .5) for v in led_state[0]]
led0, led1, led2, led3 = [color[idx] for idx in self.color_map]
self.reg_write(PCA9632_PWM0, led0, minclock=minclock)
self.reg_write(PCA9632_PWM1, led1, minclock=minclock)
self.reg_write(PCA9632_PWM2, led2, minclock=minclock)
self.reg_write(PCA9632_PWM3, led3, minclock=minclock)
LEDOUT = (LED_PWM << PCA9632_LED0 if led0 else 0)
LEDOUT |= (LED_PWM << PCA9632_LED1 if led1 else 0)
LEDOUT |= (LED_PWM << PCA9632_LED2 if led2 else 0)
LEDOUT |= (LED_PWM << PCA9632_LED3 if led3 else 0)
self.reg_write(PCA9632_LEDOUT, LEDOUT, minclock=minclock)
def get_status(self, eventtime):
return self.led_helper.get_status(eventtime)
def load_config_prefix(config):
return PCA9632(config)

View File

@ -136,7 +136,7 @@ class ControlAutoTune:
pwm = ["pwm: %.3f %.3f" % (time, value)
for time, value in self.pwm_samples]
out = ["%.3f %.3f" % (time, temp) for time, temp in self.temp_samples]
f = open(filename, "wb")
f = open(filename, "w")
f.write('\n'.join(pwm + out))
f.close()

View File

@ -3,7 +3,7 @@
# Copyright (C) 2020 Dmitry Butyugin <dmbutyugin@google.com>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import collections, importlib, logging, math, multiprocessing
import collections, importlib, logging, math, multiprocessing, traceback
shaper_defs = importlib.import_module('.shaper_defs', 'extras')
MIN_FREQ = 5.

View File

@ -143,7 +143,7 @@ class PrinterSkew:
"update the printer config file and restart the printer."
% (name))
elif gcmd.get('REMOVE', None) is not None:
name = gmcd.get('REMOVE')
name = gcmd.get('REMOVE')
if name in self.skew_profiles:
configfile = self.printer.lookup_object('configfile')
configfile.remove_section('skew_correction ' + name)

View File

@ -0,0 +1,154 @@
# SmartEffector support
#
# Copyright (C) 2021 Dmitry Butyugin <dmbutyugin@google.com>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
from . import probe
# SmartEffector communication protocol implemented here originates from
# https://github.com/Duet3D/SmartEffectorFirmware
BITS_PER_SECOND = 1000.
class ControlPinHelper:
def __init__(self, pin_params):
self._mcu = pin_params['chip']
self._pin = pin_params['pin']
self._start_value = self._invert = pin_params['invert']
self._oid = None
self._set_cmd = None
self._mcu.register_config_callback(self._build_config)
def _build_config(self):
self._mcu.request_move_queue_slot()
self._oid = self._mcu.create_oid()
self._mcu.add_config_cmd(
"config_digital_out oid=%d pin=%s value=%d default_value=%d"
" max_duration=%d" % (self._oid, self._pin, self._start_value,
self._start_value, 0))
cmd_queue = self._mcu.alloc_command_queue()
self._set_cmd = self._mcu.lookup_command(
"queue_digital_out oid=%c clock=%u on_ticks=%u", cq=cmd_queue)
def write_bits(self, start_time, bit_stream):
bit_step = 1. / BITS_PER_SECOND
last_value = self._start_value
bit_time = start_time
for b in bit_stream:
value = (not not b) ^ self._invert
if value != last_value:
clock = self._mcu.print_time_to_clock(bit_time)
self._set_cmd.send([self._oid, clock, value])
last_value = value
bit_time += bit_step
# After the last bit, the signal on the control pin must go back
# to its start value.
if value != self._start_value:
clock = self._mcu.print_time_to_clock(bit_time)
self._set_cmd.send([self._oid, clock, self._start_value])
bit_time += bit_step
return bit_time
class SmartEffectorEndstopWrapper:
def __init__(self, config):
self.printer = config.get_printer()
self.gcode = self.printer.lookup_object('gcode')
self.probe_accel = config.getfloat('probe_accel', 0., minval=0.)
self.recovery_time = config.getfloat('recovery_time', 0.4, minval=0.)
self.probe_wrapper = probe.ProbeEndstopWrapper(config)
# Wrappers
self.get_mcu = self.probe_wrapper.get_mcu
self.add_stepper = self.probe_wrapper.add_stepper
self.get_steppers = self.probe_wrapper.get_steppers
self.home_start = self.probe_wrapper.home_start
self.home_wait = self.probe_wrapper.home_wait
self.query_endstop = self.probe_wrapper.query_endstop
self.multi_probe_begin = self.probe_wrapper.multi_probe_begin
self.multi_probe_end = self.probe_wrapper.multi_probe_end
# SmartEffector control
control_pin = config.get('control_pin', None)
if control_pin:
ppins = self.printer.lookup_object('pins')
pin_params = ppins.lookup_pin(control_pin, can_invert=True)
self.control_pin = ControlPinHelper(pin_params)
self.gcode.register_command("RESET_SMART_EFFECTOR",
self.cmd_RESET_SMART_EFFECTOR,
desc=self.cmd_RESET_SMART_EFFECTOR_help)
else:
self.control_pin = None
self.gcode.register_command("SET_SMART_EFFECTOR",
self.cmd_SET_SMART_EFFECTOR,
desc=self.cmd_SET_SMART_EFFECTOR_help)
def probe_prepare(self, hmove):
toolhead = self.printer.lookup_object('toolhead')
self.probe_wrapper.probe_prepare(hmove)
if self.probe_accel:
systime = self.printer.get_reactor().monotonic()
toolhead_info = toolhead.get_status(systime)
self.old_max_accel = toolhead_info['max_accel']
self.gcode.run_script_from_command(
"M204 S%.3f" % (self.probe_accel,))
if self.recovery_time:
toolhead.dwell(self.recovery_time)
def probe_finish(self, hmove):
if self.probe_accel:
self.gcode.run_script_from_command(
"M204 S%.3f" % (self.old_max_accel,))
self.probe_wrapper.probe_finish(hmove)
def _send_command(self, buf):
# Each byte is sent to the SmartEffector as
# [0 0 1 0 b7 b6 b5 b4 !b4 b3 b2 b1 b0 !b0]
bit_stream = []
for b in buf:
b = b & 0xFF
bit_stream.extend([0, 0, 1, 0])
bit_stream.extend([b & 0x80, b & 0x40, b & 0x20, b & 0x10])
bit_stream.append((~b) & 0x10)
bit_stream.extend([b & 0x08, b & 0x04, b & 0x02, b & 0x01])
bit_stream.append((~b) & 0x01)
# Wait for previous actions to finish
toolhead = self.printer.lookup_object('toolhead')
toolhead.wait_moves()
start_time = toolhead.get_last_move_time()
# Write generated bits to the control pin
end_time = self.control_pin.write_bits(start_time, bit_stream)
# Dwell to make sure no subseqent actions are queued together
# with the SmartEffector programming
toolhead.dwell(end_time - start_time)
toolhead.wait_moves()
cmd_SET_SMART_EFFECTOR_help = 'Set SmartEffector parameters'
def cmd_SET_SMART_EFFECTOR(self, gcmd):
sensitivity = gcmd.get_int('SENSITIVITY', None, minval=0, maxval=255)
respond_info = []
if sensitivity is not None:
if self.control_pin is not None:
buf = [105, sensitivity, 255 - sensitivity]
self._send_command(buf)
respond_info.append("sensitivity: %d" % (sensitivity,))
else:
raise gcmd.error("control_pin must be set in [smart_effector] "
"for sensitivity programming")
self.probe_accel = gcmd.get_float('ACCEL', self.probe_accel, minval=0.)
self.recovery_time = gcmd.get_float('RECOVERY_TIME', self.recovery_time,
minval=0.)
if self.probe_accel:
respond_info.append(
"probing accelartion: %.3f" % (self.probe_accel,))
else:
respond_info.append("probing acceleration control disabled")
if self.recovery_time:
respond_info.append(
"probe recovery time: %.3f" % (self.recovery_time,))
else:
respond_info.append("probe recovery time disabled")
gcmd.respond_info("SmartEffector:\n" + "\n".join(respond_info))
cmd_RESET_SMART_EFFECTOR_help = 'Reset SmartEffector settings (sensitivity)'
def cmd_RESET_SMART_EFFECTOR(self, gcmd):
buf = [131, 131]
self._send_command(buf)
gcmd.respond_info('SmartEffector sensitivity was reset')
def load_config(config):
smart_effector = SmartEffectorEndstopWrapper(config)
config.get_printer().add_object('probe',
probe.PrinterProbe(config, smart_effector))
return smart_effector

View File

@ -72,7 +72,7 @@ class TemperatureFan:
return self.max_speed
def get_status(self, eventtime):
status = self.fan.get_status(eventtime)
status["temperature"] = self.last_temp
status["temperature"] = round(self.last_temp, 2)
status["target"] = self.target_temp
return status
cmd_SET_TEMPERATURE_FAN_TARGET_help = \
@ -147,9 +147,9 @@ class ControlPID:
self.Ki = config.getfloat('pid_Ki') / PID_PARAM_BASE
self.Kd = config.getfloat('pid_Kd') / PID_PARAM_BASE
self.min_deriv_time = config.getfloat('pid_deriv_time', 2., above=0.)
imax = config.getfloat('pid_integral_max',
self.temperature_fan.get_max_speed(), minval=0.)
self.temp_integ_max = imax / self.Ki
self.temp_integ_max = 0.
if self.Ki:
self.temp_integ_max = self.temperature_fan.get_max_speed() / self.Ki
self.prev_temp = AMBIENT_TEMP
self.prev_temp_time = 0.
self.prev_temp_deriv = 0.

View File

@ -64,6 +64,7 @@ class PrinterTemperatureMCU:
cfg_funcs = [
('rp2040', self.config_rp2040),
('sam3', self.config_sam3), ('sam4', self.config_sam4),
('same70', self.config_same70),
('samd21', self.config_samd21), ('samd51', self.config_samd51),
('stm32f1', self.config_stm32f1), ('stm32f2', self.config_stm32f2),
('stm32f4', self.config_stm32f4),
@ -100,6 +101,9 @@ class PrinterTemperatureMCU:
def config_sam4(self):
self.slope = 3.3 / .004700
self.base_temperature = self.calc_base(27., 1.44 / 3.3)
def config_same70(self):
self.slope = 3.3 / .002330
self.base_temperature = self.calc_base(25., 0.72 / 3.3)
def config_samd21(self, addr=0x00806030):
def get1v(val):
if val & 0x80:

View File

@ -224,6 +224,8 @@ class TMCCommandHelper:
self.stepper_enable = self.printer.load_object(config, "stepper_enable")
self.printer.register_event_handler("stepper:sync_mcu_position",
self._handle_sync_mcu_pos)
self.printer.register_event_handler("stepper:set_sdir_inverted",
self._handle_sync_mcu_pos)
self.printer.register_event_handler("klippy:mcu_identify",
self._handle_mcu_identify)
self.printer.register_event_handler("klippy:connect",
@ -306,14 +308,14 @@ class TMCCommandHelper:
if enable_line.is_motor_enabled():
raise
return
if not stepper.is_dir_inverted():
if not stepper.get_dir_inverted()[0]:
driver_phase = 1023 - driver_phase
phases = self._get_phases()
phase = int(float(driver_phase) / 1024 * phases + .5) % phases
moff = (phase - stepper.get_mcu_position()) % phases
if self.mcu_phase_offset is not None and self.mcu_phase_offset != moff:
logging.warning("Stepper %s phase change (was %d now %d)",
self.mcu_phase_offset, moff)
self.stepper_name, self.mcu_phase_offset, moff)
self.mcu_phase_offset = moff
# Stepper enable/disable tracking
def _do_enable(self, print_time):
@ -520,8 +522,9 @@ def TMCStealthchopHelper(config, mcu_tmc, tmc_freq):
velocity = config.getfloat('stealthchop_threshold', 0., minval=0.)
if velocity:
stepper_name = " ".join(config.get_name().split()[1:])
stepper_config = config.getsection(stepper_name)
step_dist = stepper.parse_step_distance(stepper_config)
sconfig = config.getsection(stepper_name)
rotation_dist, steps_per_rotation = stepper.parse_step_distance(sconfig)
step_dist = rotation_dist / steps_per_rotation
step_dist_256 = step_dist / (1 << fields.get_field("mres"))
threshold = int(tmc_freq * step_dist_256 / velocity + .5)
fields.set_field("tpwmthrs", max(0, min(0xfffff, threshold)))

View File

@ -116,30 +116,33 @@ class TMCCurrentHelper:
vref = 0.32
if vsense:
vref = 0.18
cs = int(32. * current * sense_resistor * math.sqrt(2.) / vref
- 1. + .5)
cs = int(32. * sense_resistor * current * math.sqrt(2.) / vref + .5) - 1
return max(0, min(31, cs))
def _calc_current(self, run_current, hold_current):
vsense = False
irun = self._calc_current_bits(run_current, vsense)
ihold = self._calc_current_bits(min(hold_current, run_current),
vsense)
if irun < 16 and ihold < 16:
vsense = True
irun = self._calc_current_bits(run_current, vsense)
ihold = self._calc_current_bits(min(hold_current, run_current),
vsense)
return vsense, irun, ihold
def _calc_current_from_field(self, field_name):
bits = self.fields.get_field(field_name)
def _calc_current_from_bits(self, cs, vsense):
sense_resistor = self.sense_resistor + 0.020
vref = 0.32
if self.fields.get_field("vsense"):
if vsense:
vref = 0.18
return (bits + 1) * vref / (32 * sense_resistor * math.sqrt(2.))
return (cs + 1) * vref / (32. * sense_resistor * math.sqrt(2.))
def _calc_current(self, run_current, hold_current):
vsense = True
irun = self._calc_current_bits(run_current, True)
if irun == 31:
cur = self._calc_current_from_bits(irun, True)
if cur < run_current:
irun2 = self._calc_current_bits(run_current, False)
cur2 = self._calc_current_from_bits(irun2, False)
if abs(run_current - cur2) < abs(run_current - cur):
vsense = False
irun = irun2
ihold = self._calc_current_bits(min(hold_current, run_current), vsense)
return vsense, irun, ihold
def get_current(self):
run_current = self._calc_current_from_field("irun")
hold_current = self._calc_current_from_field("ihold")
irun = self.fields.get_field("irun")
ihold = self.fields.get_field("ihold")
vsense = self.fields.get_field("vsense")
run_current = self._calc_current_from_bits(irun, vsense)
hold_current = self._calc_current_from_bits(ihold, vsense)
return run_current, hold_current, self.req_hold_current, MAX_CURRENT
def set_current(self, run_current, hold_current, print_time):
self.req_hold_current = hold_current

Some files were not shown because too many files have changed in this diff Show More