Home > other >  Consult: PROTEUS simulation MAX6675 temperature measurement with LCD display error is how to return
Consult: PROTEUS simulation MAX6675 temperature measurement with LCD display error is how to return

Time:09-18

Write your own keilc program, and PROTEUS built a simple temperature measurement circuit, found with the LCD1602 display temperature and the difference of thermocouple temperature 10 degrees, such as temperature to several baidu, error is reduced a little, but when the thermocouple temperature of 10 degrees, according to the temperature of 0 degrees or so, is this why? Ask ace to give directions


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
MAX6675 test program
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include
# include "intrins. H"//_nop_ (); Delay function in

# define uchar unsigned char
# define uint unsigned int


Sbit SO=P2 ^ 4;//P3.6 mouth connected with SO
Sbit SCK=P2 ^ 5;//P3.4 mouth connected with SCK
Sbit CS=P2 ^ 6;//P3.5 mouth is linked together with CS

Sbit wx=P2 ^ 5;//??
Sbit dx=P2 ^ 6;//??

Const unsigned char DevID=1;//the native device ID
Unsigned char buffer;//serial port receive buffer
Unsigned char rcv_buffer [20].
Unsigned char send_buffer [20].
Unsigned char flag_ok=0;//receive over the identity of the
Unsigned int MAX6675_Temp;
Unsigned char Flag_connect;
Unsigned char CRCH CRCL;
Unsigned char wd [2].//wd [] : the temperature of the BCD code
Unsigned char flag_dis;//display refresh the identity of the

Unsigned char dis [4]={0 x00 to 0 x00 to 0 x00 to 0 x00};
Unsigned char code SMG []={xa4 xc0 0, 0 xf9, 0, 0, xb0 x99 0, 0 x92, 0 x82, 0 xf8, 0 x80, 0 x90, 0 x88, 0 x83, 0 xc6, 0 xa1, 0 x86, 0 x8e};



Unsigned char data disdata [5].
Int t_zhi=0;
/* * * * * * * * * * * * * * * * * * * * *!!!!!!!!!! 1014 to modify!!!!!! 1 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
//temperature reading
Unsigned int ReadMAX6675 ()//read from the MAX6675 temperature
{
Unsigned char count;
Unsigned int Value.
CS=0;//buy low, enabling MAX6675
SCK=0;
Value=https://bbs.csdn.net/topics/0;
_nop_ ();
_nop_();
_nop_();
_nop_();
for(count=0; Count<16. Count++)//to get 16 MSB
{
Value=https://bbs.csdn.net/topics/Value <1;//left
SCK=1;//SCK buy high
_nop_ ();
_nop_();
_nop_();
_nop_();
If (SO==1)//get the current value
The Value |=0 x01;
SCK=0;
}
CS=1;//close MAX6675
The return Value.
}

/* * * * * * * * * * * * * * * * * * * * * - millisecond delay function * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

Void DelayMs (unsigned int I)//a time delay function, the function in the 11.0592 M crystal vibration under the delay time is about 1 ms
{
Unsigned int j, k;
For (j=I; J> 0; J -)
For (k=114; K> 0; K -);
}


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
LCD1602 DRIVER

The File Name: LCD1602. H
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

# # ifndef LCD_CHAR_1602_2009_6_28
# define LCD_CHAR_1602_2009_6_28

#include
Sbit LcdRs=P2 ^ 0;//define port
Sbit LcdRw=P2 ^ 1;
Sbit LcdEn=P2 ^ 2;
# define DBPort P1


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Wait functions within
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
Unsigned char LCD_Wait (void)
{
LcdRs=0;
LcdRw=1; _nop_();
LcdEn=1; _nop_();

LcdEn=0;
Return DBPort;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
To write command or LCD data
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
//# define LCD_COMMAND 0 Command
# define LCD_DATA 1//Data
# define LCD_CLEAR_SCREEN 0 x01//clear screen
# define LCD_HOMING 0 x02//the cursor to return to the origin
Void LCD_Write (bit style, unsigned char input)
{
LcdEn=0;
LcdRs=style;
LcdRw=0; _nop_();
DBPort=input; _nop_();//note order
LcdEn=1; _nop_();//note order
LcdEn=0; _nop_();
LCD_Wait ();
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Set the display mode
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# define LCD_SHOW 0 x04//show
# define LCD_HIDE 0 x00//show off

# define LCD_CURSOR 0 x02//show the cursor
# define LCD_NO_CURSOR 0 x00//no cursor

# define LCD_FLASH 0 x01//the cursor flashing
# define LCD_NO_FLASH 0 x00//not flashing cursor

Void LCD_SetDisplay unsigned char (an)
{
LCD_Write (LCD_COMMAND, 0 x08 | an);
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Set the input mode
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# define LCD_AC_UP 0 x02
# define LCD_AC_DOWN 0 x00//default

# define LCD_MOVE 0 x01//picture can translation
# define LCD_NO_MOVE 0 x00//default

Void LCD_SetInput (unsigned char an InputMode)
{
LCD_Write (LCD_COMMAND, 0 x04 | an InputMode);
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Initializes the LCD
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
Void LCD_Initial ()
{
LcdEn=0;
LCD_Write (x38 LCD_COMMAND, 0);//8 bits of data port, 2 rows, according to 5 * 7 lattice
LCD_Write (x38 LCD_COMMAND, 0);
LCD_SetDisplay (LCD_SHOW | LCD_NO_CURSOR);//open display, no cursor
LCD_Write (LCD_COMMAND LCD_CLEAR_SCREEN);//clear screen
LCD_SetInput (LCD_AC_UP | LCD_NO_MOVE);//AC increment, the picture is not moving
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
The location of the liquid crystal character input
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
Void GotoXY (unsigned char x, unsigned char y)
{
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related