One other thing: Step 12 on the DAC is pretty close to the threshold you were looking at for the comparator input. 2.73/32*12 =1.023V. So, if you use the DAC as the divider instead of the external resistors, you can eliminate those as well. If you run the FVR at 2.048V instead, you can then use step 24. 2.73/32*24 = 2.047. Step 25 would end up being 2.62, and Step 22 would end up being 2.979 as a threshold. You can pull the DAC reference from either Vcc or from the external Vref pin, which could be used as a remote sense if you have a spare cable pin to hook Vref up to the far end's Vcc (assuming you're not otherwise using Vref). I haven't done tolerances, etc. on these so they might need to be adjusted.
I spent the day testing the
DAC, since I had never used it before. The
16F1508 datasheet has a number of errors, and the DAC pages are especially afflicted. The datasheet specifies "DAC1CON0" & "DAC1CON1" but using those generates Assember errors. "DACCON0" & "DACCON0" are correct. Then on page 143 in section 16.3, paragraph-2 ends like this:
"Reading the DACxOUTn pin when it has been
configured for DAC reference voltage output will""Will" what? Nobody knows!
Despite this hassle, I finally got the DAC working with Comparator1. Keeping the threshold somewhat close to 2.70v is desirable because I don't want it to go too high with Hysteresis enabled. So I thought Step-12 in combination with FVR=1.024v would be best. On my breadboard test I measured the lower threshold to be
2.725v (that voltage and below results in Comparator1-OUT=HI, which then cuts power to the fingerprint sensor).
"Tolerances" are the key issue though. I wouldn't want the power-cut to start at below 2.70v. Table 29-16 on pg.332 in the 16F1508 datasheet says the parameters are characterized but not tested, and Note 1 links to graphs that have nothing to do with the DAC. However, it does say the absolute accuracy is
1/2 LSb, which must be referring to bits 4:0 of DACCON1. So +/-0.5LSb would be 11.5 or 12.5 (since I'm using 12). That yields the following calculations:
EQUATION 16-1:
DACx_output = ((Vsource+ – Vsource-) x DACR[4:0]/32) + Vsource-
Since Vsource- is Vss(GND) according to Figure 16-1 in the datasheet, and since Vsource+ is set to Vdd in my code, we have:
DACx_output = Vdd x DACR[4:0]/32
Find Vdd when DACx_out = FVR(1.024v):
1.024v = Vdd x 12/32
Vdd = (1.024v x 32) / 12 = 2.731v (nominal)
And with the 1/2LSb tolerance, we have:
Vdd = (1.024v x 32) / 12.5 =
2.621v (min) <- too low!
Vdd = (1.024v x 32) / 11.5 = 2.849v (max)
So a power cut-off threshold of 2.621v would be a problem, seeing it is below the 2.70v specified by the fingerprint manufacturer.
Using Step-11 instead of 12 would give:
Vdd = (1.024v x 32) / 11 = 2.979v (nominal)
Vdd = (1.024v x 32) / 11.5 =
2.849v (min)
Vdd = (1.024v x 32) / 10.5 = 3.121v (max) <- too high!
Using a 2x multiplier on the FVR and Step-24 would yield:
Vdd = (2.048v x 32) / 24 = 2.731v (nominal)
Vdd = (2.048v x 32) / 24.5 =
2.674 (min) <- too low!
Vdd = (2.048v x 32) / 23.5 = 2.789v (max)
Using Step-23:
Vdd = (2.048v x 32) / 23 = 2.849v (nominal)
Vdd = (2.048v x 32) / 23.5 = 2.789 (min)
Vdd = (2.048v x 32) / 22.5 =
2.913v (max) <- a bit high, but perhaps acceptable.
So I bench-tested FVR with a 2x multiplier and Step-23 on my DAC and measured the following:
Lower Threshold Voltage: 2.874v (this and below cut power to F.Sensor)
Upper Threshold Voltage: 2.900v (this and higher restore power to F.Sensor)
And that small
26mV difference between Upper and Lower is with Comparator Hysteresis ON. I must assume it has something to do with using the DAC instead of external voltage divider resistors. With the resistors I was getting a
66mV difference between Upper and Lower, which offers better noise immunity.
If you have any thoughts on this and my previous post, please let me know.