I can blink a few leds, now I would like to try to turn on an led when my LM35 temp sensor reaches about 80 degrees F (27C), eventually running it out serially to a display.
I have a few questions about digitizing the analog signal. I am in the process of setting up the AN registers. I was going to use the internal Vref but not sure how to do it. Datasheet gives option (p43) for vdd or Vref pin. It is shown disconnected on my schematic. How do I scale this? The LM gives 10mv/degreeC (21 = 210mV = 69.8F about ROOM TEMP) Is there another way to calibrate it? Do I need to put a reference voltage on this pin?? I am including what I have so far- far from complete - just getting things configured. I am having a hard time writing the pseudocode especially with the above info missing. I guess what I want to do is:
set up an
set up digital output
read an input
compare it to vref
if vref register<AN input, scan again
if vref register>AN input, change states of GPIO2
maintain this state while scanning again
http://ww1.microchip.com/downloads/e...doc/41190c.pdf
Thanks for any help or kick in the right direction. JeffCode:SYMBOL ANSEL = $9F 'SET TO AI, NOT DI 'SET OSC - p44 DATASHEET SYMBOL ADCON0 = $1F 'SET PIN0 TO ANALOG IN p43 'TURN ON AD 'START AD 'SET CHAN AN0 'VREF PIN ??????????????? 'LH JUSTIFIED SYMBOL CMCON = $19 '001 ON/OFF COMPARE MODULE. BIT6 IS STATUS CHANGE FLAG P37 symbol VRCON = $99 'INTERNAL VREF CTRL REGISTER '=============================================================================== POKE ANSEL,%00011111 'SEE ABOVE POKE ADCON0,%01100011 'SEE ABOVE POKE CMCON,%01000001 'COMPARITOR CONTROL CONFIG POKE VRCON,%01000111 'SET LOW RANGE 'CVREF ENABLE ???????????????? '=============================================================================== SYMBOL TRISA = $85 'IO ADDRESS DIRECTION POKE TRISA,%00000011 'SET PIN0 AS INPUT – TEMP SENSOR 'SET PIN1 AS INPUT – VREF 'SET PIN2 AS OUTPUT SYMBOL GPIO = $05 ' SYMBOL TEMPSENS_IN = B1 'BYTE VAR TO STORE ANALOG DATA SYMBOL VREF = B2 'BYTE VAR TO STORE REF DATA SYMBOL FAN_ON = BIT8 'SET BIT8 TO ENABLE FAN ON '=============================================================================== SYMBOL TEMP_PIN = PIN0 SYMBOL VREF_PIN = PIN1 SYMBOL FAN_PIN = PIN2




Bookmarks