alfamosk » 01 май 2016, 19:52 
			
			решил я попробовать собрать схему как по ссылке DIY Filament Extruderб смотря схему, не понятно куда подключать экранчик, и в скетче не найду к какому выходу цеплять. кто может подсказать? как я понял в проекте использовался с переходником  iic/i2c .. у меня к сожалению такого пока нет(..  
у меня обычный экранчик с 16тью выходами, lcd1602c. 
код:
/*  Dincer Hepguler 2014
 *  Read preset temperature value from pot at A1
 *  Command a MOSFET controlled heating system with PID algorithm
 *  
 * For Reading a 100K thermistor.
 *============================================================
 *
 * (Gnd) ---- (100k-Resistor) -------|------- (100K-Thermistor) ---- (+5v)
 *                                   |
 *                             Analog Pin 0
 *============================================================
 */
#include <PID_v1.h>
#include <math.h>
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);  // set the LCD address for a 16x2 line display
#define ThermistorPin 0            //Analog Pin thermistor connected   
#define ThresholdPin 1             //Analog pin temp pot connected
#define HeaterPin 9                //digital PWM pin heater connected
double SetPoint, ActualTemp, Output;
//Specify the links and initial tuning parameters
PID myPID(&ActualTemp, &Output, &SetPoint,2,5,1, DIRECT);
//the time we give the sensor to calibrate (10-30 secs according to the datasheet)
int calibrationTime = 10; 
double Thermister(int RawADC) {
 double Temp;
 Temp = log(((10240000/RawADC) - 10000));
 Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );
 Temp = Temp - 273.15;            // Convert Kelvin to Celcius
 //Temp = (Temp * 9.0)/ 5.0 + 32.0; // Convert Celcius to Fahrenheit
 return Temp;
}
void setup() {
  pinMode(ThresholdPin, INPUT);
  pinMode(HeaterPin, OUTPUT);
  Serial.begin(57600);
  lcd.init();   // initialize the lcd
  lcd.backlight();
  lcd.clear();
  //give the sensor some time to calibrate
  Serial.print("calibrating sensor ");
  lcd.setCursor(0,0);
  lcd.print("calibrating....");
    for(int i = 0; i < calibrationTime; i++){
      Serial.print(".");
      delay(1000);
      }
    Serial.println(" done");
    Serial.println("SENSOR ACTIVE");
    delay(50);
  SetPoint = map(analogRead(ThresholdPin),0,1023,0,300);
  ActualTemp = double(Thermister(analogRead(ThermistorPin)));  
  
  lcd.clear();
  lcd.setCursor(0,0); //Start at character 0 on line 0
  lcd.print("THRESHOLD  TEMP ");
  lcd.setCursor(3,1);
  lcd.print(SetPoint);
  
  //turn the PID on
  myPID.SetMode(AUTOMATIC);
}
void loop() {
  SetPoint = map(analogRead(ThresholdPin),0,1023,0,300);
  ActualTemp = double(Thermister(analogRead(ThermistorPin)));
  myPID.Compute();
  analogWrite(HeaterPin,Output);
  // Print a message to the LCD.
  lcd.backlight();
  lcd.setCursor(11,1);
  lcd.print(ActualTemp); 
  lcd.setCursor(3,1);
  lcd.print("     ");
  lcd.setCursor(3,1);
  lcd.print(SetPoint);
  
  Serial.print(SetPoint);  Serial.print("     ");
  Serial.println(ActualTemp);  // display 
  delay(100);