国产免费AV|泡泡玛特欧洲总部将设在伦敦|中文天堂网www新版资源在线|一本久道综合在线中文|国精产品一二三产区的使用方法|香蕉鱼在线观看|www.27eee
ELEOK
標題:
51單片機PID控制的制動能量回收系統程序與仿真設計
[打印本頁]
作者:
coolfire
時間:
2021-4-21 15:42
標題:
51單片機PID控制的制動能量回收系統程序與仿真設計
內含PID控制、AD轉換、12864顯示、電機測速、控制邏輯程序
仿真原理圖如下(proteus仿真工程文件和C源碼可到本帖附件中下載)
1.png
(79.6 KB)
下載附件
2021-4-21 15:39 上傳
3.png
(13.82 KB)
下載附件
2021-4-21 15:40 上傳
部分源程序:完整源碼下載附件后查看
#include <reg52.h>
#include <intrins.h>
#include <LCD12864.h>
#include <ADC.h>
#include <WORDMODEL.h>
#include <MOTOR.h>
#define uint unsigned int
#define uchar unsigned char
#include <string.h>
uchar SOC = 0, V = 0, VOLT = 0;
//SOC
void display0()
{
SOC = vol*100/255;
temp0 = SOC / 100;
temp1 = (SOC % 100) / 10;
temp2 = SOC % 10;
show_ch1(1, 0, 4 * 6, ch1 + (12 * (temp0 + 4)));
show_ch1(1, 0, 5 * 6, ch1 + (12 * (temp1 + 4)));
show_ch1(1, 0, 6 * 6, ch1 + (12 * (temp2 + 4)));
}
//車速
void display1()
{
V = vol * 192 / 255;
temp0 = V / 100;
temp1 = (V % 100) / 10;
temp2 = V % 10;
show_ch1(2, 0, 3 * 6, ch1 + (12 * (temp0 + 4)));
show_ch1(2, 0, 4 * 6, ch1 + (12 * (temp1 + 4)));
show_ch1(2, 0, 5 * 6, ch1 + (12 * (temp2 + 4)));
}
//電池電壓
void display2()
{
VOLT = vol * 400 / 255;
temp0 = VOLT / 100;
temp1 = (VOLT % 100) / 10;
temp2 = VOLT % 10;
show_ch1(2, 2, 0 * 6, ch1 + (12 * (temp0 + 4)));
show_ch1(2, 2, 1 * 6, ch1 + (12 * (temp1 + 4)));
show_ch1(2, 2, 2 * 6, ch1 + (12 * (temp2 + 4)));
}
//目標制動力矩
void display3()
{
targetM = vol * 200 / 255;
D= vol * 100 / 255;
temp0 = targetM / 100;
temp1 = (targetM % 100) / 10;
temp2 = targetM % 10;
show_ch1(2, 4, 3 * 6, ch1 + (12 * (temp0 + 4)));
show_ch1(2, 4, 4 * 6, ch1 + (12 * (temp1 + 4)));
show_ch1(2, 4, 5 * 6, ch1 + (12 * (temp2 + 4)));
}
//實際制動力矩
void display4()
{
// val=100;
factM=num1/5 ;
// val = vol * 192 / 255;
temp0 = factM / 100;
temp1 = (factM % 100) / 10;
temp2 = factM % 10;
show_ch1(2, 6, 3 * 6, ch1 + (12 * (temp0 + 4)));
show_ch1(2, 6, 4 * 6, ch1 + (12 * (temp1 + 4)));
show_ch1(2, 6, 5 * 6, ch1 + (12 * (temp2 + 4)));
}
void main()
{
InitLCD();
TimeInit();
ClearScreen(0);
Set_line(0);
//SOC顯示
show_ch1(1,0,0*6,ch1+12*1);
show_ch1(1,0,1*6,ch1+12*2);
show_ch1(1,0,2*6,ch1+12*3);
show_ch1(1, 0, 3 * 6, ch1 + 12 * 0);
show_ch1(1, 0, 7 * 6, ch1 + 12 * 14);
//車速顯示
show_ch2(1, 0, 52, ch2 + 24 * 6);
show_ch2(2, 0, 0 * 12, ch2 + 24 * 7);
show_ch1(2, 0, 1 * 12, ch1 + 12 * 0);
show_ch1(2, 0, 6*6, ch1 + 12 * 15);
show_ch1(2, 0, 6 * 7, ch1 + 12 * 16);
show_ch1(2, 0, 6 * 8, ch1 + 12 * 17);
show_ch1(2, 0, 6 * 9, ch1 + 12 * 18);
//電池電壓顯示
show_ch2(1, 2, 0 * 14, ch2 + 24 * 12);
show_ch2(1, 2, 1 * 14, ch2 + 24 * 13);
show_ch2(1, 2, 2 * 14, ch2 + 24 * 14);
show_ch2(1, 2, 3 * 14, ch2 + 24 * 15);
show_ch1(1, 2, 4 * 14, ch1 + 12 * 0);
show_ch1(2, 2, 6 * 3, ch1 + 12 * 21);
//目標制動力矩顯示
show_ch2(1, 4, 0, ch2 + 24 * 0);
show_ch2(1, 4, 13, ch2 + 24 * 1);
show_ch2(1, 4, 26, ch2 + 24 * 2);
show_ch2(1, 4, 39, ch2 + 24 * 3);
show_ch2(1, 4, 52, ch2 + 24 * 4);
show_ch2(2, 4, 0 * 12, ch2 + 24 * 5);
show_ch1(2, 4, 1 * 12, ch1 + 12 * 0);
show_ch1(2, 4, 6 * 6, ch1 + 12 * 19);
show_ch1(2, 4, 7 * 6, ch1 + 12 * 20);
//實際制動力矩顯示
show_ch2(1, 6, 0 , ch2 + 24 * 16);
show_ch2(1, 6, 13, ch2 + 24 * 17);
show_ch2(1, 6, 26, ch2 + 24 * 2);
show_ch2(1, 6, 39, ch2 + 24 * 3);
show_ch2(1, 6, 52, ch2 + 24 * 4);
show_ch2(2, 6, 0 * 12, ch2 + 24 * 5);
show_ch1(2, 6, 1 * 12, ch1 + 12 * 0);
show_ch1(2, 6, 6 * 6, ch1 + 12 * 19);
show_ch1(2, 6, 7 * 6, ch1 + 12 * 20);
while(1)
{
ADDA=0;
ADDB=0;
ADDC=0;
adc();
display0();
ADDA=1;
adc();
display1();
ADDA=0;
ADDB=1;
adc();
display2();
ADDA=1;
adc();
display3();
if (SOC>95)
{
targetM = 0;
}
if (V <20)
{
targetM = 0;
}
if (VOLT > 390)
{
targetM = 0;
}
if (targetM > 150)
{
targetM = 0;
}
else if(targetM > 100)
{
targetM = targetM*0.5;
}
if (time1 > 100)
{
time1 = 0;
num1 = Inpluse*103/27 ;
Inpluse = 0;
PIDControl();
PWM =D;
}
display4();
}
}
//-------------------------------
//定時器0
//-------------------------------
void Timer0(void) interrupt 1
{
// TH0 = 0XFF; //重裝初值
// TL0 = 0X9c; //標準值
// TL0 = 0Xb8; //包含誤差
TH0=0XFF;
TL0=0X37;
time++;
if (time >= 100) //PWM周期為100*0.1ms
time = 0;
if (time < PWM)
IN01 = 1;
else
IN01 = 0;
time1++; //轉速測量周期
}
完整代碼見附件
復制代碼
2.png
(18.72 KB)
下載附件
2021-4-21 15:39 上傳
完整仿真文件和C源碼程序:
51單片機程序和電路仿真.zip
(120.2 KB, 售價: 10 E幣)
2021-4-21 15:42 上傳
點擊文件名下載附件
售價: 10 E幣
[記錄]
[
購買
]
歡迎光臨 ELEOK (http://m.afoofa.cn/)
Powered by Discuz! X5.0