1
完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嗨,我正在使用PIC16F1778上的ADC通道来读取一个坩埚值(简单的分压器,引脚1到地,引脚2到ADC,引脚3到5V)。我注意到这些值是相当摇摆的,这意味着它们会粘在一个0V或大约5V左右。我用一个作用域检查了这个值,我看到了电压的这种情况。对于一半的锅的范围,它粘附到一个值附近的地面,然后另一半它附着到一个值在5V附近。这是怎么回事?它扰乱了我的应用程序中参数控制的范围。有没有办法我应该缓冲罐让它与ADC一起工作?
以上来自于百度翻译 以下为原文 Hi, I am using an ADC channel on the PIC16F1778 to read a pot value (simple voltage divider, pin 1 to ground, pin 2 to ADC, pin 3 to 5v). I noticed the values were fairly swingy, meaning that they would cling to around a 0v or around 5v. I checked this with a scope and I see this literally happening to the voltage. For half the pot's range it clings to a value near ground, then for the other half it clings to a value near 5v. What is going on here? It's messing up the range of a parameter control in my application. Is there some way I should be buffering the pot to make it work with the ADC? |
|
相关推荐
11个回答
|
|
我怀疑你没有把PIN作为相关的TrISX寄存器中的一个输入。我也怀疑你是在使用PORTX寄存器而不是匹配的LATX寄存器在同一个端口上写入其他的位。同时,确保在ANSELX寄存器中PIN处于模拟模式。如果不是这些原因之一。S,然后Puress显示你正在谈论的是哪一个PIN。
以上来自于百度翻译 以下为原文 I suspect you have not set the pin as an input in the relevant TRISx register. I also suspect you are writing to other bits in the same port using the PORTx register rather than the matching LATx register. Also make sure the pin is in analog mode in the ANSELx register. If it's not one of those reasons, then plese reveal WHICH PIN it is you're talking about. |
|
|
|
是的,我想你是对的。我误读了文档的相关部分并设置了TrccBist.RC3=0(PIN i使用),当它应该是1时。Pin被配置为模拟,所以这绝对是问题所在。
以上来自于百度翻译 以下为原文 Yes, I think you are right. I had misread the relevant part of the documentation and set TRISCbits.RC3 = 0 (pin I am using) when it should be = 1. Pin is configured as analog so that is definitely the issue. |
|
|
|
请注意我对LATX V PORTX的评论。不要通过写入PotocBIT来控制PORTC中的其他位。RCx,而是写入LATCITS.LATCX。
以上来自于百度翻译 以下为原文 Note my comments about LATx v PORTx also. Do NOT control other bits in PORTC by writing to PORTCbits.RCx, instead, write to LATCbits.LATCx. |
|
|
|
好吧,PORTC寄存器和LATC寄存器有什么区别?这对我来说并不完全清楚。
以上来自于百度翻译 以下为原文 Okay what is the difference between the PORTC register and LATC register? That is not exactly clear to me. |
|
|
|
写入端口实际上写入锁存器(LAT)。但是从端口读取来自引脚。这对端口寄存器端口上的位操作是重要的是读、修改和写回,并且这种读修改写可能导致问题。最好总是在LAT寄存器上写或做位操作,你甚至不必考虑RMW问题。
以上来自于百度翻译 以下为原文 Writes to PORT actually write to the latch (LAT). But reads from PORT come from the pin. This is significant on bit operations on the PORT register - PORT is read, modified, and written back, and this read-modify-write can cause problems. Best to always write or do bit operations on the LAT register and you don't have to even think about RMW problems. |
|
|
|
好吧,这有道理。因此端口读取PIN的状态,然后根据需要改变LAT来改变PIN的状态。而LAT直接改变引脚上的闩锁电压正在做什么。这似乎是正确的理解吗?此外,将相关的TRIS寄存器位设置为1,解决了我所面临的问题。谢谢你的解答!
以上来自于百度翻译 以下为原文 Okay that sort of makes sense. So PORT reads the state of the pin, then changes the LAT as necessary to change the state of the pin. Whereas LAT directly changes what the Latch voltage on the pin is doing. Does that seem like a correct understanding? Also, setting the relevant TRIS register bits to 1 solved the issue I was having. Thank you qɥb for that solution! |
|
|
|
两个操作都写入内部锁存器,差异是在修改一个比特之前读取的值。当TIS错误时,它报告的高或低的副作用对我来说是一个红旗,在您的代码的其余部分中存在RMW问题。
以上来自于百度翻译 以下为原文 Close enough. Both operations write to the internal latch, the difference is in the value read before modifying one bit. The reported side effect, of it clamping high or low when TRIS was wrong, is a red flag to me that you have RMW problems in the rest of your code. |
|
|
|
在这种情况下,RMW问题会是什么样子?正如我所说的,我的问题是通过改变这一点来解决的。
以上来自于百度翻译 以下为原文 What would RMW problems look like in this case? As stated my issue got resolved by changing that bit. |
|
|
|
R-M W表现出几种方式。更改端口上的位会导致其他位发生变化。2。销钉的快速变化有时被忽略,但不是其他的。3。其他奇怪的症状。(如果引脚被加载,或者设置为模拟模式,它将工作)
以上来自于百度翻译 以下为原文 R-M-W shows up several ways 1. changing a Bit on a Port causes other bits to change. 2. rapid changes on a Pin are ignored sometimes, but not others. 3. other odd symptoms. (ie it will but work if the pin is loaded, or set to analog mode) |
|
|
|
当仍然处于输出模式时,PIN将保持在接近地面或VDD,它不会“啪嗒啪嗒”地靠近最近的轨道。事实上,它确实表明您正在编写代码中其他地方的PORTX寄存器。如果你使用RMW安全写,它就不会改变。
以上来自于百度翻译 以下为原文 While still in output mode, the pin would have stayed close to ground or VDD, it wouldn't have "snapped" to the nearest rail. The fact that it did indicates you were writing to PORTx registers elsewhere in your code. If you'd been using RMW safe writes, it wouldn't have changed. |
|
|
|
这取决于“锅子”是如何连接的——如果它是直接供给轨道的,那么刮水器可以将输出引脚与“相反”状态进行战斗,直到RMW操作发生。只是猜测,没有来自OP. Susan的任何实际信息。
以上来自于百度翻译 以下为原文 It depends on how the 'pot' was connected - if it was directly to the supply rails then the wiper could be fighting the output pin to the "opposite" state until the RMW operation occurred. Just a guess without any actual information from the OP. Susan |
|
|
|
只有小组成员才能发言,加入小组>>
5238 浏览 9 评论
2028 浏览 8 评论
1950 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3204 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2253 浏览 5 评论
777浏览 1评论
666浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
595浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
676浏览 0评论
576浏览 0评论
小黑屋| 手机版| Archiver| 德赢Vwin官网 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-23 03:14 , Processed in 2.257985 second(s), Total 97, Slave 81 queries .
Powered by 德赢Vwin官网 网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
德赢Vwin官网 观察
版权所有 © 湖南华秋数字科技有限公司
德赢Vwin官网 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号