Strain Gauge/Load Cell based Endstops

PR #1 with the sensors is out: Bulk ADC Sensors by garethky · Pull Request #6555 · Klipper3d/klipper · GitHub

5 Likes

Captured by the momentum of enthusiasm reading your PR I bought a ads1220 (just received it) and a strain gauge used by some anycubic printer (I thought that if it works, it’s already designed to mount an hotend…).

So now I only have to:

  1. figure out how/where to wire it (since I have various MCUs and a pi in the canbus net).
  2. figure out how to wire the strain gauge.
  3. pull the PR branch and see if I can even make it work.
  4. designs a new toolhead to properly mount everything :sweat_smile:.

Thanks for the hard work!!

1 Like

Fair warning: we have found the dev boards for the ADS1220 to be really noisy. I don’t think this is the sensors fault, it’s just the nature of analog sensors in a noisy environment. Every other dev board I have tried has also had noise problems. The board were meant to be connected to a battery. We stick them in a printer with a PSU, switching voltage converters and noisy stepper drivers.

On the love board, prusa used 10u and 100n caps in parallel on the 5V supply. They also have a high speed fuse that dumps 5V to ground in 1 picosecond.

I don’t know what the solution is for us. I need some electrical engineering/power electronics knowledge that I don’t have to solve it.

Hi Gareth,
interesting project. I’m just following/reading.

This is not so difficult.

My proposal would be two staged for your power management problem. I would recommend ADI components since they bought all the good companies like Linear Technologies, Maxim, or even TMC.

Input voltage of 12V to at least 60V DC. TMC driver go up to 60V DC supply voltage. The step-down regulator converts the input voltage to ca. 6,5V DC.
The second stage converts the voltage to 5V DC without noise.

Your ADS1220 comes in a TSSOP package with 0,65mm pitch and no power pad. So it can be soldered by hand.

Basic things to consider…

Choosing the components and their packages:

bigger= 0402 (resistors, capacitors, coils), pitch >=0,5mm (ICs), no thermal pad on IC package: to be able to hand solder the naked PCB
I guess an LDO with a capability of 300mA@5V is good enough. How many ADS1220 do you want to place on the PCB?

Software:

LTSpice (freeware) from Linear Technologies/ADI for simulation of the circuit
KiCad (open source) for schematics and layout of PCB

PCB:

I would recommend a 4-layer board with a standard thickness of 1,6mm. Cheapest from a pool manufacturer.

Workers/helpers/enthusiasts:

People, who are willing to help you. It’s a bit of work.

Money/fund for PCB and components:

How are you planning to sponsor this subproject?

Good luck, hcet14

Like @hcet14, I’ve been following this thread as well.

I’m a bit hesitant to make recommendations without really understanding the application and its requirements.

Are you looking for a small, cheap board for one sensor and wire it into a main controller board through the end stop sensors or multiple sensors on a board pulling power from the main supply and communicating serially/CAN/USB?

Dev kit boards can range from being excellent to very poor and designed for one application. Similarly in terms of the 5V SMPS on most main controller boards. I’ve run a fair number of them and looked at their outputs on a scope while under load (I’m a nerd that way) and they can vary quite a bit.

Before people start making decisions on what needs to be done, I think you should first outline what you want and we can go from there.

It doesn’t matter which ADC Gareth chooses. ADC applications HATE noisy supply voltages. My very basic proposal stands. I agree with

1 Like

What do I want:

  1. I’m sure some vendor is going to integrate a load cell onto a toolhead board for us. I’d like to have a suggested reference design for them to copy. My fear is that we get a bad design that ships and I get a lot of upset users that want me to fix the noise problem in software. Noise isn’t really fixable in software.

  2. Personally I’d love to have more reliable/robust dev boards for people to try. The available dev boards are not fit for purpose. I think we need:

  • Surge/ESD protection
  • Voltage smoothing designed to work with a printers 5v supply
  • RS485 for long serial connection wires
  • some sort of isolation on the data ready pin

I want to have the time to learn enough KiCad to do this but I really am too busy.

How are you seeing this architected with a printer?

I was surprised to see the suggestion of “RS485 for long serial connection wires” as I always imagined this as being something within the perimeter of a printer (no wires longer than one metre).

Personally, I was thinking along the lines of a simple board with an MCU that either communicated with the main controller board using CAN or even just had three wires (+5V, GND and an Open Drain output).

It’s exciting that this has progressed to the point where there are discussions on prototyping but I think there needs to be some kind of consensus on how it is to be implemented.

Without being the expert, it seems that @garethky has a very good point with his concerns and the design decisions to take might really require someone who has some professional experience with this kind of application.

Just for my understanding:

Interface to Klipper:

  • The ADC are either SPI or I2C devices and as such need to be directly connected to a host or MCU that is running an “ADC-aware” Klipper version
  • From the ADXL345, we know that wiring such components over a certain distance can be challenging

→ In a reference design, it might be prudent to marry the ADC directly with a Klipper MCU on one board, e.g. a toolboard or a dedicated board like it is done for the IMU devices (e.g. GitHub - FYSETC/FYSETC-PortableInputShaper: Portable Input Shaper(PIS)). Such a board could even offer USB and CAN in parallel for easy of integration into the printer’s setup

Purpose of the ADC

  • The needed circuits differ between measuring a wheatstone bridge or, e.g., an RTD

→ ADC boards will be single purpose and tuned to the given application. In this case, measuring load-cells.

Reference Voltage

  • The ADCs seem to require a reference voltage of 5V for the load-cell application
  • Going by @garethky’s experience, it seems to need a low noise power supply
  • The datasheets also lists some additional requirements for noise resilience, e.g.
    • proper ground planes
    • placement of components
    • quality of components, e.g. low ESR / ESL capacitors

→ This seems to be the major challenge and the effect of the individual contributors, i.e. layout, quality of components and quality of the power supply, needs to be determined by someone with the proper knowledge in this field.

Is this a correct understanding?

How is your your strain gauge load cell hooked up to your ADC?
Like this
https://www.ti.com/lit/ds/symlink/ads1220.pdf chapter 9.2.3
or
https://cdn.sparkfun.com/datasheets/Sensors/ForceFlex/hx711_english.pdf Fig. 1?

to 1:

You are talking about something like BTT’s EBB boards?

I work in a global company (>50000 people worldwide) and we have a big business unit in China. I have seen layouts from them when we try to help them fixing problems.
Digital circuits are ok, not great but ok. Analog circuits lack some basic layout knowledge. I don’t know about the layouters at 3D vendors. Maybe they are much better than my Chinese fellow workers? I found some mistakes in their schematics though!
I think, your concerns are reasonable.
I have never seen any layout or Gerber files from 3D vendors!
Also unknown are the passive components they use on their boards!

to 2:

  • Surge/ESD protection
    https://www.ti.com/lit/ds/symlink/ads1220.pdf chapter 6.2 looks encouraging
    I guess, you’ll never find ESD ratings in Chinese ADCs datasheets. I just had a look into those two ADC datasheets.
  • Voltage smoothing designed to work with a printers 5v supply
    Like I said above, I would supply from the printer voltage supply. My proposal is e.g. used on BTT’s EBB boards. They just support 40V see http://www.natlinear.com/uploadfiles/2014/ln/LN5016_E.pdf. I would suggest at least 60V.
  • RS485 for long serial connection wires
    I agree with Myke and Sineos
  • some sort of isolation on the data ready pin
    I don’t understand that point. It’s an output pin on your ADC. Should be safe, but a special protection is no big deal.

Are you experienced with schematics design and/or layout design?

1 Like

This is a good list of considerations, but I would still like to see a requirements document.

There’s two points here. The first is how will the endstop sensor interface to Klipper. For prototypes, I would expect the board to be something like what @Sineos is suggesting but I think there needs to be a long term vision of what the sensor will look like. Personally, I would like to see something like:

That is self-contained and simply plugs into the main controller and provides a two state output. Easy peasy for the end user.

Secondly, I agree that there needs to be an MCU local to the ADC. This is not something that adds significantly to the cost or complexity of the design. Thought must be put into the implementation to ensure that there is a method of debugging and programming of the prototypes (with an eye to long term production).

Again, there needs to be a requirements document because people are throwing out the term “ADS1220” without understanding the requirements so that the best part can be selected.

TI, alone, has almost 100 different ADC part numbers that provide differential inputs and at least 24 bits of precision. 23 of these are in the “ADS122” family of devices.

Low noise power supplies are not a “major challenge”. The science of power supply design is highly advanced and there are many simulation tools that help the designer anticipate power supply noise. There’s a lot more angst on this point than there needs to be.

There needs to be a definite requirement set out for the power supply. Statements like: “The ADCs seem to require a reference voltage of 5V for the load-cell application” isn’t acceptable. For this application, there needs to be a statement regarding the expected common-mode voltage (1/2 of the total voltage) as well as required accuracy of the ADC in this application. Note that this requirement will affect the determination of the best ADC part number to use.

The issue isn’t providing a low noise power supply but to provide a low noise environment for the best operation of the ADC and the strain gauge/load cell. Again, it’s not rocket science but a set of requirements needs to be set forth.

All these points illustrate why a requirements document is required. From an electrical/electronics perspective, nothing I see here is concerning but I don’t have a set of requirements that I can make an informed comment on.

@garethky I would be happy to take this offline and help you with making up a requirements document that can be shared with the group and would help more this forward quickly and positively.

Yes, I think we could take this discussion to Discord and find some place to write a document. @Sineos, @hcet14 you are welcome to join the discussion!

1 Like

I have a sort of pragmatic plan.
I have a spare thr36 canbusboard. There are unused spi pads I’d need to solder, but I think I can add a pretty short wire to the ads pcb.
afterwards I have to figure out how to wire the loadcell. hopefully a 10~15cm wire length will be short enough to reduce noise. But than it will be pretty close to the extruder motor. I don’t know how this will impact the adc

Hi, I downloaded your latest adc-endstop code and replaced the file on my printer. I found a mistake in using it. Sending “probe” returns “LoadCellSampleCollector timed out” error.
I wonder if you could help me see what’s wrong.
I use the Raspberry PI 4B, the motherboard uses the MKS-nanoV3.1, and the sensor uses the hx711.

Here is my configuration.

[load_cell_probe]
sensor_type: hx711
sclk_pin: PB10 #PE11  #PB10
#   The pin connected to the HX711 clock line. This parameter must be provided.
dout_pin: PB11 #PE12  #PB11
#   The pin connected to the HX711 data output line. This parameter must be
#   provided.
counts_per_gram: 131.755777
reference_tare_counts: 537140
#counts_per_gram = 131.35294
#reference_tare_counts = 557651
safety_limit: 1000.0
#   The safe limit for probing force relative to the reference_tare_counts on
#   the load_cell. The default is +/-1Kg.
trigger_force: 200.0
#   The force that the probe will trigger at. 50g is the default.
continuous_tare_highpass: 0.8
#   Enable optional continuous taring while homing & probing to reject drift.
#   The value is a frequency, in Hz, below which drift will be ignored.This
#   option requires the SciPy library. Default: None
continuous_tare_lowpass: 39
#   The value is a frequency, in Hz, above which high frequency noise in the
#   load cell will be igfiltered outnored. If this option is set,
#   continuous_tare_highpass must also be set. Default: None
continuous_tare_notch: 30, 25
#   1 or 2 frequencies, in Hz, to filter out of the load cell data. This is
#   intended to reject power line noise. If this option is set,
#   continuous_tare_highpass must also be set. Default: None
#continuous_tare_notch_quality: 2.0
#   Controls how narrow the range of frequencies are that the notch filter
#   removes. Larger numbers produce a narrower filter. Minimum value is 0.5 and
#   maximum is 3.0. Default: 2.0
continuous_tare_trigger_force: 100
#   The force that the probe will trigger at whe using the continuous tearing
#   filter. 40g is the default.
#tap_filter_notch: 60.0
#tap_filter_notch_quality: 2.0
#   Filters the load cell data before the tap is evaluated. This option may
#   provide marginal accuracy improvement when notch filtering at the mains
#   power frequency. Requires SciPy. Default: None
#trigger_count: 1
#   The number of samples over the trigger_force_grams threshold that will cause
#   the probe to trigger. 1 is the default.
#pullback_dist: 0.1
#   The distance of the pullback move in mm. This move needs to be long enough
#   to bring the probe away from the bed after it makes contact.
#pullback_speed: 0.4
#   Speed of the pullback move. The default value is to move at a speed of 1
#   sample every 1 micron based one the sensors sample rate is.
settling_time: 0.375
#   Additional time to wait before taring the probe. This allows any vibrations
#   to settle and bowden tubes time to flex etc. This improves repeatability.
#   If the continuous_tare_filter is used this may be set to 0.
#pullback_extra_time: 0.3
#   Time to collect additional samples after the pullback move ends in seconds.
#   This improves accuracy by giving the algorithm more points after the probe
#   breaks contact with the bed. Disabling this entirely may impact reliability.
#tare_count: 16
#   The number of samples to use when automatically taring the load_cell before
#   each probe. The default value is: sample_per_second * (1 / 60) * 4. This
#   collects samples from 4 cycles of 60Hz mains power to cancel power line
#   noise.
#bad_tap_module:
#   Name of a printer object that implements the BadTapModule interface. This
#   checks taps to see if they meet minimum requirements and can
#nozzle_cleaner_module:
#   Name of a printer object that implements the NozzleCleanerModule interface
#   than can handle nozzle cleaning. If one is provided the nozzle_cleaner_gcode
#   is disabled.
#nozzle_cleaner_gcode:
#   A Gcode macro that is called when a bad tap is detected and the nozzle needs
#   to be cleaned. The default Gcode prints a warning to the console.
z_offset: 0
speed: 2
samples: 3
sample_retract_dist: 2
lift_speed: 2
samples_result: median
#samples_tolerance:
#samples_tolerance_retries:
#activate_gcode:

Unfortunately i dont have much to contribute as far as coding or pcb design, but i think that USB would be better than CANbus for communication. Higher data transfer rate, no need for creating a can0 network, no usb to canbus convert or canbus bridges on mcu needed, allows to integrate a usb hub onto the board for future expansion, for example nozzle camera, nozzle adxl or beacon in case someone wants the strain gauge only for pressure monitoring to detect clogs or automatic PA calibration. It would also be beneficial for troubleshooting as we wouldn’t have to deal with canbus network issues or timeouts.

Another thing that would make the board attractive to a wider target audience are higher temperature capable mcus. As you know we currently have rp2040 or Stm32g0b1 chips available on the typical vendors (btt, ldo, mellow, etc.) boards. This would rule out the rp2040 entirely and the base version of the stm32 chips. The stm32 microcontrollers are usually available in a base 85c spec, 105 and 125c rating. Only difference would be cost, the layout stays the same to my knowledge. Of course other components need to be adequately chosen. Reason being is that its not uncommon for people to experience thermal issues in warmer passively heated chambers, often needing active cooling for the microcontroller. It would also allow the usage in 80-90c actively heated chambers, many of the high temp printer owners would like to have a toolhead mcu but cant use them

1 Like

Did you try running a LOAD_CELL_DIAGNOSTIC?

I tried, send “LOAD_CELL_DIAGNOSTIC” and it returns “Error on ‘LOAD_CELL_DIAGNOSTIC’: missing LOAD_CELL”.

LOAD_CELL_DIAGNOSTIC LOAD_CELL=load_cell_probe

(TODO: make that argument optional if there is only 1 load cell)

Okay, I tried again.
image
Is there something wrong with my configuration? I’m collecting too little data.

You have a 10 samples per second (SPS) HX711. It cannot be changes into an 80SPS sensor with software. Do not under any circumstances use a 10SPS HX711 as a probe.