第一范文网 - 专业文章范例文档资料分享平台

数字式开关电源的PID控制

来源:用户分享 时间:2025/8/25 9:25:09 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

/********开关电源的数字化控制******/

/********所用拓扑为Buck,单片机msp430**********/

/*****PID算法实现开关电源的恒流、恒压、恒功率功能******/ /*********糖coffee@uestc************/

/********************************************** Part 1 Main.C

**********************************************/ #include #include \#include \#include \#include \

#include \#include \

void main( void ) {

WDTCTL = WDTPW + WDTHOLD; init_clk(); init_lcd(); GUI_CU(); init_ADC12(); init_TA(); init_TB(); initKey(); _EINT(); while(1) {

KeyScan();

if(Mode==0) //恒压模式 {

DisplaySetU(); Delay(100); ADC();

Delay(100); }

else if(Mode==1) //恒流模式 {

DisplaySetI(); Delay(100); ADC();

Delay(100); }

else //恒功率模式 {

DisplaySetP(); Delay(100); ADC();

Delay(100); } } }

/********************************************** Part 2 Headfile

**********************************************/

/********************************************** Part 2.1 LCD12864Headfile

**********************************************/

#ifndef __LCD12864 #define __LCD12864

#define LCD_CS BIT0 #define LCD_SID BIT2 #define LCD_CLK BIT4

#define LCD_EN P3DIR #define LCD_CTRL P3OUT

#define LCD_CS_Set_high LCD_CTRL |= LCD_CS #define LCD_CS_Set_low LCD_CTRL &= ~LCD_CS #define LCD_SID_Set_high LCD_CTRL |= LCD_SID #define LCD_SID_Set_low LCD_CTRL &= ~LCD_SID #define LCD_CLK_Set_high LCD_CTRL |= LCD_CLK #define LCD_CLK_Set_low LCD_CTRL &= ~LCD_CLK

#define LCD_delay 1

voidWrite_Data(unsigned char byte ,unsigned char reffer); voidSend_Byte(unsigned char byte); voidClearLCD(void);

voidPut_Array(unsigned char *data , unsigned char length ,unsigned char address);

/*************延时**********************/

void Delay(unsigned char time) //主时钟1微秒延时 {

unsignedinti; i=0x08*time; for(; i; i--); }

/************************************************ //函数名称:Initial_LCD(void) //函数功能:启动初始化

************************************************/ voidInitial_LCD(void) {

LCD_EN |= LCD_CS + LCD_SID + LCD_CLK; Write_Data (0x30,0); //基本指令集 Delay(LCD_delay);

Write_Data(0x30,0);

Write_Data(0x0C,0); Delay(LCD_delay);

Write_Data(0x01,0); //清屏 Delay(LCD_delay);

Write_Data(0x06,0); Delay(LCD_delay); }

/**************************************************************** *函数名称:Write_Data(unsigned char byte,unsigned char reffer) *函数功能:发送指令或数据 reffer数据 1 指令 0

*输入变量:unsigned char byte unsigned char byte

****************************************************************/ voidWrite_Data(unsigned char byte ,unsigned char reffer) {

unsigned char temp,stemp; temp = byte;

LCD_CS_Set_high; LCD_CLK_Set_low; if(reffer==1)

Send_Byte(0xFA); else

Send_Byte(0xF8); //发送第一个字节 stemp = (temp & 0xF0); Send_Byte(stemp); stemp = temp <<4; Send_Byte(stemp); LCD_CS_Set_low; }

/********************************************************* *函数名称:Send_Byte(unsigned char byte) *函数功能:发送一字节数据 *输入变量:unsigned char byte

*********************************************************/ voidSend_Byte(unsigned char byte) {

unsigned char temp,i; temp = byte;

for(i=0;i<8;i++) //send 8 times {

if (temp&0x80) //send the highest LCD_SID_Set_high; else

LCD_SID_Set_low;

temp = (temp<<1); LCD_CLK_Set_low;

LCD_CLK_Set_high; Delay(LCD_delay); } }

/***********************************************************************************

*函数名称:Put_Array( unsigned char data, unsigned char length,unsigned char address ) *函数功能: 在LCD上显示一个数组 *输入变量:unsigned char data unsigned char length unsigned char address

***********************************************************************************/

voidPut_Array(unsigned char *data , unsigned char length ,unsigned char address) {

搜索更多关于: 数字式开关电源的PID控制 的文档
数字式开关电源的PID控制.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c184ie1bti43ibqw7sio0_1.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top