📄 13fre100.c.bak
字号:
//0105 communication modify
#include <stdlib.h>
#define cregbank 1
#define CENDRAM 0x043f
#define CSTARTRAM 0x0c0
#define pwmfrequence 2808 //2800
#define f3khz 8000000/pwmfrequence/*2857 */
#define minpulse 32 //020725
#define overflow 2
#define MINFRE 30
#define sincont 1
#define offset f3khz/4
#define volt220 178 /*0320 173 0318 0311(178) 230V 173(220) 1204 201*/
#define maxlinevoltage 174 /*183 0227 it is squ(6)*edc/4*/
#define maxload 174
#define modux maxload*100/maxlinevoltage
#define cRegBank 1
#define fc 16
#define halfperiod pwmfrequence/2
#define quaterperiod pwmfrequence/4
#define thirdperiod pwmfrequence*3/4
#define onethirdperiod pwmfrequence/3
#define twothirdperiod pwmfrequence*2/3
#define tx9msh 9000*fc/8
#define tx9msmax 90*120*fc/8
#define tx9msmin 90*80*fc/8
#define tx4msl 4000*fc/8
#define tx4mslmax 40*fc*120/8
#define tx4mslmin 40*fc*80/8
#define tx13ms tx9msh+tx4msl
#define tx13msmax tx9msmax+tx4mslmax
#define tx13msmin tx9msmin+tx4mslmin
#define indoorsendlength 2 //030308 fredrive 9
#define outdoorsendlength 2// 030308 4
#define indoornum 8 //0926
#define tx1h 1000*fc/8
#define tx1l 5000*fc/8
#define tx1max 7000*fc/8
#define tx1min 3200*fc/8
#define tx0max 3000*fc/8
#define tx0min 1000*fc/8
#define tx0h 1000*fc/8
#define tx0l 2000*fc/8
#define txhigh 1
#define txlow 0
/*electric valve constant value*/
#define valvemax 520
#define valvemax1 350 /*1227 300*/
#define valvemax2 500 /*1227 300*/
#define valvemin 220 /*021219 120 */
#define heatvalvemin 120 /*021219 120 */
#define valveheatmin 90 /*0927 */
#define valvenamea 250
#define valvenameb 250
#define valvenamec 250
#define poweron 0xaa
#define cmp4min 41
#define cmp10min 35
/*define mode constant*/
#define coolmode 0x0f
#define drymode 0x33
#define fanmode 0x66
#define heatmode 0x00
#define namecool 0xff
#define nameheat 0xf0
#define fanlowcoolmode 0x5f
#define startcode 0x6e //030308 v10 fredrv 08
#define finishcode 0xed //f0
#define valveminstep 2
#define valvestep 3 /*1225 4*/
#define valve8pulse 8
#define valveaction 20 /*define valve privious control frequence*/
#define maxheatplace 420 /*define valve privious control frequence*/
#define avalvecoolinit 180 /*210 1225 define valve open initial vavlue*/
#define avalveheatinit 180 /*define valve open initial vavlue*/
#define bvalvecoolinit 180 /*210 1225 define valve open initial vavlue*/
#define bvalveheatinit 180 /*define valve open initial vavlue*/
#define cvalvecoolinit 180 /*210 1225 define valve open initial vavlue*/
#define cvalveheatinit 180 /*define valve open initial vavlue*/
#define icerecovetemp 37 /*if coil temperature is larger than 7,ice recove.*/
#define iceprotecttemp 29 /*if coil temperature is lower than -1,ice protect enter.*/
#define icedecfretemp 33 /*if coil temperature is lower than 3,ice protect enter.*/
#define icedecfretime 30 /*if coil temperature is lower than 3 for 30s,ice protect enter.*/
#define iceprotecttime 255 /*if coil temperature is lower than -1,for 255s,ice protect enter.*/
#define CNTRCONSTANT 100 /*2 SECOND CONTROL PERIOD*/
#define VALVECONST 40 /*1225 55 SECOND VALVE CONTROL PERIOD*/
#define ROOM40DEGREE 152 /*55 SECOND VALVE CONTROL PERIOD*/
#define ROOM21DEGREE 102 /*0317 2.02v 20degree from 107 */
#define room35under 137 /*136 1225 */
#define room35above 148 /*0127 145*/
#define room27under 116 /*0317 25degree from 120 55 SECOND VALVE CONTROL PERIOD*/
#define room27above 127 /*0317 29degree from 125 55 SECOND VALVE CONTROL PERIOD*/
#define room20under 103 /* indoor room VALVE CONTROL PERIOD*/
#define room20above 108 /*55 SECOND VALVE CONTROL PERIOD*/
#define room7under 66 /* 0317 5degree 55 SECOND VALVE CONTROL PERIOD*/
#define room7above 73 /*0317 55 SECOND VALVE CONTROL PERIOD*/
#define room24degree 114 /*2.23v 0203*/
#define room28degree 133 /*030212 129 VALVE CONTROL PERIOD*/
#define decfrehightemp 85 /*0320 90 88 1128 heat protect high temp decrease fre 58 degree*/
#define protecthightemp 97 /*95 1128 heat protect high temp stop compressor if 58 degree*/
#define braketime 120
#define compvalveopentemp 135 /*2.65 v and 95 degree*/
#define compdecfretemp 176 /*0903 3.46v 120 degree from 2.98 v and 104 degree*/
#define comprecovertemp 126 /*2.47 v and 90 degree*/
#define comp40degree 40 /*1.672 v and 40 degree*/
#define comp50degree 55 /*1.672 v and 50 degree*/
#define comp70degree 85 /*1.672 v and 70 degree*/
#define comp75degree 95 /*1.872 v and 75 degree*/
#define comp80degree 105 /*1.672 v and 70 degree*/
#define comp85degree 115 /*1.672 v and 70 degree*/
#define comp90degree comprecovertemp /*2.47 v and 90 degree*/
#define comp95degree compvalveopentemp /*2.65 v and 95 degree*/
#define comp100degree 143 /*1.672 v and 70 degree*/
#define comp105degree 152 /*2.65 v and 95 degree*/
#define comp110degree 160 /*2.65 v and 95 degree*/
#define comp113degree 167 /*3.27 v and 113 degree*/
#define comp115degree 169 /*2.65 v and 95 degree*/
#define comp120degree 176 /*2.65 v and 95 degree*/
#define comp125degree 184 /*2.65 v and 95 degree*/
#define compstoptemp comp120degree /*184 3.61v 125 degree from 3.18 v and 110 degree*/
#define room5degree 66/*1.297v and 5 degree*/
#define room3degree 61/*1.2097v and 3 degree*/
#define room2degree 59/*1.084v and 0 degree*/
#define room0degree 53/*0320 55 1.084v and 0 degree*/
#define minus1degree 52/*0311 1.084v and 0 degree*/
#define minus2degree 51/*0311 1.084v and 0 degree*/
#define minus4degree 47/*0.928v and -4 degree*/
#define minus5degree 45/*0.891v and -5 degree*/
#define minus6degree 44/*0.891v and -5 degree*/
#define minus8degree 40/*0.787v and -8 degree*/
#define minus10degree 37/*0.787v and -8 degree*/
#define minus12degree 34/*0.66v and -12 degree*/
#define minus16degree 27/*0.66v and -12 degree*/
#define minus18degree 25/*0.498v and -18 degree*/
#define coolsingledecfre 78 /*8.5A 100 1.538V 1227 1.59v*/
#define coolsinglestop 180 /*10A,1231.809V 0112 from 105 ,0123 from 120*/
#define cooltwodecfre 151 /*14A,161 3.2326V*/
#define cooltwostop 220 /*17A 0112 from 175,0123 from 185*/
#define coolthreedecfre 150 /*143 16A 180 18A 1227 187*/
#define coolthreestop 163 /*23021A 0112 209*/
#define heatsingledecfre 120 /*12A */
#define heatsinglestop 180 /*15A 1227 167, 0123 from 160*/
#define heattwodecfre 168 /*16A 1227 173*/
#define heattwostop 220 /*18A*187 1227 0112 from180,0123 from 190*/
#define heatthreedecfre 160//181 //mod. from '172' at 040412 /*143 16A 150 16A from 18A 180187*/
#define heatthreestop 176//199 /*163 18A 3V 0112 from 220*/
//030113 12A/2.03v
#define communotrecnum 255 //debug 030113
typedef unsigned char unsigned8;
typedef unsigned int unsigned16;
typedef struct ram_bit_format {
unsigned char bit0:1;
unsigned char bit1:1;
unsigned char bit2:1;
unsigned char bit3:1;
unsigned char bit4:1;
unsigned char bit5:1;
unsigned char bit6:1;
unsigned char bit7:1;
} ram_byte_field;
typedef union ram_format{
unsigned char ram_byte;
ram_byte_field ram_bit;
} ram_field;
typedef struct ioram_bit_format {
unsigned char iobit0:1;
unsigned char iobit1:1;
unsigned char iobit2:1;
unsigned char iobit3:1;
unsigned char iobit4:1;
unsigned char iobit5:1;
unsigned char iobit6:1;
unsigned char iobit7:1;
} ioram_byte_field;
typedef union ioram_format{
unsigned char ioram_byte;
ioram_byte_field ioram_bit;
} ioram_field;
typedef union ram2word{
unsigned char ram_char[2];
unsigned int ram_int;
} r2word;
typedef struct ramstruct{
unsigned char r_char;
r2word r2wrd;
} rstruct;
/*** RAM extern
typedef union ioram_format
{
unsigned char ioram_byte;
byte_field ioram_bit;
} ioram_field;***/
//#define flowpressure _P3.ioram_bit.iobit3
/*io_field __io(0x0003) Port3; // R/W P1 Port output latch
// ===================== // P1
#define PORT3OUT Port3.ioram_byte // 可用作output port and p12 used as INT1 input
#define flowpressure Port3.ioram_bit.bit0 // comp output*/
/***********************************************
* SFR definition *
***********************************************/
unsigned8 __io(0x00) P0;
unsigned8 __io(0x01) P1;
unsigned8 __io(0x02) P2;
#define defaultport P2
unsigned8 __io(0x03) P3;
//ioram_field _P3;
//#define P3 _P3.ioram_byte
//#define flowpressure _P3.ioram_bit.iobit3
//#define lowpressureport P3
/*ioram_field _P3;*/
#define fourvalveport P1 /*020725 P3 0127 */
#define passbyport P1//020725
unsigned8 __io(0x04) P4;
unsigned8 __io(0x05) P5;
//#define outfanport P5
unsigned8 __io(0x06) P6;
unsigned8 __io(0x07) P7;
#define commuenableport P5//P7
unsigned8 __io(0x0a) P0CR;
unsigned8 __io(0x0b) P1CR;
unsigned8 __io(0x0c) P6CR;
unsigned8 __io(0x0d) P7CR;
unsigned16 __io(0x10) TREG1A;
unsigned16 __io(0x12) TREG1B;
unsigned8 __io(0x14) TC1CR;
unsigned8 __io(0x0e) ADCCR;
unsigned8 __io(0x0f) ADCDR1;
unsigned8 __io(0x24) ADCDR2L;
unsigned8 __io(0x25) ADCDR2H;
unsigned8 __io(0x34) WDTCR1;
unsigned8 __io(0x35) WDTCR2;
unsigned8 __io(0x15) TC2CR;
unsigned16 __io(0x16) TREG2;
unsigned8 __io(0x2b) EIRC;
unsigned16 __io(0x2c) EIRE;
unsigned16 __io(0x3a) EIRL;
#define ILC EIRC
unsigned16 __io(0x2e) ILE;
unsigned16 __io(0x3c) ILL;
unsigned8 __io(0x30) CGCR;
unsigned8 __io(0x36) TBTCR;
unsigned8 __io(0x37) EINTCR;
// 1. PMD channel number (1 or 2)
#define cPMDChn 1
//#define cPMDChn 2
unsigned16 __io(0x0f60 + 0x0020 * cPMDChn + 0x00) PDCR;
unsigned8 __io(0x0f60 + 0x0020 * cPMDChn + 0x02) SDREG;
unsigned8 __io(0x0f60 + 0x0020 * cPMDChn + 0x03) CMPCR;
unsigned16 __io(0x0f60 + 0x0020 * cPMDChn + 0x04) MTCR;
unsigned16 __io(0x0f60 + 0x0020 * cPMDChn + 0x06) MCAP;
unsigned16 __io(0x0f60 + 0x0020 * cPMDChn + 0x08) CMP1;
unsigned16 __io(0x0f60 + 0x0020 * cPMDChn + 0x0a) CMP2;
unsigned16 __io(0x0f60 + 0x0020 * cPMDChn + 0x0c) CMP3;
unsigned16 __io(0x0f60 + 0x0020 * cPMDChn + 0x0e) CMP4;
unsigned16 __io(0x0f60 + 0x0020 * cPMDChn + 0x10) EMGCR;
unsigned8 __io(0x0f60 + 0x0020 * cPMDChn + 0x12) DTR;
unsigned8 __io(0x0f60 + 0x0020 * cPMDChn + 0x13) MDCR;
unsigned16 __io(0x0f60 + 0x0020 * cPMDChn + 0x14) MDOUT;
unsigned16 __io(0x0f60 + 0x0020 * 2 + 0x14) MDOUT2;
unsigned16 __io(0x0f60 + 0x0020 * cPMDChn + 0x16) MDCNT;
#define EMGREL MDCNT
unsigned16 __io(0x0f60 + 0x0020*cPMDChn + 0x18) CMPU;
unsigned16 __io(0x0f60 + 0x0020*cPMDChn + 0x1a) CMPV;
unsigned16 __io(0x0f60 + 0x0020*cPMDChn + 0x1c) CMPW;
unsigned16 __io(0x0f60 + 0x0020*cPMDChn + 0x1e) MDPRD;
/*#define MDPRD2 MDPRD*/
#define u_on CMPU
#define v_on CMPV
#define w_on CMPW
//
unsigned8 __io(0x0ffb) RDBUF;
#define TDBUF RDBUF;
unsigned8 __io(0x0ffc) UARTCR1;
#define UARTSR UARTCR1;
/*BRG 0-3BITS IS 4800BITS/S-100
PE 3BIT HAS PARITY ADDED-1
EVEN 4BIT IS EVEN PARITY- 1
STBT 5BIT IS 1 STOP BIT LENGTH -0
RXE 6BIT RECEIVE ENABLE
TXE 7BIT RECEIVE ENABLE
set baud is 4800,1,even,*/
unsigned8 __io(0x0ffd) UARTCR2;
/*0 BIT IS 0 1STOP RECEIVE BIT
RXDNC 10 31/Fc 0725 */
void __interrupt INTEMG1(void); /**/
extern void __interrupt INTPWM2(void); /* */
extern void __interrupt INTPWM1(void);/* */
extern void __interrupt INTTC2(void);/**/
extern void __interrupt INTUARTR(void);
extern void __interrupt INTUARTT(void);
extern void speed();
extern void main();
void initvar();
void commu();
void receiveinte();
void cooldeal();
void heatdeal();
void moddeal();
void fandeal();
void drydeal();
void protectice();
void addeal();
void clkdeal();
//extern void ClearRam();
extern void calculate();
void protectoverheat();
void closevalve();
void heatclosevalve();
void openvalve();
void receivedeal();
void receivedeal1();
void coolvalvecal();
void heatvalvecal();
void defrostdeal();
//void frecontrol();
void __interrupt IntDummy(void){
}
void __interrupt_n IntDummyN(void){
}
//
/******************************************************************************/
/* RAM definition */
/******************************************************************************/
//#define frxend _P3.ioram_bit.bit3
enum StateTag {cStop, cRun};
enum StateTag StateCh1; /* State of Ch1 */
enum StateTag StateCh2; /* State of Ch2 */
ram_field __tiny _flagcommu; /*commu FLAG AREA */
#define flagcommu _flagcommu.ram_byte
#define ftxenable _flagcommu.ram_bit.bit0 /*if ftxenable is high,enable sending,or receive*/
#define ftxbusy _flagcommu.ram_bit.bit1 /* if ftxbusy is 0,send process dosen't start*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -