G31 and temperature tables



  • According to the Wiki, the facility to setup a G31 temperature and compensation tables is deprecated and likely to be removed in a future version of RepRapFirmware (C and S parameters).

    Both capacitive and inductive proximity sensors drift with temperature and some clarification on the logic and feature might help increasing accuracy of these sensors.

    Is it possible to explain the calculation behind the logic and hot to setup the C and S parameters?. I would like to play with the feature to improve the accuracy of my probes.


  • administrators

    As the wiki says, in the G31 command the C parameter is the temperature coefficient in mm/degC and the S parameter is the temperature at which the trigger height in the Z parameter is correct. Although these parameters were introduced to help support an ultrasonic sensor, they can be used with any type of sensor. The bed temperature reading is used to calculate the correction.

    So far as I know, nobody is using these parameters any more.



  • @dc42 Thanks for the answer. This means that this is a linear relationship and I could calculate the offset for a certain Bed temperature and the firmware would recalculate for different temperatures using a linear relationship [Offset_at_T'] = [Offset_at_T] + C*(T'-T) ?
    I find it is really usefull to compensate on temperature drifts for Inductive and capacitive probes. I am using a capacitive probe and the drift can be more and 0.1mm in 80C, which is driving me crazy for Mesh leveling, because it is changing the height of my nozzle and this could be a very good fix.
    I will try tonight.


  • administrators

    @carlosspr said in G31 and temperature tables:

    @dc42 Thanks for the answer. This means that this is a linear relationship and I could calculate the offset for a certain Bed temperature and the firmware would recalculate for different temperatures using a linear relationship [Offset_at_T'] = [Offset_at_T] + C*(T'-T) ?

    That is correct.



  • I have dome some measurements to validate the compensation for my capacitive probe (this would also apply to inductive probes or probes that drift with temperature). The following are my results:

    1./ Calibrate the Z probe trigger height to zero at near room temperature
    2./ Run G31 S-1 and annotate the Trigger height reported. (I run it on a script 25 times and record the average value).
    3.- Repeat the process increasing temperature 10C on each run.

    We end up with a table like this:

    Temperature Trigger Height (mm)
    30 1.92944
    40 1.90196
    50 1.84032
    60 1.80004
    70 1.81672
    80 1.66856
    90 1.3272
    100 1.28496
    110 1.23432

    If we plot these values, we can see that the relationship compared with a linear trendline:
    0_1526904672963_Screenshot from 2018-05-21 16-00-43.png

    Now I use the trendline as the "ground truth" for the trigger distance and calculate the errors versus the average measurements. On a second colums I calculate the error versus a fixed heigh at 80C without temperature compensation.
    Temp Error (mm)
    (linear – Measurement) (linear – fixed height at 80C)
    30 0.10134222222219 0.260880000000001
    40 0.03233555555552 0.2334
    50 -0.00251111111115 0.171760000000001
    60 -0.05871777777782 0.13148
    70 -0.17188444444449 0.148160000000001
    80 -0.120211111111159 0
    90 0.12466222222217 -0.341359999999999
    100 0.0704155555555 -0.383599999999999
    110 0.02456888888883 -0.43424

    Definitely the temperature compensation reduces error, but the accuracy is still not so good.

    I understand this feature is going to be deprecated and it might make sense, but then different solutions to the problem might be needed. Some solutions that I came across are:

    • Setup the G31 code for the specific bed temperature on the Slicer (under filament custom start G code) - I could perform the mesh leveling on this section, with different Trigger height based on filament bed requirements.

    • I had the idea to use the motor stall probe on the same point of the bed every time to run a G30, the change the probe to the capacitive/inductive, report the trigger and then update the G31 parameter. With this update I would peroform a mesh level with the reported trigger height. If would be great if the G30 S-1 could update automatically the G31 value based on the reading )or an average of readings).

    If somebody has other solutions, I would be glad to try them.


  • administrators

    If people are using the temperature compensation feature, I'll leave it in.


Log in to reply