(A/D threads merged - Robert)
Hi All!
So I have my PIC doing the A to D conversion and the reading is strange! With a volt meter I know the voltage is .441 volts. This should give a value of 362. The value I get is 582 which would be for .710 volts! Now I am completely lost as to why the results are not what is expected. Can anyone explain what I am doing wrong?
Thanks, Ed
'************************************************* ****************
'* Name: XXXXSPEEDT2.bas *
'* Author: Ed Cannady *
'* Notice: Copyright (c) 2011 *
'* : All Rights Reserved *
'* Date: 8/29/2014 *
'* Version: 1.0 *
'* Notes: For a 18F1320 and MS4515 *
'************************************************* *****************
Define OSC 20
Define LOADER_USED 1
Include "Modedefs.bas"
include "hpwm10L.pbp" ' For future calculations
ENABLE DEBUG
#CONFIG
__CONFIG _CONFIG1H, _HS_OSC_1H & _FSCM_OFF_1H
__CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_8K_2H
__CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_OFF_2L & _BORV_27_2L
__CONFIG _CONFIG3H, _MCLRE_OFF_3H
__CONFIG _CONFIG4L, _DEBUG_OFF_4L & _LVP_OFF_4L & _STVR_ON_4L
__CONFIG _CONFIG5L, _CP0_OFF_5L & _CP1_OFF_5L
__CONFIG _CONFIG5H, _CPB_OFF_5H & _CPD_OFF_5H
__CONFIG _CONFIG6L, _WRT0_OFF_6L & _WRT1_OFF_6L
__CONFIG _CONFIG6H, _WRTC_OFF_6H & _WRTB_OFF_6H & _WRTD_OFF_6H
__CONFIG _CONFIG7L, _EBTR0_OFF_7L & _EBTR1_OFF_7L
__CONFIG _CONFIG7H, _EBTRB_OFF_7H
#ENDCONFIG
Define ADC_BITS 10
DEFINE ADC_CLOCK 3
DEFINE ADC_SAMPLEUS 100
ADCON1 = %11101111
TRISB = %11111111
VOLTS VAR WORD ' Volts reading
VOLTS = 0 ' Start with a Volts value of zero
GETVOLTS:
ADCIN 4, VOLTS
VOLTS = VOLTS/10
GOTO GETVOLTS
Bookmarks