📄 att7027.lst
字号:
130 2 }
131 1 }
132 /****************************************************************************
133 电表寄存器经过转变为实际数据
134 函数原型:void EMU_Parameter_change1()
135 功能: 电表寄存器经过转变为实际数据
136 输入:
137 Read Calibration registers at att7027
138 addr:the address of the first register.
139 comm:the val which written to the registers.
140 ******************************************************************************/
141 void EMU_Parameter_change1()
142 {
143 1 unsigned char i;
144 1 unsigned long *PA1,*PA2;
145 1 unsigned long tempA;
146 1 ReadATT7027(0,(unsigned char*)Emu_Parameter.Current_Waveform_Spl_I1,sizeof(Emu_Parameter));//SIZE_OF(Emu
-_Parameter,Current_Waveform_Spl_I1)Emu_Parameter_change
147 1 PA1=&(Emu_Parameter.Current_Waveform_Spl_I1);
148 1 // *temp1= SIZE_OF(EEPROM_DATA,Apparent_Power_Gain_GS2);
149 1 //*temp1= sizeof(Emu_Parameter.Current_Waveform_Spl_I1);
150 1 //*temp1= SIZE_OF(Emu_Parameter.Current_Waveform_Spl_I1);
151 1 PA2=&(Emu_Parameter_change.Current_Waveform_Spl_I1);
152 1 for(i=0;i<3;i++)// Current_Waveform_Spl_I1 Current_Waveform_Spl_I2 Voltage Waveform_Spl_U;
153 1 {
154 2 if((*PA1)>=0x8000) //2^15
155 2 *PA2=(0x10000-(*PA1)); //2^16
156 2 else *PA2=*PA1;
157 2 PA1=PA1+1;
158 2 PA2=PA2+1;
159 2 }
160 1 for(i=0;i<3;i++)// Active_Power_Waveform_Spl_P
161 1 { //Reactive_Power_Waveform_Spl_Q Apparent Power Waveform_Spl_S ;
162 2 if((*PA1)>=0x800000) //2^23
163 2 *PA2=(0x1000000-(*PA1)); //2^24
164 2 else *PA2=*PA1;
165 2 PA1=PA1+1;
166 2 PA2=PA2+1;
167 2 }
168 1 for(i=0;i<3;i++)//Current_Rms_I1 Current_Rms_I2 Current_Rms_U;
169 1 {
170 2 tempA=(*(unsigned long*)&Emu_Parameter_change.EMU_Krms_Rms[i])>>16;
171 2 *PA2=((*PA1)*tempA);//Kp=5/234880*001000=2.1287466×10^(-4)
172 2 // PA=Emu_Parameter_change.EMU_Krms_Rms[i];
173 2 PA1=PA1+1;
174 2 PA2=PA2+1;
175 2 }
176 1 *PA2=(5529600/6/(*PA1))<<8; //femu =5529600Hz f=femu/6/UFREQ Current_Freq_U;
177 1 PA1=PA1+1;
C51 COMPILER V7.20 ATT7027 04/14/2007 11:59:58 PAGE 4
178 1 PA2=PA2+1;
179 1 for(i=0;i<3;i++)// Active_Power_P Reactive_Power_Q Apparent_Power_S;
180 1 {
181 2 if((*PA1)>=0x800000) //2^23
182 2 *PA1=0x1000000-(*PA1); //2^24
183 2 tempA=*(unsigned long*)&Emu_Parameter_change.EMU_Krms_Kpqs[i]>>16;//Kpqs=1000/51673=0.01935
184 2 //*temp2=(*temp1)*(*tempA);//P=Kpqs*Preg=0.01935*(-47820)= -925.3 w
185 2 *PA2=((*PA1)*(tempA));
186 2 PA1=PA1+1;
187 2 PA2=PA2+1;
188 2 }
189 1 for(i=0;i<3;i++)// Active_Energy_P Reactive_Energy Apparent_Energy_S;
190 1 {
191 2 tempA=*(unsigned long*)meter_para.MeterConstantReal;
192 2 *PA2=((*PA1)/(tempA));
193 2 PA1=PA1+1;
194 2 PA2=PA2+1;
195 2 }
196 1 }
197
198 /****************************************************************************
199 电表通过RS485communicate进行校表
200 函数原型:void Calibration_meter(void)
201 功能: 读RS485communicate数据放到mt_data指针指向电表校验寄存器要存放的地址中
202 输入:
203 Read Calibration registers at att7027
204 addr:the address of the first register.
205 comm:the val which written to the registers.
206 ******************************************************************************/
207 void Calibration_meter(void)
208 {
209 1 //unsigned char data_id;
210 1 //unsigned char cali_data[3];
211 1 /* data_id=rxdatabuffer[10];
212 1 //较表写命令
213 1 if((data_id>=0x41)&&(data_id<=0x48)||(data_id>=0x4A)&&(data_id<=0x4F))
214 1 {
215 1 cali_data[0]=rxdatabuffer[11];
216 1 cali_data[1]=rxdatabuffer[12];
217 1 // cali_data Data_ID write ram and ATT7027
218 1 WriteCALATT7027(data_id,&cali_data[0],2)
219 1 Write_EEPROM(2,&cali_data[0],(0x40+(data_id-1)*2));
220 1 }
221 1 //较表读电压电流
222 1 else if((data_id==0x0F)||(data_id==0x10))
223 1 {
224 1 rxdatabuffer[9]=6;
225 1 rxdatabuffer[8]+=0x40;
226 1
227 1 //返回数据在10-15
228 1 if(data_id==0x0F)
229 1 {
230 1 rxdatabuffer[10]=*((unsigned char *)&Emu_Parameter.Current_Rms_I1+2);
231 1 rxdatabuffer[11]=*((unsigned char *)&Emu_Parameter.Current_Rms_I1+3);
232 1 }
233 1 else if(data_id==0x10)
234 1 {
235 1 rxdatabuffer[10]=*((unsigned char *)&Emu_Parameter.Current_Rms_I2+2);
236 1 rxdatabuffer[11]=*((unsigned char *)&Emu_Parameter.Current_Rms_I2+3);
237 1 }
238 1 else
239 1 {
C51 COMPILER V7.20 ATT7027 04/14/2007 11:59:58 PAGE 5
240 1 rxdatabuffer[10]=*((unsigned char *)&Emu_Parameter.Current_Rms_U+2);
241 1 rxdatabuffer[11]=*((unsigned char *)&Emu_Parameter.Current_Rms_U+3);
242 1 }
243 1 }
244 1 //错误命令回错误应答
245 1 else
246 1 {
247 1 rxdatabuffer[9]=1;
248 1 rxdatabuffer[8]+=0x40;
249 1 }
250 1 */
251 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 950 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- 41
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -