On Tuesday 04 February 2003 07:13 am, you wrote: > > As far as feeding the comparator <300mV (even though > > the data sheet seems to say that's fine), the comparator's > > output is quite simply wrong. :-O 300mV to the + input > > and 0V to the - input does *not* result in a high comparator > > output, even though the + input is at a higher voltage than > > the - input > > I've had no trouble at all using the comparators at low voltages, Very interesting. > for example C2 as a motor status indicator. A2 is set to 60mV > by a 100R : 8k2 division of 5V and A1 gets either 0V (motor off) > or 110mV (motor on) back from the motor sense resistor and the > value of cmcon,c2out is used to enable/disable the motor drive > circuitry. The set-up for C2 > > bank0 > movlw b'00000101' ;enable Comparator2 > movwf cmcon > > and > > btfsc cmcon,c2out ;test comparator Hmm, I will have to see what happens when I try using another 10K pot to=20 supply the voltage to the - input, instead of the cap voltage. AFAIK,=20 I'm not using a RevA chip (It would be marked that way, right?) As many years as I have been scratching my head over computers, I'm=20 fully willing to accept that I have made some kind of mistake or logic=20 error. My setup code is as follows: ; Initialize the comparator clrf FLAG_REG clrf PORTA ; Not sure why I do this, but the datasheet example does it = =20 movf CMCON, W andlw 0xC0 iorwf FLAG_REG, F ; end of odd code movlw 0x05 ; One Comparator - Pot Wiper is=20 Comp2 + movwf CMCON bsf STATUS, RP0 movlw 0x06 ; RA1 and RA2 are inputs to=20 Comp2 movwf TRISA bcf STATUS, RP0 call DELAY50 ; more datasheet example oddness movf CMCON, F The interrupt routine does this: movlw TMRVAL ; Reload TMR0 movwf TMR0 ; Test for cap V too high btfsc CMCON, C2OUT =20 goto too_low ; Copy comparator output to charging pin bcf PORTA, 3 =20 goto cont_1 too_low bsf PORTA, 3 incf ADC_TMP, F cont_1 incfsz ADC_CNT, F=20 goto no_rollover ; Counter rollover has occured (255 readings taken) movfw ADC_TMP ; Save off the ADC reading movwf ADC_VAL clrf ADC_TMP incf ADC_CNT ; Only do 255 tests/sample no_rollover bcf INTCON, T0IF ;Clear Int occured flag bsf INTCON, T0IE ;Re-enable Timer0 goto IntExit ****** End of code sample ******** ADC_CNT counter that is used to determine when 255 reading have taken=20 place. ADC_TMP is the accumulator for counting times that the cap=20 voltage was lower than the pot voltage. ADC_VAL is the last captured=20 reading that is used by the main level code. -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body