XY_Offset

Update 18-Januari-2025. Read the Disclaimer.
Maybe you know 'Brian\'s index Nozzle calibration tool' or TAMV or kTAMV (k for klipper) ?
These tools use an USB (microscope) camera, often with build in leds for the exposure of the object. The tools make it easyier to determine the XY offsets for the Z-probe or for a multi toolhead setup. My 3D printer has 2 toolheads, a 3dTouch Z-Probe and runs Klipper.
kTAMV, for Klipper, failed sometimes to detect the nozzle on my printer or the offsets were just off. Sometimes its caused by a not clean nozzle but a new, clean, dark colored nozzle also failed.
Its not always clear why it went wrong. Its not possible to manually select a detection method or to tweak the parameters of the used methods. The detection methods are global and not per extruder.

Ad by Google.

The (microscope) camera, connected to a Pi, is setup in Klipper as WebCam and its available on the Klipper web-page. The camera stream is also avaiable on the local network and can be displayed in a browser or picked up by an app. Moonraker has an API which can be accessed via HTTP. Well, seems like everything is there. "How hard can it be to make an app in Android that allows all kinds of tweaks ?" This is the beginning of it with a first step: 'manual calibration'.

The app needs some settings, see Menu Preferences:
- the ip address of the processor board used for Klipper
- the port number of Moonraker
- the webstream of the camera
- logging to Android Studio LogCat and/or to a text file on the phone or no logging

Note: The app is a heavy CPU load and memory consumer. The app will drop camera frames. Within Klipper the webcam frame rate can be set, probably for internal usage in Klipper, but via the network the app still gets the full frame rate (in my case ~14 fps) of the camera.

The app uses OPENCV's blob detection or hough circles. All parameters can be tweaked. There is ample opportunity to screw image preparation and nozzle detection up. Select None (no blob detection) or 1 of the 4 sets of blob detection parameters: Simple, Standard, Relax and Super. Simple is available per extruder and the other 3 are global, thus used for all extruders. Hough circle detection is added for the sake of completeness. It has much jitter on the nozzle position. Per extruder the selection and preparation method can be selected and remembered or kept at automatic (Find 1st fit). Automatic find does a 'brick' find, through the detection and preparation methods, until the 1st solution with only 1 blob detection. When this solution is confirmed during 14 frames the find stops. With "Find continue" the blob detection is forced to continue with the next method or preparation.

   

    The app's menu has:
  1. Disclaimer Use the app at your own risk.
  2. Find 1st fit Find the first detection which has only 1 solution (blob) from the start.
  3. Find continue Continue the find with the next method.
  4. View Save frame to file, Flip frame horizontal or vertical, display processed frame, tweak colors and line size.
  5. Home axes Home X, Y, Z or XYZ axes.
  6. Extruder Select an extruder (T0-T7).
  7. Prepare image Select a preparation method for the nozzle detection, tweak the method.
  8. Nozzle detection Select a nozzle detection method and tweak its parameters (save/reset). The detection method BLOB SIMPLE is per extruder. All BLOB methods have the same parameters but different values.
  9. Preferences Set Ip address, Moonraker port, webcam stream, logging.
  10. Privacy Policy The app does not collect and share any kind of data.
  11. Exit Exit the app.

     

    Before you start:
  1. set all gcode offsets to zero in the Klipper configuration file
  2. clean all nozzles of any filament particles
  3. retract the filament, per toolhead, 2 mm so that the filament is not visible as a blob in/on the nozzle
  4. make sure the microscope camera has a solid pedestal and does not move due to vibrations when the toolhead/bed moves (via the USB cable !!). I had to 3d print a pedestral, added soft rubber pads to its bottom and pin down the USB cable to the bed before it was stable.
  5. home all axes before you position the camera on the build plate.
    You will have to 'lower' the buildplate before the camera will fit.
    Manually adjust the focus of the camera.
    Pin the USB cable to the build-plate to prevent very tiny movements !!!
  6. select a reference extruder from which the other extruder offsets will be calculated.
    If applicable, start with the extruder which has the Z-probe attached too it.
  7. Note: 'dark' nozzles are much more difficult to detect

    Offset determination with offsets set to zero:
  1. Home the XYZ axes
  2. Position the microscope camera on the build plate, the nozzle of extruder TO is visible (sharp/focussed) in the microscope picture.
  3. Select from the menu "Find 1st fit"
  4. If you are not satisfied with the found fit continue with "Find continue" from the menu.
  5. Or select via the menu an image preparation method and blob detection method, and tweak them.
  6. Move the extruder (T0) to the center of the display (haircross)
    Fine tune until the displayed "Bitmap XYR" values X and Y are stable.
    This means the blob center is within 1 pixel accurate.
    Note that the blob center can differ from the nozzle center.
  7. Press button "SET ORIGIN".
  8. Use menu "Select Extruder" to select another (T1..T7) extruder and wait for the extruder swap
  9. Press button "GOTO ORIGIN".
  10. Move the selected extruder (T1..T9) to the center of the display (crosshair)
  11. Press button "CALCULATE OFFSET" and the X and Y offset values are displayed.
Button "GOTO ORIGIN" moves the extruder to the coordinates set with button "SET ORIGIN".
Button "GOTO OFFSET" moves the extruder to the coordinates when button "CALCULATE OFFSET" was pressed.

Currently, that is ALL !

    Sources:
  1. https://moonraker.readthedocs.io/en/latest/printer_objects/
  2. https://github.com/Life0fBrian/Brians-IDEX-Nozzle-Calibration-tool
  3. https://github.com/DanalEstes/TAMV
  4. https://github.com/HaythamB/TAMV
  5. https://github.com/TypQxQ/kTAMV
  6. https://github.com/niqdev/ipcam-view
  7. https://github.com/perthcpe23/android-mjpeg-view
  8. https://opencv.org/android/
  9. https://medium.com/@sdranju/android-studio-step-by-step-guide-for-setting-up-opencv-sdk-4-9-on-android-740547f3260b

  10. Used camera: From WALLY SKY, microscope camera MGH1000, Resolution 640x480, zoom 50x-1000x

Ad by Google.

Back