Custom Controls Thread

Talk about the web based OctoPrint controllers
User avatar
daftscience
Printmaster!
Posts: 205
Joined: Sun Jan 13, 2013 12:37 pm

Custom Controls Thread

Postby daftscience » Sat Feb 08, 2014 10:41 pm

Here are some useful custom controls I've created for the RostockMax and Repetier. If anyone else has any please feel free to add to this. Octoprint's Github has a great guide and some good examples.

Just place these in the controls section of config.yaml.

Bed Calibration:

Code: Select all

- children:
  - commands:
    - G28
    - G0 Z%(height)s F1500
    input:
    - default: 5
      name: Height
      parameter: height
    name: Move Z
    type: parametric_commands
  - commands:
    - G28
    - G0 X0 Y90 Z%(height)s F1500
    input:
    - default: 5
      name: G0 X0 Y90 Z
      parameter: height
    name: Zero Z axis
    type: parametric_commands
  - commands:
    - G28
    - G0 X77.94 Y-45 Z%(height)s F1500
    input:
    - default: 5
      name: G0 X77.94 Y-45 Z
      parameter: height
    name: Zero Y Axis
    type: parametric_commands
  - commands:
    - G28
    - G0 X-77.94 Y-45 Z%(height)s F1500
    input:
    - default: 5
      name: G0 X-77.94 Y-45 Z
      parameter: height
    name: Zero X Axis
    type: parametric_commands
  name: Calibrate
  type: section


This will create custom controls that make calibration go much quicker.
Basically, enter a value into the box and it will lower the nozzle to that height at which ever calibration point you want. From there use the LCD to lower it step by step.


EEPROM Updater

Code: Select all

- children:
  - commands:
    - M206 T3 P145 X%(maxLength)s
    - M206 T3 P149 X%(maxLength)s
    - M206 T3 P153 X%(maxLength)s
    - M500
    - G28
    input:
    - default: null
      name: Max Z height
      parameter: maxLength
    name: Set XYZ max length
    type: parametric_commands
  - commands:
    - M206 T%(type)s P%(location)s X%(value)s
    - M500
    - G28
    input:
    - default: null
      name: Type
      parameter: type
    - defualt: null
      name: Location
      parameter: location
    - default: null
      name: Value
      parameter: value
    name: EEPROM
    type: parametric_commands
  - commands:
    - M206 T3 P218 X%(pgain)s
    - M206 T3 P222 X%(igain)s
    - M206 T3 P226 X%(dgain)s
    - M500
    input:
    - default: null
      name: P-gain
      parameter: pgain
    - default: null
      name: I-gain
      parameter: igain
    - default: null
      name: D-gain
      parameter: dgain
    name: Update PID
    type: parametric_commands
  name: Set EEPROM
  type: section
- children:
  - command: M114
    name: Get Position
    regex: X:([0-9.-]+) Y:([0-9.-]+) Z:([0-9.-]+) E:([0-9.-]+)
    template: 'Position: X={0}, Y={1}, Z={2}, E={3}'
    type: feedback_command
  - command: M503
    name: Get EEPROM
    type: command
  - name: Z Height
    regex: EPR:([0-9.-]+) ([0-9.-]+) ([0-9.-]+) X max length
    template: ' {2} |Type: {1}  | Location: {0}'
    type: feedback
  - command: M503
    name: P-Gain
    regex: EPR:([0-9.-]+) ([0-9.-]+) ([0-9.-]+) Extr.1 PID P-gain
    template: ' {2} |Type: {1}  | Location: {0}'
    type: feedback
  - command: M503
    name: I-Gain
    regex: EPR:([0-9.-]+) ([0-9.-]+) ([0-9.-]+) Extr.1 PID I-gain
    template: ' {2} |Type: {1}  | Location: {0}'
    type: feedback
  - command: M503
    name: D-Gain
    regex: EPR:([0-9.-]+) ([0-9.-]+) ([0-9.-]+) Extr.1 PID D-gain
    template: '{2}  |Type: {1}  | Location: {0}'
    type: feedback
  - name: Printer Radius
    regex: EPR:([0-9.-]+) ([0-9.-]+) ([0-9.-]+) Horizontal radius
    template: '{2}  |Type: {1}  | Location: {0}'
    type: feedback
  name: Reporting
  type: section





This block does a few things. First, it allows you to update a specific EEPROM value, or update PID values. Second it looks for specific EEPROM values and will save them. This makes it easier to keep track of the M503 output (the terminal only keeps them for so long.) Someday, I will make a complete list of EEPROM values.
Last edited by daftscience on Mon Feb 17, 2014 11:26 pm, edited 2 times in total.

User avatar
Eaglezsoar
ULTIMATE 3D JEDDI
Posts: 7185
Joined: Sun Apr 01, 2012 5:26 pm

Re: Custom Controls Thread

Postby Eaglezsoar » Sun Feb 09, 2014 4:42 pm

Daftscience, thanks for the custom controls, those are going to come in handy when I do the PI setup.
Don't forget to post the last one you said you had. :)

User avatar
daftscience
Printmaster!
Posts: 205
Joined: Sun Jan 13, 2013 12:37 pm

Re: Custom Controls Thread

Postby daftscience » Sun Feb 09, 2014 11:19 pm

Thanks for reminding me. I just updated my first post with EEPROM reporting

User avatar
Eaglezsoar
ULTIMATE 3D JEDDI
Posts: 7185
Joined: Sun Apr 01, 2012 5:26 pm

Re: Custom Controls Thread

Postby Eaglezsoar » Mon Feb 10, 2014 4:17 am

daftscience wrote:Thanks for reminding me. I just updated my first post with EEPROM reporting

Thank you for posting them.

User avatar
bubbasnow
ULTIMATE 3D JEDDI
Posts: 1064
Joined: Fri Aug 02, 2013 4:24 pm
Location: Dayton, WA

Re: Custom Controls Thread

Postby bubbasnow » Mon Feb 17, 2014 3:30 pm

daftscience wrote:Here are some useful custom controls I've created for the RostockMax and Repetier. If anyone else has any please feel free to add to this. Octoprint's Github has a great guide and some good examples.


Bed Calibration:

Code: Select all

- children:
  - commands:
    - G28
    - G0 Z%(height)s F1500
    input:
    - default: 5
      name: Height
      parameter: height
    name: Move Z
    type: parametric_commands
  - commands:
    - G28
    - G0 X0 Y90 Z%(height)s F1500
    input:
    - default: 5
      name: G0 X0 Y90 Z
      parameter: height
    name: Zero Z axis
    type: parametric_commands
  - commands:
    - G28
    - G0 X77.94 Y-45 Z%(height)s F1500
    input:
    - default: 5
      name: G0 X77.94 Y-45 Z
      parameter: height
    name: Zero Y Axis
    type: parametric_commands
  - commands:
    - G28
    - G0 X-77.94 Y-45 Z%(height)s F1500
    input:
    - default: 5
      name: G0 X-77.94 Y-45 Z
      parameter: height
    name: Zero X Axis
    type: parametric_commands
  name: Calibrate
  type: section


So throwing this into the config.yaml file will create custom controls that make calibration go much quicker.
Basically, enter a value into the box and it will lower the nozzle to that height at which ever calibration point you want. From there use the LCD to lower it step by step.


EEPROM Updater

Code: Select all

- children:
  - commands:
    - M206 T3 P145 X%(maxLength)s
    - M206 T3 P149 X%(maxLength)s
    - M206 T3 P153 X%(maxLength)s
    - M500
    - G28
    input:
    - default: null
      name: Max Z height
      parameter: maxLength
    name: Set XYZ max length
    type: parametric_commands
  - commands:
    - M206 T%(type)s P%(location)s X%(value)s
    - M500
    - G28
    input:
    - default: null
      name: Type
      parameter: type
    - defualt: null
      name: Location
      parameter: location
    - default: null
      name: Value
      parameter: value
    name: EEPROM
    type: parametric_commands
  - commands:
    - M206 T3 P218 X%(pgain)s
    - M206 T3 P222 X%(igain)s
    - M206 T3 P226 X%(dgain)s
    - M500
    input:
    - default: null
      name: P-gain
      parameter: pgain
    - default: null
      name: I-gain
      parameter: igain
    - default: null
      name: D-gain
      parameter: dgain
    name: Update PID
    type: parametric_commands
  name: Set EEPROM
  type: section
- children:
  - command: M114
    name: Get Position
    regex: X:([0-9.-]+) Y:([0-9.-]+) Z:([0-9.-]+) E:([0-9.-]+)
    template: 'Position: X={0}, Y={1}, Z={2}, E={3}'
    type: feedback_command
  - command: M503
    name: Get EEPROM
    type: command
  - name: Z Height
    regex: EPR:([0-9.-]+) ([0-9.-]+) ([0-9.-]+) X max length
    template: ' {2} |Type: {1}  | Location: {0}'
    type: feedback
  - command: M503
    name: P-Gain
    regex: EPR:([0-9.-]+) ([0-9.-]+) ([0-9.-]+) Extr.1 PID P-gain
    template: ' {2} |Type: {1}  | Location: {0}'
    type: feedback
  - command: M503
    name: I-Gain
    regex: EPR:([0-9.-]+) ([0-9.-]+) ([0-9.-]+) Extr.1 PID I-gain
    template: ' {2} |Type: {1}  | Location: {0}'
    type: feedback
  - command: M503
    name: D-Gain
    regex: EPR:([0-9.-]+) ([0-9.-]+) ([0-9.-]+) Extr.1 PID D-gain
    template: '{2}  |Type: {1}  | Location: {0}'
    type: feedback
  - name: Printer Radius
    regex: EPR:([0-9.-]+) ([0-9.-]+) ([0-9.-]+) Horizontal radius
    template: '{2}  |Type: {1}  | Location: {0}'
    type: feedback
  name: Reporting
  type: section





This block does a few things. First, it allows you to update a specific EEPROM value, or update PID values. Second it looks for specific EEPROM values and will save them. This makes it easier to keep track of the M503 output (the terminal only keeps them for so long.) Someday, I will make a complete list of EEPROM values.



My config.yaml did not include the "controls:" section so be sure to add this above this copy paste if yours does not have it either

User avatar
bubbasnow
ULTIMATE 3D JEDDI
Posts: 1064
Joined: Fri Aug 02, 2013 4:24 pm
Location: Dayton, WA

Re: Custom Controls Thread

Postby bubbasnow » Mon Feb 17, 2014 4:58 pm

also, is there a way to run a python script from the system pull down menu?

here is what exists now

Code: Select all

system:
  actions:
  - action: shutdown
    command: sudo shutdown -h now
    confirm: You are about to shutdown the system.
    name: Shutdown


here is an example on how to switch a relay on or off

Code: Select all

system:
 actions:
  - action: printer off
   command: gpio mode 7 in
   confirm: You are about to turn off the printer.
   name: Turn off printer


but when i try to do a

Code: Select all

command: sudo python script.py
i get an error returned to octoprint.

i was thinking of using GPIO pwm feature to control some servos or LED strips

User avatar
bubbasnow
ULTIMATE 3D JEDDI
Posts: 1064
Joined: Fri Aug 02, 2013 4:24 pm
Location: Dayton, WA

Re: Custom Controls Thread

Postby bubbasnow » Mon Feb 17, 2014 5:17 pm

i got it nm

User avatar
daftscience
Printmaster!
Posts: 205
Joined: Sun Jan 13, 2013 12:37 pm

Re: Custom Controls Thread

Postby daftscience » Mon Feb 17, 2014 11:35 pm

What did you have to do to get it working?

User avatar
bubbasnow
ULTIMATE 3D JEDDI
Posts: 1064
Joined: Fri Aug 02, 2013 4:24 pm
Location: Dayton, WA

Re: Custom Controls Thread

Postby bubbasnow » Tue Feb 18, 2014 12:52 am

daftscience wrote:What did you have to do to get it working?



This was from the Octoprint wiki

Code: Select all

pi@raspberrypi ~ $ sudo -s
root@raspberrypi:/home/pi# echo "pi ALL=NOPASSWD: /sbin/shutdown" > /etc/sudoers.d/octoprint-shutdown
root@raspberrypi:/home/pi# exit


and this will add my move to the system drop down and run my "servo1.py"

Code: Select all

system:
 actions:
  - action: move
    command: cd /home/pi && sudo python servo1.py
    confirm: false
    name: move it

User avatar
bubbasnow
ULTIMATE 3D JEDDI
Posts: 1064
Joined: Fri Aug 02, 2013 4:24 pm
Location: Dayton, WA

Re: Custom Controls Thread

Postby bubbasnow » Sun Feb 23, 2014 3:40 am

Using WiringPi
https://projects.drogon.net/raspberry-pi/wiringpi/

I've added these controls to the system pull down.

Code: Select all

system:
  actions:
  - action: update
    command: cd ~/OctoPrint && git pull && sudo pip install -r requirements.txt
    confirm: You are about to update Octoprint.
    name: Update (git pull)
  - action: update
    command: sudo apt-get -y update && sudo apt-get -y upgrade
    confirm: You are about to update Raspbian.
    name: Update Raspbian
  - action: shutdown
    command: sudo shutdown -h now
    confirm: You are about to shutdown the system.
    name: Shutdown
  - action: reboot
    command: sudo shutdown -r now
    confirm: You are about to reboot the system
    name: Reboot
  - action: move
    command: cd /home/pi && sudo python servo1.py
    confirm: false
    name: move it
  - action: LightOn
    command: gpio mode 3 out
    confirm: You are about to turn the Lights On
    name: Turn Lights On
  - action: LightOff
    command: gpio mode 3 in
    confirm: You are about to turn the Lights off
    name: Turn Lights Off
  - action: PrinterOn
    command: gpio mode 2 out
    confirm: You are about to turn on the Printer
    name: Turn Printer On
  - action: PrinterOff
    command: gpio mode 2 in
    confirm: You are about to turn off the Printer
    name: Turn Printer Off
  - action: HeatBedOn
    command: gpio mode 0 out
    confirm: You are about to turn on the Heatbed
    name: Turn HeatBed On
  - action: HeatBedOff
    command: gpio mode 0 in
    confirm: You are about to turn off the Heatbed
    name: Turn HeatBed Off


be mindful that when you use GPIO command it is NOT the GPIOPIN# of the pi, there is a table on the site above listing what pin is connected to what number.

DGBK
Printmaster!
Posts: 106
Joined: Sun May 17, 2015 10:03 pm

Re: Custom Controls Thread

Postby DGBK » Tue Jul 14, 2015 11:56 am

Well, I must be doing something wrong here. After applying your code to my config.yaml file, I see no changes.

I copied both of your code blocks into my config.yaml file. I added "control:" above it without the quotation marks. I added this alphabetically between "appearance:" and "feature: {}". I then rebooted my pi, restarted the server, and checked the config.yaml file to make sure my additions were intact.

When I opened the OctoPrint page, I expected to see some new controls in my control tab, but nothing had changed. I then checked the settings. The additional options weren't there either.

Where should I expect to see the commands? Did I screw up somewhere?

Thanks

Edit: For clarity, this message is addressed to the first post, not the more advanced controls farther down the page.

DGBK
Printmaster!
Posts: 106
Joined: Sun May 17, 2015 10:03 pm

Re: Custom Controls Thread

Postby DGBK » Tue Jul 14, 2015 12:10 pm

Of course as soon as I posted this, I realized what I did wrong. I needed to add "controls" instead of "control". It is all working now. Thanks for the awesome code.


Return to “OctoPrint”

Who is online

Users browsing this forum: No registered users and 2 guests