📄 ct_monitor.lst
字号:
##############################################################################
# #
# IAR MSP430 C/C++ Compiler V3.21A/W32 [Kickstart] 19/Sep/2005 17:10:33 #
# Copyright 1996-2004 IAR Systems. All rights reserved. #
# #
# __rt_version = 2 #
# __double_size = 64 #
# __reg_r4 = free #
# __reg_r5 = free #
# __pic = no #
# __core = 64kb #
# Source file = D:\WILLFARwork\CT项目\CT开短路MSP430\程序\1A_Check_200 #
# 50906\CT_monitor.c #
# Command line = -I "D:\Program Files\IAR Systems\Embedded Workbench #
# 4.0\430\INC\" -I "D:\Program Files\IAR #
# Systems\Embedded Workbench 4.0\430\INC\DLIB\" -lC #
# D:\WILLFARwork\CT项目\CT开短路MSP430\程序\1A_Check_200 #
# 50906\Debug\List\ -la D:\WILLFARwork\CT项目\CT开短路MS #
# P430\程序\1A_Check_20050906\Debug\List\ -o #
# D:\WILLFARwork\CT项目\CT开短路MSP430\程序\1A_Check_200 #
# 50906\Debug\Obj\ -z3 --no_cse --no_unroll --no_inline #
# --no_code_motion --no_tbaa --library_module #
# --module_name= --debug -e --double=64 --dlib_config #
# "D:\Program Files\IAR Systems\Embedded Workbench #
# 4.0\430\LIB\DLIB\dl430dn.h" #
# D:\WILLFARwork\CT项目\CT开短路MSP430\程序\1A_Check_200 #
# 50906\CT_monitor.c #
# List file = D:\WILLFARwork\CT项目\CT开短路MSP430\程序\1A_Check_200 #
# 50906\Debug\List\CT_monitor.lst #
# Object file = D:\WILLFARwork\CT项目\CT开短路MSP430\程序\1A_Check_200 #
# 50906\Debug\Obj\CT_monitor.r43 #
# #
# #
##############################################################################
D:\WILLFARwork\CT项目\CT开短路MSP430\程序\1A_Check_20050906\CT_monitor.c
1 //CT检测子程序
2 #include "msp430x13x.h"
3 #include "math.h"
4
5 unsigned int CTA_init_data=1313,CTB_init_data=1188,CTC_init_data=900; //三相的初始化数据
6 #define JDQA_ON 0x40
7 #define JDQA_OFF !JDQA_ON
8 #define JDQB_ON 0x20
9 #define JDQB_OFF !JDQA_ON
10 #define JDQC_ON 0x10
11 #define JDQC_OFF !JDQA_ON
12
13 #define kai_lu_state 3000 //开路状态特征值,如果当前数据减初始数据大于此值则认为CT开路
14 #define duan_lu_state 14000 //如果当前值加上此数据还小于初始值则认为此相短路
15
16 unsigned char one_CT_state=0; //一次CT状态字
17
18 unsigned char two_CT_state=0; //二次CT状态字
19 //位 : 7 6 5 4 3 2 1 0
20 //定义: 未定义 未定义 C相开路 B相开路 A相开路 C相短路 B相短路 A相短路
21 #define CTA_duan_lu_ON 0x01
22 #define CTA_duan_lu_OFF 0xfe
23 #define CTB_duan_lu_ON 0x02
24 #define CTB_duan_lu_OFF 0xfd
25 #define CTC_duan_lu_ON 0x04
26 #define CTC_duan_lu_OFF 0xfb
27
28 #define CTA_kai_lu_ON 0x08
29 #define CTA_kai_lu_OFF 0xf7
30 #define CTB_kai_lu_ON 0x10
31 #define CTB_kai_lu_OFF 0xef
32 #define CTC_kai_lu_ON 0x20
33 #define CTC_kai_lu_OFF 0xdf
34
35 unsigned char kai_lu,duan_lu;
36 unsigned char ICC; //电流大小判断
37 unsigned int CT_check_data_a;
38 unsigned int CT_check_data_b;
39 unsigned int CT_check_data_c;
40
41 unsigned int CT_current_A,CT_current_B,CT_current_C;
42
43 extern void init_time_a (void); //初始化TIMEA 处于增计数模式
44 extern void init_time_b (void);
45 extern unsigned int time_b_count; //TA中断时TB的计时数值
46 extern unsigned int TA_int_count; //TA中断的次数
47 extern unsigned char data_chang; //检测数据更新标志
48 extern unsigned char TB_over; //TB超时标志
49
50 extern unsigned char temp_H,temp_M,temp_L;
51 extern unsigned char temp_aH,temp_aM,temp_aL,temp_bH,temp_bM,temp_bL,temp_cH,temp_cM,temp_cL;
52 extern void hex_to_dec(unsigned long int a);
53
54
55 void delay_ns (unsigned char n)
56 { unsigned char a,b;
57 for (;n>0;n--)
58 { clr_wdt();
^
Warning[Pe223]: function declared implicitly
59 for(a=200;a>0;a--)
60 for(b=10;b>0;b--);
61 }
62 }
63
64
65 //**************************************************************//
66 void JDQ(unsigned char n,unsigned char ON_OFF) //n 表明要吸合哪一路继电器 1:A相 2:B相 3:C相
67 { //ON_OFF 表明是要吸合还是断开继电器 1:吸合 0:断开
68 if(ON_OFF==1)
69 {
70 switch (n)
71 {
72 case 1 : P4OUT|=JDQA_ON;
73 break;
74 case 2 : P4OUT|=JDQB_ON;
75 break;
76 case 3 : P4OUT|=JDQC_ON;
77 break;
78 default: break;
79 }
80 }
81 if(ON_OFF==0)
82 {
83 switch (n)
84 {
85 case 1 : P4OUT&=JDQA_OFF;
86 break;
87 case 2 : P4OUT&=JDQB_OFF;
88 break;
89 case 3 : P4OUT&=JDQC_OFF;
90 break;
91 default: break;
92 }
93 }
94 }
95 //**************************************************************
96
97 unsigned int load_CT_data(unsigned a) //返回N次CT检测数据的平均值
98 {
99 unsigned int d;
100 unsigned char c;
101 unsigned long int s=0;
102 c=a;
103 while(!data_chang) clr_wdt(); //当数据没有更新时等待
^
Warning[Pe223]: function declared implicitly
104 data_chang=0; //复位数据更新标志,重新读取一次CT检测数据
105 for(;c>0;c--)
106 {
107 while(!data_chang) clr_wdt();
108 s=s+time_b_count;
109 data_chang=0;
110 }
111 d=s/a;
112 return d;
113
114 }
115
116 void save_all_CT_data(void) //保存三相CT的初始化数据
117 {
118 }
119
120 void CT_one_check(unsigned char n) //检测单相的CT状态
121 { unsigned int a,b,c; //n表明检测哪一相CT: 1:A相 2:B相 3:C相
122 //delay_ns(50);
123 JDQ(1,1); //闭合继电器
124 delay_ns(100);
125 a=load_CT_data(3);
126 JDQ(1,0);
127 delay_ns(50);
128
129 JDQ(2,1); //闭合继电器
130 delay_ns(100);
131 b= load_CT_data(3);
132 JDQ(2,0);
133 delay_ns(50);
134
135 JDQ(3,1); //闭合继电器
136 delay_ns(100);
137 c=load_CT_data(3);
138 JDQ(3,0);
139 delay_ns(50);
140
141 CT_check_data_a=a;
142 CT_check_data_b=b;
143 CT_check_data_c=c;
144
145 hex_to_dec(CT_check_data_a);
146 temp_aH=temp_H;
147 temp_aM=temp_M;
148 temp_aL=temp_L;
149 hex_to_dec(CT_check_data_b);
150 temp_bH=temp_H;
151 temp_bM=temp_M;
152 temp_bL=temp_L;
153 hex_to_dec(CT_check_data_c);
154 temp_cH=temp_H;
155 temp_cM=temp_M;
156 temp_cL=temp_L;
157
158
159 two_CT_state=0;
160 if((c<1000)&&(c>50))
161 two_CT_state|=CTC_duan_lu_ON;
162 if(((a<1000)&&(a>50))||((b<1000)&&(b>50)))
163 {
164 two_CT_state|=CTA_duan_lu_ON;
165 two_CT_state|=CTB_duan_lu_ON;
166 }
167 if(((a>4000)&&(a<8000))||((b>4000)&&(b<8000)))
168 {
169 two_CT_state|=CTA_kai_lu_ON;
170 two_CT_state|=CTB_kai_lu_ON;
171 }
172 if((c>4000)&&(c<8000))
173 two_CT_state|=CTC_kai_lu_ON;
174 }
175
176
177
178
179
180 void CT_all_check(void) //检测三相CT的状态,并将状态写入CT_state
181 { init_time_a();
182 init_time_b();
183 CT_one_check(1);
184 CT_one_check(2);
185
186 }
^
Warning[Pe001]: last line of file ends without a newline
Errors: 1
Warnings: 3
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -