How to make permanent changes to z axis kp ki kd

Hi there,

I am new to this forum and I am building my maslow from the february batch.

I am building a custom Z axis with custom hardware and motor, but I get oscillations on the Z motor.
I use GC and Firmware 1.17

I am trying to change the Z axis z kp ki kd PID with the gcode $29, $30, $31 …
I set in “advanced settings” the “Enable custom velocity PID values” and “Enable custom velocity PID values”
When I set them one by one with a macro it works fine but it is tedious …
When I set them with a gcode file with a content like this

$29=100
$30=0
$31=0

the global setting is updated but a few line later in the log they are reset to the default values an extract of the log is written at the end of this post My questions are 1) Did i miss something regarding z axis PID parameters in the settings 2) How to make permanent changes to z axis kp ki kd Position and Velocity thanks Dominique extract of log.txt ........................................................................................... Sent: $29=100 ok Sent: $30=0 <Idle,MPos:170.55,101.99,64.27,WPos:0.000,0.000,0.000> [PE:0.00,0.00,127] ok Sent: $31=0 ok Sent: $$ $0=2438.40 (machine width, mm) $1=1219.19995117 (machine height, mm) $2=3000.00000000 (motor distance, mm) $3=480.00000000 (motor height, mm) $4=310.00000000 (sled width, mm) $5=139.00000000 (sled height, mm) $6=79.00000000 (sled cg, mm) $7=2 (Kinematics Type 1=Quadrilateral, 2=Triangular) $8=140.00000000 (rotation radius, mm) $9=2000 (axis idle before detach, ms) $10=3360 (full length of chain, mm) $11=1650 (calibration chain length, mm) $12=8113.73046875 (main steps per revolution) $13=63.50000000 (distance / rotation, mm) $15=800 (max feed, mm/min) $16=1 (Auto Z Axis, 1 = Yes) $17=0 (auto spindle enable 1=servo, 2=relay_h, 3=relay_l) $18=20.00000000 (max z axis RPM) $19=1.00000000 (z axis distance / rotation) $20=18270.00000000 (z axis steps per revolution) $21=1300.00000000 (main Kp Pos) $22=0.00000000 (main Ki Pos) $23=34.00000000 (main Kd Pos) $24=1.00000000 (main Pos proportional weight) $25=5.00000000 (main Kp Velocity) $26=0.00000000 (main Ki Velocity) $27=0.28000001 (main Kd Velocity) $28=1.00000000 (main Velocity proportional weight) $29=100.00000000 (z axis Kp Pos) $30=0.00000000 (z axis Ki Pos) $31=0.00000000 (z axis Kd Pos) $32=1.00000000 (z axis Pos proportional weight) $33=5.00000000 (z axis Kp Velocity) $34=0.00000000 (z axis Ki Velocity) $35=0.28000001 (z axis Kd Velocity) $36=1.00000000 (z axis Velocity proportional weight) $37=0.00000000 (chain sag correction value) $38=1 (chain over sprocket) $39=3 (PWM frequency value 1=39,000Hz, 2=4,100Hz, 3=490Hz) $40=63.50000000 (distance / rotation, including chain tolerance, left chain, mm) $41=63.50000000 (distance / rotation, including chain tolerance, right chain, mm) $42=2.00000000 (position error alarm limit, mm) ok Sent: $29=1300.0 <Idle,MPos:170.55,101.99,64.27,WPos:0.000,0.000,0.000> [PE:0.00,0.00,127] ok Sent: $31=34.0 ok

This sounds like the right solution to me. When you set them in the settings they should stay. You may need to disconnect and reconnect the arduino for the change to take effect.

Hi Bar,
Thanks for your quick answer.
I redo the operation and I got the same result but I can give you more informations.
I double check “Enable custom velocity PID values” and “Enable custom velocity PID values” which are “On”

here is the sequence

  1. run GC and execute the gcode file setting PID values but not $$
    t2) Exit GC
  2. run GC : the log inidicate the updated PID values and just after logging GC and Firmware version the values are reset to the default values.

I think the problem comes from GC.
Hope this help
thanks
Dominique

What happens if the gcode file is not run? You should be able to change them just from settings with no gcode file needed

Hi Bar,

I didn’t see where to set zAxis PID parameters in GC 1.17 ‘advanced setting’. I saw the 8 PID parameters but I want to keep the preset value for the Left and Right Axis.
Sorry if I am blind …

My Z axis need specific PID values : It is a 20 rpm motor driving a metric 6 screw (1mm per revolution) and the encoder is around 15000 pulses per revolution. this make my zaxis very slow.

For the moment I use a gcode file to set the zAxis settings. Those values are lost at each GC restart.

Dominique

Dominique

1 Like

I’m sorry! I totally didn’t understand the question. I didn’t realize that you are 100% correct that there is not a PID value setting for just the z-axis.

Let me look into how difficult it would be to add a setting option for that.

@bar, I think there might be a problem with main.py around line 192:

        elif key == 'enablePosPIDValues':
            for key in ('KpPos', 'KiPos', 'KdPos', 'propWeight'):
                if int(self.config.get('Advanced Settings', 'enablePosPIDValues')) == 1:
                    value = float(self.config.get('Advanced Settings', key))
                else:
                    value = maslowSettings.getDefaultValue('Advanced Settings', key)
                self.config.set('Computed Settings', key + "Main", value)
                self.config.set('Computed Settings', key + "Z", value)

        elif key == 'enableVPIDValues':
            for key in ('KpV', 'KiV', 'KdV'):
                if int(self.config.get('Advanced Settings', 'enablePosPIDValues')) == 1:
                    value = float(self.config.get('Advanced Settings', key))
                else:
                    value = maslowSettings.getDefaultValue('Advanced Settings', key)
                self.config.set('Computed Settings', key + "Main", value)
                self.config.set('Computed Settings', key + "Z", value)
        

This looks to me like it sets the values of the K_PosZ variables to those taken from K_Pos. That seems to be what is happening; otherwise the values sent should get written to EEPROM and persist. Am I missing something?
Having separate settings available on the GC Advanced page would be nice as well…

1 Like

Brilliant @blurfl!!! :heart: I wasn’t going to start looking there at all and probably would have spent hours trying to figure out why things kept getting reset.

So we should be safe just to take that line out, right? I think you are right that without that line we would just have the value stored in the firmware. Is there any case in which we might have a bad value stored in the firmware and want to overwrite it like this? (although this wouldn’t be the right value for that anyway)

If a bad value were stored, it could be overwritten by the full settingsWipe of RST= or $RST=# or $RST=*, or by a new value using $29=xxx, etc. - yes?

Yes I agree

Would an average user know to do that? What if we leave it the way it is when the default PID values are enabled (because it’s working :stuck_out_tongue_winking_eye:) , and set it to not push the z-PID values when the custom PID values setting is enabled. That would solve the issue @Dominique is seeing because the values once set will be saved on the Arduino and it won’t risk confusing all the folks who are putting their machines together right now

Unfortunately, commenting out the lines I mentioned doesn’t seem to do the trick :thinking: when I tried it. Did you have different results?

1 Like

I haven’t started looking at it yet, but I’ll jump in now

2 Likes

I think I see what is going on.

That line is just responsible for updating the computed settings value, which will persist even when the line is removed. To really make the z-axis PID values not get pushed to the machine would involve coding a special case for them which would kinda disrupt the protocol for how everything is set which seems like not the right way to do things. The right way to do things I think is to add 6 more fields to the advanced settings for the z-axis PID values. It will clutter up the settings window a little.

Does that feel like a reasonable option?

Yes, that would be the best. Thanks for digging deeper.

2 Likes

Thanks for showing me the jumping off point!

I’ve created pull request #744 to add those settings options.

@Dominique if you have a chance to test it I would be much obliged. I entered some different PID values and saw the behavior of the motor change but PID things are always so finicky that it can be hard to tell the different between a change and everything working right. It would be good to know that it fixes your problem (or not :grimacing:)

1 Like

Hi Bar,
Sure I will test it as soon as the new GC is available.
I use Windows 10. To test the new GC will It require a Python dev environment or package for windows will be released ? For the moment I don’t have a Python dev environment.

Dominique

2 Likes