Name:  schematic of voltage.jpg
Views: 979
Size:  23.3 KB

Hi sorry about the late reply I have added the schematic and included the programming below. The Led would turn on when the potentiometer has been adjusted and the voltage comes to 2.5volts as I would be using comparator to detect voltage. The software I am using is MPLAB IDE version 8.92. The program doesn't seem to work I would appreciate your help on this.

list p=16F690
include "p16F690.inc"
radix dec

;***** CONFIGURATION
; ext reset, no code protect, no watchdog, 4 MHz int clock
__CONFIG _MCLRE_ON & _CP_OFF & _WDT_OFF & _IOSCFS_OFF & _IntRC_OSC_RB4EN
; pin assignments
#define LED PORTC,3 ; indicator LED on RC3
constant nLED=3 ; (port bit 3)

;***** RC CALIBRATION
RCCAL CODE 0x3FF ; processor reset vector
res 1 ; holds internal RC cal value, as a movlw k
;***** RESET VECTOR ************************************************** ***
RESET CODE 0x000 ; effective reset vector
movwf OSCCAL ; apply internal RC factory calibration

;***** MAIN PROGRAM ************************************************** ***
;***** Initialisation
start
; configure ports
movlw ~(1<<nLED) ; configure LED pin (only) as an output
tris PORTC

; configure comparator 1
movlw 1<<C1PREF|1<<C1NREF|1<<C1POL|1<<C1ON
; +ref is C1IN+ (C1PREF = 1)
; -ref is C1IN- (C1NREF = 1)
; normal polarity (C1POL = 1)
; comparator on (C1ON = 1)
movwf CM1CON0 ; -> C1OUT = 1 if C1IN+ > C1IN-

;***** Main loop
main_loop
; display comparator output
btfsc CM1CON0,C1OUT ; if comparator output high
bsf LED ; turn on LED
btfss CM1CON0,C1OUT ; if comparator output low
bcf LED ; turn off LED
; repeat forever
goto main_loop

END