引腳對應 avr arduino
加熱器1 PB4 10 只能使用PB_XX端口
加熱器2 PH5 8 只能使用PH_XX端口, 詳細見TIMER.h #define
熱電偶MAX6675 硬件spi
CS PB0 53 詳細見SPIMAX6675.h,只能使用PB_XX端口
SCk PB1 52 不要改
S0 PB3(MISO) 50 不要改
加熱棒 12v 40W (3d打印機噴頭)
PID的3個參數(shù)如果加熱器相同基本不需要修改,我的參數(shù),謙虛的說只能保持+-3度左右的一個誤差,細心的網(wǎng)友可以繼續(xù)調(diào)一調(diào)。
程序多使用寄存器操作,具體詳見手冊。使用arduino框架。
程序里面包括了NTC熱敏電阻的ADC,軟件濾波,二分查表的內(nèi)容,因為那個表格兼容性不好,所以這次只使用熱電偶。
有能力的網(wǎng)友可以更改并使用,請閱讀NTC.h #define TABLE_LONG (列表長度)
這個程序已經(jīng)連續(xù)更改3次了,點開主頁看以前的。
紅 pid輸出
藍 當前溫度
綠 目標溫度
Arduino源程序如下:
- #include "Arduino.h"
- #include "NTC.h"
- #include "PID.h"
- #include "TIMER.h"
- #include "DELAY.h"
- #include "SPI_MAX6675.h"
- TEMP_PID heart(7.19, 0.40, 32.4, 1, 2048);
- TEMP_PID bed(10, 0.023, 305.4, 0.95, 2048);
- NTC NTC_1(A13);
- NTC NTC_2(A14);
- float MAX;
- void setup(void)
- {
-
- Serial.begin(115200);
- spi_init();
- heart.temp_pid_change_target(200);
- bed.temp_pid_change_target(0);
- temp_timer_port_init();
- temp_timer_on();
- }
- void loop(){
- MAX=spi_read_temp();
- delay_nms(1000);
- //NTC_1.temp_ntc_read();
- //NTC_2.temp_ntc_read();
- /*
- if(Serial2.available()>6){
- float a=Serial2.parseFloat();
- float b=Serial2.parseFloat();
- float c=Serial2.parseFloat();
- heart.temp_pid_change_kp(a);
- heart.temp_pid_change_ki(b);
- heart.temp_pid_change_kd(c);
- Serial2.println("***********************");
- Serial2.println(a);
- Serial2.println(b);
- Serial2.println(c);
- Serial2.println("***********************");
- }
- */
- }
復制代碼
所有資料51hei提供下載:
2020_2_27 PID temperature.zip
(921.48 KB, 下載次數(shù): 191)
2021-3-21 18:01 上傳
點擊文件名下載附件
|