完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
大家好,我已经写了一些代码,看一个称为位置的子例程的输出,它返回一个浮点P。这个浮标被与一个叫做FRORORSELSET子程序的其他输入进行比较,我让这些FroRoSLead选项对应于浮点(F1,F2和F3)。其中,“地板”P最接近.FY.位置子程序是ADC中的一个输出,并将其转换成米的测量值。在构建时,我得到了下面的“非空洞函数结束时的隐式返回”。ENT if语句。代码是相当基本的,可以更流利的提示,将不胜感激。
以上来自于百度翻译 以下为原文 Hello All, I have written some code, to look at the output of a subroutine called position, which returns a float p. This float is compared to other input from a subroutine called floor_select, I have made these floor_select options correspond to floats (f1,f2 and f3) . A calculation is made to determine which "floor" the p is closest to. FYI the position subroutine is an out put from an ADC and converts its to a measurement in meters. I have been getting the following when building, "Implicit return at end of non-void function" I have a general understanding that it might be do to with the 3 different if statements. The code is fairly basic and could be more eloquent Any hints would be greatly appreciated. short Floor_Comparision (float p) { position; //Runs position subroutine to gain a value of the float "p" float diff; //Float "diff" being the difference between selected floor and position "p" short w; int floor_selected; float floor_level; //Tolerance and Individual Floor Floats float tole = 0.0125; //Allowable tolerance difference of +/- 0.0125 meters float f1 = 0.0000; //Floor 1 Float of 0.0000 Meters float f2 = 3.0000; //Floor 2 Float of 3.0000 Meters float f3 = 6.0000; //Floor 3 Float of 6.0000 Meters //For the particular floor_select short int //A corresponding "floor_level" is given as a float if (floor_selected == 1) { floor_level == f1; } if (floor_selected == 2) { floor_level == f2; } if (floor_selected == 3) { floor_level == f3; } //Comparison Calculation floor_level - p == diff; //Requested floor height - current height = difference in height //Either a positive or negative number if (diff > 0.125) //If Difference is greater than +0.0125m { //Requested floor height is higher current position w = 1; //Set w =1 (Lift Run and Up-wards ) return w; } if (diff < -0.125) //If Difference is less than -0.0125m { //Requested floor height is lower current position w = 2; //Set w =2 (Lift Run and Down-wards ) return w; } if (-0.125 <= diff <= 0.125) //If Difference is greater than or equal to -0.0125m { //Or Difference is less than or equal to +0.0125m w = 0; //Set w =0 (Lift Stop) return w; } } |
|
相关推荐
7个回答
|
|
我不知道如果没有“IF”条件会发生什么?
以上来自于百度翻译 以下为原文 I wonder what happens if none of the "if" conditions are met ? |
|
|
|
“如果(-0.125& lt;=diff& lt;=0.125)/ /如果差值大于或等于-0.0125M”,我认为这并不是OP认为它所做的。看起来有点像BASIC。
以上来自于百度翻译 以下为原文 "if (-0.125 <= diff <= 0.125) //If Difference is greater than or equal to -0.0125m" I don't think this does what the OP thinks it does either. Looks a bit like BASIC. |
|
|
|
重写该代码,使最终返回为W.例如(x=1)w=7;否则,如果(x=2)w=11;否则w=13;返回w;
以上来自于百度翻译 以下为原文 Rewrite the code so that the final return is w. e.g. if (x==1) w=7; else if(x==2) w=11; else w=13; return w; |
|
|
|
|
|
|
|
它在最后一个岗位,但不是第一个。(打开完整版)
以上来自于百度翻译 以下为原文 It did on the last post but not the first. (open full version) |
|
|
|
他应该为作业的答案做点工作。
以上来自于百度翻译 以下为原文 he should have to work a little for the answer to his homework. |
|
|
|
“非空洞函数结束时的隐式返回”应该是:“非空洞函数结束时的预期隐式返回”
以上来自于百度翻译 以下为原文 "Implicit return at end of non-void function" Should really be: "Expected implicit return at end of non-void function" |
|
|
|
只有小组成员才能发言,加入小组>>
5231 浏览 9 评论
2026 浏览 8 评论
1950 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3200 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2253 浏览 5 评论
771浏览 1评论
659浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
588浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
669浏览 0评论
571浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-19 14:37 , Processed in 1.726836 second(s), Total 90, Slave 73 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号