Temperature control program part report - based on msp430g2553

Publisher:InspiredDreamerLatest update time:2015-08-18 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Created on: 2012-9-14

      Author: zhang bin

 

Study Notes

for msp430g2553

redesigned by zhang bin

2012-09-14

versions:12_09_01

All Rights Reserved
 
 

 

    The program is a very important part of the whole system. It coordinates the work of all the hardware parts of the whole system on the basis of the hardware and controls every move of the whole temperature control system. The main functions of the software include:

(1) Collection and processing of sensor signals

(2) PWM output of heating wire

(3) Heating temperature and speed control

(4) Temperature control system operation process control: program initialization, temperature control start and end, LCD display module control

(5) Temperature control information display and parameter setting: status display, control algorithm parameter setting, etc.

    

Among the functions above, except for the initialization of the program which is executed in the main function, all other parts are executed in the interrupt function, among which keyboard detection and data input are executed in the keyboard interrupt, and other data collection, processing, control, etc. are all executed in the timer 5ms interrupt. The microcontroller is usually in low power mode to reduce power consumption.

The flowchart of the program is as follows:

Temperature control program part report - based on msp430g2553

This paper mainly uses two algorithms to achieve the requirements of the topic:

The first is the improvement of PID algorithm. Since temperature control can only heat but not cool, we only use PI. First, use P to increase the temperature to a temperature close to the set temperature, and then use I to approach the set temperature.

The procedure is as follows:

 

void pid()

{

 

   if (set_t-now_t>13)

  e2=0;

 

e1=set_t-now_t;    //Error between set value and actual value

uk=kp*e1+ki*e2+kd*e3;

// wr_float(0,1,e2);

e2=e1+e2;

e3=e1-e4;

e4=e1;

if(uk>speed)    //Prevent heating too fast

uk=speed;

if(uk<0)

uk=0;

 

control_value=1-uk;    //The control value of pid output   is the duty cycle of PWM

}

 

 

The second is a time-controlled linear algorithm

In time control, the temperature is required to be evenly heated from 40° to 60°, and the time can be set arbitrarily.

The method of this program is: set the time set_time in seconds, and divide the 20° temperature difference from 40° to 60° into set_time parts. Then, in the control cycle, let the time period time_m increase by 1 in each cycle, and then calculate the temperature that should be reached in this time period according to the average formula, the formula is as follows:

Temperature control program part report - based on msp430g2553

Because the control time input set_time is in seconds, and the control period is 100ms, the above needs to be divided by 10.

The specific implementation code is as follows:

 

control_m_value=(float)time_m/set_time;

control_m_value=control_m_value/10;   //The time control is in units of 100ms, and the time setting is in units of 1s

control_m_value=40+20*control_m_value;

set_t=control_m_value; 

pid();

 

CCR1=control_value*12000;       //Adjust the PWM duty cycle     to 12000 as the PWM period

Reference address:Temperature control program part report - based on msp430g2553

Previous article:Temperature control system based on msp430
Next article:My matrix keyboard usage notes - based on msp430g2553

Recommended ReadingLatest update time:2024-11-24 20:37

Driver for msp430g2553 and serial port communication
#include "uart.h" #include msp430g2553.h #include "typedef.h" rece_data uart_buf; //Serial port buffer void init_uart_buf(void) {        uart_buf.head = 0;        uart_buf.tail = uart_buf.head; } //获取串口数据 u8 get_uart_data(u8* data) {        if(uart_buf.tail == uart_buf.head)        {                ret
[Microcontroller]
Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号