完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
你好,来自德国,我希望这是合适的论坛。我正在尝试读取PIC16F1576车载温度指示器模块测量的温度,但我真的不知道如何处理测量值。我使用XC8Pro版本…FVR设置为2048 V。FVRCON被设置为0xAA.在初始化后,我的主叫。C,我调用ADC。C看起来像这样:结果通常是0x01(高字节)和0x00(低字节),或者仅仅是0x00(high)和0x00(低)……在某些情况下,LoByTeValk不同于0x00…我通过labview读取串行数据,并希望在LabVIEW中进行数学运算。但是用这些值,我甚至无法确定偏移量……我不是专家,我真的很感激一些帮助。有人知道一些好的教程或例子吗?找不到他们…谢谢你,菲利克斯
以上来自于百度翻译 以下为原文 Hello from Germany, I hope this is the appropriate Forum for this. I'm trying to read the Temperature measured by the PIC16F15376 onboard Temperature Indicator Module, but I don't really know how to handle the measured values. I use XC8 pro Version... FVR is set to 2,048 V. FVRCON is set to 0xAA After the initialisations in my main.c I'm calling the function if(FVR_IsOutputReady()){ convertedValue = ADC_GetConversion(channel_Temp); } The adc.c looks like this: void ADC_Initialize(void) { // set the ADC to the options selected in the User Interface // GO stop; ADON enabled; CHS ANA0; ADCON0 = 0x01; // initial : ADPREF VDD; ADCS FOSC/2; ADCON1 = 0x00; ADCON1bits.ADFM = 1; ADCON1bits.ADPREF0 = 1; ADCON1bits.ADPREF1 = 1; // ADRESL 0; ADRESL = 0x00; // ADRESH 0; ADRESH = 0x00; } void ADC_SelectChannel(adc_channel_t channel) { // select the A/D channel ADCON0bits.CHS = channel; // Turn on the ADC module ADCON0bits.ADON = 1; } void ADC_StartConversion() { // Start the conversion ADCON0bits.GO = 1; } bool ADC_IsConversionDone() { // Start the conversion return ((bool)(!ADCON0bits.GO)); } adc_result_t ADC_GetConversion(adc_channel_t channel) { // select the A/D channel ADCON0bits.CHS = channel; // Turn on the ADC module ADCON0bits.ADON = 1; // Acquisition time delay ADC_TemperatureAcquisitionDelay(); // Start the conversion ADCON0bits.GO = 1; // Wait for the conversion to finish while (ADCON0bits.GO) { } // Conversion finished, return the result HIGHbyte = ADRESH; LOWbyte = ADRESL; EUSART2_Write(0xAF); //This Byte indicates, that the next Bytes are High and Low- Temperature Bytes __delay_ms(50); EUSART2_Write(HIGHbyte); __delay_ms(50); EUSART2_Write(LOWbyte); return ((adc_result_t)((ADRESH << 8) + ADRESL)); } void ADC_TemperatureAcquisitionDelay(void) { __delay_ms(200); } The result is often 0x01 (Highbyte) and 0x00 (Lowbyte), or just 0x00 (High) and 0x00 (Low)... In just some Cases the Lowbytevalue differs from 0x00... I'm reading the serial Data via Labview and want to do the math in Labview. But with these Values, I am not even able to determine the Offset... I'm no expert and would really appreciate some help. Does anybody know some good Tutorials or Examples for this? Couldn't find them.... Thanks in Advance, Felix |
|
相关推荐
1个回答
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
5184 浏览 9 评论
2005 浏览 8 评论
1932 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3179 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2230 浏览 5 评论
742浏览 1评论
629浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
512浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
640浏览 0评论
538浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-29 03:13 , Processed in 1.523805 second(s), Total 76, Slave 60 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号