TAMV

From Jubilee
Jump to navigation Jump to search

Overview

  • TAMV = Tool Alignment with Machine Vision.

Fully automated process that uses a camera to calculate XY tool offsets set with G10 L1 that go in your config.g to correctly set the X Y alignment for correct tool-to-tool behavior when printing.

  • ZTATP = Z Tool Align with Touch Plate.

Fully automated process that uses a touch plate to calculate Z tool offsets also set with G10 L1 that go in your config.g to correctly set the Z alignment for tool-to-tool correct behavior when printing. It also sets the bed-to-tool-zero spacing!

ZTATP Wiki Page here

Special note to AVOID MACHINE DAMAGE

TAMV will move your tools around in ways that may be different than day-to-day printing.

In particular, if your camera is anywhere beyond the Y coordinate of the parking stalls for other tools, collisions could occur. To ensure this does not happen, two things must be true:

  • TAMV expects a tool change, as initiated by a T0 or T1 or so forth, will not cause a collision, no matter where the tool is when the tool change initiates.

It is entirely possible that your tool change macros do not ensure this today, particularly when a ‘current tool’ is beyond the Y line of the parking stalls at the moment a tool change is initiated.

  • TAMV itself will always “manhattan move”, that is move in square blocks, and will move X (only!) first, they Y (only!) as required to get FROM wherever the tool is after a Tx, TO the camera.

If (big IF) your tool change macros end with the tool at a ‘safe Y’, then ‘Manhattan moves’ will always prevent collisions. In fact, this form of move is best practice within your tool change macros.

Please read this section for more information.

Requirements

  • Rasberry Pi 3B or 4B, with USB attached camera (no Picam at this time).
  • Almost any webcam with auto-exposure and the ability to focus within a few centimeters of the lens will work. Logitech C270 is one that is known to have a threaded lens and a case that can be removed and replaced with a printed case.
  • A Duet printer, reachable from the Pi by network, running V2 or V3 firmware
  • May run on Duet3+Pi; does NOT require that configuration, run on any Pi.

Useful Links for TAMV

  1. Set up headless Raspberry Pi VNC
  2. VNC Viewer for Windows (freeware)
  3. PuTTY SSH client for Windows (freeware)

Installation steps for TAMV

  1. Enable boot to desktop and VNC for your Raspberry Pi
  2. Connect to the Raspberry Pi using VNC Viewer on Windows
  3. Install the OpenCV libraries and dependencies
  4. Install the TAMV script
  5. (pending) Webcam mounting and TAMV preparation
  6. (pending) Running TAMV calibration for the first time
  7. (pending) Post calibration checklist

What you’ll need before you start

  1. A Raspberry Pi with a working installation of Raspbian, with an internet connection from the Pi
  2. Your SUDO user of choice (default is usually the “pi” user) and SUDO password (default is “raspberry”) with SSH login
  3. An SSH client of your choosing, such as Windows 10 built in ‘winterm’ and ‘ssh’ or install PuTTY
  4. A VNC client of your choosing, such as VNC Viewer

Enable boot to desktop and VNC for your Raspberry Pi

  1. Login via SSH to your Raspberry Pi and and run the Raspberry Pi config tool using the command: sudo raspi-config
    01.PNG

  2. Select “3 Boot Options”
    02.PNG

  3. Select “Desktop / CLI”
    03.PNG

  4. Select “Desktop”
    04.PNG

  5. Now from the main menu, select “5 Interfacing Options”
    05.PNG

  6. Select “VNC”
    06.PNG

  7. Confirm that you would like to enable VNC server by selecting “Yes”
    07.PNG

  8. You’ll get a confirmation that the VNC server has been enabled
    08.PNG

  9. Select the “7 Advanced Options” from the main menu
  10. Select “Resolution”
  11. Select “DMT Mode 16 1024x768” or any other resolution you’d like
  12. Once you’re done, reboot the Raspberry Pi!

Connect to the Raspberry Pi using VNC Viewer on Windows

  1. Launch VNC Viewer on your computer, and select “File” -> “New connection…”
    01.PNG

  2. Enter the IP address or network name of your Raspberry Pi in the “VNC Server” field, and give this connection a name to identify it in the VNC viewer connection list
    02.PNG

  3. Right-click on the new connection you’ve just created and select “Connect”
    03.PNG

  4. You’ll be connected to your Raspberry Pi and prompted for a username and password. Use your SUDO login credentials (most commonly the Pi user) and click “Log In”
    04.PNG

  5. Welcome to the Raspbian desktop! Your background and interface may vary depending on the version of Raspbian you have running on the Pi
    05.PNG

Install the OpenCV libraries and dependencies

  1. Launch a new “Terminal” process to access the CLI (Command Line Interface) of your Pi
    01.PNG

    *****NOTE: The terminal will launch into your “home” directory, which is “/home/username” under Linux. The following screenshots were for a user called “tamv”, but generally you’ll be seeing the “pi” user

  2. Run the following command from the prompt, which will clone the GitHub repo from Danal to the current folder you’re in: git clone https://github.com/DanalEstes/installOpenCV.git

  3. 02.PNG

  4. Once the clone is done, you’ll need to switch to the new folder using: cd installOpenCV and then run the installation script using: ./installOpenCV.sh
    You’ll get a welcoming message from Danal, and the script will prompt you for a sudo password to start installing any updates, dependencies, and upgrades needed to get OpenCV on your machine. Be warned that this process should take anywhere from 45 minutes to three hours to complete, and make sure your Pi doesn’t run out of power during this period, especially if you’re running it off a battery source.

  5. 04.PNG


  6. Go grab a coffee/tea/beer/nap until the process is done. It should complete without any RED errors (there will be YELLOW warnings, these are OK) since Danal did a great job of setting this up for everyone!

  7. Once the process has been completed, do a little victory dance if you’d like.

Install the TAMV script

This step will install all the files necessary for the TAMV script to launch, including the DuetWebAPI library from the same repository on GitHub.

  1. Launch a terminal window into your home directory (if you don’t already have one open from the last step). Make sure you’re actually in the home location and your prompt looks similar to this: “pi@duet3:~ $”. If not, enter cd
  2. Run the following command to clone the repo to a local folder: git clone https://github.com/DanalEstes/TAMV.git
    01.PNG

(pending) Webcam mounting and TAMV preparation

Preliminary steps 1. Mount webcam somewhere fixed on the bed using gluestick/double sided tape OR on the frame in a spot where the nozzle of the tool can be positioned over the lens. 2. Shorten webcam focal distance to about an inch away from the lens (webcams are generally set up for longer focus distances so this would probably necessitate opening up the camera shell and manually turning a focus ring) 3. Heat nozzles and clean up all nozzles from gunk and filament blobs to enable correct nozzle circle detection in TAMV. 4. Make sure they cool. You don’t want to ‘drool’ on the camera! 5. Set tool active and standby temperatures to 0 before running TAMV. Again to avoid drooling.

(pending) Running TAMV calibration for the first time

  1. Run TAMV with no arguments. This MUST be on a VNC session, not ssh (because you have to see the graphic image).
    1. cd
    2. cd TAMV
    3. ./TAMV.py
  1. It will mount Tool0 and ask you to jog the tool over the camera.
  2. Jog the tool to the camera, and adjust centering (rough), focus, etc, etc, so that there is a good view of the tool. 3.5 Make a note of the X Y where the tool is over the camera, to make future runs faster.
  3. Click back to the text window and press Ctrl+C one time.

Everything after that will be automatic. The final output is G10 statements, one per tool.

(pending) Post calibration checklist

  1. Remove webcam from build plate
  2. Place the G10 commands in config.g
  3. If you have already manually aligned Z, time to print!

If not, take a look at the ZTATP script. (Wiki page coming soon)

Future runs of TAMV: Supply that X Y you noted above ./TAMV.py xxx yyy and TAMV will not prompt you at all.

Updating To Latest

First Remove old files

cd TAMV/

rm TAMV*

rm DuetWeb*

Then re-downloaded the updates

wget -N https://raw.githubusercontent.com/DanalEstes/DuetWebAPI/master/DuetWebAPI.py

wget -N https://github.com/DanalEstes/TAMV/raw/master/TAMV.py

Build the exe

chmod 744 TAMV.py

For features rundown

./TAMV.py -h