I am trying to figure out how to use a 12F675 to compare voltage.
This will eventually be used to meaure a current load.
I am sending the output to serial and checking it via hyperterm just so I can see whats going on.
I have the chip connected like this.
1 + 3
2 NC
3 NC
4 NC
5 NC
6 pin2 serial.
7 testing connected to ground/pos/nothing.
8 ground and serial ground.
Here is my code most copied off this forum.
When I have pin 7 connected to ground.Code:@ __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_OFF & _BODEN_ON ' Internal Oscillator ' Enable watch dog timer ' Enable power up timer ' Disable MCLR pin ' Enable brown out detect DEFINE OSCCAL_1K 1 INCLUDE "modedefs.bas" CMCON = 7 ' turn off analog comparator DEFINE OSC 4 DEFINE ADC_BITS 10 '10 BIT A/D CONVERSION RESULT DEFINE ADC_CLOCK 3 'INTERNAL A/D RC CLOCK DEFINE ADC_SAMPLEUS 50 'SET SAMPLE TIME IN MICROSECONDS adval0 VAR WORD 'Create adval0 to store result TRISIO = %000001 ' Set GSIO 0 & 3 TO INPUTS, others to OUTPUT ANSEL.0 = 1 ' Set GSIO 0 to ANALOG ADCON0.7 = 1 ' Right Justify for 10-bit I var byte Pause 2000 loop: ADCIN 0, ADVAL0 ' Read A/D channel 0 SerOut GPIO.1,N2400,["Result ",#adval0,13,10] Pause 200 GoTo loop
I get all 0's
When I have pin 7 connected to +
I get Result 1020
When I disconnect 7 from + I get Result 600 and it slowly goes down to 113 to 140.
Can someone explain to me what this is telling me?


Stuck again. I'm just not understanding this math


Bookmarks