Skip to content

Commit d12b00c

Browse files
committed
Update load_cell Documentation
* Add API server load_cell/dump_force endpoint * Update [load_cell] config with calibration fields * Add G-Code commands for working with load cells * Add status reference for load_cell objects Signed-off-by: Gareth Farrington <gareth@waves.ky>
1 parent 5b31daf commit d12b00c

6 files changed

Lines changed: 196 additions & 0 deletions

File tree

docs/API_Server.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,22 @@ and might later produce asynchronous messages such as:
396396
`{"params":{"data":[[3292.432935, 562534, 0.067059278],
397397
[3292.4394937, 5625322, 0.670590639]]}}`
398398

399+
### load_cell/dump_force
400+
401+
This endpoint is used to subscribe to force data produced by a load_cell.
402+
Using this endpoint may increase Klipper's system load.
403+
404+
A request may look like:
405+
`{"id": 123, "method":"load_cell/dump_force",
406+
"params": {"sensor": "load_cell", "response_template": {}}}`
407+
and might return:
408+
`{"id": 123,"result":{"header":["time", "force (g)", "counts", "tare_counts"]}}`
409+
and might later produce asynchronous messages such as:
410+
`{"params":{"data":[[3292.432935, 40.65, 562534, -234467]]}}`
411+
412+
The "header" field in the initial query response is used to describe
413+
the fields found in later "data" responses.
414+
399415
### pause_resume/cancel
400416

401417
This endpoint is similar to running the "PRINT_CANCEL" G-Code command.

docs/Config_Reference.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4758,6 +4758,18 @@ scale.
47584758
[load_cell]
47594759
sensor_type:
47604760
# This must be one of the supported sensor types, see below.
4761+
#counts_per_gram:
4762+
# The floating point number of sensor counts that indicates 1 gram of force.
4763+
# This value is calculated by the LOAD_CELL_CALIBRATE command.
4764+
#reverse:
4765+
# Reverse the polarity of the force reported by the load cell. The default
4766+
# is False.
4767+
#reference_tare_counts:
4768+
# The integer tare value, in raw sensor counts, taken when LOAD_CELL_CALIBRATE
4769+
# is run. This is the default tare value when klipper starts up.
4770+
#reverse:
4771+
# Reverses the polarity of the load cell. This is a boolean value, the
4772+
# default is False.
47614773
```
47624774

47634775
#### HX711

docs/G-Codes.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,40 @@ and RAW sensor value for calibration points.
721721
#### DISABLE_FILAMENT_WIDTH_LOG
722722
`DISABLE_FILAMENT_WIDTH_LOG`: Turn off diameter logging.
723723

724+
### [load_cell]
725+
726+
The following commands are enabled if a
727+
[load_cell config section](Config_Reference.md#load_cell) has been enabled.
728+
729+
### LOAD_CELL_DIAGNOSTIC
730+
`LOAD_CELL_DIAGNOSTIC [LOAD_CELL=<config_name>]`: This command collects 10
731+
seconds of load cell data and reports statistics that can help you verify proper
732+
operation of the load cell. This command can be run on both calibrated and
733+
uncalibrated load cells.
734+
735+
### LOAD_CELL_CALIBRATE
736+
`LOAD_CELL_CALIBRATE [LOAD_CELL=<config_name>]`: Start the guided calibration
737+
utility. Calibration is a 3 step process:
738+
1. First you remove all load from the load cell and run the `TARE` command
739+
1. Next you apply a known load to the load cell and run the
740+
`CALIBRATE GRAMS=nnn` command
741+
1. Finally use the `ACCEPT` command to save the results
742+
743+
You can cancel the calibration process at any time with `ABORT`.
744+
745+
### LOAD_CELL_TARE
746+
`LOAD_CELL_TARE [LOAD_CELL=<config_name>]`: This works just like the tare button
747+
on digital scale. It sets the current raw reading of the load cell to be the
748+
zero point reference value. The response is the percentage of the sensors range
749+
that was read and the raw value in counts.
750+
751+
### LOAD_CELL_READ load_cell="name"
752+
`LOAD_CELL_READ [LOAD_CELL=<config_name>]`:
753+
This command takes a reading from the load cell. The response is the percentage
754+
of the sensors range that was read and the raw value in counts. If the load cell
755+
is calibrated a force in grams is also reported.
756+
757+
724758
### [heaters]
725759

726760
The heaters module is automatically loaded if a heater is defined in

docs/Load_Cell.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# Load Cells
2+
3+
This document describes Klipper's support for load cells. Basic load cell
4+
functionality can be used to read force data and to weigh things like filament.
5+
A calibrated force sensor is an important part of a load cell based probe.
6+
7+
## Related Documentation
8+
9+
* [load_cell Config Reference](Config_Reference.md#load_cell)
10+
* [load_cell G-Code Commands](G-Codes.md#load_cell)
11+
* [load_cell Status Reference](Status_Reference.md#load_cell)
12+
13+
## Using `LOAD_CELL_DIAGNOSTIC`
14+
15+
When you first connect a load cell its good practice to check for issues by
16+
running `LOAD_CELL_DIAGNOSTIC`. This tool collects 10 seconds of data from the
17+
load cell and resport statistics:
18+
19+
```
20+
$ LOAD_CELL_DIAGNOSTIC
21+
// Collecting load cell data for 10 seconds...
22+
// Samples Collected: 3211
23+
// Measured samples per second: 332.0
24+
// Good samples: 3211, Saturated samples: 0, Unique values: 900
25+
// Sample range: [4.01% to 4.02%]
26+
// Sample range / sensor capacity: 0.00524%
27+
```
28+
29+
Things you can check with this data:
30+
* The configured sample rate of the sensor should be close to the 'Measured
31+
samples per second' value. If it is not you may have a configuration or wiring
32+
issue.
33+
* 'Saturated samples' should be 0. If you have saturated samples it means the
34+
load sell is seeing more force than it can measure.
35+
* 'Unique values' should be a large percentage of the 'Samples
36+
Collected' value. If 'Unique values' is 1 it is very likely a wiring issue.
37+
* Tap or push on the sensor while `LOAD_CELL_DIAGNOSTIC` runs. If
38+
things are working correctly ths should increase the 'Sample range'.
39+
40+
## Calibrating a Load Cell
41+
42+
Load cells are calibrated using the `LOAD_CELL_CALIBRATE` command. This is an
43+
interactive calibration utility that walks you though a 3 step process:
44+
1. First use the `TARE` command to establish the zero force value. This is the
45+
`reference_tare_counts` config value.
46+
2. Next you apply a known load or force to the load cell and run the
47+
`CALIBRATE GRAMS=nnn` command. From this the `counts_per_gram` value is
48+
calculated. See [the next section](#applying-a-known-force-or-load) for some
49+
suggestions on how to do this.
50+
3. Finally, use the `ACCEPT` command to save the results.
51+
52+
You can cancel the calibration process at any time with `ABORT`.
53+
54+
### Applying a Known Force or Load
55+
56+
The `CALIBRATE GRAMS=nnn` step can be accomplished in a number of ways. If your
57+
load cell is under a platform like a bed or filament holder it might be easiest
58+
to put a known mass on the platform. E.g. you could use a couple of 1KG filament
59+
spools.
60+
61+
If your load cell is in the printer's toolhead a different approach is easier.
62+
Put a digital scale on the printers bed and gently lower the toolhead onto the
63+
scale (or raise the bed into the toolhead if your bed moves). You may be able to
64+
do this using the `FORCE_MOVE` command. But more likely you will have to
65+
manually moving the z axis with the motors off until the toolhead presses on the
66+
scale.
67+
68+
A good calibration force would ideally be a large percentage of the load cell's
69+
rated capacity. E.g. if you have a 5Kg load cell you would ideally calibrate it
70+
with a 5kg mass. This might work well with under-bed sensors that have to
71+
support a lot of weight. For toolhead probes this may not be a load that your
72+
printer bed or toolhead can tolerate without damage. Do try to use at least 1Kg
73+
of force, most printers should tolerate this without issue.
74+
75+
When calibrating make careful note of the values reported:
76+
```
77+
$ CALIBRATE GRAMS=555
78+
// Calibration value: -2.78% (-59803108), Counts/gram: 73039.78739,
79+
Total capacity: +/- 29.14Kg
80+
```
81+
The `Total capacity` should be close to the theoretical rating of the load cell
82+
based on the sensor's capacity. If it is much larger you could have used a
83+
higher gain setting in the sensor or a more sensitive load cell. This isn't as
84+
critical for 32bit and 24bit sensors but is much more critical for low bit width
85+
sensors.
86+
87+
## Reading Force Data
88+
Force data can be read with a GCode command:
89+
90+
```
91+
LOAD_CELL_READ
92+
// 10.6g (1.94%)
93+
```
94+
95+
Data is also continuously read and can be consumed from the load_cell printer
96+
object in a macro:
97+
98+
```
99+
{% set grams = printer.load_cell.force_g %}
100+
```
101+
102+
This provides an average force over the last 1 second, similar to how
103+
temperature sensors work.
104+
105+
## Taring a Load Cell
106+
Taring, sometimes called zeroing, sets the current weight reported by the
107+
load_cell to 0. This is useful for measuring relative to a known weight. e.g.
108+
when measuring a filament spool, using `LOAD_CELL_TARE` sets the weight to 0.
109+
Then as filament is printed the load_cell will report the weight of the
110+
filament used.
111+
112+
```
113+
LOAD_CELL_TARE
114+
// Load cell tare value: 5.32% (445903)
115+
```
116+
117+
The current tare value is reported in the printers status and can be read in
118+
a macro:
119+
120+
```
121+
{% set tare_counts = printer.load_cell.tare_counts %}
122+
```

docs/Overview.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,4 @@ communication with the Klipper developers.
101101
- [TSL1401CL filament width sensor](TSL1401CL_Filament_Width_Sensor.md)
102102
- [Hall filament width sensor](Hall_Filament_Width_Sensor.md)
103103
- [Eddy Current Inductive probe](Eddy_Probe.md)
104+
- [Load Cells](Load_Cell.md)

docs/Status_Reference.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,17 @@ The following information is available for each `[led led_name]`,
303303
chain could be accessed at
304304
`printer["neopixel <config_name>"].color_data[1][2]`.
305305

306+
## load_cell
307+
308+
The following information is available for each `[load_cell name]`:
309+
- 'is_calibrated': True/False is the load cell calibrated
310+
- 'counts_per_gram': The number of raw sensor counts that equals 1 gram of force
311+
- 'reference_tare_counts': The reference number of raw sensor counts for 0 force
312+
- 'tare_counts': The current number of raw sensor counts for 0 force
313+
- 'force_g': The force in grams, averaged over the last polling period.
314+
- 'min_force_g': The minimum force in grams, over the last polling period.
315+
- 'max_force_g': The maximum force in grams, over the last polling period.
316+
306317
## manual_probe
307318

308319
The following information is available in the

0 commit comments

Comments
 (0)