Halloween Offer 2014
It is currently 01 Nov 2014 01:56

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: 10 Feb 2006 03:19 
Offline

Joined: 09 Feb 2005 23:03
Posts: 181
Location: UK
Here's a routine to read a MCP9701 sensor on any ADC port:

sub function Sample_MCP9701(dim PORT as byte) as byte
' Samples MCP9701 128 times and returns temp in degrees celcius (0 - 125)
    dim MCP9701_SampleAvg as longint
    dim MCP9701_Loop as byte
    dim MCP9701_ADC as word
   
     MCP9701_SampleAvg = 0
     for MCP9701_Loop = 1 to 128
         MCP9701_ADC = ADC_Read(PORT)
         if (MCP9701_ADC < 92) then
            MCP9701_ADC = 0
         else
            MCP9701_ADC = MCP9701_ADC - 92 ' (0 C)
         end if
         MCP9701_ADC = MCP9701_ADC >> 2   ' not needed for 8 bit ADC
         MCP9701_SampleAvg = MCP9701_SampleAvg + MCP9701_ADC
     next MCP9701_Loop
     MCP9701_SampleAvg = MCP9701_SampleAvg >> 7   ' /128
     result = MCP9701_SampleAvg
end sub



The 9701 is a cheap, tiny (2mm!) linear active thermister & this mB function makes it fairly accurate by taking 128 samples and returning an average.


Top
 Profile  
 
 Post subject:
PostPosted: 10 Feb 2006 04:10 
Offline

Joined: 18 May 2005 00:59
Posts: 5465
Location: NYC
Keeping up the good work I see Niki.....nice job!

_________________
xor
CircuitED -


Top
 Profile  
 
 Post subject:
PostPosted: 10 Feb 2006 12:13 
Offline

Joined: 09 Feb 2005 23:03
Posts: 181
Location: UK
Hi xor

That's from my first attempt at an SMT board. If you prototype your own boards, lookup acetone toner transfer as it works faster than UV light boxes & is vastly more reliable than press'n'peel or other iron-on transfers :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: Exabot [Bot] and 1 guest


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group