Tuesday, February 22, 2022

Dealing with limit cycles in my hot end in Marlin

I replaced my Melzi 2.0 board with a Bigtree Tech SKR V1.3. 

I replaced my Bowden tube extruder with a nearly direct extruder hoping to be able to use Flex filament.

When I installed the new extruder, I had a very difficult time getting the extruder temperature under control. I repeatedly tried autotuning to get the hotend under control, but it was to no avail. I continually had temperature excursions of +/- 5 degrees C, which I had never had before. 

It appeared that the power (and cooling) in my hot end were so large that the speed of the controller was too low to keep up with the changes. But I didn't know how to troubleshoot this. I observed that during autotuning, the temperature control was *much* better than during PID control, which is exactly opposite of what I would expect. 

I finally figured out the meaning of the temperature message reported by Marlin(I never found a description on the Marlin website or anywhere else on the web). 

 Here's a typical temperature report message, as captured in the terminal on Octoprint:
Recv: T:175.89 /0.00 B:17.21 /0.00 @:0 B@:0

This tells me that the current extruder temperature is 175.89, with a setpoint of 0.  The current bed temperature is 17.21, with a setpoint of zero.  The PWM value of the extruder heater is 0, and the PWM value of the bed heater is zero.

Here's a temperature report while I'm trying to heat to 240:

Recv: T:45.23 /240.00 B:14.11 /0.00 @:127 B@:0

This shows me that I'm trying to get my extruder up to 240, but it's only at 45.23.  However, the heater is currently set to 127, which is the maximum value established in the firmware as PID_MAX.

In contrast, during autotuning, the hotend heats up a a PWM value of one half of PID_MAX.  If PID_MAX is set to 127, heating during autotuning will be at 63.  If PID_MAX is set too low, you will never be able to get up to temperature for autotuning.

In my case, I had PID_FUNCTIONAL_RANGE set to 10, which means that if the temperature is more than 10 degrees away from the setpoint, the controller will be in bang-bang mode (either PID_MAX or 0).  If the temperature is changing quickly, the temperature may get out of the PID_FUNCTIONAL_RANGE before the PID controller settles.  By looking at my temperature messages during heating, I could see that the PID controller never settled.  In order to give the controller time to adapt, I increased the PID_FUNCTIONAL_RANGE from 10 to 30.  At that point, I could control the temperature of the extruder, although it was still not as tight a control as I would prefer.

I insulated the hot end block to decrease the cooling rate and slow the system down a little bit.  That helped somewhat.

Bottom line -- my printer is now functional.  But there is still more variability in the extrusion temperature than I would like.  I'll keep working on it.


Saturday, February 19, 2022

Using Octoprint with one Raspberry Pi and two printers

I have two Tronxy X3A printers.  I have Octoprint on one, but not on the other.  I love Octoprint so much that I can't stand not having it.  So I decided to connect both printers to my Pi.

Detailed instructions are given on the web here.

Without further ado, here's what I did.

Identify the port for my current printer

  1. ssh into my Raspberry pi, with the user name of pi (which was set up when I installed Octoprint).  
     ssh -lpi octopi.local  
  2. List the ports for the connected usb devices
     ls /dev/ttyUSB*  
  3. Plug in the second printer, then relist the ports for the connected usb devices. The new device is the one for the second printer.
     ls /dev/ttyUSB*  
  4. Get the device info for both devices, and find the differences (I have /dev/ttyUSB0 and /dev/ttyUSB1. You might have different devices.)
    udevadm info -a -n /dev/ttyUSB0 > devInfoUSB0
    udevadm info -a -n /dev/ttyUSB1 > devInfoUSB1
    diff -u devInfoUSB0 devInfoUSB1  
    My difference is this:
    ATTRS{bInterfaceProtocol}=="02"
    ATTRS{bInterfaceProtocol}=="ff"  
    Where my old printer is 02, and my new printer is ff
  5. Create a named symlink to the appropriate USB port that will last through a reboot by editing the /etc/udev/rules.d/99-usb.rules file
    cd /etc/udev/rules.d
    sudo vi 99-usb.rules  
    Enter the following two lines in the file (specific for my printers):
    SUBSYSTEM=="tty", ATTRS{bInterfaceProtocol}=="02", SYMLINK+="ttyCDSX3A"
    SUBSYSTEM=="tty", ATTRS{bInterfaceProtocol}=="ff", SYMLINK+="ttyCPSX3A"
    
    The symlinks are the names I choose to use for the printer ports.
  6. Open up Octoprint, go to the settings menu, and add the new ports to the additional ports box.

Create a second copy of Octoprint

  1. Copy the octoprint directory
    cp -R .octoprint .octoprint2 
  2. Copy the octoprint configuration file
    sudo cp /etc/default/octoprint /etc/default/octoprint2
  3. Edit the octoprint2 configuration file to change the port and add a basedir
    sudo vi /etc/default/octoprint2

Edit my haproxy.cfg flie

The

Monday, December 2, 2019

Changing to a 12V 360W Power Supply

Why a 360W power supply?

I was trying to print ABS, but I couldn't get good bed adhesion.  The web tells me I need a bed temperature of 100C for printing ABS.  I could only get my bed up to about 80C, even when I let it heat up for an hour or so.

I thought there might be a problem with the wiring, so I checked the voltage to the hotbed while it was heating.  It was 10.4 V instead of 12 V.  So I checked the output of the power supply, thinking I might have some high resistance in the wiring.  Still 10.4 V.  So I adjusted the Vout using the trim pot on the power supply.  The highest I could get was 10.7 V with the heater on.   With the heater off, the output was 13.4 V.  So it was pretty obvious to me that I was running the power supply at its maximum capacity.

Some internet searchingfor under  showed me that I could get a 12V, 30A (360 W) power supply for under $20 (https://www.amazon.com/eTopxizu-Universal-Regulated-Switching-Computer/dp/B00D7CWSCG/ref=sr_1_3?keywords=12V+25A+power+supply&qid=1576126279&sr=8-3) if you are interested).  This power supply is physically a little bit larger than the 12V, 240W supply provided by Tronxy, but it fits in the power supply holder.  I haven't yet worked out the mounting issues, but I think I just need to get the right holes in the base and make sure I cut a new fan outlet in the top cover.


With the new power supply wired up, the bed easily and quickly heated up to 100C.  The hotend also heated up much more rapidly than it had in the past.  So I decided to autotune both the bed and the hotend.

With the procedure below followed, I can easily run 100C on the bed and 240C on the extruder.  This was a great upgrade!

Doing the Autotune

The autotune is accomplished with an M303 command.  For the heated bed:

M303 E-1 C8 S100

For the hotend:

M303 E0 C8 S230

Bed Autotune Parameters

The autotune parameters for the bed were:

Kp= 370.71
Ki = 41.90
Kd = 819.97

In oder to make autotune work, I made a couple of changes, which unfortunately required recompiling Marlin.  You can see my instructions for updating the firmware here.  

The changes I made to the firmware included:

1) Enable PIDTEMPBED

2) Disable BED_LIMIT_SWITCHING

Final PID parameters for Extruder

Set Kp = 8.15, Ki = 0.38, Kd = 43.16 (values came from an autotune cycle)




Saturday, November 2, 2019

Updating my Motherboard to SKR v 1.3, TFT 28, and 2208

Well, I  just had my printer set up so it was printing reliably each and every time.  All of my prints wer good.  And then I had a motherboard failure.  I believe it was due to one of the thermistor wires on the heatbed coming loose and touching the 12V supply line on the heated bed, which destroyed the hot bed A/D converter on the Melzi board.  Whether this is the exact case or not, both the hot end and the heated bed thermistors read properly when plugged into the hot end themistor plug.  And they both read Max Temp when plugged into the hot bed thermistor plug.  So it was time for a new motherboard.

I ordered a replacement motherboard from Tronxy.  And waited and waited for it to come.  And thought about some of the neat features that are available on other 3D printers.  Like a cool graphic LCD.  Easy ability to make on-the-fly temperature and speed adjustment.  Filament break detection.  Silent stepping.   And I decided to upgrade my motherboard.

So I ordered a Big Tree Tech SKR v 1.3 motherboard, a Big Tree TechTFT 28 touch screen display, 5 Big Tree Tech TMC 2208 v3.0 UART stepper drivers, and a Biqu Smart Filament Detector.  Now it's time to get them installed.

Installation instructions are pretty sparse on the web.  There are some great YouTube videos that show how to do it.  But although I love watching videos to see how things are done, I hate watching videos to get information that is easily captured in writing.  So I'm going to capture the content of the videos in writing as I work through my install.

You can get the motherboard instructions here.

Configuring the Motherboard Hardware

  1. Because I will be using an extenal power supply, rather than powering off the USB, I need to set the power jumper on the board so it connects +5V to INT, rather than connecting +5V to USB.
  2. Because I will be using UART stepper drivers, I need to remove all the jumpers from the stepper driver sockets.  Note: I will be using the E1 driver as muy second Z stepper.
  3. Install the UART jumpers for each of the stepper motor ports

Tuesday, September 10, 2019

Adding Octoprint

Well, I finally got my system reliable enough that all I need to do is insert the SD card, select "Print from SD", and then let it run to completion.

With this kind of reliability, it's time to stop using SD cards to print, in my opinion, so I decided to set up Octoprint on a Raspberry Pi.

I purchased a Raspberry Pi 3B+ from Amazon (see this link), along with a casecamera, and longer cable.  Everything came quickly and was of high quality.  I did not purchase a microSD card, as I already had some.  Note that it will require a card of at least 4GB (I used 16)

I downloaded Octopi from the Octoprint website and followed its instructions.  I  used Balena Etcher to flash my .img.

I had to set up the camera using raspi-config.  Under the Advanced menu option I enabled the camera and enabled I2C.  Once I had those items enabled, and the camera plugged into the proper ribbon cable socket (near the middle of the board, rather than at the end), the camera worked great.

It turns out that my wi-fi is really poor in my printing room, so I decided to connect the octopi to my network with a wired ethernet connection.  I edited octopi-wpa-supplicant.txt to comment out the wi-fi configuration.  Now I have success!

Sometimes I have trouble seeing the camera feed.  When this occurs, try killing the webcamd and mjpg_streamer processes, thenrestart webcamd.  That will often get the camera going again.

Part Cooling Fan

After reading a lot on the web, I decided to add a part cooling fan to my Tronxy X3.  I found a couple of fan mounts on Thingiverse.    I found a really simple one, but it was too fragile.  I found some complex ones, but they wouldn't print well without supports, and removing the supports was a pain in the neck.

So I designed my own, using Onshape.  And posted in on Thingiverse  here.

For me, it's a great addition.

Thursday, July 25, 2019

Setting the Z-axis Offset

With the autolevel installed, the Z-axis offset is important to set correctly.  It took me a while to figure out what that parameter meant.  Now that I have got it figured out, I'll write it to my blog to  make sure I always remember it.

The Z-axis offset is the Z-coordinate that will be loaded in the controller when the axis is homed.  That means, when my auto-leveler detects a home condition, the Z-axis offset should be the distance between the bed and the nozzle.

This can be measured with feeler gages.  It can also be measured by setting a high Z offset, then manually lowering the Z-axis until the nozzle reaches the bed.  The difference between the original offset and the Z-coordinate when the nozzle touches the bed is the Z offset.

You can also get close, then make fine adjustments.  If your first layer shows that the nozzle is too high, raise the Z-axis offset.  If your first layer shows that the nozzle is too low, lower the Z-axis offset.

To adjust the Z-axis offset in the Marlin firmware, go to Control/Motion/Z offset.  Use the up and down buttons to raise and lower the offset.

Once you get an offset you like, be sure to go to ControlStore Memory to save the settings in permanent memory so they'll be there after you power down your system.

Note: I have found out how to set the Z axis offset in G Code.

Use M851 Z<negative of Z axis offset>

Use M500 to store the current offset to firmware

Use M501 to load the current offset (and other settings) from firmware.

My Tronxy has a Z offset of about 4.9 mm.