@@ -58,7 +58,7 @@ uint16_t getTipInstantTemperature() {
|
|||||||
uint16_t getTipRawTemp(uint8_t instant) {
|
uint16_t getTipRawTemp(uint8_t instant) {
|
||||||
#define filterDepth1 1
|
#define filterDepth1 1
|
||||||
/*Pre filter used before PID*/
|
/*Pre filter used before PID*/
|
||||||
#define filterDepth2 16
|
#define filterDepth2 32
|
||||||
/*Post filter used for UI display*/
|
/*Post filter used for UI display*/
|
||||||
static uint16_t filterLayer1[filterDepth1];
|
static uint16_t filterLayer1[filterDepth1];
|
||||||
static uint16_t filterLayer2[filterDepth2];
|
static uint16_t filterLayer2[filterDepth2];
|
||||||
@@ -92,8 +92,14 @@ uint16_t getInputVoltageX10(uint8_t divisor) {
|
|||||||
//Therefore we can divide down from there
|
//Therefore we can divide down from there
|
||||||
//Ideal term is 117
|
//Ideal term is 117
|
||||||
#define BATTFILTERDEPTH 64
|
#define BATTFILTERDEPTH 64
|
||||||
|
static uint8_t preFillneeded = 1;
|
||||||
static uint32_t samples[BATTFILTERDEPTH];
|
static uint32_t samples[BATTFILTERDEPTH];
|
||||||
static uint8_t index = 0;
|
static uint8_t index = 0;
|
||||||
|
if (preFillneeded) {
|
||||||
|
for (uint8_t i = 0; i < BATTFILTERDEPTH; i++)
|
||||||
|
samples[i] = getADC(1);
|
||||||
|
preFillneeded = 0;
|
||||||
|
}
|
||||||
samples[index] = getADC(1);
|
samples[index] = getADC(1);
|
||||||
index = (index + 1) % BATTFILTERDEPTH;
|
index = (index + 1) % BATTFILTERDEPTH;
|
||||||
uint32_t sum = 0;
|
uint32_t sum = 0;
|
||||||
@@ -102,7 +108,8 @@ uint16_t getInputVoltageX10(uint8_t divisor) {
|
|||||||
sum += samples[i];
|
sum += samples[i];
|
||||||
|
|
||||||
sum /= BATTFILTERDEPTH;
|
sum /= BATTFILTERDEPTH;
|
||||||
|
if (sum < 50)
|
||||||
|
preFillneeded = 1;
|
||||||
return sum / divisor;
|
return sum / divisor;
|
||||||
}
|
}
|
||||||
uint8_t getTipPWM() {
|
uint8_t getTipPWM() {
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ int main(void) {
|
|||||||
GUITaskHandle = osThreadCreate(osThread(GUITask), NULL);
|
GUITaskHandle = osThreadCreate(osThread(GUITask), NULL);
|
||||||
|
|
||||||
/* definition and creation of PIDTask */
|
/* definition and creation of PIDTask */
|
||||||
osThreadDef(PIDTask, startPIDTask, osPriorityHigh, 0, 256);
|
osThreadDef(PIDTask, startPIDTask, osPriorityRealtime, 0, 256);
|
||||||
PIDTaskHandle = osThreadCreate(osThread(PIDTask), NULL);
|
PIDTaskHandle = osThreadCreate(osThread(PIDTask), NULL);
|
||||||
|
|
||||||
/* definition and creation of ROTTask */
|
/* definition and creation of ROTTask */
|
||||||
@@ -73,7 +73,7 @@ int main(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
void GUIDelay() {
|
void GUIDelay() {
|
||||||
osDelay(60);
|
osDelay(50);//20Hz
|
||||||
}
|
}
|
||||||
ButtonState getButtonState() {
|
ButtonState getButtonState() {
|
||||||
/*
|
/*
|
||||||
@@ -681,7 +681,7 @@ void startGUITask(void const * argument) {
|
|||||||
lcd.clearScreen(); //Ensure the buffer starts clean
|
lcd.clearScreen(); //Ensure the buffer starts clean
|
||||||
lcd.setCursor(0, 0); //Position the cursor at the 0,0 (top left)
|
lcd.setCursor(0, 0); //Position the cursor at the 0,0 (top left)
|
||||||
lcd.setFont(1); //small font
|
lcd.setFont(1); //small font
|
||||||
lcd.print((char*) "V2.00a5"); //Print version number
|
lcd.print((char*) "V2.00a6"); //Print version number
|
||||||
lcd.setCursor(0, 8); //second line
|
lcd.setCursor(0, 8); //second line
|
||||||
lcd.print(__DATE__); //print the compile date
|
lcd.print(__DATE__); //print the compile date
|
||||||
lcd.refresh();
|
lcd.refresh();
|
||||||
@@ -791,8 +791,8 @@ void startPIDTask(void const * argument) {
|
|||||||
int32_t kp, ki, kd, kb;
|
int32_t kp, ki, kd, kb;
|
||||||
int32_t backoffOverflow = 0;
|
int32_t backoffOverflow = 0;
|
||||||
kp = 20;
|
kp = 20;
|
||||||
ki = 50;
|
ki = 40;
|
||||||
kd = 40;
|
kd = 30;
|
||||||
kb = 0;
|
kb = 0;
|
||||||
const int32_t itermMax = 40;
|
const int32_t itermMax = 40;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
|||||||
Reference in New Issue
Block a user