MarlinFirmware / Marlin

Marlin is an optimized firmware for RepRap 3D printers based on the Arduino platform. Many commercial 3D printers come with Marlin installed. Check with your vendor if you need source code for your specific machine.
https://marlinfw.org
GNU General Public License v3.0
16.17k stars 19.21k forks source link

[FR] Adding support for the Pyr0-Piezo Z-Probe (adding uart/i2c comms) #13702

Open pyr0ball opened 5 years ago

pyr0ball commented 5 years ago

Description

I've been working on a self-calibrating piezo sensor for a while, and I'm nearing completion, so I wanted to reach out and start working on code integration with Marlin.

Information and sources can be found here: https://github.com/pyr0ball/pyr0piezo

Requirements from Marlin

The sensor has been designed with UART and I2C input to allow the user to adjust the auto-calibration parameters on-the-fly. These sensors imitate a standard active-low endstop signal for it's output, so they can work out-of-the-box without these inputs, but there are a number of possible benefits for being able to adjust the sensitivity of the circuit:

This integration could be implemented using GCode commands, and/or an LCD menu option

Input Syntax

To set the auto-tuning parameters using serial input, use the following:

These commands should be wrapped in this format: <CMD, INT, FLOAT>

You must include the unused variable for each instance.

Examples: <GAIN_F, 3, 0.00> <VADJH, 0, 2.35>

*Note for Gain Factor:

The gain STATE is representative of these values:

InsanityAutomation commented 4 years ago

Just dropping a note here to subscribe to the thread, as weve had some discussion on discord as well.

pyr0ball commented 3 years ago

Just dropping this here as it's been a bit and I've added more documentation as well as an I2C interface chart: https://docs.pyroballpcbs.com/tutorials/config/pyr0piezo-i2c/pyr0piezo-i2c/

Copied here for reference:

Integration using I2C

Default I2C Address: 0x10

I2C Command Register Map

see Pyr0-Piezo Parameters Explanation for more specific details on the command aliases.

I2C Register Command Alias Arguments Type Bytes Length
0x00 GAIN_F Gain Factor Input 2
0x01 VFOL Millivolts Input 2
0x02 VCOMP Millivolts Input 2
0x03 LOOP_D Milliseconds Input 2
0x04 TRG_D Milliseconds Input 2
0x05 HYST Millivolts Input 2
0x06 LOGIC Boolean Input 2
0x07 PZDET Boolean Input 2
0x08 CONST Millivolts Input 4
0x09 CONFIG None Output 32
0x0a ERASE None Input 1
0x0b STATE None Output 10
0x0c SIGVOL Boolean Input 1
0x0d VCCADJUST Millivolts Input 2

I2C Command Syntax

I2C input syntax uses "Least Significant Byte First" formatting, which means the data bytes are sent in reverse order:

[Address Byte] [Command Byte] [Data 8] ... [Data 0]

For example, to set the Logic output to Active Low:

0x10 0x06 0x00

Or to set VCOMP to 2650:

0x10 0x02 0x5A 0x0A