1. Got a question or need help troubleshooting? Post to the troubleshooting forum or Search the forums!

PID tuning and Marlin

Discussion in 'General Questions' started by WheresWaldo, Sep 19, 2017.

  1. WheresWaldo

    WheresWaldo Volunteer ( ͠° ͟ʖ ͡°)
    Staff Member

    Joined:
    Feb 18, 2015
    Messages:
    5,806
    Likes Received:
    3,521
    To PID tune your printer :

    The M304 command is for setting Bed PID values and not actually an offset, you would use it like this. Execute a command to autotune Bed PID:
    1. M303 E-1 C8 S60 - this will set bed temp at 60°C for 8 cycles, the result will be expressed as kP, kI and kD values.
    2. When you get the results you can insert them into memory with M304 Pnnn Innn Dnnn ; replace the nnnn with the number you got.
    3. You can then save them permanently by issuing a M500
     
    #1 WheresWaldo, Sep 19, 2017
    Last edited by a moderator: Sep 19, 2017
    tkoco and nytcrawlr like this.
  2. WheresWaldo

    WheresWaldo Volunteer ( ͠° ͟ʖ ͡°)
    Staff Member

    Joined:
    Feb 18, 2015
    Messages:
    5,806
    Likes Received:
    3,521
    So to fine tune you hotend
    1. M303 E0 C8 S225 - this would set the hotend to 225°C for 8 cycles, the results are expressed as kP, kI, and kD
    2. Insert them into M301 H1 Pnnn Innn Dnnn - replace the nnnn with the number from the auto tuning, Note that you test Extruder 0 but apply your values to Hotend 1.
    3. You can then save the values permanently using the M500 command.
     
    #2 WheresWaldo, Sep 19, 2017
    Last edited by a moderator: Sep 19, 2017
    tkoco and nytcrawlr like this.
  3. Day Vid

    Day Vid New Member

    Joined:
    Oct 27, 2017
    Messages:
    20
    Likes Received:
    3
    I was able to tune the hotend ok, but I've tried the bed several times and it times out during the cycle.
     
  4. mark tomlinson

    mark tomlinson ༼ つ ◕_ ◕ ༽つ
    Staff Member

    Joined:
    Feb 21, 2013
    Messages:
    21,138
    Likes Received:
    6,997
    Not unheard of. The bed on one of mine will never pass PID tuning for much the same reason -- it responds too slow.
     
  5. WheresWaldo

    WheresWaldo Volunteer ( ͠° ͟ʖ ͡°)
    Staff Member

    Joined:
    Feb 18, 2015
    Messages:
    5,806
    Likes Received:
    3,521
    Try doing the bed PID at something like 60°C any higher and the bed heats so slowly on the R2 that it likely will time out every time.

    One thing to note, if you are doing PID tuning on either the Hotend or Bed and saving those to EEPROM If you use the Z-Offset wizard afterwards all those settings will be erased.
     
  6. WheresWaldo

    WheresWaldo Volunteer ( ͠° ͟ʖ ͡°)
    Staff Member

    Joined:
    Feb 18, 2015
    Messages:
    5,806
    Likes Received:
    3,521
    Please note that PID tuning may not be permanent unless you physically edit the firmware and reflash. There appears to be a bug/feature of RoboOS that resets EEPROM to firmware defaults every time you power up your printer. This also occurs every time you run the Z Offset wizard.
     
  7. Iamkar33m

    Iamkar33m New Member

    Joined:
    Nov 9, 2017
    Messages:
    4
    Likes Received:
    1
    What a pain! So you have to re-PID tune after you run a z-offset?
     
  8. WheresWaldo

    WheresWaldo Volunteer ( ͠° ͟ʖ ͡°)
    Staff Member

    Joined:
    Feb 18, 2015
    Messages:
    5,806
    Likes Received:
    3,521
  9. nytcrawlr

    nytcrawlr New Member

    Joined:
    Sep 17, 2016
    Messages:
    15
    Likes Received:
    8
    Not a python programmer, but the block starting at line 142 in z_offset_wizard.py from the GitHub posted by WheresWaldo, I think I found the issue at least when running the wizard, specifically lines 151 and 152 (bolded below):

    def _prepare_printer(self):
    # Prepare printer for zoffset configuration
    #jog the Z Axis Down to prevent any bed interference
    jogger = {'z': 160}
    printer_jog.jog(desired=jogger, speed=1500, relative=True)
    #kill the extruder
    roboprinter.printer_instance._printer.commands('M104 S0')
    roboprinter.printer_instance._printer.commands('M140 S0')
    roboprinter.printer_instance._printer.commands('M106 S255')
    roboprinter.printer_instance._printer.commands('M502')
    roboprinter.printer_instance._printer.commands('M500')

    roboprinter.printer_instance._printer.commands('G28')
    bed_x = 0
    bed_y = 0
    roboprinter.printer_instance._printer.commands('G1 X' + str(bed_x) + ' Y' + str(bed_y) +' F10000')
    roboprinter.printer_instance._printer.commands('G1 Z20 F1500')

    It appears that block is running when prepping for z-offset, so if I'm reading that right, the EEPROM has already been fully reset before you even get to setting the new value.
     
  10. WheresWaldo

    WheresWaldo Volunteer ( ͠° ͟ʖ ͡°)
    Staff Member

    Joined:
    Feb 18, 2015
    Messages:
    5,806
    Likes Received:
    3,521
    Yes, that is the problem. You can delete those two lines and then save the file. But in order for it to work you must also delete the z_offset_wizard.pyc file or Python won't use the correct code. It is in the same directory. Don't forget if you ever apply the Robo update or reinstall the Robo theme the issue will come back. I posted a bug report on the GITHUB but there has been no activity since mid-October and certainly no acknowledgement of the open issue.
     
    mark tomlinson likes this.
  11. mark tomlinson

    mark tomlinson ༼ つ ◕_ ◕ ༽つ
    Staff Member

    Joined:
    Feb 21, 2013
    Messages:
    21,138
    Likes Received:
    6,997
    Bingo :)
     
  12. JeffreyB

    JeffreyB Member

    Joined:
    Mar 25, 2016
    Messages:
    68
    Likes Received:
    29
    Is PID even used on the bed? I thought the bed was in bang bang...
     
  13. WheresWaldo

    WheresWaldo Volunteer ( ͠° ͟ʖ ͡°)
    Staff Member

    Joined:
    Feb 18, 2015
    Messages:
    5,806
    Likes Received:
    3,521
    PID is enabled in the Robo Firmware, but most flavors of Marlin used to use Bang Bang.
     
  14. tkoco

    tkoco Active Member

    Joined:
    May 7, 2018
    Messages:
    190
    Likes Received:
    96
    After modifying said file, make a copy of it like: cp z_offset_wizard.py z_offset_wizard-py.fixed
    That way you will have a copy of the changes if you should ever install a Robo update or Robo theme.
     

Share This Page