Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] [bugfix-2.0.x] Filament Width Sensor on SKR1.3 shows wrong values (*5V/3.3V) #14680

Closed
pseudex opened this issue Jul 19, 2019 · 13 comments
Closed
Labels
C: Peripherals Needs: Work More work is needed T: HAL & APIs Topic related to the HAL and internal APIs.

Comments

@pseudex
Copy link
Contributor

pseudex commented Jul 19, 2019

Description

Jasons Filament Sensor shows wrong values if connected to the SKR1.3 Board with the LPC1786 CPU.
The Analog Inputs on this Board can only read up to 3.3V. Marlin expects a 5V value and scales it to 5 instead of 3.3V

Steps to Reproduce

  1. Connect Filament Sensor to PIN A0[5] (1.31)
    image
  2. Activate Filament Sensor in Configuration_adv.h
  3. flash Firmware
  4. M407 (get reading in mm)

Expected behavior:
Reading in mm of the Filament
The Sensor outputs a Voltage value 1:1 to the width in mm
1.75mm -> 1.75V

Actual behavior:
Reading is scaled to 5V instead of 3.3V so the diameter is shown with a factor of 1.51
1.75V -> 2.64mm

Additional Information

I changed the temperature.cpp in the marlin/src/module folder. This works for me. But there might be a better way to fix this issue.

  // Convert raw Filament Width to millimeters
  float Temperature::analog_to_mm_fil_width() {
    #ifdef TARGET_LPC1768
      return current_raw_filwidth * 3.3f * (1.0f / 16383.0f);
    #else    
      return current_raw_filwidth * 5.0f * (1.0f / 16383.0f);
    #endif
  }

Commit on my Server

For people who want to try the sensor on their SKR1.3 Board be aware that the sensor can output up to 5V. I put a Zener Diode (3.3v) on the output to limit the voltage. Not all of the analog inputs of this CPU are 5V tolerant.

@pseudex pseudex changed the title [BUG] Filament Width Sensor on SKR1.3 shows wrong values (*5V/3.3V) [BUG] [bugfix-2.0.x] Filament Width Sensor on SKR1.3 shows wrong values (*5V/3.3V) Jul 19, 2019
@InsanityAutomation
Copy link
Contributor

setting up scaling factors for min/max reading to measurement has actually been on my todo list for awhile specifically because of this issue. If someone else gets to it before me by all means!

@Titi9237
Copy link

Titi9237 commented Aug 8, 2019

@pseudex Do you know a way to set Z_MAX_PIN as the analog pin used for the sensor ? I can not see anywhere in Marlin where to put this option for the SKR V1.3 boad.

@pseudex
Copy link
Contributor Author

pseudex commented Aug 18, 2019

@Titi9237 : I don't think, that this is possible. This doesn't look like an analog input pin.

in the pin definition file (pins_BIGTREE_SKR_V1.3.h) zmax is pin 1.24.

#define Z_MAX_PIN          P1_24

In the datasheet on page 15 it says nothing about analog input.
image
datasheet LPC1768

the Analog inputs pins are:

  • AD0[0]: P1.23: #define TEMP_BED_PIN 0 // A0 (T0) - (67) - TEMP_BED_PIN
  • AD0[1]: P1.24: #define TEMP_0_PIN 1 // A1 (T1) - (68) - TEMP_0_PIN
  • AD0[2]: P1.25: #define TEMP_1_PIN 2 // A2 (T2) - (69) - TEMP_1_PIN
  • AD0[3]: P1.26: #define Y_MAX_PIN P1_26
  • AD0[4]: P1.30: #define BEEPER_PIN P1_30 // (37) not 5V tolerant
  • AD0[5]: P1.31: #define SD_DETECT_PIN P1_31 // (49) (NOT 5V tolerant)
  • AD0[6]: P0.3: not in pin file and not in the schematic
  • AD0[7]: P0.2: not in pin file and not in the schematic

schematic for SKR1.3 board

I would suggest to use Y_MAX_PIN P1.26 if 1.31 doesn't work for you. The second temp sensor (TEMP_1_PIN) is also possible to use.
Be aware they might not be 5V tolerant. Have a look at the datasheet of the processor.

this is my definition in the conf_adv.h

/**
 * Filament Width Sensor
 *
 * Measures the filament width in real-time and adjusts
 * flow rate to compensate for any irregularities.
 *
 * Also allows the measured filament diameter to set the
 * extrusion rate, so the slicer only has to specify the
 * volume.
 *
 * Only a single extruder is supported at this time.
 *
 *  34 RAMPS_14    : Analog input 5 on the AUX2 connector
 *  81 PRINTRBOARD : Analog input 2 on the Exp1 connector (version B,C,D,E)
 * 301 RAMBO       : Analog input 3
 *
 * Note: May require analog pins to be defined for other boards.
 */
#define FILAMENT_WIDTH_SENSOR

#if ENABLED(FILAMENT_WIDTH_SENSOR)
  #define FILWIDTH_PIN      5   // Analog Input 5, Input 1.31 auf EXP1
  #define FILAMENT_SENSOR_EXTRUDER_NUM 0    // Index of the extruder that has the filament sensor. :[0,1,2,3,4]
  #define MEASUREMENT_DELAY_CM        44    // (cm) The distance from the filament sensor to the melting chamber

  #define FILWIDTH_ERROR_MARGIN       0.2  // (mm) If a measurement differs too much from nominal width ignore it
  #define MAX_MEASUREMENT_DELAY       50    // (bytes) Buffer size for stored measurements (1 byte per cm). Must be larger than MEASUREMENT_DELAY_CM.

  #define DEFAULT_MEASURED_FILAMENT_DIA DEFAULT_NOMINAL_FILAMENT_DIA // Set measured to nominal initially

  #define FILWIDTH_FACTOR 1.0294

  // Display filament width on the LCD status line. Status messages will expire after 5 seconds.
  #define FILAMENT_LCD_DISPLAY
#endif

@boelle
Copy link
Contributor

boelle commented Sep 24, 2019

@pseudex still having issues?

@pseudex
Copy link
Contributor Author

pseudex commented Sep 25, 2019

I don't have this issue anymore. But I fixed this in my own fork for my printer.

@boelle
Copy link
Contributor

boelle commented Sep 25, 2019

@pseudex maybe consider submitting a PR so it can be fixed in marlin?

@InsanityAutomation
Copy link
Contributor

I don't have this issue anymore. But I fixed this in my own fork for my printer.

Or at least point us to the fork / commit and we can take it from there! Even a partial implementation is better than whats there currently before I ever get around to a full scaling setup.

@pseudex
Copy link
Contributor Author

pseudex commented Sep 30, 2019

Everything I changed I described in my initial post. Also I pointed to the commit on my fork

@boelle
Copy link
Contributor

boelle commented Oct 12, 2019

@pseudex maybe submit a PR to marlin 2.0.x instead so it can get fixed for everyone

@stefi01
Copy link

stefi01 commented Oct 23, 2019

i used todays bugfix (23rd october) with skr v1.3, it compilled ok and uploaded to the board but the board reset itself every 30 seconds or so in a permanant boot loop kinda thing, i comented out filament width sensor from marlin and everything works ok again, i tried my settings from marlin 1.1 and then the standard stock settings but no change

@boelle
Copy link
Contributor

boelle commented Nov 3, 2019

will close this one as @pseudex do not have issues

it would have been nice if @pseudex would make a PR and send it to 2.0.x

@boelle boelle closed this as completed Nov 3, 2019
@ReneSchmidts
Copy link

@boelle Sorry, I´m a newbe here. Anyway I´m interested into this topic and got the opinion pseudex was describing his solution in detail, already - see his first comment from the 19th, July - "Additional Information".
Isn´t it possible to use this as a solution for all?

@github-actions
Copy link

github-actions bot commented Jul 4, 2020

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Jul 4, 2020
@thisiskeithb thisiskeithb added T: HAL & APIs Topic related to the HAL and internal APIs. C: Peripherals labels Apr 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
C: Peripherals Needs: Work More work is needed T: HAL & APIs Topic related to the HAL and internal APIs.
Projects
None yet
Development

No branches or pull requests

7 participants