完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
您好,我试图确保电压电位器如何得到错误的电压(甚至得到负电压)显示在LCD上,这是代码和顶部设计:
有什么想法,为什么我会得到错误的电压? 以上来自于百度翻译 以下为原文 hello I am trying to meassure voltage across potentiometer how ever i get the wrong voltage (and get even negetiv Voltage ) that displayes on the LCD , here is the code and top design : any ideas why am i getting the wrong voltage ? |
|
相关推荐
23个回答
|
|
|
尝试用调试器检查值是否真的是负的。
在StaveFF()中尝试使用“%LD”格式 鲍勃 以上来自于百度翻译 以下为原文 Try with debugger to check if values are really negative. Try using "%ld" format in sprintf() Bob |
|
|
|
|
|
我没有理解你的意思。你是什么意思? 以上来自于百度翻译 以下为原文 i did not undestand what do you mean . and what do you mean ? |
|
|
|
|
|
你能把你的完整的项目,我们都可以在你所有的设置,一看。为此,使用 创建者-gt;文件& gt;创建工作区束(最小) 并附加生成的文件。 鲍勃 以上来自于百度翻译 以下为原文 Can you please post your complete project so that we all can have a look at all of your settings. To do so, use Creator->File->Create Workspace Bundle (minimal) and attach the resulting file. Bob |
|
|
|
|
|
嗨,鲍勃,我找不到附件文件 以上来自于百度翻译 以下为原文 hi bob i cant find the attach file butten |
|
|
|
|
|
在“使用高级编辑器点击”(右上角)和一个“高度”会(在右下角)。 你使用哪一个柏树套件?CY8CKIT-???? 鲍勃 以上来自于百度翻译 以下为原文 Click on "Use advanced Editor" (upper right hand corner) and an "Attach" will come up (at lower right corner). Which Cypress kit are you using? CY8CKIT-??? Bob |
|
|
|
|
|
我使用PSoC 5 LP097 电容电压 539.8 K 以上来自于百度翻译 以下为原文 i am using psoc 5 lp097
|
|
|
|
|
|
我看不出你的电位器连接在哪里,但我假设是GND和+5V。 ADC被配置为输入范围为1到2V,这将在飞行时产生不可预测的结果。您冷尝试设置输入范围为6 * Vref。 鲍勃 以上来自于百度翻译 以下为原文 I cannot see where your potentiometer is connected to, but I assume beween GND and +5V. The ADC is configured for an input range of 1 to 2V which will give unpredictable results when overflown. You cold try setting the input range to 6*Vref. Bob |
|
|
|
|
ncmza 发表于 2018-10-19 19:32 我试着换成6VRF,但是电压仍然是正确的。 以上来自于百度翻译 以下为原文 i tried changing to 6Vref yet the voltage is still in correct |
|
|
|
|
|
你好。我不知道你为什么要使用DAC。这将导致你得到否定的结果,这取决于DAC的输出电压和测量的电压。 要检查您的设置和程序,请尝试使用单端模式的ADC,并检查组件配置中定义的测量范围。 我在每一个设计中都使用ADC,并且没有问题,从正弦波测量RMS值到9 MUX输入到ADC以进行各种外部测量和过采样,以获得4个附加的PTE100温度测量用线长度补偿的分辨率。 当做 克里斯 以上来自于百度翻译 以下为原文 Hi. I am not sure why you are using the DAC. This would cause you to get negative results, depending on the DAC output voltage and the measured voltage. To check your setup and program, try using the ADC in single ended mode and check the measurement range as defined in the component configuration. I use an ADC in just about with every design and have no issues, from sine wave measurement for RMS values to 9 mux inputs into the ADC for various external measurements and oversampling to get 4 additional bits of resolution for PT100 temperature measurements with wire length compensation. Regards Chris |
|
|
|
|
60user33 发表于 2018-10-19 20:07 嗨,我试过你所说的,把ADC放在单端,写下这个代码: / ***************************************************************************************************** *文件名: * *版本:2.20 * *描述: *这是一个源代码,例如ADC单端模式的项目。 * *可变电阻(POT)连接到+VE输入ADC使用I/O引脚。 *P0.0。当ADC的正端子电压为0时,输出显示。 *在液晶屏上是0x000。正端子上的电压继续 *增加值,转换值从0x000增加到 当电压变为1.024V时,电压值进一步增加, *不会对LCD中显示的值造成任何更改。 * *硬件连接: *将模拟输入从可变电阻器连接到DVK1板端口P0〔0〕。 * ***************************************************************************************************************************************************************************************** *赛普拉斯半导体公司2012-2015版权所有。版权所有。 *该软件由赛普拉斯半导体公司所有,并受到保护。 *受世界专利和著作权法和条约的约束。 因此,您只能使用许可协议中所提供的软件。 *伴随着软件包,从中获得了这个软件。 *赛普拉斯及其供应商不作任何保证,明示或默示, *关于该软件,包括但不限于不侵权, *对适销性和适合特定用途的默示保证。 *** 项目包括: 包括: / ***************************************************************************************************** *函数名:主 ***************************************************************************************************************************************************************************************** * *摘要: *()执行以下功能: * 1:初始化LCD * 2:启动ADC * 3:开始ADC对话。 * 4:获取转换后的结果并显示在LCD中。 * *参数: 没有。 * *返回: 没有。 * *** int() { 32输出; *启动组件*/ LCDX START(); AdcDeligy11StIX(); *开始ADC转换*/ AdcDeligy11SistCurror(); *显示液晶显示器上ADC输出的值* LCDI位置(0U,0U); LCDApReltScript(“ADCX输出”); (;) { 如果(AdcDelsiGui1i ISEN转换(AdcDelsiGy11ReTurnSytStand)) { 输出=ADCJ-DELSIGLY1GETRESULT32(); /*饱和ADC结果为正数。*/ 如果(输出& lt;0) { 输出=0; // CyDelay(100U); } LCDI位置(1U,0U); LCDA PrimtIn16((UTIM16)输出); CyDelay(500 U); //LCD-CHARAL PrimtNoT((UTI16)输出); //LCDA CHARAL PRUTUT32号((UIT32)输出); } } } /*[]文件结束*/ 问题是,我再次得到错误的编号,它是用ASCII代码编写的。 以上来自于百度翻译 以下为原文 hi I tried what you said and put the ADC on single ended and wrote this code : /******************************************************************************* * File Name: main.c * * Version: 2.20 * * Description: * This is a source code for example project of ADC single ended mode. * * Variable resistor(pot) is connected to +ve input of ADC using the I/O pin. * P0.0. When voltage to positive terminal of ADC is 0, the output displayed * on the LCD pannel is 0x0000. As voltage on positive terminal goes on * increasing, the converted value goes on increasing from 0x0000 and reaches * 0xFFFF when voltage becomes 1.024V. Futher increase in voltage value, * doesn't cause any changes to values displayed in the LCD. * * Hardware Connections: * Connect analog input from Variable resistor to port P0[0] of DVK1 board. * ******************************************************************************** * Copyright 2012-2015, Cypress Semiconductor Corporation. All rights reserved. * This software is owned by Cypress Semiconductor Corporation and is protected * by and subject to worldwide patent and copyright laws and treaties. * Therefore, you may use this software only as provided in the license agreement * accompanying the software package from which you obtained this software. * CYPRESS AND ITS SUPPLIERS MAKE NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * WITH REGARD TO THIS SOFTWARE, INCLUDING, BUT NOT LIMITED TO, NONINFRINGEMENT, * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. *******************************************************************************/ #include #include /******************************************************************************* * Function Name: main ******************************************************************************** * * Summary: * main() performs following functions: * 1: Initializes the LCD * 2: Starts ADC * 3: Starts ADC converstion. * 4: Gets the converted result and displays it in LCD. * * Parameters: * None. * * Return: * None. * *******************************************************************************/ int main() { int32 output; /* Start the components */ LCD_Start(); ADC_DelSig_1_Start(); /* Start the ADC conversion */ ADC_DelSig_1_StartConvert(); /* Display the value of ADC output on LCD */ LCD_Position(0u, 0u); LCD_PrintString("ADC_Output"); for(;;) { if(ADC_DelSig_1_IsEndConversion(ADC_DelSig_1_RETURN_STATUS)) { output = ADC_DelSig_1_GetResult32(); /* Saturate ADC result to positive numbers. */ if(output < 0) { output = 0; // CyDelay(100u); } LCD_Position(1u, 0u); LCD_PrintInt16((uint16)output); CyDelay(500u); // LCD_Char_PrintNumber((uint16)output); // LCD_Char_PrintU32Number((uint32) output); } } } /* [] END OF FILE */ and the problem is that i get wrong numers again , and it is written in ASCII code |
|
|
|
|
ueywyrsdfs 发表于 2018-10-19 20:15 您好! 几个问题。 ADC设置了多少位?选择什么转换率?选择哪一个输入范围?选择什么缓冲区增益?在你设计范围内的资源中,选择了什么电压?请张贴一些结果,这样我就可以明白你所说的错误的价值是什么意思。 实际上,请发布你的项目,然后我有所有的信息。 如果我有机会,我会把代码放在我的一个工具包上,看看我得到了什么。 克里斯 以上来自于百度翻译 以下为原文 Hi A few questions.
Actually, please post your project, then I have all the info. If I get a chance, I will put the code on one of my kits to see what I get. Chris |
|
|
|
|
60user33 发表于 2018-10-19 20:27 您好! 作为CY8CITK- 050下载的一部分,还有一个DeltasigMA ADC使用的好例子,具有过滤和显示功能。 当做 克里斯 以上来自于百度翻译 以下为原文 Hi As part of the CY8CKit -050 download, there is also a nice example of the DeltaSigma ADC usage, with filtering and display. Regards Chris |
|
|
|
|
60user33 发表于 2018-10-19 20:27 这是我的项目下载。 AdcSunLeNeDeNoD01.CyWrk.CaseV01.Zip 533.9 K 以上来自于百度翻译 以下为原文 here is my project download. |
|
|
|
|
|
似乎需要使用LCDApReltIt32和输入范围= VSSA到VDDA。 AdcSunLeNDENDEMOD01.ZIP 24.1 K 以上来自于百度翻译 以下为原文 It seems necessary to use LCD_PrintInt32 and input range = Vssa to Vdda.
|
|
|
|
|
chenzhenbo1984 发表于 2018-10-19 21:03 您好! 可以将测量范围更改为组件配置中的任何允许范围。你只需要保持输入电压在这个范围内以获得适当的输出。 当在单端模式下使用ADC时,对于结果也使用无符号整数,否则,当您使用16位结果的16位变量时,当达到一半的输入电压时,就会得到负值。所以在选择位数分辨率和可变大小时,请记住这一点。 如果在8位模式下使用ADC,可以使用LCDApReltIt8,9至16位,LCDApReltIt16和16位以上,必须使用LCDApReltIt32。还将结果变量与所需的位大小相匹配。你可以使用一个更大的变量,尽管它没有很好的用途。 关于增益设置的进一步说明。请记住,如果将增益应用于输入,则通过增益因子来减小输入测量范围。当输入噪声被放大以及放大器噪声增加时,你也会给ADC输入增加更多的噪声。对于非常敏感的测量,如称重传感器、PT100和其他仪器,这可能变得重要。 在IIR上有一个非常好的APP注释(AN2099),用于将转换结果平均化以得到结果。它提供了按原样工作的代码,或者您可以将代码更改为适合您自己的应用程序。 如果你有一个没有DeltasigMA ADC的PSoC,并且需要更好的解决你的SAR ADC,你总是可以过采样和平均。我已经成功地在SAR上实现了16位。AN118提供了它背后的理论。 我希望你能找到以上有用的东西。 当做 克里斯 以上来自于百度翻译 以下为原文 Hi You can change the measurement range to any of the allowed ranges in the component configuration. You just have to keep the input voltage within that range to get appropriate outputs. When using the ADC in single-ended mode, also use unsigned integers for the result, otherwise you get negative values when you get to half your input voltage if you use a 16-bit variable for a 16-bit result. So just keep it in mind when selecting the number of bits resolution and variable size. If you use the ADC in 8-bit mode, you can use LCD_PrintInt8, For 9 to 16 bits, LCD_PrintInt16 and above 16-bits, you have to use LCD_PrintInt32. Also match your result variable to the bit size required. You can always use a larger variable, although it does not serve much of a purpose. A further note on the gain setting. Keep in mind that if you apply gain to the input, you reduce the input measurement range by the gain factor. You also add more noise to the ADC input as the input noise is amplified as well as adding the amplifier noise. For very sensitive measurements, like load cells, PT100's and other instrumentation, this can become significant. There is a very good app note (AN2099) on IIR for use in averaging conversion results to average your results. It provides code that works as is or you can change it to suit your own application. if you have a PSoC without the DeltaSigma ADC and need better resolution out of your SAR ADC, you can always oversample and average. I have very successfully achieved 16-bits on the SAR. AN118 provides the theory behind it. I hope you find the above useful. Regards Chris |
|
|
|
|
chenzhenbo1984 发表于 2018-10-19 21:03 首先感谢您的帮助,我尝试了您的代码,我得到了一个输出电压的决心如何输出电压是错误的EXMPLAE电压在0.3-4.01V之间(上引脚到地面,第二引脚去Vdd的PSoC 5)。但是我的电压是0.5-4.9V。你知道为什么我会再次得到错误的值吗? 以上来自于百度翻译 以下为原文 first of all thank you for your help and I tried your code ,i got a resolt of the output voltage how ever the output voltage was wrong for exmplae the voltage are between 0.3-4.01v ( on pin goes to the ground and the second pin goes to Vdd of the Psoc 5 ) . but i get voltages of 0.5-4.9v. do you have idea why am i I getting the wrong value again ? |
|
|
|
|
ueywyrsdfs 发表于 2018-10-19 21:24 查看此文档: AN68 403-PSoC®3和PSoC 5LP模拟信号链校准 以上来自于百度翻译 以下为原文 View this document: AN68403 - PSoC® 3 and PSoC 5LP Analog Signal Chain Calibration |
|
|
|
|
chenzhenbo1984 发表于 2018-10-19 21:03 嗨,你的代码,仍然给我错误的答案。我需要添加LP过滤器吗? 以上来自于百度翻译 以下为原文 hi itreid your code and still gives me the wrong answer . maeby i need to add LP filter ? |
|
|
|
|
|
我希望你使用ADCJStOffice(); 在LCD上显示,就足够平均结果。 我的旧项目有一个简单的移动平均值:电压显示平均值41.Zip 以上来自于百度翻译 以下为原文 I hope you used ADC_SetOffset (); and ADC_SetGain (); For display at LCD, it is sufficient to average the result. My old project with a Simple Moving Average: VoltageDisplayMean41.zip |
|
|
|
|
只有小组成员才能发言,加入小组>>
787个成员聚集在这个小组
加入小组cyUSB3014一直显示2.1,不能到3.0情况,谁遇到过
7315 浏览 0 评论
2484 浏览 1 评论
2178 浏览 1 评论
4042 浏览 1 评论
请问可以直接使用来自FX2LP固件的端点向主机FIFO写入数据吗?
2087 浏览 6 评论
CY8C4025LQI在程序中调用函数,通过示波器观察SCL引脚波形,无法将pin0.4(SCL)下拉是什么原因导致?
7804浏览 2评论
CYUSB3065焊接到USB3.0 TYPE-B口的焊接触点就无法使用是什么原因导致的?
6367浏览 2评论
CX3连接Camera修改分辨率之后,播放器无法播出camera的画面怎么解决?
757浏览 2评论
729浏览 2评论
使用stm32+cyw43438 wifi驱动whd,WHD驱动固件加载失败的原因?
8210浏览 2评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-12 04:53 , Processed in 1.110215 second(s), Total 80, Slave 73 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
4583