Home > other >  Which big help solve
Which big help solve

Time:09-24

# include "is the main. H"
# include "HX711. H"

Unsigned long HX711_Buffer=0;
Unsigned long Weight_Maopi=0;
Long Weight_Shiwu=0;

Unsigned int Temp_Buffer=0;
//?????????????
Uchar code table []={x5b x3f 0, 0 x06, 0, 0, x4f x66 0, 0 x6d, 0 x7d, 0 x07, 0 x7f, 0 x6f, 0 x00 to 0 XFF, 0 x40};//0,1,2,3,4,5,6,7,8,9,?????????? , g, e, r, h, o, l//??????
//??????? Lambda???
Uchar code P0 []={0 xfe, 0 XFD, 0 XFB, 0 xf7};
Unsigned char flag=0;

Unsigned char timer=0;

Bit Flag_ERROR=0;
Bit Flag_yemian=0;

Sbit beep=P2 ^ 3;
Sbit CS=P3 ^ 7;
Sbit DCLK=P2 ^ 1;
Sbit DIN=P2 ^ 0;
Sbit DOUT=P2 ^ 5;
Sbit DU=P2 ^ 6;//???????????
Sbit WE=P2 ^ 7;//??????? Lambda?
Unsigned char q=0, b=0, s=0, g=0;
Unsigned int GapValue=https://bbs.csdn.net/topics/430;//У???????
Unsigned char num1, num2 num3;//num1?? Num2?? 洢???????? Eeprom???????? Num3?????? +/-???
# include "eeprom52. H"




/* * * * * * * * * * * * * * * * * *?????????? 浽???????? Eeprom?? * * * * * * * * * * * * * * * * * */
Void write_eeprom ()
{
Num1=GapValue/256;
Num2=GapValue % 256;
SectorErase (0 x2000);
Byte_write (0 x2001, num1);
Byte_write (0 x2002, num2);
Byte_write (0 x2060, a_a);
}

/* * * * * * * * * * * * * * * * * *???????????????????? Eeprom? ж??????? * * * * * * * * * * * * * * * * */
Void read_eeprom ()
{
X2001 num1=byte_read (0);
Num2=byte_read x2002 (0);
X2060 a_a=byte_read (0);

GapValue=https://bbs.csdn.net/topics/num1 * 256 + num2;
}

/* * * * * * * * * * * * * *??????????? Eeprom??????? * * * * * * * * * * * * * * * * */
Void init_eeprom ()
{
Read_eeprom ();//???
If (a_a!=3)//? Mu??????????????????????? Eeprom
{
GapValue=https://bbs.csdn.net/topics/430;
A_a=3;
Write_eeprom ();
}
}

//?? Task??
Void Scan_Key ()
{
If (KEY1==0)
{
Delay_ms (5);
If (KEY1==0)
{
While (KEY1==0);
Get_Maopi ();//??
}
}

If (KEY2==0)
{
Delay_ms (25);
If (KEY2==0)
{
//while (KEY2==0);
Flag_yemian=1; Num3=0;

If (GapValue<999) {GapValue++; }
Write_eeprom ();//????????

Q=12;
B=GapValue/100;
S=100/10 GapValue %;
G=GapValue % 10;
}
}

If (KEY3==0)
{
Delay_ms (25);
If (KEY3==0)
{
Flag_yemian=1; Num3=0;
//while (KEY3==0);
If (GapValue> 1) {GapValue -; }
Write_eeprom ();//????????

Q=12;
B=GapValue/100;
S=100/10 GapValue %;
G=GapValue % 10;
}
}
}



//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
//????????
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Void main ()
{
Init_eeprom ();
Init_Timer0 ();

Q=12;
B=12;
S=12;
G=12;
Delay_ms(1000);//??? And??????????????????
Get_Maopi ();//????????

While (1)
{

EA=0;
Get_Weight ();//??????
EA=1;

Scan_Key ();
Num3 + +;
If (num3 & gt;=10) {num3=0; Flag_yemian=0; }
If (Flag_yemian==0)
{
//????????????????
If (Flag_ERROR==1)
{
Beep=0;//????????????????
}

The else
{
Beep=1;
Q=Weight_Shiwu/1000;
B=Weight_Shiwu % 1000/100;
S=100/10 Weight_Shiwu %;
G=Weight_Shiwu % 10;

}
Delay_ms (100);


}
}
}



//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
//??????
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Void Get_Weight ()
{
Weight_Shiwu=HX711_Read ();
Weight_Shiwu=Weight_Shiwu - Weight_Maopi;//???????????
If (Weight_Shiwu & gt; 0)
{
Weight_Shiwu=(unsigned int) ((float) Weight_Shiwu/GapValue);//???????????????????????


If (Weight_Shiwu & gt; 5000)//???????????
{
Flag_ERROR=1;
Q=5;//
B=0;//
S=0;//
G=0;//
}
The else
{
Flag_ERROR=0;

}
}
The else
{
Weight_Shiwu=0;
//Flag_ERROR=1;//???????????
}

}

//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
//?????????????
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Void Get_Maopi ()
{
Weight_Maopi=HX711_Read ();
}


//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
//???????????????? 0
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Void Init_Timer0 ()
{
TMOD=0 x01;//T0,?????????? 1

TH0=(65536-1000)/256;
TL0=(65536-1000) % 256;

TR0=1;//????????
ET0=1;//????????????? ж?
EA=1;//??????????? ж?
}


//? ж??????
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Void Timer0 () interrupt 1
{
TH0=(65536-1000)/256;
TL0=(65536-1000) % 256;

Flag++;
If (flag & gt;
=4){
flag=0;

}

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related