I'm still looking for clues as to why the PIC will not do the entire voltage range with it's A-D. Clues so far: Lowpass filtering the voltage to the A-D got me .5 volt improvment. (Went from failing at 3.56 volts to 4.07 volts.) Slowing the conversion by a factor of 4 got me an additional .07 volts. (It fails at 4.14 volts now.) Perhaps some one can spot a code error in my source. ; RADIX DEC ; Specify Decimal default Radix. list p=16c73a ; list directive to define processor #include ; processor specific variable definitions ; ;****************************************************************************** ; '__CONFIG' directive is used to embed configuration data within .asm file. ; Set the PIC configuration for: CodeProtection OFF, WatchDogTimer OFF, ; BrownOutDetectENable ON, PoWeR-upTimerEnable ON, EXTernal OSCillator enabled. ;****************************************************************************** ; __CONFIG _CP_OFF & _WDT_OFF & _BODEN_ON & _PWRTE_ON & _XT_OSC ; ;****************************************************************************** ; ORG 0x00 GOTO Restart ; ORG 0x04 ;************************* Restart Program ************************************ ; This Program is called on a power on reset. ; The routine: Initialize the A-D, PORTs A,B,C, Start the Scheduler. ;****************************************************************************** ; Restart BSF STATUS, RP0 ; Select Bank 1 Registers. MOVLW B'00000100' ; Form a byte to signify: MOVWF ADCON1 ; Set RA<5> LED Driver. ; RA<4:3> unused analog inputs. ; RA<2> LED Driver. ; RA<1:0> as Sensor Analog inputs. BCF STATUS, RP0 ; Select Banks 0 Registers. MOVLW B'01000001' ; Form a byte to signify: MOVWF ADCON0 ; Set Analog to Digital as: ; <7:6> Fosc/8 ; <5> Read Analog Channel 0. ; <2> Stop A-D. ; <0> A-D on. Init_PORTA BSF STATUS, RP0 ; Select Bank 1 Registers. MOVLW B'00011011' ; Form I/O pins Definitions. MOVWF TRISA ; Set RA<5> LED Driver. ; RA<4:3> unused analog inputs. ; RA<2> LED Driver. ; RA<1:0> as Sensor Analog inputs. Init_PORTB BCF STATUS, RP0 ; Select Banks 0 Registers. CLRF PORTB ; Clear all Port B outputs. BSF STATUS, RP0 ; Select Bank 1 Registers. CLRF TRISB ; Set Port B all outputs. BCF STATUS, RP0 ; Select Banks 0 Registers. Init_PORTC CLRF PORTC ; Clear all Port C outputs. BSF STATUS, RP0 ; Select Bank 1 Registers. CLRF TRISC ; Set Port C all outputs. BSF PIE1, ADIE ; Enable A-D IRQs. BCF STATUS, RP0 ; Select Bank 0 Registers. Clear_IRQs CLRF INTCON ; Clear all Interrupts. BCF PIR1, ADIF ; Clear any random A-D IRQ. Start_A2D BSF ADCON0, GO ; Start the A to D processes. ; ;******************************* Scheduler ************************************ ; The Scheduler checks all task STATEs for "Active", (Non zero) ; activates the associated task for each state. ;****************************************************************************** ; Scheduler BTFSC ADCON0,2 ; Is the A-D Ready? GOTO Scheduler ; No, Return to scheduler loop. ;******************************* NEW SWR ************************************** ; Write the forward and reflected power to 1 ma. panel meters. ;****************************************************************************** ; NEW_SWR BTFSS ADCON0,3 ; Yes, Are we doing the Reflected sensor? GOTO Read_F ; No, Go process the Forward sensor. Read_R BCF ADCON0,3 ; Yes, Set A-D to Read (Forward)Analog Channel 0. CALL P_Table ; Convert the value to the output current. MOVWF PORTC ; Send the Reflected power meter current. BCF PORTA,5 ; Set the Status LED Red. BSF PORTA,2 ; Set the Status LED Red. GOTO Read_Exit ; Return to scheduler loop. ; Read_F BSF ADCON0,3 ; Set A-D to Read (Reflected) Analog Channel 1. CALL P_Table ; Convert the value to the output current. MOVWF PORTB ; Send the Forward power meter current. BSF PORTA,5 ; Set the Status LED Green. BCF PORTA,2 ; Set the Status LED Green. Read_Exit BSF ADCON0, GO ; Start the A to D processes. GOTO Scheduler ; Return to scheduler loop. ; ;****************************************************************************** P_Table MOVF ADRES,W ; Fetch the sensor voltage. ADDWF PCL,1 ; Index into the Power table. RETLW 0 ; RETLW 1 ; etc... -- Thomas C. Sefranek WA1RHP ARRL Instructor, Technical Specialist, VE Contact. http://www.harvardrepeater.org http://hamradio.cmcorp.com/inventory/Inventory.html