Coder Social home page Coder Social logo

piln's Introduction

This project is based on code from pvarney/PiLN

Electricity and heat are dangerous! Evaluate the risk and make go no go decision!

Most kiln manufactures state "Do Not Fire Unattended". Commercial controllers deal with many fault modes that this controller does not address. Intermittent thermocouple connections, stuck relay, shorted element and weak elements, these faults have all happened to me and the control just keeps say "kiln thinks kiln can, kiln thinks kiln can". I had to intervene. Stuck relay and bad thermocouple readings are run away condition that could become meltdown/fire/death. "DO NOT FIRE UNATTENDED!"

Web-based Raspberry Pi Kiln Control:

  • achieved my goal to run on Rasberry Pi Zero W, but I am currently firing on a Raspberry Pi 3b:

    • sqlite3 database for firing profiles and logging (small memory footprint)
    • lighttpd web server (small memory footprint)
  • kiln sitter(KS) as a sensor

    • KS functions as 'ARMED', can not start firing without kilnsitter being armed
    • set profile top temp higher than KS cone, KS is intended trigger, thermocouple is safety

Future improvements:

  • performance watchdog:
    • warning notifications, klexting;
    • shutdown when a minimum rate cannot be maintained,
  • inductive current sensors: element fault indication;
  • crash/loss of power recovery:
    • PI comes up, KS is armed & profile is 'Running' then how to consider unfinished segment
    • compare temp at the timestamp to current temp
    • compare last timestamp of 'Running' firing to current time
    • notify on power resume, klexting (kiln text message)

Hardware:

Thermocouple tip: One side of the type-K thermocouple and type-k wire is magnetic(red side), Test with magnet to wire correctly.

  • Current kiln controller is attached to is a Old Skutt 281, which is a previous model number of KS1027:
    • old elements, I am surprised that it easily reaches temp at a reasonable rate, this kiln sat unused, outside under roof for 15 years;
    • lid(split and flaking)repaired/coated;
    • base(cracks) repaired;
    • rust removal on controller boxes, painted;
    • built rolling stand out of 2"x3" mild steel rectangular tube;

Stuff to get it to work:

  • Pin-Out:

      RPLCD:  	GPIO 2 SDA
      RPLCD:  	GPIO 3 SCL
      RPLCD:  	5V
      RPLCD:  	GND
      MAX31856 Vcc:	3.3V    PIN17
      MAX31856 GND:	GND     PIN14
      MAX31856 SDO:	GPIO 9
      MAX31856 SDI:	GPIO 10
      MAX31856 CS:	GPIO 8 & GPIO 7
      MAX31856 SCK:	GPIO 11
      unl2003a 1:	GPIO 22 
      unl2003a 3:	GPIO 23
      unl2003a 5:	GPIO 24
      unl2003a 7:	GPIO 13
      unl2003a 8:	GND
      unl2003a 9:	12V
      unl2003a 10:	FAN black/gnd
      unl2003a 16:	relay #1 coil (input is across the chip on pin1)
      unl2003a 14:	relay #2 coil (input is pin3)
      unl2003a 12:	relay #3 coil (input is pin5)
      12V:    	relay 1,2,3 coils and FAN red/+
    
  • Install PiLN files in /home and create log directory:

      su - pi
      git clone [email protected]:BlakeCLewis/PiLN.git
      mkdir ./log ./db ./html ./html/images ./html/style
    
  • Install sqlite3:

      sudo apt-get install sqlite3
    
  • Set up directories/link for web page:

      ln -s /home/pi/PiLN/images/hdrback.png /home/pi/html/images/hdrback.png
      ln -s /home/pi/PiLN/images/piln.png    /home/pi/html/images/piln.png
      ln -s /home/pi/PiLN/style/style.css    /home/pi/html/style/style.css
    
  • lighttpd:

      sudo apt-get install lighttpd
      sudo cp lighttpd.conf /etc/lighttpd/
      cd /etc/lighttpd/conf-enabled
      sudo ln -s ../conf-available/10-cgi.conf .
      sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
      sudo iptables save
      cd 
      chown www-data:www-data PiLN/html/pilnstat.json
    
  • Install required Python packages:

      sudo raspi-config #enable interfaces ic2 & spi
      lsmod | grep spi
    
  • Instal RPLCD for the 20x4 lcd: sudo pip install RPLCD sudo apt install python-smbus

  • Install John Robison's Adafruit Pyhton MAX31856 library:

      cd
      git clone https://github.com/johnrbnsn/Adafruit_Python_MAX31856
      cd Adafruit_Python_MAX31856
      sudo python setup.py install
    
  • create the sqlite3 database:

              sudo chown -R www-data:www-data /home/pi/PiLN/db
      sqlite3 /home/pi/db/PiLN.sqlite3
      sqlite> .read /home/pi/PiLN/docs/PiLN.sql;
    
  • Tuning:

    • Skutt KS1027 with old elements:

        Kc:   6.0
        Kp:   3.0
        Ki:   0.4
        Kd:  13.0
        Time internal:  30 seconds
      
  • Using the Web App:

      On the same network that the RPi is connected, http://<RPi_IPAddress>/pilnapp/home.cgi
      Or, on the controller RPi, http://localhost/pilnapp/home.cgi
    
  • Start the firing daemon:

      python3 /home/pi/PiLN/daemon/pilnfired.py
    
  • PID with C algorithm:

    My implementation of a PID algorithm that is optimized for a system that can only add heat;
    
    Kc is not determined by a time sensitive value;
    Ki is not time sensitive;
    Kp & Kd are determined by an amount of error over a time segment 
        these terms should be normalized by the time segment like (term*60/window)
    
    Cterm = Kc/100 * (Current_temp - room_temp);
    Window = determined by bump test, mine is 30 seconds
    error = Setpoint - Currrent_temp;
    Pterm = Kp * 60/Window * error;
    Iterm = Summation (Ki * error), constrained by (Imin <= Iterm <= Imax);
    Dterm = Kd * 60/Window * (error - previous_error);
    output = (Cterm + Pterm + Iterm + Dterm) constrained by (0 <= output <= 100);
    
    Window:
        Size of the base time unit, the controller will decide what to do every window;
        based on the response time of the kiln (how long it takes to finish reacting to input);
        my kiln window = 30;
        bump test
    
            turning on kiln for 30 seconds
            record time/temp every 10 seconds until temp starts falling
            tau_temp = .75 * (hi_temp - start_temp)
            window = .25 * (time of tau_temp)
    
    Cterm:
    
        Kc = 6;
        steady state term, required amount of energy to maintain temp;
        linear, inverse proportional to r-value of kiln;
        my kiln requires about 6% of output per 100C of temp differential;
        (100C ~= 6% to hold temp, 1000C ~= 60% to hold temp);
        tune:
            after determining "window", do a Bisque cone 06 to ~1000C, with a 10 minute hold every 100C;
            query the database to average output during the holds;
            mine was about 6% per 100C.
    
    Pterm:
    
        Kp = 3;
        proportional to desired change in temp;
        TODO - test runs with rate 60 and 166 C/hr, query the database and average(pid_output-Pterm) for each 100C segment.
    
    Iterm:
        
        Ki = 0.4;
        Imin = -25;
        Imax = 25;
        Imax and Imin are hard coded, may need to make tunable or auto-adjusted based on temp and/or temp climb rate;
        accumlitive error correction of Cterm + Pterm;
        to reduce "Iterm Windup", limit with (Imin <= Iterm <+ Imax).
    
    Dterm:
    
        Kd = 13;
        change in error;
        Dterm is the acceleration term.
        it allows time for Iterm to wind up or down, to keep from falling behind or over shooting.
    
    output:
    
        output = (Cterm + Pterm + Iterm + Dterm);
        output is a percentage and therefore needs to be constrained by (0 <= output <= 100)
    

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.