完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
PIC32 MZ2048 EFH144MPLABX V3.35和谐编译器XC32(V1.42)优化:GCC01C++01ICD3 I开发了一种功率计和涡轮机控制使用PIC32 MZ。这有很多问题,但最近事情进展顺利。我被要求改变它,它包含了一个功率限制功能。因此,我创建了一个函数,并从我的PARSEDATA(int DataSet)函数调用它。为了便于处理,我将数据收集到数组中的一个元素中,同时解析另一个数组中已经收集到的数据。在ISR控制和定时器触发下,从六个ADC端口收集数据。当我写限制函数时,它有两种限制涡轮出口的方法,首先是Cap设定为最大允许值。第二个是作为电网电压的函数导出的。这似乎起作用了。我现在被要求实施一个由于高电网频率导致的出口限制,这是事情出了问题的地方。当IO改变了频率时,我得到了负载库的随机发射。在调试中,我得到了非常奇怪的结果。我已经追溯到两个简单的错误。当我将INT传递到极限函数空隙LimitExport(int DataSet){// /调用每一个网格周期一次时,数据集被报告为超出范围,但仅在函数的第一行之后。我用这个地址作为数组元素我可以使用,因为另一个元素正在被ADC ISR更新。然后,我做了一个全局var并保存过去的值给它,现在调试器可以看到正确的地址。现在我使用新的网格值,每次通过循环添加它们来累积11个读数。在11次循环中,我将累积值除以平均值。为了帮助在前一节中调试,使涡***率等于1100。为了帮助调试,我将+=变为只是=,正如您可以看到的分配PrimeAvaGePoWe= =(GrdPARAMEtiTER(1).ActuvEpWar);//在0.1kW的STEP中的总功率永远不会发生。在分配之后,我可以单步执行代码或设置制动点,但PrimeAvaPeWER对GRIDPARAMITER(1)有不同的值。ActuvPoWe我已经尝试将变量声明为静态的,但是这没有帮助。您能给我一个想法吗?我尝试从调试器屏幕上传图片,但在下面键入了这个错误。代码行PrimeAvaGePoWe= =(GrdPARAMETITER(1).ActuvPoW);//在0.1kW的STEPSORT点上的总功率设置在codeI GetPhaseAveragePower“地址=0x800×42C,PrimeAvaGePoWar=25067”GRIDP以上行之后。ActhITER(1).ActuvPosiver“地址=0x800 025f4,GrdPARAMITER(1).ActuvPosiver=1100”上载错误形式FoUMUU没有权限访问“http://www. McCys.com /论坛/上载.ASPX?”在这个服务器上。参考文献18.CDD3Del.1491813801.36B5028。
以上来自于百度翻译 以下为原文 PIC32MZ2048EFH144 MPLABX v3.35 HARMony Compiler XC32(v1.42) Optimization: gcc01c++01 ICD3 I have developed a power meter and turbine control using the PIC32MZ. This has had many problems but recently thing have been going OK. I have been asked to change this it incorporate a power limiting functionality. So I created a function and called it from my ParseData(int DataSet) function. To make things easier I collect my data into one element of an array while I am parsing the already collected data in the other array. Data is collected from six ADC ports under ISR control and timer to trigger. When I wrote the limiting function, it had two ways of limiting the turbine export, first was just a Cap set to maximum permitted. The second was derived as a function of Grid voltage. This seemed to work. I have now been requested to implement an export limed as a result of high grid frequency this is where things have gone wrong. AS IO changed the frequency I was getting a random firing of the load bank. In trying to debug I get very strange results. Which I have traced back to two simple errors. When I pass the int into limit function void LimitExport(int DataSet){ // called once every grid cycle The DataSet is reported as out of scope but only after the first line in the function. I use this as an address to which array element I can use as the other element is being updated by the ADC ISR. I then made a global var and saved the past value to it, now the debugger can see the proper address. Now I use the new grid values and each time through the loop add them to accumulate 11 readings. On the 11 time through the loop I divide the accumulated values to get an average. To help with debug in previous section a make Turbine power equal to 1100. To help debug I changed the += to just = and as you can see the assignment PhaseAveragePower = (GridParamiter[1].ActivePower); // total power in in 0.1kW steps never happens. I can single step through the code or set brake point after assignment but the PhaseAveragePower has a different value to GridParamiter[1].ActivePower I have tried declaring variable as static but this did not help Can you possibly give me an idea of what to try? I tried uploading picture from debugger screen but got this error below so typed it in. Line of code PhaseAveragePower = (GridParamiter[1].ActivePower); // total power in in 0.1kW steps Break point set after above line of code I Get PhaseAveragePower "Address = 0x8000042c, PhaseAveragePower =25067" GridParamiter[1].ActivePower "Address =0x800025f4, GridParamiter[1].ActivePower = 1100" Upload error form Forum You don't have permission to access "http://www.microchip.com/forums/upload.aspx?" on this server. Reference #18.cdd3dead.1491813801.36b5028 Attached Image(s) |
|
相关推荐
5个回答
|
|
没有所有的源代码,很难调试这些类型的错误。然而,我注意到25067正好是22倍1100。由于每次累积11个样本,看来25067是通过样本集的2个循环的结果。也许这会有助于孤立这个问题。
以上来自于百度翻译 以下为原文 Without all of the source code it is difficult to debug these types of errors. However, I did notice that 25067 is EXACTLY 22 times 1100. Since you are accumulating 11 samples at a time, it appears that the 25067 is the result of 2 loops through the sample sets. Maybe that will help isolate the problem. |
|
|
|
我得到1100×22=24200。在进行这种计算时,可能需要第二个变量来对总数进行计算,并为后续读数设置总计数为零。例如:在你的主要代码中,你可以使用“OLDUnt11/11”来进行平均阅读。
以上来自于百度翻译 以下为原文 I get 1100 * 22 = 24200. When doing this sort of calculation, you may need a second variable on which to perform the calculation on the total, and set the total count to zero for subsequent readings. Something like: unsigned long Total11; unsigned long OldTotal11; volatile int i=0; ADCISR() { Total11 += ADCreading; if(i >= 10) { OldTotal11 = Total11; Total11 = 0; i = 0; } } In your main code you can then just use "OldTotal11/11" for your average reading. |
|
|
|
哎呀。我的错。匆匆忙忙地用我的程序员计算器代替了科学计算器。1100×22=24200。忽略我的帖子。使用PestCh保罗。
以上来自于百度翻译 以下为原文 Oops. My bad. In a hurry and was using my programmers calculator instead of the scientific one. 1100*22 = 24200. Ignore my post. Use PStechPaul's. |
|
|
|
谢谢你的帮助,我已经解决了问题,正如你所料,这都是我的错。我有一个复杂的结构来保存读数。这是在一个文件中声明的,然后在另两个文件中声明为外部。当我更新这个时,我只更新了原件和一个外部数据,这就损坏了数据。我必须保存一些值到EEPROM,但我会提出一个单独的职位,谢谢你的时间。
以上来自于百度翻译 以下为原文 Thanks for your help I have solved the problem and as you would expect it was all my fault. I have a complex structure in which to save the readings. This is declared in one file and subsequently declared as external in another two files. When I updated this I only updated the original and one of the externals this was therefore corrupting the data. It all works fine now. I have to save some values to EEPROM but I will raise a separate post for that Thanks for your time. |
|
|
|
如果在头文件中定义了Stutter和EXTLN,那么在C文件中声明变量,那么您可以只在所有需要访问它的地方包含头。这样,你只有一个地方可以更新,所有使用它的地方都会使用正确的结构。John Vickers
以上来自于百度翻译 以下为原文 If you define your struct and extern in a header file, then declare your variable in your c file, then you can just include the header where the struct is in all the places that need access to it. That way you only have one place to update, and all the places that use it will always be using the correct structure. John Vickers |
|
|
|
只有小组成员才能发言,加入小组>>
5183 浏览 9 评论
2005 浏览 8 评论
1932 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3178 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2229 浏览 5 评论
739浏览 1评论
626浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
510浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
637浏览 0评论
535浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-28 00:13 , Processed in 1.312401 second(s), Total 87, Slave 70 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号