Microchip
直播中

刘强

7年用户 1204经验值
私信 关注
[问答]

从内部温度指示器读取值PIC16F15376

你好,来自德国,我希望这是合适的论坛。我正在尝试读取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)

肖舒

2018-9-10 15:45:50
这个话题还开着吗?

以上来自于百度翻译


      以下为原文

    Is this topic still open?
举报

更多回帖

发帖
×
20
完善资料,
赚取积分