aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBen V. Brown <[email protected]>2017-07-07 23:22:11 +1000
committerBen V. Brown <[email protected]>2017-07-07 23:22:20 +1000
commit7b4f467eec819d2ff9d8ae1424c16d9cf1a94e97 (patch)
treef49ae3a886f909f486c58ab011bba565246b418f
parentf72fc364278b0566dd09e0c24be046ee3c305098 (diff)
downloadIronOS-1.10.1.tar.gz
IronOS-1.10.1.zip
Increase pre PID filtering, reducing display flicker1.10.1
Also improve movement sensitivities to be less extreme ramp up
-rw-r--r--workspace/ts100/inc/Settings.h4
-rw-r--r--workspace/ts100/src/Analog.c12
-rw-r--r--workspace/ts100/src/MMA8652FC.c15
-rw-r--r--workspace/ts100/src/Main.c2
-rw-r--r--workspace/ts100/src/Modes.c32
-rw-r--r--workspace/ts100/src/PID.c10
6 files changed, 51 insertions, 24 deletions
diff --git a/workspace/ts100/inc/Settings.h b/workspace/ts100/inc/Settings.h
index f6ceae8b..d3e01d34 100644
--- a/workspace/ts100/inc/Settings.h
+++ b/workspace/ts100/inc/Settings.h
@@ -14,8 +14,8 @@
#define SETTINGSVERSION 0x08 /*Change this if you change the struct below to prevent people getting out of sync*/
//Motion Sensitivity
#define MOTION_HIGH (0x00)
-#define MOTION_MED (0x10)
-#define MOTION_LOW (0x20)
+#define MOTION_MED (0x01)
+#define MOTION_LOW (0x02)
//Display Speeds
#define DISPLAYMODE_FAST (0x00)
#define DISPLAYMODE_MEDIUM (0x01)
diff --git a/workspace/ts100/src/Analog.c b/workspace/ts100/src/Analog.c
index fcc99b51..9f6e8996 100644
--- a/workspace/ts100/src/Analog.c
+++ b/workspace/ts100/src/Analog.c
@@ -23,7 +23,7 @@ uint16_t readDCVoltage(uint16_t divFactor) {
//This allows us to read it in X10 mode
//Returns temperature in C X10 mode
int16_t readTipTemp() {
- static uint32_t rollingAverage[4];
+ static uint32_t rollingAverage[16];
static uint8_t rIndex = 0;
/*The head has a thermocouple inline with the heater
@@ -54,9 +54,13 @@ int16_t readTipTemp() {
ad_sum = ad_sum - max - min; //remove the two outliers
avg_data = ad_sum / 8; //take the average
rollingAverage[rIndex] = avg_data;
- rIndex = (rIndex + 1) % 4;
+ rIndex = (rIndex + 1) % 16;
return (rollingAverage[0] + rollingAverage[1] + rollingAverage[2]
- + rollingAverage[3]) / 4; //get the average
+ + rollingAverage[3] + rollingAverage[4] + rollingAverage[5]
+ + rollingAverage[6] + rollingAverage[7] + rollingAverage[8]
+ + rollingAverage[9] + rollingAverage[10] + rollingAverage[11]
+ + rollingAverage[12] + rollingAverage[13] + rollingAverage[14]
+ + rollingAverage[15]) / 16; //get the average
}
@@ -110,7 +114,7 @@ uint16_t readIronTemp(uint16_t calibration_temp, uint8_t read,
static uint16_t calTemp = 0;
static uint16_t lastVal = 0;
static uint16_t lastSetTemp;
- if(setPointTemp!=0xFFFF)
+ if (setPointTemp != 0xFFFF)
lastSetTemp = setPointTemp;
if (calibration_temp != 0)
calTemp = calibration_temp;
diff --git a/workspace/ts100/src/MMA8652FC.c b/workspace/ts100/src/MMA8652FC.c
index e6df4ab0..43876421 100644
--- a/workspace/ts100/src/MMA8652FC.c
+++ b/workspace/ts100/src/MMA8652FC.c
@@ -34,7 +34,20 @@ void StartUp_Accelerometer(uint8_t sensitivity) {
I2C_RegisterWrite( CTRL_REG2, 0x40); // Reset all registers to POR values
delayMs(2); // ~1ms delay
I2C_RegisterWrite(FF_MT_CFG_REG, 0x78); // Enable motion detection for X and Y axis, latch enabled
- I2C_RegisterWrite(FF_MT_THS_REG, sensitivity|0x0F); // Set threshold
+ uint8_t sens =0x0F;
+ switch(sensitivity)
+ {
+ case 0:
+ sens=0x1A;
+ break;
+ case 1:
+ sens=0x20;
+ break;
+ case 2:
+ sens=0x2A;
+ break;
+ }
+ I2C_RegisterWrite(FF_MT_THS_REG, sens); // Set threshold
I2C_RegisterWrite(FF_MT_COUNT_REG, 0x01); // Set debounce to 100ms
I2C_RegisterWrite( CTRL_REG4, 0x04); // Enable motion interrupt
diff --git a/workspace/ts100/src/Main.c b/workspace/ts100/src/Main.c
index 8a287f15..9ac59b9a 100644
--- a/workspace/ts100/src/Main.c
+++ b/workspace/ts100/src/Main.c
@@ -38,6 +38,6 @@ void setup() {
Init_Oled(systemSettings.flipDisplay); //Init the OLED display
OLED_DrawString("VER 1.10", 8); //Version Number
- delayMs(800); //Pause to show version number
+ delayMs(500); //Pause to show version number
Start_Watchdog(1000); //start the system watch dog as 1 second timeout
}
diff --git a/workspace/ts100/src/Modes.c b/workspace/ts100/src/Modes.c
index 73691d3c..e98e9e67 100644
--- a/workspace/ts100/src/Modes.c
+++ b/workspace/ts100/src/Modes.c
@@ -5,14 +5,14 @@
* Author: Ralim <[email protected]>
*/
#include "Modes.h"
-const char *SettingsLongNames[] = { " Undervoltage Cutout",
- " Sleep Temperature", " Sleep Timeout",
- " Shutdown Timeout", " Motion Detection",
+const char *SettingsLongNames[] = { " Undervoltage Cutout (V)",
+ " Sleep Temperature (C)", " Sleep Timeout (Minutes)",
+ " Shutdown Timeout (Minutes)", " Motion Detection",
" Motion Sensitivity", " Temperature Unit",
" Temperature Rounding Amount",
" Temperature Display Update Rate",
" Flip Display for Left Hand" };
-const uint8_t SettingsLongNamesLengths[] = { 25, 23, 19, 22, 22, 24, 22, 33, 37,
+const uint8_t SettingsLongNamesLengths[] = { 29, 27, 29, 32, 22, 24, 22, 33, 37,
25 };
uint8_t CalStatus = 0;
//This does the required processing and state changes
@@ -141,9 +141,8 @@ void ProcessUI() {
systemSettings.flipDisplay = !systemSettings.flipDisplay;
break;
case MOTIONSENSITIVITY:
- systemSettings.sensitivity += 0x10;
- if (systemSettings.sensitivity > 0x20)
- systemSettings.sensitivity = 0; //reset to high on wrap
+ systemSettings.sensitivity++;
+ systemSettings.sensitivity = systemSettings.sensitivity % 3;
break;
case TEMPROUNDING:
@@ -320,6 +319,9 @@ void drawTemp(uint16_t temp, uint8_t x, uint8_t roundingMode) {
*/
void DrawUI() {
static uint32_t lastOLEDDrawTime = 0;
+ static uint16_t lastSolderingDrawnTemp1 = 0;
+ static uint16_t lastSolderingDrawnTemp2 = 0;
+
static uint8_t settingsLongTestScrollPos = 0;
uint16_t temp = readIronTemp(0, 0, 0xFFFF);
switch (operatingMode) {
@@ -348,17 +350,24 @@ void DrawUI() {
&& (millis() - lastOLEDDrawTime < 50))
return;
- drawTemp(temp, 0, systemSettings.temperatureRounding);
-
+ uint32_t tempavg = (temp + lastSolderingDrawnTemp1
+ + lastSolderingDrawnTemp2);
+ tempavg /= 3;
+ drawTemp(tempavg, 0, systemSettings.temperatureRounding);
+ lastSolderingDrawnTemp1 = temp;
+ lastSolderingDrawnTemp2 = lastSolderingDrawnTemp1;
lastOLEDDrawTime = millis();
//Now draw symbols
OLED_DrawChar(' ', 3);
OLED_BlankSlot(6 * 12 + 16, 24 - 16);//blank out the tail after the arrows
OLED_BlankSlot(4 * 12 + 16, 24 - 16);//blank out the tail after the temp
- if (getIronTimer() == 0) {
+ if (getIronTimer() == 0
+ && (temp / 10) > (systemSettings.SolderingTemp / 10)) {
+ //Cooling
OLED_DrawSymbol(6, 5);
} else {
- if (getIronTimer() < 1000) {
+ if (getIronTimer() < 1500) {
+ //Maintaining
OLED_DrawSymbol(6, 7);
} else { //we are heating
OLED_DrawSymbol(6, 6);
@@ -507,6 +516,7 @@ void DrawUI() {
//Draw in temp and sleep
OLED_DrawString("SLP", 3);
drawTemp(temp, 4, systemSettings.temperatureRounding);
+ OLED_BlankSlot(84, 96 - 85); //blank out after the temp
if (millis() - getLastMovement() > (10 * 60 * 1000)
&& (millis() - getLastButtonPress() > (10 * 60 * 1000))) {
diff --git a/workspace/ts100/src/PID.c b/workspace/ts100/src/PID.c
index fb63a8b0..97601d3a 100644
--- a/workspace/ts100/src/PID.c
+++ b/workspace/ts100/src/PID.c
@@ -15,8 +15,8 @@ int32_t computePID(uint16_t setpoint) {
uint16_t currentReading = readIronTemp(0, 1,setpoint); //get the current temp of the iron
int16_t error = (int16_t) setpoint - (int16_t) currentReading; //calculate the error term
ITerm += (pidSettings.ki * error);
- if (ITerm > MAXPIDOUTPUT)
- ITerm = MAXPIDOUTPUT;
+ if (ITerm > MAXPIDOUTPUT/2)
+ ITerm = MAXPIDOUTPUT/2;
else if (ITerm < 0)
ITerm = 0; //cap at 0 since we cant force the iron to cool itself :)
@@ -34,8 +34,8 @@ int32_t computePID(uint16_t setpoint) {
}
/*Sets up the pid values*/
void setupPID(void) {
- pidSettings.kp = 25;
- pidSettings.ki = 7;
- pidSettings.kd = 2;
+ pidSettings.kp = 15;
+ pidSettings.ki = 2;
+ pidSettings.kd = 3;
}