-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
879f28e
commit f40dc22
Showing
21 changed files
with
10,051 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
校准温度曲线的方法 | ||
1.准备好能测量0 - 500摄氏度的设备,探头建议使用裸装,以免外壳热传导导致热量损失测量不准 | ||
2.将探头紧压住烙铁头发热前段(上锡部分再下来一点),一定要紧紧压住,不然也会测量不准 | ||
3.放置好烙铁头以免校准时烫伤手或物品! | ||
4.接上电源,从控制板进入‘校准’界面,将空心选框移动至第1段温度处(即对应的ADC 10下面) | ||
5.按下确认键,此时空心选框变成实心选框,烙铁头开始加热,等待最下方的‘Now ADC’值稳定在一定的范围,与第一行相应的ADC值差不多即可(此时是ADC 10) | ||
6.使用测量设备测量烙铁头的温度,将第1段温度调至测量得到的温度(实心选框状态可旋转旋钮调节数值) | ||
7.依次测量剩下的第2段、第3段、第4段温度并输入至控制器 | ||
8.测量完4段温度后将光标移至Save,按下确认键,等待程序计时温度曲线 | ||
9.计算完会显示P系数界面,,再按下确认键即可退出校准界面 | ||
10.在主界面准备进行二次校准 | ||
11.在主界面开启加热至第二段校准的温度,如265,则加热至260度,若显示温度比实际高的话就到校准界面调高第二段温度,低则调低 | ||
12.依次加热至第三第四段温度并校准,直至自己满意为止 | ||
13.进入到“烙铁”选项,将冷端补偿温度改为此时主界面所显示的环境温度值(屏幕右上角),完毕。 | ||
*/ | ||
|
||
/* | ||
长按操作(5下短音最后1下长音) | ||
主界面,进入设置界面 | ||
其他界面,退出至主界面 | ||
双击操作(2下短音) | ||
主界面,加热或停止状态切换 | ||
其他界面,无 | ||
单击(1下短音) | ||
主界面,无 | ||
设置界面,进入二级菜单 | ||
二级菜单,切换数值更改选中状态,或确认更改数值,无选框状态则退出至一级菜单 | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
//********** 控制蜂鸣器发声的频率和时间,系统延时法,占用系统速度大 ********** | ||
uint32_t error_buzzer_db_time = 0; | ||
void buzzer_run() | ||
{ | ||
if (buzzer_state == 1) | ||
{ | ||
for (uint16_t i = 0; i < buzzer_count; i++) | ||
{ | ||
digitalWrite(buzzer_pin, 1); | ||
delayMicroseconds(buzzer_time); | ||
digitalWrite(buzzer_pin, 0); | ||
if (i < buzzer_count - 1) delayMicroseconds(buzzer_time); //最后一次不需要延时 | ||
} | ||
buzzer_state = 0; | ||
} | ||
//错误提示报警音 | ||
if (vin_error == 1 || t12_adc_error == 1) | ||
{ | ||
if (millis() - error_buzzer_db_time > 1000) | ||
{ | ||
buzzer(120, 300); | ||
error_buzzer_db_time = millis(); | ||
} | ||
} | ||
|
||
if (buzzer_szjm_state == 1) //进入设置界面时发出声音提示一下 | ||
{ | ||
buzzer(150, 720); | ||
buzzer_szjm_state = 0; | ||
} | ||
else if (buzzer_zjm_state == 1) //退出至主界面时发出声音提示一下 | ||
{ | ||
buzzer(150, 720); | ||
buzzer_zjm_state = 0; | ||
} | ||
} | ||
|
||
void buzzer(uint16_t time, uint16_t count) | ||
{ | ||
buzzer_state = 1; //准备好蜂鸣器 | ||
buzzer_time = time; //设置时间 | ||
buzzer_count = count; //设置次数 | ||
} | ||
//********************************************************* | ||
|
||
//****** 控制蜂鸣器发声的频率和时间,内部中断法,占用系统速度小 ****** | ||
|
||
/*void buzzer(uint16_t time, uint16_t count) //时间单位ms | ||
{ | ||
if (buzzer_state == 0 && digitalRead(buzzer_pin) == 0) //蜂鸣器停止状态才能设置定时器 | ||
{ | ||
buzzer_count = count; //设置次数 | ||
Timer1.initialize(time); //设置时间 | ||
Timer1.attachInterrupt(buzzer_isr); //设置定时器中断函数 | ||
Timer1.start(); //启动定时器 | ||
} | ||
} | ||
void buzzer_isr() | ||
{ | ||
buzzer_isr_count++; | ||
bitWrite(PINB, 0, 1); //设置pin8为输出 PINX写1翻转状态 | ||
buzzer_state = 1; //标识蜂鸣器正在工作 | ||
if (buzzer_isr_count >= buzzer_count) | ||
{ | ||
buzzer_isr_count = 0; // 清除计数 | ||
buzzer_state = 0; //标识蜂鸣器已停止 | ||
digitalWrite(buzzer_pin, 0); //关闭蜂鸣器 | ||
Timer1.stop(); //停止中断 | ||
} | ||
}*/ | ||
//********************************************************* | ||
uint8_t get_num_digit(uint32_t num)//获取数字的位数 | ||
{ | ||
uint8_t count = 0; | ||
if (num == 0) count = 1; | ||
while (num != 0) | ||
{ | ||
// n = n/10 | ||
num /= 10; | ||
++count; | ||
} | ||
return count; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
//********** 曲线拟合程序 ********** | ||
//曲线拟合算法来至https://blog.csdn.net/m0_37362454/article/details/82456616 by欧阳小俊 | ||
void qxnh_run() //曲线拟合运行 | ||
{ | ||
int16_t i, sizenum; | ||
float P[4]; | ||
int8_t dimension = 3; //3次多项式拟合 | ||
// 要拟合的数据 | ||
int xx[] = {sz_adc0, sz_adc1, sz_adc2, sz_adc3}; //t12 adc | ||
//int yy[] = {45, 219, 366, 435}; //测量设备的温度 | ||
|
||
sizenum = sizeof(xx) / sizeof(xx[0]); //拟合数据的维数 | ||
polyfit(sizenum, xx, sz_temp, dimension, P); | ||
|
||
sz_p[0] = P[0]; | ||
sz_p[1] = P[1]; | ||
sz_p[2] = P[2]; | ||
sz_p[3] = P[3]; | ||
/* | ||
得出系数:P[0],P[1],P[2] | ||
曲线公式:y = P[3]*X*X*X+P[2]*X*X + P[1]*X + P[0] | ||
曲线公式:t12_temp =P[3]* t12_ad * t12_ad* t12_ad + P[2] * t12_ad * t12_ad + P[1] * t12_ad + P[0]; | ||
*/ | ||
} | ||
|
||
/*==================polyfit(n,x,y,poly_n,a)===================*/ | ||
/*=======拟合y=a0+a1*x+a2*x^2+……+apoly_n*x^poly_n========*/ | ||
/*=====n是数据个数 xy是数据值 poly_n是多项式的项数======*/ | ||
/*===返回a0,a1,a2,……a[poly_n],系数比项数多一(常数项)=====*/ | ||
void polyfit(int n, int x[], int y[], int poly_n, float p[]) | ||
{ | ||
int i, j; | ||
float *tempx, *tempy, *sumxx, *sumxy, *ata; | ||
|
||
tempx = (float *)calloc(n , sizeof(float)); | ||
sumxx = (float *)calloc((poly_n * 2 + 1) , sizeof(float)); | ||
tempy = (float *)calloc(n , sizeof(float)); | ||
sumxy = (float *)calloc((poly_n + 1) , sizeof(float)); | ||
ata = (float *)calloc( (poly_n + 1) * (poly_n + 1) , sizeof(float) ); | ||
for (i = 0; i < n; i++) | ||
{ | ||
tempx[i] = 1; | ||
tempy[i] = y[i]; | ||
} | ||
for (i = 0; i < 2 * poly_n + 1; i++) | ||
{ | ||
for (sumxx[i] = 0, j = 0; j < n; j++) | ||
{ | ||
sumxx[i] += tempx[j]; | ||
tempx[j] *= x[j]; | ||
} | ||
} | ||
for (i = 0; i < poly_n + 1; i++) | ||
{ | ||
for (sumxy[i] = 0, j = 0; j < n; j++) | ||
{ | ||
sumxy[i] += tempy[j]; | ||
tempy[j] *= x[j]; | ||
} | ||
} | ||
for (i = 0; i < poly_n + 1; i++) | ||
{ | ||
for (j = 0; j < poly_n + 1; j++) | ||
{ | ||
ata[i * (poly_n + 1) + j] = sumxx[i + j]; | ||
} | ||
} | ||
gauss_solve(poly_n + 1, ata, p, sumxy); | ||
|
||
free(tempx); | ||
free(sumxx); | ||
free(tempy); | ||
free(sumxy); | ||
free(ata); | ||
} | ||
/*============================================================ | ||
高斯消元法计算得到 n 次多项式的系数 | ||
n: 系数的个数 | ||
ata: 线性矩阵 | ||
sumxy: 线性方程组的Y值 | ||
p: 返回拟合的结果 | ||
============================================================*/ | ||
void gauss_solve(int n, float A[], float x[], float b[]) | ||
{ | ||
int i, j, k, r; | ||
float max; | ||
for (k = 0; k < n - 1; k++) | ||
{ | ||
max = fabs(A[k * n + k]); // find maxmum | ||
r = k; | ||
for (i = k + 1; i < n - 1; i++) | ||
{ | ||
if (max < fabs(A[i * n + i])) | ||
{ | ||
max = fabs(A[i * n + i]); | ||
r = i; | ||
} | ||
} | ||
if (r != k) | ||
{ | ||
for (i = 0; i < n; i++) //change array:A[k]&A[r] | ||
{ | ||
max = A[k * n + i]; | ||
A[k * n + i] = A[r * n + i]; | ||
A[r * n + i] = max; | ||
} | ||
max = b[k]; //change array:b[k]&b[r] | ||
b[k] = b[r]; | ||
b[r] = max; | ||
} | ||
|
||
for (i = k + 1; i < n; i++) | ||
{ | ||
for (j = k + 1; j < n; j++) | ||
A[i * n + j] -= A[i * n + k] * A[k * n + j] / A[k * n + k]; | ||
b[i] -= A[i * n + k] * b[k] / A[k * n + k]; | ||
} | ||
} | ||
|
||
for (i = n - 1; i >= 0; x[i] /= A[i * n + i], i--) | ||
{ | ||
for (j = i + 1, x[i] = b[i]; j < n; j++) | ||
x[i] -= A[i * n + j] * x[j]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
//********** 显示决策 ********** | ||
uint32_t system_sleep_db_time = 0; //系统进入睡眠对比时间 | ||
void display() | ||
{ | ||
if (xp_state == 0) //正常显示 | ||
{ | ||
if (display_count == ZJM) zjm(); | ||
else if (display_count == SZJM) szjm(); | ||
else if (display_count == SZJM_PID) szjm_pid(); | ||
else if (display_count == SZJM_SLEEP) szjm_sleep(); | ||
else if (display_count == SZJM_OLED) szjm_oled(); | ||
else if (display_count == SZJM_POWER) szjm_power(); | ||
else if (display_count == SZJM_LAOTIE) szjm_laotie(); | ||
else if (display_count == SZJM_JIAOZHUN) szjm_jiaozhun(); | ||
} | ||
else xpjm(); //显示息屏界面 | ||
} | ||
|
||
void draw_page(void) | ||
{ | ||
static uint8_t is_next_page = 0; | ||
// 调用第一页,如果需要 | ||
if ( is_next_page == 0 ) | ||
{ | ||
u8g2.firstPage(); | ||
is_next_page = 1; | ||
} | ||
// 画我们的屏幕 | ||
display(); | ||
// 调用下一页 | ||
if ( u8g2.nextPage() == 0 ) | ||
{ | ||
is_next_page = 0; // 确保调用了第一个页面 | ||
} | ||
} | ||
|
||
void display_hfccsz() //恢复出厂设置进度显示界面 | ||
{ | ||
uint16_t x_old = 0; | ||
for (int i = 0 ; i < EEPROM.length() ; i++) | ||
{ | ||
__asm__ __volatile__ ("wdr"); //防止没清除完因看门狗没喂狗导致重启 | ||
uint16_t x_new = map(i, 0, EEPROM.length(), 0, 100); | ||
if (x_new - x_old >= 5) | ||
{ | ||
u8g2.firstPage(); | ||
do { | ||
u8g2.setCursor(50, 16); | ||
u8g2.print(x_new); | ||
u8g2.setCursor(75, 16); | ||
u8g2.print("%"); | ||
x_old = x_new; | ||
} while ( u8g2.nextPage() ); | ||
} | ||
EEPROM.write(i, 0); //清除所有EEPROM | ||
} | ||
set_wdt_mod(1, 0); //利用看门狗实现软重启 | ||
} | ||
|
||
void kj_display() //开机显示版本号 | ||
{ | ||
u8g2.firstPage(); | ||
do { | ||
u8g2.setFont(chinese15); | ||
u8g2.setCursor(50, 21); | ||
u8g2.print(version); | ||
} while ( u8g2.nextPage() ); | ||
} | ||
|
||
void xpjm() //息屏界面 | ||
{ | ||
if (xp_x - xp_x_old > 0) | ||
{ | ||
if (xp_x_old != xp_x) xp_x_old++; | ||
} | ||
else if (xp_x - xp_x_old < 0 ) | ||
{ | ||
if (xp_x_old != xp_x) xp_x_old--; | ||
} | ||
|
||
if (xp_y - xp_y_old > 0) | ||
{ | ||
if (xp_y_old != xp_y) xp_y_old++; | ||
} | ||
else if (xp_y - xp_y_old < 0 ) | ||
{ | ||
if (xp_y_old != xp_y) xp_y_old--; | ||
} | ||
|
||
u8g2.setFont(chinese15); | ||
u8g2.setCursor(xp_x_old, xp_y_old); | ||
u8g2.print(tc1047_temp, 1); | ||
u8g2.setCursor(xp_x_old + 27, xp_y_old - 1); | ||
u8g2.print("℃"); | ||
} | ||
|
||
/*u8g2.firstPage(); | ||
do { | ||
u8g2.setFont(chinese15); | ||
u8g2.setCursor(xp_x, xp_y); | ||
u8g2.print(tc1047_temp, 1); | ||
u8g2.setCursor(xp_x + 27, xp_y - 1); | ||
u8g2.print("℃"); | ||
} while ( u8g2.nextPage() );*/ |
Oops, something went wrong.