Skip to content

How to customize source before uploading

Shingo Hisakawa edited this page May 2, 2020 · 2 revisions

Customization

To customize for your hardware, modify arduino/NinjaLAMP_Arduino/NinjaLAMP_Arduino.ino

Target temperature

#define TARGET_TEMP 63

Pinouts

const int WELL_HEATER_PWM = 15;
const int WELL_THERMISTOR_AIN = A0;
const int AIR_THERMISTOR_AIN = A1;

Thermistors & resistors

Some thermistors have multiple pairs of B constants and temperature ranges. For such types of thermistors, you can define ranges as arrays of ThermistorRange struct.

/* Well */
struct ThermistorRange wellThermistorRanges[3] = {
  { 0.0, 4250, 0.0, }, /* 4250 for 0-50 deg */
  { 50.0, 4311, 0.0, }, /* 4311 for 50-85 deg */
  { 85.0, 4334, 0.0, } /* 4334 for 85-100 deg */
};
Thermistor wellThermistor = { 
  .bConstRangeCount = 3, /* Number of B-constant ranges */
  .bConstRanges = wellThermistorRanges, /* Pointer to the B-constant ranges array */
  .r0 = 100.0, /* Resistance at "baseTemp" (kOhm) */
  .baseTemp = 25.0,
  .place = THERMISTOR_LOW_SIDE,
  .useSwitching = false,
  .r = 47.0 /* kOhm */
};
/* Air */
struct ThermistorRange airThermistorRanges[3] = {
  { 0.0, 4250, 0.0, }, /* 4250 for 0-50 deg */
  { 50.0, 4311, 0.0, }, /* 4311 for 50-85 deg */
  { 85.0, 4334, 0.0, } /* 4334 for 85-100 deg */
};
Thermistor airThermistor = { 
  .bConstRangeCount = 3, /* Number of B-constant ranges */
  .bConstRanges = airThermistorRanges,  /* Pointer to the B-constant ranges array */
  .r0 = 100.0, /* Resistance at "baseTemp" (kOhm) */
  .baseTemp = 25.0,
  .place = THERMISTOR_LOW_SIDE,
  .useSwitching = false,
  .r = 47.0 /* kOhm */
};
  • bConstantRangeCount : Numbers of B-constant ranges
  • bConstantRanges : Pointer to B-constant ranges (Array of ThermistorRange)
  • r0 : Resistance value at "baseTemp"
  • baseTemp
  • place : Position of the thermistor (See below)
  • useSwitching : For advanced functionalities of switching resistors
  • r : Value of the counter resistor (unit:kOhm)

Please specify "place" value according to the position of the thermistor.

THERMISTOR_HIGH_SIDE

High Side

THERMISTOR_LOW_SIDE

Low Side

The example above stands for the hardware composition below:

High Side

Thermistors (Well & Air)

Resistance (25℃)(ohm) B-const(25-50℃) B-const(25-80℃) B-const(25-100℃)
100k ± 1% 4250 4311 4334

PID constants

NinjaLAMP keeps its temperature by PID control. PID controller needs 3 constants for proportional, integral and derivative factors. If the temperature often exceeds the target or you find the graph is wavy, please modify the PID constants.

https://en.wikipedia.org/wiki/PID_controller#Loop_tuning

Note that reducing overshoots is more important than heating faster because it takes long time to cool the well after it gets too hot.

#define WELL_KP (0.11)
#define WELL_KI (0.5)
#define WELL_KD (2.0)