The library that Octoprint uses to connect to a webcam and stream images to the octoprint window is called mjpg-streamer. It works for many webcams, but of course not my trusty Logitech Quickcam Pro 4000. Upon further investigation it turns out my camera only supports the Y12 format but that library can support just the YUV version of that format (there's even a pull request to add support for it). Luckily someone has made their own service called PICS which can read that format and it works pretty well. I forked the project and added some helpful code to allow you to automatically run PICS at boot. Clone the repo, follow the steps to build and run in the Readme, then scroll to the end and follow the steps to "Creating a service to start PICS on boot". This creates a stream that can be viewed at http://octopi.local:8080/dev/video0 which is the URL you can use in the Octoprint WebCam config.
Saturday, November 19, 2022
Monday, October 31, 2022
Connecting the Raspberry Pi to the Robin Nano via GPIO pins
Since the Robin Nano board is mounted such that the USB port is only accessible outside the printer, I had to snake the USB cable out through one of the holes and around the printer to reach the port. For a clean installation, I need a way to let the Raspberry Pi connect to the nano using the GPIO pins.
USB port can only be reached from the outside |
Currently, however, most of the easily accessible pins are already taken on my board as part of enabling SPI communication on the TMC2209 drivers.
Most easy to access pins are used |
Establishing Common Grounds
Klipper/RPi Configuration
- saved the config
- ran "make" to build the image
- used the mks script to convert the image to one compatible with robin nano
- used Filezilla to get the file onto my computer
- copied image to sd card
- booted robin nano with sd card (the image file will get renamed with a *.CUR extension)
Wednesday, August 17, 2022
Crashplan Scripts on QNAP
Looks like QNAP will delete/recreate many directories like /root when it reboots so you can't keep your crashplan scripts there. You can get around this by creating a shared directory. I made one called scripts which can be access by /share/scripts.
I put the update scripts there too so now I can ssh into the QNAP, cd to /share/scripts and run update_crashplan.sh.
Sunday, June 26, 2022
Refuting the Chinese Room Argument
This post assumes you already know about the Chinese Room Argument developed by John Searle.
Before I refute it, let's begin with a simple explanation of what the experiment entails:
- A person who understands Chinese writes down a message using Chinese characters and places it into the mail slot of a room. The person cannot observe anything about the room's contents including what is going on inside of it.
- Inside the room is John Searle, he has buckets of Chinese symbols and a book that describes for each combination of Chinese symbols, English instructions on how to arrange the Chinese symbols in the buckets onto a piece of paper which he send back out through the same mail slot. Searle, himself has no understanding of Chinese, he blindly follows the instruction in the book.
- The person outside the room, reads the message from Searle and because it's content and the fact that it is written in Chinese is then convinced that there must be a person who understands Chinese in the room.
- Because Searle never understands Chinese, he is only performing syntactic symbol manipulation. There is no semantics going on. Without semantics there can be no strong AI.
- Chinese speaker writes down message, places it in mail slot
- Searle looks at message, thumbs through book to find matching page
- Searle follows the instructions on the page to form a response
- Searle places the response back through the mail slot
- Chinese speaker reads Searle's message and concludes Searle understands Chinese
- Suppose that the room has a 2nd mail slot on the back wall that leads to a 2nd room. Just as the Chinese speaker cannot see into Searle's room, Searle cannot see into the 2nd room. Additionally, to the Chinese speaker, the original room and this room are identical (conceptually the original room is divided into 2 rooms internally).
- The book that Searle uses is also different. It still contains all the same Chinese symbols except now, the place where there were English instructions is blank.
- Searle however can now tear out that page from his book and place it into the 2nd mail slot and within a negligible amount of time, the page will be returned through the same slot with the previously missing English instructions. Assume these instructions match the instructions in the original experiment.
- Chinese speaker writes down message, places it in mail slot
- Searle looks at message, thumbs through book to find matching page
- Searle tears out the page and places it into 2nd mail slot
- The page is returned with the instructions on it
- Searle puts the page back into his book
- Searle follows the instructions on the page to form a response
- Searle places the response back through the mail slot
- Chinese speaker reads Searle's message and concludes Searle understands Chinese
Monday, January 31, 2022
[3D Printer Series] AC powered heated bed and safety
A normal 24v DC heated bed usually takes a while to come up to temp, especially if you want to print with higher temperature filament. Not only does it take a long time, but it also consumes a lot of the PSU power. That's why if you want to heat up your bed faster, you'll want an AC powered unit.
I purchased this:
Which perfectly fit my new cast aluminum plate and it's mounting holes. Since we can no longer use the Robin Nano controller board to feed this 120V AC and 750 watts is much more than my PSU can handle, I also got a 40amp solid state relay (SSR). You'll want an SSR so that the Robin Nano can still control the heater with a PWM signal. The SSR needs to support a control input of 24V DC and be able to switch 120V AC. For our needs a good quality 10A SSR would suffice but since I don't trust these off brand models I went with a 40A model for extra insurance.DC to AC 40A SSR |
Thermal Runaway
First line of defence: Thermal Fuse
RTV Silicone Sealant |
2nd Line of defense: Pi controlled relay
Elegoo 4 relay module |
Why do we need to electrically isolate?
Remove the jumper to allow mixed voltages |
Then you can wire up the module like so. (Note only the top pin under the jumper should be supplied with 5V)
I chose these pins (green), but you do you |
Configuration
[mcu pi]
serial: /tmp/klipper_host_mcu
[controller_fan heater_relay]
pin: !pi:gpiochip0/gpio3
heater: heater_bed
Tuesday, January 18, 2022
[3D Printer Series] Understanding how to set z_offset on Klipper
Z-Offset is a general name for telling the printer how far the nozzle is from some reference point. The reference point can be either a z end stop or the probe position of a bed probe like a BLTouch. The confusing bit is what happens when you have both an end stop and a probe. In that case you'll want to use the end stop to move the z-axis to a fixed position and then rely on the bed probe only for bed leveling/compensation.
Klipper doesn't explain how the different options interact with each other making this process very confusing. Additionally, following their calibration guide will lead you down the wrong path if you are using a similar configuration as me. Here's how I do it and why:
Offset for z end stop/probe for bed mesh
- Use the [bed_screws] and [screws_tilt_adjust] configuration to define where the bed level screws are on the xy plane. While you're at it, create an OctoPrint macro/button to move the nozzle above the first screw, this will come handy later.
- Next, tighten all the bed screws so the nozzle doesn't crash into the bed.
- Use your macro to move the head above the first screw and home the z-axis.
- Adjust the first bed screw so that the nozzle is about 1-2 mm above the bed.
- Use the SCREWS_TILT_CALCULATE command to level the other 3 screws, repeat till you get it pretty close
- ACCEPT when you are done
- SAVE_CONFIG
- Preheat the bed to your normal print temp
- Run Z_ENDSTOP_CALIBRATE but use a feeler gauge to get a precise gap between the nozzle and bed, then subtract out the thickness of the gauge. We do this instead of the paper test because the bed is now heated and the gauge is an accurate thickness. This is your effective z offset. If you get an out of bounds error, you will need to configure the min z position with a small negative number.
- ACCEPT when you are done
- SAVE_CONFIG
- Add a [bed_mesh] config, but be sure to include a relative_reference_index that corresponds to the first screw position.
- Run BED_MESH_CALIBRATE
- SAVE_CONFIG, if you look at your printer.cfg, see if you can find the bed mesh values at the end. The value for the relative_reference_index should be 0 if you've configured it correctly.
- Do a single layer test print. I use calipers measure the thickness of the layer. I'll then manually change the [stepper_z] position_endstop to tweak the first layer until I get a thickness that matches the thickness specified in the gcode.
[3D Printer Series] Updating Octoprint/Klipper for Python 3
After upgrading/resurrecting my Sapphire Plus with a new cast aluminum build plate, 750 AC silicone bed heater, SSR, relay board, magnetic textured PEI build surface, I was prompted to update OctoPrint since it was going to stop supporting Python 3. Unfortunately, if you use OctoPrint w/ Klipper the update steps are a lot more involved than explained.
After you update your Raspberry Pi, you basically have to reinstall Klipper as well and installing Klipper on the Sapphire has a lot of special steps that are unique to the Robin Nano 1.2 board that we use.
You need to follow the klipper install guide: https://www.klipper3d.org/Installation.html , but during the make menuconfig section you need to match this:
Then the make command failed for me. Previously, when running one of the earlier scripts I got a message that looked more like a warning than a true error:
InRelease' changed its 'Suite' value from 'stable' to 'oldstable' N: This must be accepted explicitly before updates for this repository can be applied. See apt-secure(8) manpage for details.
Which then allows you to update all the packages. The subsequent errors to make can be resolved by installing the missing packages using apt-get install <package>.
Once make can run successfully, you still need to run (do not attempt to flash the mcu):
./scripts/update_mks_robin.py ./out/klipper.bin ./out/Robin_nano35.bin
Then you can use something like Filezilla to SFTP the Robin_nano35.bin file to your computer and then onto a microSD card to put in the Robin nano. If the LCD screen never goes blank, you will likely have to repeat the process starting from make, but before you do run:
make clean
If the screen does go blank, it means the update succeeded so you should remove the SD card and restart the MCU
Monday, January 17, 2022
Fixing my Blogger Theme
I figured out why I didn't have the same configuration options in my theme as others. Turns out blogger has a completely customizable theme configuration engine (mind blown). You can define variables and metadata about them in your HTML code and then blogger will scan the code and build a dynamic UI for you to tweak it.
My issue was that there was no way to style the fonts for the different heading types in blog posts:
The lesser headings turned out to be bigger than the major ones. This turned out to be a bad CSS rule, but still its good to be able to change it.
So now my headings look like this:
Major Heading
Heading
Subheading
Minorheading
Paragraph
Source code syntax highlighting on Blogger
<pre><code>YOUR CODE GOES HERE</code></pre>
it will highlight it. However if you have HTML in the code, you will still need to escape it first using something like https://www.freeformatter.com/html-escape.html. Also highlight.js will try to figure out the language that you're code is in, but if you want to force it, you can by adding a class="language-<ALIAS>" attribute to the <code> element. For instance, to do Typescript:
<pre><code class="language-typescript">class MyClass extends SubClass {
private field;
constructor() {}
}</code></pre>
And you'd get something like this:
class MyClass extends SubClass {
private field;
constructor() {}
}
Configuration
Blogger doesn't allow <link> elements in the post template so we have to edit the whole theme HTML to add the CSS styles. Goto the dashboard and click on "Theme" then click on the down arrow next to "Customize"
<link href='https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@latest/build/styles/stackoverflow-dark.min.css' rel='stylesheet'/>
<script src='https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@latest/build/highlight.min.js'/>
<script>hljs.highlightAll();</script>
You can find other themes on the highlight.js site, but make sure you use the CDN path like I did so you will always get the latest version.