K-value override possible?

Hey everyone!
First of all I want to say, that I’ve gone trough all forum posts and reddit posts over the past few years and haven’t found a solution.

I really prefer to always calibrate my K-values based on the filament and if I know it has been sitting for a while, do a re-calibration. BUT, as we all know the K-values are stored in the machine and can only save up to 16-values, which is pretty limiting if you have about 30 colors.
So far I’ve gotten around this issue by marking down the filament K-values in the notes of the filament profile and then choosing some pre-saved one that is the closest.
I’d like to find a better solution to this.

My current theory is that maybe there is a way to add g-code to the filament settings advanced tab? Something like “pressure_advance = 0.034”
But my fear is that the software k-value over-rides this and won’t apply.

How have you solved this issue?
Because if this doesn’t work my plan was to create manual K-values for ‘generic PETG’ and ‘generic PLA’ with steps of 0.005 and then just choose a value from there that’s closest to the one marked on my filaments. (Ie I have 0.033 marked down for Bambu PLA Grey, so I choose ‘generic PLA’ profile with 0.035 value).

[EDIT]:After poking around I found a way you can edit the K values for a filament.

  • Go to the Calibration tab in Studio
  • Select ‘Manage Result’ at the bottom of the Flow Dynamics Calibration page
  • Find the filament you want to edit in the list
  • Scroll to the right and select ‘Edit’
  • Input your desired K value and select ‘Save’

I do not understand why they removed the ability to manually edit K values from the Device tab.

Hey, thank you for the answer, but this isn’t what I asked for :wink:

In there you can only have 16 result, meaning if you have more than 16 different filaments, you would have to go and change the value manually every time you use a filament that doesn’t fit into the 16 ones you can select.
I have 37 different filaments, so that would get old really fast. This is why I’m looking for a better solution :wink:

I’m pretty sure I have more than 16 PA values, all my filaments have one for each color and my ASA Aero and PLA Aero have more than one depending of what I’m printing.

I’m sorry, but it is 16 per nozzle not per filament type. It has been acknowledged that they are saved in the printer itself and the limitation lies in the hardware.

But I still don’t understand why the K-value couldn’t be saved in the filament profile.
This is why I’m trying to figure out a work-around :wink:

OrcaSlicer:

Yes, Orca supports it, I’m well aware of it. But I have my own reasons on why I prefer BambuStudio, so thank you for the anwer, but unfortunately it’s not helping me in this exact scenario :wink:

I think I have 69 different values here on a X1 Carbon




For me its way better to have the K-values in the machine, that makes allready sliced models use the new K-value, if they were stored in the process or filament setting it would also repeat the information since I also have many many different profiles for the same filament etc.

Wow, do you have any theories on how?
I have been using A1Mini and P1S. I do have a P2S coming hopefully this week, so maybe that also supports more profiles due to a more powerful processing unit…

Unfortunately that still doesn’t solve my issue. Don’t get me wrong, I’m happy it works for you and the X1C.
It’s sometimes funny on how the internet you can ask a question and people start commenting solutions outside the scope :smiley:

So again, I’ll try to re-focus on the current question in hand:
Has anyone succesfully used g-code in the filament settings to enforce your own K-value without the printer overriding it with the value it has in the machine K-values?

Unfortunately, at least on my current A1M it won’t allow me to save over 16-values (view the screenshot above). Otherwise I would agree, I’d prefer to keep them in the designated area, but 37-values don’t fit inside the 16-value limit, because number 16 is smaller than 37 :smiley:

Not entirely sure. The X1 Carbon was my first Bambu Lab printer, but even so, a limit of only 16 PA/K entries sounds unusually low, even for machines with limited memory. In your situation it would definitely be better to store them directly in the filament profile.

If you add the PA/K values to the G-code and then disable PA/K calibration for the print job, the printer should use the values embedded in the G-code.

Even my generated gcode have these

; enable_pressure_advance = 0
; pressure_advance = 0.02

So if enabled I think it would use that value of 0.02 which is the default for PLA on X1 Carbon

There are multiple threads on the web, where it is noted that there is a 16-value limit.
On one thread someone had gotten a reply from the support stating:
“Currently, the P series printers can save a maximum of 16 K-values for the same nozzle diameter. If you want to save more K-values, would you please try using a different nozzle diameter”

Can you please let me know where did you get this gcode, because I found the same gcode (stated in my first post) from a random reddit post without confirmation of it working.
I am planning on running my own tests with gcode values set to weird extremes to produce a repeatable test, but I wanted to ask people here hoping that someone has already tested this and I wouldn’t have haha :smiley:
Testing is cool and all, but no point in wasting time if there already is an answer.

And having seen countless of posts about the 16-value limit over the past few years, I couldn’t fathom that no-one has tried this :wink:

If you’re comfortable with Python, Lua, or similar scripting languages, you can create a post-processor that retrieves the PA values from the notes section of the filament profile. I built something similar for a special project some time ago — I think it was during the brick-layering experiment I ran.

Hmm… that sounds interesting.
I have no experience of Python or Lua except copy-pasteing some scripts when I was on an Ender 3, but then again I didn’t have CAD experience before learning CAD either, so I’m guessing all is learnable.
I was thinking about GPT help, but it can only know if you already know what and how you want to achieve something. It’s basically helpless if you just tell it your end goal without directions.
Could you give me a few pointers maybe?
So I could retrieve the PA value from notes (where I already keep my K-values right now)… And then add the post-processing script to the print process, correct?

I’m still afraid that the machine-stored K-values (in this case stock 0.020) would over-write whatever I give it in the post-processing script or filament gcode. You seem pretty knowledgable, so what are your opinions on this?

I can see if I can put together a simple script. Do you want to keep the PA values inside the filament profile? I can work on it later today — right now I need to study math with my daughter. :wink:

1 Like

If you could do that that would be amazing, this would be an amazing solution to a lot of users!
For me it doesn’t matter where I keep them, but I think it would be easiest to keep them inside filament profile, yes. This would avoid forgetting to set them :wink:

And no worries, take your time, this ain’t no rush issue :wink:
Good luck! School-level math is usually much more annoying than we as adults remember :smiley:

Script that will do the translation

param(
    [string]$InputFile,
    [string]$OutputFile
)

# If Bambu Studio only passes one parameter:
# use the same file as both input and output (in-place editing)
if (-not $OutputFile -or $OutputFile -eq "") {
    $OutputFile = $InputFile
}

# Read all lines as an array
$lines = Get-Content -Encoding UTF8 $InputFile

# Look for a line like "; PA_OVERRIDE = 0.045"
$pa = $null
$paLine = $lines | Where-Object { $_ -match '^\s*;\s*PA_OVERRIDE\s*=' } | Select-Object -First 1

if ($paLine -and $paLine -match '=\s*([0-9.]+)') {
    $pa = $matches[1]
}

# If no PA_OVERRIDE was found: write the original G-code back and exit
if (-not $pa) {
    Set-Content -Encoding UTF8 -Path $OutputFile -Value $lines
    exit 0
}

# Update the pressure advance header fields
$updated = $lines | ForEach-Object {
    if ($_ -match '^; enable_pressure_advance') {
        '; enable_pressure_advance = 1'
    }
    elseif ($_ -match '^; pressure_advance =') {
        "; pressure_advance = $pa"
    }
    else {
        $_
    }
}

# Write the modified G-code to output
Set-Content -Encoding UTF8 -Path $OutputFile -Value $updated

exit 0

Then I used a batch to fire this up

@echo off
powershell -NoProfile -ExecutionPolicy Bypass -File "C:\tmp\PA.ps1" "%1" "%2"

Put the batch as PA.bat and the PS skript as PA.ps1 in a folder

Then in your filament profile that need a special PA you should put

; PA_OVERRIDE = 0.9999

As the last row in your startup gcode for that filament.

Be aware that I only tested this to change it to correct values

; enable_pressure_advance = 1
; pressure_advance = 0.9999

At least they are now active when you send the print job