CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

PIC10F322 - Internal Temperature Indicator
Goto page Previous  1, 2, 3, 4
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
joergn



Joined: 15 Jul 2010
Posts: 15
Location: Hamburg Germany

View user's profile Send private message Visit poster's website

PostPosted: Tue Sep 13, 2016 3:44 am     Reply with quote

Thanks for the hint, I wanted to create extra delay, because of the bad samples I am wondering about, meanwhile I found inside the datasheet I have to wait 200us befor each internal tempread conversion, which I think is a quite big delay for my application.

However my assembly below (5.062) looks different to yours, let's hope that in your code the assembly is not always that different!?

I was not aware that a read_adc(ADC_READ_ONLY)
includes also the test for the go bit - for my language understanding
"only" should mean only like there is only one max or min value so there should be just a read with no other commands, but you are right
there are two assembly lines extra Shocked

Code:
....................                 read_adc(ADC_START_ONLY);
057A:  MOVLB  01
057B:  BSF    1D.1
....................         while (bit_test(*ADCON0, 1));
057C:  BTFSC  1D.1
057D:  GOTO   57C
....................         dummy=read_adc(ADC_READ_ONLY);
057E:  BTFSC  1D.1
057F:  GOTO   57E
0580:  MOVF   1C,W
0581:  MOVWF  7A
0582:  MOVF   1B,W
0583:  MOVLB  00
0584:  MOVWF  39
0585:  MOVF   7A,W
0586:  MOVWF  3A
.................... 
joergn



Joined: 15 Jul 2010
Posts: 15
Location: Hamburg Germany

View user's profile Send private message Visit poster's website

PostPosted: Wed Sep 14, 2016 4:38 am     Reply with quote

I have now on this 16F1765 the internal temp sensor on a first DUT in action and need to check the accuracy and tolerance on other chips.

I calibrated it at 0°C and 50°C manually.
It resolves 1°C very well - so very good option for me Very Happy

It was not possible to use the 4 diodes mode at all, which is set by TEMPERATURE_RANGE_HIGH
The unit just delivered bad ADC values no matter how long time was waited. I wonder why there is no error of this unit noted inside the datasheet?
I started with the HIGH option, because I expected a better ADC resolution and better performance out of it.
I think the internal current regulator of this module can simply not regulate it out. If this is the case I expect this as a possible problem also on other chips?

I have a MAX15007 5V reg as the supply.

Have you tested the TEMPERATURE_RANGE_LOW on the PIC10F322
also?

Code:


signed int16 pcbtemper;
int8 pcbc=0;
int16 cstor,dummy,pcbbuf;


#separate
void pcbtemp(void)
{   
   
   
    setup_vref(TEMPERATURE_INDICATOR_ENABLED|TEMPERATURE_RANGE_LOW);
        set_adc_channel(TEMPERATURE_INDICATOR);

        delay_us(200);  // is important if set less the result changes
                        // depending on the load of the chip
        read_adc(ADC_START_ONLY);
        dummy=read_adc(ADC_READ_ONLY);

        setup_vref(VREF_OFF);
   
 
                pcbbuf+=dummy;
                if(pcbc>16)
                {
                pcbc=0;
                cstor=pcbbuf;
                pcbbuf=0;
                }
                pcbc++;
           
       
}

//     inside main loop:         
                pcbtemp();
                if(pcbc==1)
                {
               
                cstor=((cstor/10)*11)/10;
                pcbtemper=cstor-1385;
                }

Ttelmah



Joined: 11 Mar 2010
Posts: 19552

View user's profile Send private message

PostPosted: Wed Sep 14, 2016 8:45 am     Reply with quote

I still have to ask why you are fiddling around starting separately.

Just use:

dummy=read_adc();

This will start, wait, and read, without anything else being needed.

Also, 'think' about your values and maths. You are summing 16 readings, then dividing by 10, multiplying by 11, and dividing by ten again. What a lot of fiddling....

Gives effectively *1.76.

Try sampling twenty eight times instead, summing into an int32, and then dividing the result by 16. You don't even need dummy at all. Just use:

pcbbuf+=read_adc();

You will find your code size should go down, and the result will probably be better.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2, 3, 4
Page 4 of 4

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group