Low Voltage Detection & Power Cut IC - Page 1
Forum section: electronics / projects

author: JDW
author_rank: Frequent Contributor
timestamp: August 26, 2019, 12:22:55 am
content: I am working on a design that uses a 3.3V fingerprint sensor with onboard UART and ARM MCU. I experienced the memory getting suddenly wiped a few times for reasons unknown, so I contacted the sensor manufacturer and they replied that when the voltage falls between 2.0V and 2.5V the memory might be erased. They suggest I add my own circuitry to power off the sensor module when voltage falls below 2.7V. To me, that seems like an oversight on their part for not having that critically important voltage detection and power-down built-in, but since I've already written the code for this module, I'd like to continue using it. Therefore, I am curious if there is a low-cost, single IC solution to this problem?In other words, I am looking for a single IC that can detect when the voltage rail fails from a nominal 3.3V to below 2.7V and then it will cut 3.3V power to the sensor (or perhaps cut the GND side). The Sensor draws about 75mA in its full power state (and microamps when sleeping) so the switch would need to handle that current.If there is no single chip IC solution, what discrete circuit would you propose?Thank you.

author: pigrew
author_rank: Frequent Contributor
timestamp: August 26, 2019, 01:08:38 am
content: One of the better ways to detect an undervoltage is a power supervisor IC. It outputs a signal (usually open drain) when the voltage is low. As an example, there is a Rohm BD4828G-TR which triggers at 2.8 V. These chips have some hysteresis, and the threshold isn't exact (within a few percent normally), so you need to dig into the datasheets. There are thousands of variations available on DigiKey, active low/high, different voltages, adjustable hysteresis, etc.... With this sort of chip, you would need to pair it with some sort of power switch which could be as simple as a high-side pFET (if you find an active high reset)....Your voltage is quite close to the minimum voltage of a Li-Ion battery. You may be able to find an undervoltage protection IC designed for batteries, which would have an integrated switch.There also exist various over-voltage/over-current/under-voltage protect switches (like 5V ones for USB) that also do this.Maybe you'd want to use a "load switch" IC (e.g. MIC2091-1YM5-TR) instead of a single FET... might end up being lower power. Also, these are available with inverting or non-inverting inputs.EDIT: Another idea, can you use the supervisor IC to send the reset/shutdown signal to the sensor, instead of cutting its power?

author: David Hess
author_rank: Super Contributor
timestamp: August 26, 2019, 04:20:06 am
content: Microprocessor supervisory ICs often include that function as part of their reset or power good output signals. Typically they would be combined with a regulator which supports disabling its output because open loop transistor switching of a logic supply can be tricky. Some regulators support or can be configured to do this without an external IC.

author: JDW
author_rank: Frequent Contributor
timestamp: August 26, 2019, 06:24:53 am
content: Thank you for the suggestions.I'm still trying to figure out why the sensor's onboard Flash memory IC containing learned fingerprints is suddenly getting erased. Again, the manufacturer told me such could occur if voltage falls between 2.7V and 2.0V, but it seems they have the circuit on their PCB to accommodate such, as shown below. Furthermore, when you kill power to the device, the voltage will always fall below 2.7V and to 2.0V as it proceeds to 0V, so perhaps I am totally misunderstanding what they are saying, or perhaps they don't know what they are talking about. Any thoughts?

author: David Hess
author_rank: Super Contributor
timestamp: August 26, 2019, 05:35:09 pm
content: Quote from: JDW on August 26, 2019, 06:24:53 amThe problem is when the device is operated outside of its specified voltage range and this includes low voltages and when the voltage momentarily dips below the minimum specified operating voltage which is a particularly dangerous condition leading to undefined behavior.Flash memory is especially a problem if a power dip or power loss occurs during an erase or programming operation but the same applies to other memory types.The solution is to detect the possibility of operation out of bounds and immediately reset or shut down. Operations which cannot be interrupted need to have backup power, sometimes with capacitors, to finish.Sometimes the supply voltage is increased closer to the maximum giving more time to detect a low voltage condition and this is reflected in voltage supervisors which may come in different versions to support slightly different trip voltages.

author: JDW
author_rank: Frequent Contributor
timestamp: August 26, 2019, 09:25:13 pm
content: Quote from: David Hess on August 26, 2019, 05:35:09 pmBut it’s my external MCU that indirectly controls reads and writes when I initiate fingerprint Learn Mode of that fingerprint sensor (via UART command), and I assure you I am not actively learning anything (i.e., the sensor module shouldn’t be writing to that Flash chip) when I toggle the main power as a test and sometimes subsequently find the memory is wiped (as per the fact that fingerprints I had previously learned no longer work). So what would you say about this?

author: tautech
author_rank: Super Contributor
timestamp: August 26, 2019, 09:44:11 pm
content: There might be better products available now but when I went looking for supply monitoring for micro power and low quiescent ICL7665 was pretty good.

author: JDW
author_rank: Frequent Contributor
timestamp: August 27, 2019, 12:36:25 am
content: Quote from: tautech on August 26, 2019, 09:44:11 pmThank you for the IC suggestion. US$1.31 in 1000pc quantities is a bit high, but then most "MAXIM" branded chips are on the high side.

author: Marco
author_rank: Super Contributor
timestamp: August 27, 2019, 02:57:40 pm
content: They might already have a low power detection routine in the firmware which triggers flash access and which is just buggy. For instance it detects voltage going low and tries to do some last minute dumps of some cached values.

author: mikerj
author_rank: Super Contributor
timestamp: August 27, 2019, 03:57:54 pm
content: Quote from: JDW on August 26, 2019, 09:25:13 pmIf a microcontroller has no internal brownout/reset controller or a buggy/inadequate one then it's quite possible for a a micro to start doing unpredictable things during a slow supply voltage rise/fall, including executing from random bits of program memory that may contain the flash erase/write functions.Some of the earlier AVR micros were known for corrupting the first address in their onboard EEPROM during power up/down events.

author: mark03
author_rank: Frequent Contributor
timestamp: August 27, 2019, 05:59:51 pm
content: Depending on your ARM MCU, you might be able to do brownout detection there with no additional parts needed. I know that some of the STM32 families, for example, have a lot of configurability where you can get interrupts at different voltage levels.

author: Gribo
author_rank: Frequent Contributor
timestamp: August 27, 2019, 07:44:48 pm
content: A MAX809 might do the trick. It is ~0.8$ at Digikey. You have several threshold voltages to choose from. Also, make sure the CPU clock has the correct setting for the supply voltage. Usually, you can't run at the highest clock rate when the voltage is low.

author: JDW
author_rank: Frequent Contributor
timestamp: August 28, 2019, 12:00:30 am
content: Quote from: mikerj on August 27, 2019, 03:57:54 pmI don't think the Brown-out feature of myPIC16F1508(which I am using) is "inadequate" but it applies to my PIC and not the Fingerprint Sensor. it is the Fingerprint Sensor that, according to the manufacturer, needs to be powered off (since there's no way to easily "RESET" it) when the sensor's input voltage falls below 2.7V.Quote from: Gribo on August 27, 2019, 07:44:48 pmPage 2 of theMAX809 datasheetin the Absolute Maximum Ratings section does mention that the Output Current of the Reset pin is up to 20 mA. But are these reset chips really best for my application where I would need to use the Reset output to power the Base of a BJT PNP transistor in order to cut +3.3V power to my fingerprint sensor (to completely power-off that sensor)?Because the fingerprint module is a self-contained unit from the factory, I cannot expect an assembly factory to hand-solder a tiny wire to multiple reset pins on the various SMD IC’s of that fingerprint sensor, and that is why I would need to cut power to the entire sensor if the voltage falls below a predetermined threshold.

author: mark03
author_rank: Frequent Contributor
timestamp: August 28, 2019, 03:34:41 am
content: Quote from: JDW on August 28, 2019, 12:00:30 amAh, I thought you said you were using an ARM. In any case, there are various MCU-based approaches that might not require a separate chip. E.g. if your MCU has a comparator, or its dedicated brown-out detector has a configurable threshold, and the MCU can run at lower voltages than your fingerprint sensor can. Then it's just a matter of wiring up the interrupt and controlling a MOSFET with a spare GPIO to turn off the sensor.

author: JDW
author_rank: Frequent Contributor
timestamp: August 28, 2019, 04:36:04 am
content: Quote from: mark03 on August 28, 2019, 03:34:41 amAn ARM is inside the fingerprint sensor module which is made by another company, yes. And to see a photo and description of the bottom of that sensor, please see myprevious postand click on the graphic I attached.Note that the manufacturer of the fingerprint sensor told me the following:When the module's power supply (powered by battery) is between 2.0v and 2.5v, the memory might be erased. We suggest you add a low voltage detection circuit. For example, when Vcc falls below 2.7V, power to the sensor would be cut.My MCU is a PIC16F1508 and has a Brown-out Voltage Reset feature and selectable threshold voltage of:Min. 2.55v, Typ. 2.70v, Max. 2.85vSince 2.55v is higher than the 2.50v the fingerprint sensor manufacturer mentioned, that brown-out range would qualify BUT I am using that to keep my PIC in RESET. And while my PIC is in RESET, I cannot trigger interrupts or do anything with the PIC at all.

author: mikerj
author_rank: Super Contributor
timestamp: August 30, 2019, 01:58:56 pm
content: Quote from: JDW on August 28, 2019, 12:00:30 amI am talking about the fingerprint sensor, which clearly has a micro inside it and it apparently doesn't behave well during slow power rise/fall times.

author: JDW
author_rank: Frequent Contributor
timestamp: August 31, 2019, 03:00:19 am
content: Quote from: mikerj on August 30, 2019, 01:58:56 pmThe fingerprint sensor hastwoMCU's inside it and a 3.0V regulator too, as shown in the following photo:https://www.eevblog.com/forum/projects/low-voltage-detection-power-cut-ic/?action=dlattach;attach=820047;imageBut I don't know what your specific recommendation to me is. As I mentioned before, the pins are too tiny for me to expect a factory to hand-solder a teensy, tiny wire to the RESET pin(s) of the various ICs shown in the photo of the bottom of the fingerprint sensor. As such, the only means of dealing with a brown-out situation would be for that detection to occur on my PIC board (separated from the fingerprint sensor by a 1.5 meter long set of cables, mind you), such that when the low voltage case is detected (say, 2.8V and less), then I would need some kind of circuit on my PIC board that would kill power completely to the fingerprint sensor until the voltage rises above that 2.8V threshold. I am just trying to figure out the best way to deal with all that in light of the 1.5 meter cable length.Consider the5 wires in that 1.5 meter cable leading from my PIC and PSU board to the Fingerprint sensor:1. +3.3V Power2. GND3. Tx (9600baud, rests at +3.3v, drops to 0v when sending data)4. Rx (9600 baud, rests at +3.3v, drops to 0v when sending data)5. +3.3v Analog Touch Wire (sends 3.3v from the sensor only while a finger is touching the metal frame of the sensor).Adding some sort of ESD chip (with diodes and zener inside) on Tx & Rx would be needed with perhaps an inline 100-ohm or 200-ohm resistor with the PIC's Tx and Rx pints for protection, but protecting the other 3 pins is a bit more complex. And to completely power off the fingerprint sensor I would need cut off all current flow to it, and that would require cutting 4 of the wires and leaving its GND intact. Then add to that the need for brown-out detection and the means to cut all those wires too. Any specific thoughts on a circuit to accomplish all that would be appreciated.At least one person in another thread suggested I route higher voltage to the sensor, then build a tiny PSU board as a buck regulator to drop that voltage down to 3.3V for the sensor. But the design requirements are such that there won't be space for such, and adding the needed protection circuitry for both 12V and 24V operation would make that tiny board not so tiny at all. In other words, I have no choice but to run 3.3V from my PIC board to the fingerprint sensor.Thank you!

author: TimNJ
author_rank: Super Contributor
timestamp: August 31, 2019, 03:30:59 am
content: How about something like LM8364?http://www.ti.com/general/docs/suppproductinfo.tsp?distId=10&gotoUrl=http%3A%2F%2Fwww.ti.com%2Flit%2Fgpn%2Flm8364

author: JDW
author_rank: Frequent Contributor
timestamp: August 31, 2019, 06:03:36 am
content: Quote from: TimNJ on August 31, 2019, 03:30:59 amThank you for your kindness in providing a link to a specific voltage reset IC. I always appreciate specifics.But as mentioned in my previous post, I need more than that. I need to find the best approach to not only detect the low voltage but also to cut power and protect. Simply put, I need to:1. Detect when voltage drops below 2.8v. (That's rather easy.)2. Cut power to my fingerprint sensor (I assume the best way is to cut 4 of the 5 wires -- all but ground, but what is the best way to cut those 4 wires at once?)3. Protect all 5 wires in light of the fact they connect via 1.5m cable. ESD filtering on Tx and Rx alone would not be enough. What if someone connects the 3.3V power line to ground? What if someone cuts the wires and causes a short as a result of the cutting (at the instant the scissors touches all 5 wires at once)?What is the best approach to this, do you think?

author: tautech
author_rank: Super Contributor
timestamp: August 31, 2019, 08:48:54 am
content: Quote from: JDW on August 31, 2019, 06:03:36 amAnd you couldn't imagine to use the IC in reply #6 with a MOSFET and/or a quad logic switch like HEF4066B ?

author: Ian.M
author_rank: Super Contributor
timestamp: August 31, 2019, 10:02:45 am
content: In JDW'sother threadI suggested:Quote from: Ian.M on August 27, 2019, 09:49:39 amI'm not suggesting a buck regulator at the sensor, I'm suggesting a linear regulator. IMHO its advisable to have the sensor's Vcc rail monitoring and undervoltage cutoff at the sensor head, not in the main unit, as connectors fret and contact surfaces oxidise with age, which will reduce the Vcc available to the sensor and increase its impedance, so its likely that it will become unreliable with age if one tries to implement the undervoltage cutout purely in the main unit.There's no need to isolate most of the signal wires when the sensor is powered down. With its Vcc at 0V, the two outputs from the sensor will effectively be at logic '0'. However one probably should isolate the sensor's serial RX pin, as that line probably idles at logic '1', and allowing the input protection to clamp it could result in out of spec voltages on the sensor Vcc rail and a return of the memory corruption problem. A simple N-MOSFET, source to sensor RX, gate to +5V and drain to the cable from the main unit will do nicely, or use a single gate logic buffer that can tolerate logic '1' in while powered down without loading the input signal.Why 5V to the sensor head?, well its a low enough voltage to minimise dissipation in the local LDO, may already be needed in the base unit, and is low enough to be maintainable during cranking. If the base unit doesn't already have a 5V rail, getting 75mA @5v from a 14V power input with a linear regulator would be possible, as that's only 675mW dissipation, and that 75mA is only needed intermittently when the sensor is active. Of cource one could also use a buck regulator. There shouldn't be any need for extra power input protection as that should already be in place for the main unit's own power supply - just T into the feed after the existing protection circuit.

author: JDW
author_rank: Frequent Contributor
timestamp: September 02, 2019, 03:06:30 am
content: Quote from: Ian.M on August 31, 2019, 10:02:45 amThank you for your reply, and yes the Rx pin does idle at 1 so it would need to be switched. But could you explain why you suggest I use a MOSFET (e.g.,2N7000G) instead of an NPN BJT for the signal switching? The required current flow would be in the microampere level, and a sufficiently high base resistor on an NPN (more than 10k) would keep current consumption on part with a MOSFET.Quote from: tautech on August 31, 2019, 08:48:54 amThank you for proposing theHEF4066B, but I see it is an "analog" switch as opposed to a dedicated "logic" switch (even though logic can be used with analog switches, I am aware) and the datasheet says Ron(rail)=340-ohm max & Ron(peak)=2.5k-ohm max (@Vdd=5v & Isw=200A). That Ron seems a bit high to run 9600bps logic level data through it.

author: JDW
author_rank: Frequent Contributor
timestamp: September 02, 2019, 07:35:41 am
content: Quote from: GeorgeOfTheJungle on September 02, 2019, 07:32:37 am"lipo"?

author: JDW
author_rank: Frequent Contributor
timestamp: September 02, 2019, 08:45:30 am
content: Here is a simplified schematic so everyone can better see what I am attempting. (The power supply is complete and not simplified. Note it accepts either 12V or 24V vehicle power -- so about 29V when a truck's engine is running.)This is my current bench-test setup, not the final product. The final product must move the fingerprint sensor 1.5m away using the 5 wires shown.Note that while the UART section of the Fingerprint sensor can accommodate 5.0V just fine, the Holtek MCU side is restricted to 3.3v only. And it's power wire goes straight into that MCU as shown, with no protection at all. The same for "Out" -- it's an MCU output pin that has no protection at all.I added a 1k pulldown on RA2 because I was sometimes getting some oddball readings without it.I added a weak 22k pulldown on RB5 because if that wire gets disconnected from the sensor, I can't leave RB5 floating.RB7 is kept at HI by the PIC, so no pull-up or pull-down is needed.There is other capacitance on the 3.3v rail not shown in the schematic. 0.1uF ceramics and a couple 47uF aluminum electrolytics.The manufacturer said that I need to power off the fingerprint sensor for Vin lower than 2.7V, since there is no RESET that I can access. It has been suggested that change my switcher power supply to 5V and then add an LDO (5.0V to 3.3V drop-down) on the PIC side. But if I drive my PIC with that LDO, I cannot switch that LDO off to power-down ONLY the fingerprint sensor. And if I drive my PIC at 5.0V and add the LDO only for the fingerprint sensor, then I would need voltage level conversion because the signals coming from the sensor would be 3.3V. Another consideration with that is that driving my PIC at 5.0V instead of 3.3V consumes more current (not a lot, but a consideration nonetheless). I would then need to add a RESET IC that would kill the 3.3V LDO (killing power to the fingerprint sensor) when voltage drops below say 2.8V, then enabling the LDO again when the voltage rises. But cutting voltage via LDO alone is insufficient, and I would need to cut the RB5 line and the RA2 line. ESD protection would be needed as well.So if you have any new thoughts to share in light of this schematic, I am happy to hear them.

author: Ian.M
author_rank: Super Contributor
timestamp: September 02, 2019, 08:51:35 am
content: Quote from: JDW on September 02, 2019, 03:06:30 amNobody gives a flying F-word about a few mA current consumption in an automotive application. The self-discharge of a Lead Acid battery is of the order of 4% per month, which for a 90AH battery, the smallest you are likely to find in a four wheel vehicle, is equivalent to a standing load current of 5mA. The problems start when you have *far* too many systems that draw tens of mA in standby with the ignition off, then you get a vehicle that you cant leave on airport long term parking for a few weeks, and expect to it to start when you return, without a solar panel to keep the battery topped off. When the vehicle is running, tens of mA is still negligible.A BJT could be used, but will give *SLOW* rising edges, as all that's available (unless you add an extra pullup) to drive high is the base current *(1 + reverse HFE), and the reverse HFE) of most transistors is pretty lousy. It will also compromise your logic levels, lifting Logic '0' slightly by Vce_on and dropping logic '1' by Vbe, affecting noise immunity A small MOSFET with its gate pulled above the logic '1' level has low on resistance in both directions, and as long as the driving signal source can handle its channel to gate capacitance as a load, will have negligible effect on logic levels and nois immunity. It also takes less PCN area as it doesn't need a resistor.N.B. a 2N7000 is *NOT* suitable unless you run your supply to the sensor at >7V as its max. Vgs threshold voltage is 3V, so it wont reliably stay on with 5V on the gate and a 3.3V logic '1' signal on the channel, which only gives 1.7V Vgs. You need one with a max threshold voltage <1.5V to guarantee a full logic '1' level at the sensor RX pin. <1.8V threshold will work with a possible slight reduction of the logic '1' level but still within spec.You could also do the level conversion with 74LVC1T45 or 74LVC2T45 level translating buffers, (one of each or three of the 1T45) as they support partial power-down applications by going hi-Z if both sides aren't powered. That would let you run 5V logic levels over the sensor cable, for better noise immunity and let you run the PIC at 5V. The extra current consumption will be negligible for an automotive application (see above) and if it was important, by judicious use of either reducing the clock speed or sleeping when inactive, in most applications you can save more than going from 3.3V to 5V at a fixed clock speed costs you. The 74LVC1T45 is available in packages as small as the 1mm x 1mm DFN1010-6, so doesn't need much board area at the sensor.Why do you think the sensor needs significant ESD protection on its cable (as long as that cable is screened)? If your usage case includes dumb users in nylon shell-suits fiddling with the connectors, and the 2KV HBM model ESD rating of the 74LVC1T45 isn't good enough, you *might* consider adding some, but remember the PIC is just as vulnerable so *IF* you need it, you need it *BOTH* ends of the cable.

author: JDW
author_rank: Frequent Contributor
timestamp: September 02, 2019, 09:18:22 am
content: Quote from: Ian.M on September 02, 2019, 08:51:35 amI know BJT's well but not MOSFETS, so I'd like to clarify. I can find parts with a "Vgs" spec as low as 2.5V and a "Vgs-thresh" spec as lows as 300mV, so am I right to assume that the "Vgs" spec is different than what you were talking about in that the "Vgs spec" is the absolute max voltage when measured across the Gate and Source? Considerthese 3 parts.If the "Vgs spec" is the absolute max, then it would be prudent for me to choose the highest "Vgs spec" that can accommodate the lowest "Vgs-thresh" -- for example,these parts.Lastly, I am seeing "Rds-ON" as high as 3.5-ohms in some of those parts I linked for you. I would assume this should be a non-issue on light of my 9600bps data rate?Many thanks.

author: JDW
author_rank: Frequent Contributor
timestamp: September 02, 2019, 09:46:27 am
content: Quote from: GeorgeOfTheJungle on September 02, 2019, 09:24:33 amThere is no glitching in the 3V rail, and currently on my bench test I am using a dedicated benchtop power supply set to 3.3V to ensure rock solid power. But when I have been doing is creating my own glitch tests by yanking and reconnecting 3.3V power by hand to the board. My PIC handles this fine, and while there is no damage to the sensor either, there are very rare occasions when it's memory gets wiped. Imagine if you will someone who learns a dozen prints to this system and then finds them all erased one day! Such is not insecure because I handle that in my PIC code, but being forced to re-learn all the prints again due to a glitch is something I must design around. For that reason I contacted the manufacturer of the sensor and they told me that if the voltage dips to between 2.0v and 2.7v, then the memory could be wiped. Clearly they were not talking about a "power off case," as such would drop the voltage to 0v (while passing through that 2.0v to 2.7v hazard land). So I must assume they mean "if the voltage STAYS between 2.0v and 2.7v the memory will be wiped." Regardless, they recommended I add a low voltage detection circuit that can kill power to the sensor completely, seeing I have no means to ground a RESET line on the sensor. Add to that the fact I must put the sensor off my main board by 1.5m cable now, and you can see why I need to consider cutting wires and adding ESD protection, etc. as mentioned in my earlier post with schematic.The fingerprints aren't normally deleted when I don't touch the 3.3v rail. It's only when I deliberately introduce glitches by hand.

author: forrestc
author_rank: Unknown
timestamp: September 02, 2019, 10:00:07 am
content: Quote from: JDW on September 02, 2019, 08:45:30 amI'm going to respond in two parts. The first is assuming you want to shut this down quickly once the voltage reaches a certain threshold:This is how I would do it:1) Use a P-channel Fet in the power line. There are quite a few out there which will work. The Advantage of a fet is that you're not going to get a lot of voltage drop. I personally use a DMG2301L for these applications. At 3.3V you should have less than 150mohm of resistance. Tie this to a output pin on the PIC. I'd recommend using a resistor from gate to source to keep the gate pulled high until your PIC pulls it low to turn on the device.The 3.3V rail connects to S, the sensor connects to D, and the G connects to the output pin on the PIC, possibly through a gate resistor, although this is probably not required and will slow the transition down.2) On the PIC side, the PIC you selected has a comparator and a DAC and a FVR. You can program the FVR to 1.024V, then connect the FVR output to the comparator (internal to the chip, not an external connection). If you're concerned about the VCC of the PIC, you can use the DAC to divide it down and feed it into the other pin of the comparitor. The output of the comparitor can then go to the FET I described above.If you are concerned about the VCC of the sensor itself, you can bring a sense wire back, maybe dividing it down and feed it into the PIC. This way you can sense the voltage at the device.The description above will automatically shut down power to the sensor. It looks like the only other pin you have to worry about is TXD. I'd set an interrupt on the comparator output as well, then in the ISR turn off the serial port and makes the pin goes either Tri-state or pull it down, whichever you feel is safest.There are other variations on this, but by just adding the Pchannel FET I described in the high side line and controlling the TXD line, you should be able to shut this down within a few microseconds. If you're worried about sleep current, I think all of the above can run in sleep, and the comparitor input can wake the processor back up. I haven't verified this last part with the datasheet on this exact part.BUT..... The second part.I'm confused why you're browning out at all. I'd highly recommend what GeorgeOfTheJungle and others say... You need to figure out why this is browning out, as you shouldn't have this happening at all. One alternative might be to run 12V to near the sensor, and then step down to 3.3V there...If this is an issue with just poorly timed power-off (which might be the case), you might also want to consider adding a supercap or largish cap near the sensor, however this would interfere with the power shutoff I described above.

author: forrestc
author_rank: Unknown
timestamp: September 02, 2019, 10:06:25 am
content: Quote from: JDW on September 02, 2019, 09:46:27 amAre you absolutely certain that this isn't just a badly timed glitch? I.E. while the sensor is for some reason writing to the flash?Also, if you are manually connecting/disconnecting/connecting the 3.3V rail, you're probably causing all sorts of evil things on the rail just because a connection isn't instantaneous. I can't tell if you mean physically yanking or being nicer.

author: JDW
author_rank: Frequent Contributor
timestamp: September 02, 2019, 10:12:22 am
content: Quote from: forrestc on September 02, 2019, 10:00:07 amI mentioned that in my previous post. As I mentioned in that post, there is no memory loss when I leave the 3.3V rail alone. And even when I deliberately take the 3.3V output and tap it on/off to my breadboard, the memory is usually fine. But on rare occasions doing that manual glitching of the 3.3v rail by hand will result in the sensor's flash memory being wiped. The manufacturer told me two things about memory wiping:1. It could happen if the voltage falls between 2.0v and 2.7v.2. It could happen because there is code in the sensor (proprietary, they won't share details) that auto-wipes the memory if the sensor sensing it is being read.#2 is as thick as mud, and it's hard for me to decipher it. I asked if they could kill that code and give me a firmware update, but they said no.But again, the memory only gets wiped rarely, and only when I am manually tapping the 3.3v power line into my board and yanking it out. I want to simulate major voltage issues on the 3.3v line by doing that. The chips survive it fine, it's just that the flash memory of the sensor (not my PIC, but the fingerprint sensor) gets wiped for reasons I've already mentioned.Thank you for your other suggestions. Using 3.3V goes against the advice of Ian M. who recommends I use 5.0v instead since I will have a 1.5m cable between my PIC board and the sensor, so I will need to ponder your suggestions along side his.And no, it's not happening during a flash WRITE. I know that.

author: JDW
author_rank: Frequent Contributor
timestamp: September 02, 2019, 10:24:08 am
content: Quote from: GeorgeOfTheJungle on September 02, 2019, 10:11:18 amI think you are suggesting that I kill power to everything including my PIC with that, but I cannot do that and here is why.This fingerprint sensor will be used in a vehicle as a security device. Think of it as an immobilizer. If the fingerprint sensor dies or gets disconnected while PIC code is in Disarmed mode, the PIC must energize a normally-Open relay to allow engine starting (when it sees the CAN wake -- there's an analog wire in the car to detect this). When the relay is not energized, the vehicle engine won't start. The PIC controls that relay. It won't kill the engine when it's already started. It only prevents starting. So if the power to the entire board goes down, the relay won't get energized and the vehicle cannot be started. So I need to keep the PIC alive regardless of what happens to the sensor. Of course, if the sensor dies while Armed, then it doesn't matter since Armed mode prevents starting anyway, and the fact the sensor is dead won't allow disarming, but for security reasons that is okay.What I am doing is just trying to follow the fingerprint sensor manufacturer's advice in an attempt to eliminate any possibility of random fingerprint memory wipes. And in my previous post, I mentioned the two things they told me that might cause an unexpected flash memory wipe (on the sensor side, not my PIC).But like I said, this occurs rarely, and only when I manually glitch the 3.3V rail by hand. I do that to simulate something bad going on in the car. I need to know what will happen in that case. And although my hardware survives it fine, sometimes the sensor memory gets wiped (rarely), and that is the main thing I am trying to resolve. The second and SEPARATE matter is how to best cut power and protect the sensor over a 1.5m cable, which will have connectors and could get disconnected. Conceivably, the wires could even get cut, which would induce a short. ESD is also a concern. So those are the 2 things I've been talking about:1. Make sure the fingerprint sensor's voltage rail doesn't fall between 2.0v and 2.7V.2. Make sure the PIC side and Sensor side are adequately protected in light of a 1.5m cable being used between them.

author: JDW
author_rank: Frequent Contributor
timestamp: September 02, 2019, 10:58:24 pm
content: Ian.M,I would certainly appreciate your reply to the questions I asked you inReply#27.When it comes to MOSFETs, I’m still very much a student in learn mode.Thank you.

author: JDW
author_rank: Frequent Contributor
timestamp: September 03, 2019, 06:20:43 am
content: Quote from: GeorgeOfTheJungle on September 02, 2019, 10:27:28 amWhile redesigning my switching power supply today for a 5.0V output, I began to wonder what the real advantage of using 5V is over using 3.3Vifmy Tx and Rx from the Fingerprint Sensor are sent across that 1.5m cable at a 3.3V voltage level. The entire point of IanM.'s original suggestion to me of using 5V stemmed from the fact that there would be loses due to wire resistance and the connectors. To keep the voltage at the fingerprint sensor's Vin as close to 3.3V as possible, IanM. suggested I use 5.0V power and then use an LDO (at the Fingerprint sensor board, not my PIC board) to drop Vcc to 3.3V.But shouldn't that thinking apply to Tx and Rx lines too?Tx & Rx are being sent across the same 1.5m length of cable, so any loss in voltage due to the cable would apply to Tx & Rx too. But if I boost the Tx and Rx lines to 5v on the fingerprint sensor side, it's all getting a bit complex in a circuit I otherwise hoped to keep as simple as possible for the sake of board space and cost.Therefore, I would appreciate hearing your thoughts on using 5V instead of 3.3V for Main powerandTx & Rx too. If you think it's fine and dandy to keep Tx & Rx at 3.3V across that cable, then why not keep the main Voltage rail at 3.3V too?Thanks.

author: JDW
author_rank: Frequent Contributor
timestamp: September 03, 2019, 06:58:23 am
content: Quote from: GeorgeOfTheJungle on September 03, 2019, 06:47:45 amDo you say that because ofnoisethat might be induced into the 1.5m long cable? Or do you say that because of the possiblevoltage drop(which I doubt would be more than 100mV)?Quote from: GeorgeOfTheJungle on September 03, 2019, 06:47:45 amSince I would need to add a 5v-to-3.3v LDO on the fingerprint sensor side, would it be preferred to do the same on the PIC side, using a 5v-to-3.3v LDO to power the PIC at 3.3V so that no conversion is required for Rx and Tx? The reason I even ponder this is because the PIC will consume less current at 3.3V than 5.0V.Thanks.

author: forrestc
author_rank: Unknown
timestamp: September 03, 2019, 07:07:41 am
content: Quote from: JDW on September 03, 2019, 06:20:43 amThe loss due to resistance in the wire is related to current. E=I*R. The higher the current, the higher the resistance, the more the voltage drop.The current in a TX or RX line should be microamps typically, and the voltage drop on those lines shouldn't be easy to measure. Even with a large resistance.The current in the power line is going to be much higher, several orders of magnitude. Possibly in short brief "surges"....If the voltage normally at the sensor board is very close to 3.3V under normal operations, but you see brief spikes being lower, the simple solution is to add capacitance to the sensor board so that the capacitors provide the power during the demand surges causing the spikes. I'd only consider moving to 5V if your average voltage at the board is too low due to voltage drop.You also mentioned that the units will self-erase if they think you're trying to read out the data. One of the common ways that people try to read out the data is to introduce a power glitch. Google "power glitch attack".I think what is likely happening here is that the firmware on the device is detecting the power is rapidly glitching and is assuming an attack is in progress and is wiping the data in defense.If this is the case, then the solution should be fairly simple:1) Add enough capacitance to the sensor board such that you never have a power droop under normal use. Don't over do it, but make sure that it is sufficient and then some. You may already have enough on the board. You can figure this out with an oscilloscope monitoring the rail on the board during normal operation.2) Introduce the circuit I described in to the PIC, and then program the PIC in such a way that if a glitch occurs, it powers off the device, and leaves it off for some reasonable amount of time has passed. The PIC can also be set up to only power on the device after power is good for a certain amount of time, which will avoid a certain additional class of power-on glitches on the 3.3V rail.You'll need to characterize or find out how long the rail should be off to prevent this from occuring.

author: forrestc
author_rank: Unknown
timestamp: September 03, 2019, 07:30:21 am
content: Quote from: JDW on September 02, 2019, 10:12:22 amLet's do some quick math:Assuming 100mA @ 3.3V:1.5m cable, let's assume it's 24AWG (tiny). Looking up the ohms per foot, and calculating the resistance of this amount of wire, you find that the resistance is 0.128\$\Omega\$.At 100mA, 0.128 Ohms. E=IR. 0.1A times 0.128\$\Omega\$ = Voltage drop is then 0.0128V. Yes, 1 hundredth of a volt. You need to double it since it's a round trip thing, so I'll say 0.025V.Let's assume it's 1A. Then it's 1A * 0.128\$\Omega\$ , or 0.128V. Or 0.25V.You're not going to get enough voltage drop over 1.5M of cable, assuming any reasonable wire gauge and any reasonable current, to matter. If your current is closer to 1A than 0.1A then you'll just need a bit larger cable.If the device is normally 0.1A, with brief surges to 1A, that's where capacitance at the end of the cable comes in. It averages the peak out.Now, there are other reasons why 3.3V might not be a good idea, but that's more about signal integrity. A car can be an electrically noisy environment, although the newest cars are much quieter than the old ones were mainly because of how many electronics are used in cars. I'm not sure moving to 5V is going to gain you a lot in this department. Depending on the specifics of the situation, a good shielded cable will likely be more useful. If you find you have communication problems, then sometimes moving to a more robust signalling method can help, but that would probably mean moving to RS-422 or similar on both ends of the wire.

author: JDW
author_rank: Frequent Contributor
timestamp: September 03, 2019, 07:53:40 am
content: Quote from: forrestc on September 03, 2019, 07:07:41 amI know what the wire resistance will be for the 1.5m cable, although contact resistance of the connectors at either end (which IanM. was considering) is something I have not considered yet. But thank you for indicating that use of 3.3V isn't altogether a bad idea. I like the 5V idea, but it adds a heck of a lot of complexity, cost and board space to the design.The fingerprint sensor draws less than 200uA when sleeping, 48mA when awake but its LED off, and 76mA when it's awake with LED lit. The datasheet says current could spike up to 130mA, but that would but the limit and only for short durations. In my own measurements using a Fluke 8845A benchtop meter I don't see current spikes above 80mA.I've measured the input capacitance at the Fingerprint sensor. There are several ceramic caps in parallel, all yielding a mere 12uF total, which certainly isn't enough.Using a shielded cable would be a good idea, but I also need to consider ease of mounting which a flat, thin cable would provide. The wires should probably be 22AWG for the sake of durability, and certainly no thinner than 24AWG. Adding a shield would make the cable thicker, which means it could not fit nicely in between panel plastics like a thinner cable.Quote from: forrestc on September 03, 2019, 07:07:41 amI fully understand that my PIC has a Comparator, DAC and Vref=1.024v (which is stable for Vdd 2.5V and higher). (My PIC also has internal Brown-out LO enabled, which keeps the PIC in RESET when Vdd falls below 2.35v~2.58v.) While I could indeed use an interrupt in conjunction with the Vref and Comparator, the fact is that I sometimes write to the high-endurance flash inside the PIC which takes 2.5ms-max during which time interrupts must be disabled. That 2.5ms is probably short enough not to pose a problem, but using theTLV3012GeorgeOfTheJungle proposed along with two 1% voltage-divider resistors and a P-MOSFET (DMG2301L, which you proposed) would be a bullet-proof external solution that would be faster than using the PIC.So if I set aside the 5V idea and stick with 3.3V, I would need the following:•Low-voltage detection and power cutfor external fingerprint sensor using TLV3012, DMG2301L, R1=1M-ohm(1%), R2=820k-ohm(1%) -- yielding a nominal trigger threshold of 2.76v and a worst-case threshold (1% resistor tolerance considered) of 2.73v, which is higher than the 2.70v mentioned by the sensor manufacturer. My PIC can monitor the output of the op-amp in the TLV3012 to know which power to the fingerprint sensor is being switched OFF or ON.•Add capacitanceon Fingerprint sensor side (to be decided).•Add ESD protection ICs, one IC for each side of the cable, for Rx & Tx. (I would assume this is prudent.)•Additional short-circuit protectionfor possible cases where Vdd gets shorted to ground? (Could occur if someone took a pair of scissors and cut through the cable.)•Use N-MOSFETs to cut Rx & Txat the same time Power is cut to the fingerprint sensor, as per IanM. But I am still not clear on Vgs vs Vgs-thresh, so if anyone reading this could kindly steer my feeble brain in the right direction, I would appreciate it.Toward that end, here is the content of Reply#27 which never got a response from anyone...Quote from: Ian.M on September 02, 2019, 08:51:35 amI know BJT's well but not MOSFETS, so I'd like to clarify. I can find parts with a "Vgs" spec as low as 2.5V and a "Vgs-thresh" spec as lows as 300mV, so am I right to assume that the "Vgs" spec is different than what you were talking about in that the "Vgs spec" is the absolute max voltage when measured across the Gate and Source? Considerthese 3 parts.If the "Vgs spec" is the absolute max, then it would be prudent for me to choose the highest "Vgs spec" that can accommodate the lowest "Vgs-thresh" -- for example,these parts.Lastly, I am seeing "Rds-ON" as high as 3.5-ohms in some of those parts I linked for you. I would assume this should be a non-issue on light of my 9600bps data rate?

author: forrestc
author_rank: Unknown
timestamp: September 03, 2019, 10:06:03 am
content: Quote from: JDW on September 03, 2019, 07:53:40 amI think what you might be missing is that the Comparator is able to expose all of it's pins to the external world, and doesn't rely on the PIC CPU to operate. It will operate whether interrupts are enabled or not. So you effectively have a TLV3012 inside. No need for an external part to get exactly the same functionality.At initial power on, the PIC's comparator wouldn't be configured to be connected to the FET. So the unit would stay off until ready.Once your PIC has started, you enable the 1.024v reference, enable the comparator, and assign pins. At this point forward the comparator works just like a TLV3012. You use the same divider 1M and 820K, hooked up to the comparator input pin. The output pin is just like the TLV3012 and hooked to the FET. Once set up, it's just as fast as the TLV3012 (well, that's not true, the one in the PIC responds in 0.8uS max, vs the 12uS of the TLV3012 so the PIC is actually a lot faster).The main advantage of this (other than the part savings) is that you can gain some software control as well. If you find you have a glitching power supply on startup, you can then delay the power on for the device. You can also force minimum off times after a drop.I also notice that the comparator can be configured in software to add some hysteresis which will prevent 'chattering' near the threshold. I.E. once it shuts off, the voltage on the reference pin has to rise to 1.224V before the unit comes on automatically. With a normal comparator, you'll find you have glitches as the voltage crosses the threshold unless you add feedback circuitry, this avoids that hassle.The interrupt I suggested only comes into play if you also want to turn off the TX pin to avoid currents through the TX pin powering the remote device, which is a definite possibility. Which you're already aware of:Quote from: JDW on September 03, 2019, 07:53:40 amYou probably don't need to cut the sensor TX/PIC RX line. You're concerned about power from the PIC TX line being fed into an off sensor, and it powering up the device, not the other way around.The software interrupt would probably work really well, well except when it is too slow. Other options:1) Use a NPN transistor with the base fed from the pic TX line with an appropriate series resistor, the emitter to ground, and a pullup from the collector to the switched Vcc for the sensor. The size of the pullup resistor combined with the cable capacitance will determine the maximum baud rate (smaller=faster). You'll also need to set the pic to invert the TX line so the inversion done by the transistor is undone. I've done this numerous times and it works well depending on the baud rate. I think I'm running a 10K resistor at 19,200 with much worse cables than you have. Note that since serial idles high, generally this isn't going to consume any meaningful current until there is data on the line. You'll also want to make sure that the Vce(sat) is low enough to end up with a voltage below VILon the sensor (the low voltage threshold) since the transistor can't pull the line down below Vce(sat).2) Replace the NPN transistor with a N channel fet. This would avoid the potential Vce(sat) issue, but only with a correct FET selection (see below). The Rds(on) will need to be low enough such that the voltage divider created by the pullup resistor and Rds(on) doesn't introduce the same VILissue.3) Use a tri-state buffer gate. These are available around ten cents US in reasonable quantities. After some digging, I found the SN74LVC1G240 which has a active-low output enable which matches the polarity of the output of the comparator when driving a P-Channel FET. There are also active-high output enables. You'd power these from the same VCC as the PIC, and then tie the OE pin to either the output of the comparator, or the switched HV rail depending on the OE polarity. This would effectively turn off the TX pin when the power goes off. Note that the SN74LVC1G240 I mentioned has an inverting gate, so you'd need to invert the TX pin on the PIC like the above solution. Some of the others don't invert, but the ones I found don't have an active-low OE pin, and I think I'd want to tie this to the output of the comparator so that this pin shuts off as quickly as possible instead of starting after the PCH fet turns off.4) A probably non-option: Use a fet as a 'true switch' in the dataline. I can't get my head around how this would work reliably in the signal line without a lot more circuitry. I'll explain below.But first to help you with the FET questions:If you look at Figure 2 in the 2n7000 datasheet athttps://www.onsemi.com/pub/Collateral/2N7000-D.PDF,you'll find a chart which shows the drain current at a certain gate voltage.If you look at this chart, you will find that in order to reliably get 200mA through the device you'll need at least 4V of Vgs, which is the voltage between gate and source. This is more than 3.3V. If you look at 3V, you'll find that the mA is pretty close to zero... so it really isn't all that functional at 3V. Vgs(th) is the point where the fet is just starting to turn on, not the point where it is fully on.Compare figure 2 at the DMG2310L datasheet athttps://www.diodes.com/assets/Datasheets/DMG2301L.pdf. Note at 3V you can actually push 10A through it. The Vgs(th) of this part is down around 1V, and you'll note that the Id at this level is also close to zero.Another chart of interest in the DMG datasheet is figure 4. This is Vgs voltage vs on-resistance. You'll notice that the resistance doesn't really start dropping until somewhere just below 2V. At 3V, it's pretty close to as good as it can get, and any additional voltage isn't really all that helpful. So this Fet is really useful only above 2V with 3V or over being ideal.In option #2 above, I said that you'd need a N channel FET. I just did a quick search, it looks like a FDV301 would probably work - in fact the Fairchild datasheet shows this very application. There are others, that's just the first one I found. I typically don't use N channel fets since I'd typically need a higher Vds, and at the voltages I use, NPNs are much more widely available and less expensive.A quick hint: The spec which is usually listed in the part summary which will quickly tell you if you should look further is a line which will be something like:Rds(on) = 5\$\Omega\$ @ Vgs = 2.7V.This says the transistor will have a resistance of 5 ohms at 2.7V. If you don't see a reasonable value below the voltage of operation, look on.One other note before I move on: There is one area where Vgs(th) is important - that is to turn *off* the device. If you have a very very very low Vgs(th) being driven by something which can't get Vgs lower than the number shown, you won't be able to turn off the device.There are other interesting characteristics, but those are probably the biggest ones to watch for.Now, back to option #4:So, let's assume you put a fet in the data line as a switch. I.E. you break your dataline, and insert the fet into the dataline with G and D attached to the two sides of the 'break'. With a N channel FET, to turn the FET on you would have to raise the gate above the voltage S terminal by the voltage described above. So in your 3.3V data line, you'd need something like 7 volts on the Gate terminal to turn on the data line when the data line is high (since you start with 3.3V, then need 3V more or so).With a P channel FET, you need to have the gate voltage below the S terminal by the appropriate voltage described above. This is why the specs in a P-channel datasheet are almost all negative. So for high voltages on your data line @ 3.3V, this is easy, you just yank the gate to zero and you get -3.3V. But now, what about low... Well, at 0V on the data line, your 0V gate voltage isn't going to be low enough to turn the FET on, which will result in a floating dataline. To fix this you'd have to have the gate voltage be below zero.I'm sure there might be tricks to make this work with a FET inline as a switch, without a lot of level shifting of the Gate, etc., but I find options 1,2, and 3 above to be a lot more straightforward.

author: JDW
author_rank: Frequent Contributor
timestamp: September 03, 2019, 10:12:59 am
content: Quote from: GeorgeOfTheJungle on September 03, 2019, 09:52:10 amThe Fingerprint sensor board has a Holtek 5301LDOthat outputs 3.0V to power the ARM processor and Winbond Flash chip:https://www.eevblog.com/forum/projects/low-voltage-detection-power-cut-ic/?action=dlattach;attach=820047;imageThank you for the capacitor calculations. I found those details very helpful.Quote from: forrestc on September 03, 2019, 10:06:03 amOh, my... You're right. Beautiful observation!I am humbled by the time spent on the rest of your amazing post. I need time for my fleshly CPU to process it all. :-) But you have put me squarely on the right track. I will proceed with my original plan to use 3.3V across the cable.THANK YOU!

author: Ian.M
author_rank: Super Contributor
timestamp: September 03, 2019, 11:06:09 am
content: Re: O.P's reply #27The problem with component distributor parametric searches is usually they employ web developers to build them who don't have even half a clue about hands-on electronics, and the result is signed off on by a MBA who's probably never picked up a hot soldering iron. For most device parameters, for them to be meaningful you need to store both a minimum and a maximum value. Exceptions are specific maximum limit parameters which don't have a meaningful minimum.e.g for a BJT, for its large signal gain hFE, lets say 100 to 400, the database would need a field for each limit. OTOH for IC(max), you only have a single value, lets say 600mA.Therefore if the parametric search doesn't offer you two columns min. and max. for all such parameters and let you make multiple (and ranged) selections in each its borked and once you've got some possibles, you'll have to do a lot of extra work checking datasheets to confirm the actual limits are suitable.It looks like Mouser's MOSFET 'Vgs - Gate-Source Voltage' parameter is just a nominal working voltage, i.e. the device will turn on in a usable fashion with that much voltage on the gate (relative to the source). It isn't the max voltage you can put on the gate without risking device destruction by gate oxide breakdown, it isn't the threshold voltage (which they have as a separate parameter, but don't have separate min. and max. limit columns for), and certainly isn't the gate voltage needed to pass a particular current. If you select 5V and 4.5V for Vgs, you'll get *MOST* of their 5V logic level drive capable MOSFETS, but that's no help whatsoever if you need 3.3V drive capable ones. To find them follow my Vcc/2 rule of thumb and look for Vgs_th in the range 1.65V to 1V:https://mou.sr/32tazApYou don't want too low a minimum as you don't want to risk the MOSFET turning on with a little stray voltage on the gate. You will have to check datasheets before ordering to confirm parameter limits.Most regular MOSFETs have an abs. max. Vgs rating (gate oxide breakdown safety limit) of around 20V. Some low voltage MOSFETs have a abs. max. Vgs rating of only 8V. Typical gate drive (Vgs) in practical applications is often between 50% and 75% of the abs. max Vgs rating.For the sensor RX line cutoff circuit I proposed, with the gate tied to 5V, Vgs would be 1.7V with a logic '1' on the line. For the MOSFET to stay on, max. Vgs(threshold) would need to be <1.7V You only get away with working right down to the threshold voltage because a CMOS logic input draws negligible current. If you have 3.3V sensor Vcc, andyou want to use the MOSFET to block voltage on sensor RX when off, it isn't going to work without a pullup and will need a very low threshold MOSFET, certainly below 2V and preferably below 1V so it isn't relying on the pullup to 3.3V for the majority of the risetime.I *REALLY* don't recommend that. Better to bite the bullet, pay the extra and add a74LVC1T45buffer in the sensor RX line with VCCB from before your sensor power switch P-MOSFET, VCCA from after it and DIR tied to Gnd to make it one way , B(in) to A(out), to guarantee there's no current into sensor RX with the sensor Vcc off.N.B. if you add two extra wires to the sensor cable to bring far end Vcc and far end Gnd back to the main unit, and use a regulator with enable and a feedback pin for the sensor Vcc supply in the base unit, you can remote regulate it to 3.3VAT THE SENSOR, and put everything required for the sensor interface with power monitoring and switching, including the sensor Vcc monitoring, except for the sensor ESD protection and extra bulk decoupling cap decoupling cap, in the main unit. There are a couple of other tricks to it needed for reliability e.g. at the main unit end fit a silicon diode between Vcc out and Vcc feedback so it doesn't blow the sensor with gross overvoltage if the feedback wire comes loose, and a few hundred ohms resistor between Gnd out and Gnd feedback for the same reason.

author: forrestc
author_rank: Unknown
timestamp: September 03, 2019, 12:00:23 pm
content: Quote from: JDW on September 03, 2019, 10:12:59 amThe 8 bit PICs are going toward "Core Independent Peripherals", where you are able to do a lot of things without involving the processor. For instance, I just realized that I missed one more thing about the PIC you selected which would be useful for your application, it was on the second page so I didn't realize this had it...This has 4 copies the CLC peripheral. Which you can configure in many ways including a set/reset latch. If instead of "wiring" the output of the comparator directly to the FET you instead configure it to first go through a CLC peripheral set up as a set/reset latch (internal to the chip), you can then configure the CLC+comparator such that if the voltage drops out, the latch gets set (or reset, whichever is more convienient). This would immediately turn off the FET (which is hooked to the output of the CLC now). Then it won't re-start without you (through software) resetting the latch. So you could enforce a minimum off-time after a brownout. Again, this is without processor control.You can also set the UART TX_out to go through CLC #3. As a result, you can set up CLC3 as a simple AND gate which will AND the TX_out and the status of the 'power control' CLC such that output of CLC3 acts as your normal TX pin from your UART when the power is on to the sensor, or forced low always when the power is off. This eliminates all of the issues with the TX pin as well since 'forced low' is the same as 'off' as far as powering the far end accidentally goes. And again, without processor involvement.So the builtin stuff in the PIC, without using any CPU other than to set things up (and possibly reset it if it browns out) can eliminate both the external comparator and all of the stuff related to disconnecting the TX pin.BTW the CLC is pretty easy to configure using the built-in tool in MCC. There are online tutorials as well.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.

author: JDW
author_rank: Frequent Contributor
timestamp: September 04, 2019, 07:57:04 am
content: Quote from: forrestc on September 03, 2019, 10:06:03 amOnce again, thank you for the advice. I finished a preliminary test with my dual-resistor voltage divider on C1IN3- (RC3, Pin-7) and comparator output on C1OUT (RA2, pin 17). I needed to decrease the 820k to put the trigger threshold closer to 2.8v, ending up with a 1M-ohm and 560k-ohm divider (1% tolerance).The PIC's onboard comparator isn't quite the same as an external device like the TLV3012 insofar as BOREN (the PIC's built-in brown-out RESET) shuts down the comparator when the PIC's Vcc drops too low. But with BOREN set to the LOW threshold, the PIC won't reset until about 2.44V (typical) which is lower than the Comparator's threshold of about 2.8V, so the Comparator will work without BOR interfering.Theproblemis that even with Hysteresis enabled, there's still chattering like mad. It's far worse with Hysteresis disabled -- I tested that case too. But it's still bad with it enabled, as shown in thevideoI made here (turn up the volume to hear my audio commentary):https://youtu.be/cVNaPSZ4-eAI would appreciate hearing your thoughts in light of what you see in my video.NOTE:IanM., I thank you for your reply.

author: JDW
author_rank: Frequent Contributor
timestamp: September 04, 2019, 10:03:21 am
content: Quote from: GeorgeOfTheJungle on September 04, 2019, 08:52:10 amIf you watch my video closely as I move the voltage both up and down, you will see chatter at many different frequencies, not just 60Hz.The point here is that if I use a P-MOSFET activated by the Comparator's output -- which moves up and down exactly as you see on my scope -- the sensor will power up and down accordingly, thereby triggering its software security measure which deliberately wipes all saved fingerprints from its Flash memory chip.The entire point of even checking voltage is to ensure the sensor's Vin doesn't fall between 2.0v and 2.7v. So a chattering solution isn't a good solution at all, I'm sure you will agree. So what I am trying to figure out is if there is a way to eliminate this chatter to have a clean break. When the voltage falls below the threshold, we get a solid HI. And when the voltage rises back, we get a solid LO. We should get those states without the chatter.

author: forrestc
author_rank: Unknown
timestamp: September 04, 2019, 10:09:39 am
content: Quote from: JDW on September 04, 2019, 10:03:21 amSee my second reply last night.Adding a CLC as I described with Set/reset will solve your problem. The first trigger of the comparator will turn off the power until you turn it back on, eliminating chatter. How you determine when you turn it on is up to you. A timeout might make sense. Combining it with monitoring the output of the comparator separate from the CLC might be useful as well (i.e. if you go through the loop for a certain number of cycles without seeing the comparator toggle then you assume power is stable). You could also do this last part with a CCP peripheral where you get a timestamp of when the comparator toggled last.

author: forrestc
author_rank: Unknown
timestamp: September 04, 2019, 10:13:24 am
content: Quote from: JDW on September 04, 2019, 07:57:04 amTry dropping the divider down by a couple decades. 10K and 5.6K. You may find you have to re-adjust the divider.

author: Ian.M
author_rank: Super Contributor
timestamp: September 04, 2019, 10:34:34 am
content: I did recommend a screened cable many posts back. Nobody wants a car you cant start if you parked under a power line or too close to a high power radio transmitting station.However it does seem over-sensitive to ambient EMI. What's the actual circuit, both schematic and photos of the layout, zoomed in on the board, and also zoomed right out showing how the leads to all your test gear are routed.Also what's your bench lighting? If its low voltage please give specific details of its transformer or PSU. It's quite common nowadays for cheaper lighting (and some badly designed expensive stuff) to radiate excessive EMI. The only types of lighting (apart from actual flames, chemlights etc.) that you can be reasonably confident *WONT* radiate EMI, is non-dimmed incandescents (but not low voltage with a switching PSU), fluorescents with line frequency magnetic ballasts and low voltage DC LEDs with a linear power supply (or battery) and linear LED current control. Unfortunately incandescents are being phased out in many countries and magnetic ballasts for fluorescents are becoming difficult to find. If you've got low EMI bench lighting don't throw it out if you upgrade to modern lighting, as you may need to go back to it when testing sensitive circuits!1Meg||560K=359K, which is quite a high impedance and may be making it excessively sensitive to noise. As Forrestc just suggested, try reducing the resistor values an order of magnitude or two. You may well need an external feedback resistor to get enough hysteresis.Forestc has pointed out how the PIC's various peripheral modules can be used to help de-glitch the sensor low voltage lockout signal. However IMHO its important to first get the signal as clean as possible, otherwise you risk designing a circuit that works on the bench, but is the weak link, failing in the field due to localised high EMI, that is not strong enough to disable an unmodified vehicle.

author: JDW
author_rank: Frequent Contributor
timestamp: September 05, 2019, 12:36:31 am
content: IanM.&forrestc,My humble and sincere thanks for kind help and advice you gentlemen are providing. I made a new video this morning showing my room lighting for Ian. The same video shows the result of using a smaller10k & 5.6kresistor divider (with PIC Hysteresis ON):https://youtu.be/5Xk1dtJ5m4YCircuit is on a breadboard using discrete components because it's still in the early design stage.I am now about to try the CLC suggestion to see if I can program my PIC satisfactorily to address the chatter, ensuring that the fingerprint sensor is never toggled ON & OFF repeatedly by a slow decrease in voltage across the chattering voltage range. I will report back on that after I've coded and tested.Thanks.

author: Ian.M
author_rank: Super Contributor
timestamp: September 05, 2019, 02:55:46 am
content: Your circular fluorescent probably has a magnetic ballast and therefore would be low EMI. The give-away clue is the presence of a gas discharge/bimetallic strip starter, as they are usually associated with magnetic ballasts as most electronic ballasts have integrated starter circuits. I haven't got a clue whether or not the fluorescent strip lighting has HF electronic ballasts. If it has the characteristic flickering startup of a gas discharge/bimetallic strip starter, (or you can find one on each strip), probably not. Otherwise check the label and see if you can Google its specs. Most manufacturers are proud enough of their energy efficient electronic ballasts to boast of them in the specs.Still no photo of your breadboard or of the experiment setup on your bench.Without seeing the actual circuit its very difficult to comment usefully on noise issues.From the soundtrack of your video I get the impression you have two DMMs with longUNSHIELDEDleads connected direct to your PIC's comparator pins. Those leads will be acting as antennae and picking up EMI and taking it right to where you don't want it. Try isolating the meter leads from the pins with 100K resistors (which will only cause a 1% readout error on a 10Meg input impedance DMM), and at the meter end of the resistor adding 100nF to ground to reduce any EMI the leads picked up. Also, reduce the loop area available to pick up H-field EMI by twisting the leads together - 5 to 10 turns per meter is plenty, it just needs to keep the positive and negative leads together for as much of their length as is practical.

author: JDW
author_rank: Frequent Contributor
timestamp: September 05, 2019, 03:22:06 am
content: Ian, thank you for sharing your thoughts on room lighting and noise. I actually discovered my stupidity about an hour ago with regard to my Fluke 8845A's RED unshielded wire being the source of induced noise into my voltage divider resistors. When I removed that red probe wire, all the chatter you saw in my videos vanished. Not a single blip across the voltage threshold from low to high. But I think the experience was good in that it is a reminded that if noise is present, chatter could still occur even with the PIC's Hysteresis turned ON. And for that reason, I still need to code the CLC as a preventative measure.For now, I've connected up a PNP and NPN in place of the FETs we've been talking about, since I don't have any FETs in my parts stock. I split my Tx line (Tx from my PIC, Rx at the sensor end) across E-C of an NPN BJT (to make it switchable), with 10k base resistor of that NPN tied to the collector of my PNP (2SB772). The base of my PNP connects to a 560-ohm resistor which connects to the Comparator Output of my PIC (the same Output pin I was probing on my scope). So basically for a rough test I am using the PNP to power the fingerprint sensor and cut the Tx line too. In my testing thus far it actually works and I only measured a scant 1mV voltage drop across the PNP to the output. For testing, I've got a Power Supply that triggers the fingerprint sensor's flash memory wipe code every time I kill power and start power to that Power Supply. But with the NPN and PNP attached, the memory no longer gets wiped at all. And again, what all this is doing is ensuring that the sensor's power gets cut when the voltage drops below 2.8v and keeps it cut all the way down to zero. So far, it's working even with my PIC's brown-out circuit enabled (LO setting).Of course the PNP base resistor requires a few milliamps of current which isn't desirable, so it's best to use a P-MOSFET instead. But again, for this rough test, the goal I set out to achieve (preventing flash memory wipes) seems to be working well. I will create a schematic that graphically explains what I just said later today.Thanks again for your kind help thus far!

author: JDW
author_rank: Frequent Contributor
timestamp: September 06, 2019, 03:00:42 am
content: Apologies for my delayed reply. Below is the simplified schematic of what I am testing on a breadboard -- "simplified" in that it leaves off my 3V relay, LEDs and other less relevant devices for greater clarity.I don't have any MOSFETS in my parts stock, so I breadboard-tested with a PNP. The PNP works great to kill power to the F.Sensor when Vdd dips below 2.81v, but the PNP's base resistor results allows a continuous 4.2mA current flow as long as the Base is LOW (fed by the Comparator1 OUT), which is most of the time. If using a P-MOSFET will eliminate that 4.2mA then I should use a FET instead.Using an NPN to break Tx in the manner shown in the schematic actually works, and signal integrity looks fine on the scope, but I am unsure if that's a sound approach -- it is a bit different than what forrestc recommended in (1) of his earlier post.My switching power supply has internal protection against the output (3.3v@250mA) being shorted to ground, so I think the PNP's collector (which powers the F.Sensor) should be OK as shown on the schematic. Leaving Ground as a straight-through connection between boards is probably okay as well for the same reason. And the 3 signal wires have basic diode ESD protection with resistor as shown (for the PIC side circuit board).I've not had time to do the CLC or the PIC internal voltage division (to eliminateR1&R2) thatforrestcsuggested, but I intend to do that soon and will report back at that time.Thanks toIanM.andforrestcfor your kind help to date.

author: GeorgeOfTheJungle
author_rank: Super Contributor
timestamp: September 06, 2019, 06:22:41 am
content: The clamping diodes ought to come before the current limiting resistors. IOW move R4 to the right side of D3/D4, R3 to the right side of D1/D2, etc. And I'd put clamps + Rs at both ends of the wires.

author: JDW
author_rank: Frequent Contributor
timestamp: September 06, 2019, 06:39:55 am
content: Quote from: GeorgeOfTheJungle on September 06, 2019, 06:22:41 amThank you for the advice!By the way, what do you think of my NPN switching of RB7 (pin 10)? It's working fine in my breadboard bench testing, passing data both ways. I've tested it with Vcc=2.9v and it works fine at that low voltage too. There is a400mV voltage dropacross CE, which is the only minor caveat I'm finding, but again, the two-way data exchange still works fine. In other words, if Vcc=2.9v, RB7(Tx) would also be 2.9v, but F.SensorRx would be 2.5V. And at Vcc=3.3v, RB7=3.3v & F.SensorRx=2.9v. That remains true even if I put RB7 on the Emitter and F.SensorRx on the Collector. (Removing the 470-ohm resistor doesn't affect the 0.4v drop -- it's definitely the drop across CE.) Again, it's working well. It's just that I've not found any other schematics or designs online that show someone else out there has done something similar to switch logic signals across CE of an NPN.

author: GeorgeOfTheJungle
author_rank: Super Contributor
timestamp: September 06, 2019, 07:09:49 am
content: I don't understand why do you want or need to switch the sensor's RX line.

author: JDW
author_rank: Frequent Contributor
timestamp: September 06, 2019, 07:15:14 am
content: Quote from: GeorgeOfTheJungle on September 06, 2019, 07:09:49 amFor now, let'spretendyou (like me) want to cut an Rx or Tx 9600bps data line (reason doesn't matter) and you use NPN as shown in my schematic. Would that circuit satisfy you; and if not, why not?By the way, I added a 100k-ohm pull-up to compensate for the 0.4V drop across CE. That is shown in the revised schematic below. 100k is large enough to ensure the F.Sensor won't be powered by Vdd through that pull-up. I also moved R3/R4/R5 per your recommendation.

author: Ian.M
author_rank: Super Contributor
timestamp: September 06, 2019, 07:59:11 am
content: Quote from: JDW on September 06, 2019, 03:00:42 amFix your designators!!! Half the components have no reference number and there are two instances of R5 with different values.Simplified is not good - Most of the professionals here are experts at reading complex schematics, and it avoids a lot of confusion if you show us the schematic you have actually built, (or that you *believe* you have built).Quote from: JDW on September 06, 2019, 03:00:42 amYou do need to get some MOSFETs, but we understand that organising a parts order and wating for it takes time and its useful to be able to push on with a substitute. However IMHO you haven't got enough base drive for the 2SD772. The rule of thumb for a single BJT saturated switch, is use a 'forced Beta' of 10, i.e. Ic_max/Ib should equal 10. Therefore for a peak load current of 75mA, you should be providing a minimum of 7.5mA base current. Replacing the 620R resistor with a 220R one will improve matters, at the expense of power consumption, which is irrelevant when breadboarding with a mains PSU.Quote from: JDW on September 06, 2019, 03:00:42 amIf you get the right transistor, designed for reversible switching applications, with a high reverse hFE, its viable, but its still going to compromise the logic levels at the sensor and the signal's falling edge. Can you afford to throw away noise margin?Quote from: JDW on September 06, 2019, 03:00:42 amThe time to design in and test over-current protection for the sensor supply is *now* while you are still breadboarding. Relying on your 3.3V switching PSU to limit the current is foolish, as 250mA is plenty to destroy ICs if it gets shorted to an output pin, and the internal bulk decoupling capacitor at the PSU output can probably transiently supply several amps or even tens of amp, if shorted.Also 1N4007 diodes aren't very good for ESD protection - too slow, too high Vf, and too much junction capacitance loading your signals. To be fully effective at eliminating CMOS latchup, external ESD protection diodes must clamp at a low enough voltage for the internal parasitic silicon diodes in the CMOS ICnot to conduct significantly. That means your clamping diodes need a Vf below 0.7V while carrying a significant current pulse, so Schottkys are frequently preferred. BAT54S is a good SMD choice here, with two series diodes in a single three pin package, or axial glass wire-ended BAT81, BAT82 or other similar small signal, low to medium voltage Schottky for breadboarding.George is half right*- the purpose of the resistor between the clamping diodes ant the IC pin is to limit the current into the pin when, at the peak of the ESD strike surge, the clamping voltage goes more than 0.6V outside the rails, but you still need another resistor in series with the signal, the other side of the clamping diodes, between the clamp and the external connection at risk of ESD, to keep the peak ESD strike current down to what the clamping diodes can actually handle (transiently).* Maybe a bit more than half right: if you only have space for one resistor and the Vcc supply is current limited, the CMOS chip may well be able to survive latchup and return to normal after power cycling, but if you don't limit the peak ESD discharge current and the ESD protection diode shorts out, its game over!Quote from: JDW on September 06, 2019, 03:00:42 amWe'll be waiting for an update.We are also still waiting for the bench and breadboard photos so we can see if there are any more obvious howlers like the test lead EMI pickup issue, that we could warn you about before you waste more days!

author: JDW
author_rank: Frequent Contributor
timestamp: September 06, 2019, 08:08:40 am
content: Quote from: forrestc on September 03, 2019, 10:06:03 amI'm not sure what you mean about "Figure 4" in that PDF, as Rds(on) decreases with increase in Vgs, starting at about 2.0V and going up to 8V. "As good as it gets" would appear to be 8V, where Rds(on) looks to be about 70m-ohm.If Rds(on) is 150m-ohm for the voltage my PIC would need to use, the voltage drop across Source & Drain would be 15mV, which I suppose is acceptable.

author: JDW
author_rank: Frequent Contributor
timestamp: September 06, 2019, 08:55:06 am
content: Quote from: Ian.M on September 06, 2019, 07:59:11 amI simplified the schematic, and for that reason alone I only put designators on the parts I felt we would discuss. (But I fully understand your desire to have the full schematic.) And as to there being two R5's though, that was a mistake in my first upload which I corrected an hour later. So a page reload will reveal (or should reveal) the newest schematic in that post of mine. I then revised the schematic for George. And later in this post will be yet a third revision.Quote from: Ian.M on September 06, 2019, 07:59:11 amUnderstood. But with all the time I've spent on replying here, I've not had the time to flesh out the full schematic. I won't have that until Monday at the earliest. For now, I've made some revisions as per your advice. I can probably get away with using the2SC3326with high reverse Hfe. There are now 470-ohm resistors on either side of the diodes, and I changed 1N4007 to BAT54S. I also added the power supply portion.I've noted your suggestion about the PNP's base resistor being 220R, but I based my 620-ohm resistor size on Hfe-min= 30, as per thedatasheet. True, that spec is for Ic=-20mA, but isn't an Hfe=10 an "assumption" as well?I am actually passing 100mA to the F.Sensor when it is fully powered and its LED is turned on. My 75mA figure was measured with my uCurrent Gold and Fluke 116, but I see 100mA when using my Fluke 8845A, which I trust more. So it's 100mA, and the 620-ohm base resistor of that 2SB772 is passing the current just fine.Thank you again for your excellent help to date, Ian. I certainly appreciate your insights and sharp eye for detail.

author: forrestc
author_rank: Unknown
timestamp: September 06, 2019, 09:42:16 am
content: Quote from: JDW on September 06, 2019, 08:08:40 amThe point I was trying to make is that at at around 3V, you start having to add a lot more voltage to get any meaningful change in rds(on). Between 2 and 3V, the Rds(on) drops by around 80mohm, between 3 and 4, you only drop a fraction of that. In fact, going all the way from 3 to 8, you only gain around another 30mV.

author: forrestc
author_rank: Unknown
timestamp: September 06, 2019, 09:47:30 am
content: Quote from: GeorgeOfTheJungle on September 06, 2019, 07:09:49 amThe TX to sensor Rx line idles high and has at least 20mA of drive, probably more.When you turn the power off to the sensor, the TX line will try to power the sensor through the sensor's input protection diode. My suggested solution of automatically turning off the TX line I think would probably be cleaner.

author: Ian.M
author_rank: Super Contributor
timestamp: September 06, 2019, 09:53:43 am
content: An incomplete diagram isn't an issue - just draw a functional block for anything you haven't finalised, but label the signals going to it meaningfully.Sure, a forced hFEof 10, is a rule of thumb assumption, but its specced in many transistor datasheets for the Vbe_sat and Vce_sat graphs. Therefore it makes sense to do so to ensure deep saturation unless your specific transistor datasheet says otherwise. It may only make one or two hundred mV difference to the Vce_sat drop For a peak 100mA load I'd probably go for 180R, but check the actual voltage drop across it as the output current is getting high enough for the Voh droop to become significant, especially at only 3.3V Vdd. If the PIC cant source enough current you may need to add a small signal PNP emitter follower between the pin and the high side PNP Vcc switch's base resistor. You will then need a pullup of 10x the base resistor at tje emitter follower end of it to get a clean turnoff, so its best avoided unless your MCU has really wimpy I/O pin drivers. Nearly all this mess of resistors and BJT driver transistors goes away when you get a suitable MOSFET.A no active devices bodge for the TX line to tide you over till you get CLC or interrupt driven gating for it working, would be a 33K series resistor with 100pF in parallel with it to speed up the edges, and 3K3 between sensor Vcc and ground. Worst case, the 33K resistor limits the current when the sensor is off to under 0.1mA, and it forms a potential divider with the 3K3 resistor, limiting the 'phantom' Vcc voltage to under 0.25V. The 3K3 resistor wastes 1mA, but that's acceptable for bench testing and initial trials.More details of the sensor 'bezel touch' signal would be useful. In fact why not go the whole hog and give us a link to the sensor datasheet?

author: GeorgeOfTheJungle
author_rank: Super Contributor
timestamp: September 06, 2019, 10:00:42 am
content: QuoteI still don't see the need to cut/isolate RX when the sensor is powered down and the PIC isn't. 470R times two (or times 4 if you put two Rs at each end) would give at most ~ 3.3/1k or /2k = 3.3 mA or 1.6mA which isn't enough to do any harm in any way as far as I can see. Not to mention the huge voltage drop means it can't possibly power up/turn on the sensor board.

author: Ian.M
author_rank: Super Contributor
timestamp: September 06, 2019, 10:15:48 am
content: Without seeing the sensor datasheet we cant know if 1.6mA is potentially harmful. Way back in the first post JDW wrote: "The Sensor draws about 75mA in its full power state (and microamps when sleeping) ...", so if it starts up in sleep mode, its Vcc could potentially reach nearly 3.3V just from parasitic power through several K of resistance from an idling UART TX pin, provided there are no other loads on the switched Vcc rail. Obviously, its not going to stay in sleep mode after powerup for long, but if Vcc rises into the danger zone before it exits sleep, and the firmware doesn't lock out EPROM writes for an adequate interval after powerup, memory corruption is highly likely.

author: GeorgeOfTheJungle
author_rank: Super Contributor
timestamp: September 06, 2019, 11:06:08 am
content: But VIn will drop to ~ nought as soon as it tries to exit sleep mode. On top of that, he could put RB7 to 0 programatically when needed just to be sure.Quote from: Ian.M on September 06, 2019, 10:15:48 am1.6e-3A * 2000Ω = 3.2V of voltage drop across R. I don't think the sensor board can run much less erase the flash with 0.1V at VIn.

author: Ian.M
author_rank: Super Contributor
timestamp: September 06, 2019, 11:56:58 am
content: If there's 1.6mA available with the far end grounded, there's about 160uA available with the far end Vcc at 90% Voh - 1 * diode_Vbe_drop. That's right in the middle of the OEM's 2.0V to 2.5V memory corruption danger zone. If the load's a lot lower Vcc will reach just above the top of the danger zone so any protection in the sensor firmware may deactivate. How many us or ms can the sensor's onboard decoupling caps hold up Vcc above its Vbor or MCU's minimum operating voltage?And then we have situations like Microchip's 8 bit PICs' tendency to keep executing instructions and incrementing the program counter slightly below the minimum voltage, but some instructions glitch. That gave a high probability of hitting the FLASH or EEPROM write routine if present, and resulting memory corruption, so that slowly rising/falling Vdd without BOR enabled had a high probability of bricking anything that used a bootloader or EEPROM.There's got to be something hinky about the firmware or hardware design in the first place for it to be vulnerable to memory corruption on brownout, as most modern MCUs have an internal BOR or UVLO module that if enabled, will hold them in reset below their minimum rated voltage, and together with an appropriate delay after powerup before unlocking writes, can reduce the risk of corruption by many orders of magnitude, and virtually eliminate it if there is sufficient bulk capacitance + self-monitoring of its Vcc, to confirm there's enough energy available to complete the pending write sequence tto leave the memory structures consistent. However they probably couldn't meet the sleep current specs marketing wanted with BOR/UVLO enabled, and writing robust NV memory access code that handles write errors and recovery from them properly isn't a job for the intern or the CEO's grandson, so it isn't so much 'cant fix' with a firmware update but 'won't fix'!I've already stated the easiest fix - increase the TX line series resistance and put a load resistor on Vcc sufficient to keep it well below the danger zone.If quiescent current is a major issue, I've already recommended the 74LVC1T45, which is explicitly specified to be hi-Z when only one side of it is powered, or as has already been suggested, simply make the master firmware disable the TX pin output or override it and drive it low when the sensor Vcc is meant to be off. No CLC is needed - simply disable the UART and release the pin (and set low/hi-Z) in the comparator ISR on sensor Vcc falling below the threshold, + flag to the main code that the UART is not available, so it aborts any pending data transfer and knows to reinitialise it when the sensor is next powered up.

author: forrestc
author_rank: Unknown
timestamp: September 06, 2019, 11:05:47 pm
content: Quote from: Ian.M on September 06, 2019, 11:56:58 amThe only reason I suggested the CLC was that there was some discussion that the worst case delay of ~2.5ms due to interrupts being off during HEF writes was too slow, and that disabling the UART in the ISR wouldn't be fast enough. The whole purpose of the CLC was simply to shorten that worst-case delay to <1uS.Just to be clear, I don't disagree with your assessment at all. Just wanted to clarify the reason I was suggesting the CLC in the dataline.I really suspect what is going on with the fingerprint sensor is that they're watching for multiple crossings of some voltage around 2.25V within a short period of time. If they see more than a given amount, they wipe internal flash to prevent any possible power glitching attack. In that case, if one hangs around with Vcc in 2.0 to 2.5V then there is a good chance that the memory will be wiped just due to Vcc noise.

author: Ian.M
author_rank: Super Contributor
timestamp: September 06, 2019, 11:26:33 pm
content: Hmm. I'd respond to power glitching by wiping a series of flag locations and for each one wiped, doubling the delay after Vcc becomes stable within its valid range before responding to any commands or fingerprints. It only takes an initial 10 second lockout and by the 16th glitch attempt they'll have to wait a week before they can try again. Reset the flag locations on command only if power is stable and the master fingerprint is used for authentication.

author: JDW
author_rank: Frequent Contributor
timestamp: September 07, 2019, 01:52:43 am
content: Quote from: Ian.M on September 06, 2019, 10:15:48 amHere is thedatasheet.Here is theProgramming Guide.Here is amarked-up photoI took of the bottom PCB of the sensor (the top is just the sensor itself with some ceramic caps and connectors at either end).As mentioned in my previous post, my earlier mention of 75mA current consumption was in error. For some reason my uCurrent Gold was giving me that value on my Fluke 116 DMM, but when I later tested with my benchtop Fluke 8845A, I measured a solid100mAflowing to the sensor at 3.3V when the sensor was powered on and its LED lit. So let's please forget the 75mA number and use the correct 100mA value going forward. Also note that the datasheet mentions130mA, which I assume are peak current because I could not measure anything above 105mA during a lot of testing with my Fluke 8845A.The manufacturer finally answered my question to them about the two 5-pin components marked "A2RC" in my photo by saying they are both LDO's used in a proprietary way they cannot disclose, which assume means they are somehow involved in the flash memory anti-tampering auto-wipe security feature. (That means there are a total of 3 LDOs on this fingerprint sensor -- U3, U4 & U5.) When I cited some Vin voltage-range specs from the Holtek "02A-4" MCU datasheet, the manufacturer replied that MCU wascustomizedby Holtek for them, but they would not disclose how. They emphasized that the Holtek 02A-4 MCU needs 3.3V and that I should not operate it within the 2.0v to 2.7v danger zone, nor should it ever be fed 5.0V. This is an important detail since the UART side Vin connector can accept voltages up to 6.0V.Using continuity-check while probing the bottom of the fingerprint sensor PCB, I found that the 5V pad on the "UART side" shown in the photo leads straight to the Holtek53013.0V regulator on the TOUCH IC side, which in turn powers the ARM processor and the Winbond Flash IC. However, Vin for the Holtek 02A-4 MCU comes straight in (unprotected, but with some ceramic decoupling capacitors) from the connector atop the TOUCH IC side. And again, according to the manufacturer, Vin for that 02A-4 MCU must be 3.3v. They refused to disclose a range of input voltages for it, but I tested that it works fine at Vin will down into the 2.0v to 2.7v danger zone.The connector on the TOUCH IC side can be left alone and unpowered (i.e., when not connected, the Holtek 02A-4 MCU would be completely powered off). But when the 02A-5 MCU is powered (it draws less than 60uA even when powered) the connector on the TOUCH IC side provides an output from a leg on that Holtek 02A-4 MCU which becomes HI for as long as a finger is touching the metal frame that surrounds the optical fingerprint sensor. When you remove your finger, that output goes LO. You can of course issue UART commands to the sensor to ask it if a finger is pressed, but they provide this other way to get that info which is faster and provides that info even when the fingerprint sensor is in sleep mode.Ground for the Holtek 02A-4 MCU is straight through to the UART side connector, so to use the TOUCH IC connector means one only needs to connect Vin (which must be 3.3v) and then one can use the Finger Detect Output, which again comes straight off the I/O pin o the 02A-5 MCU. The manufacturer confirmed that so long as the UART side connector's Vin is a nominal 3.3V, I can safely connect the TOUCH IC side's Vin to the UART side Vin, powering them both at the same time. And since the TOUCH IC side draws so little current, it's fine to keep it powered all the time. And that is why you see it connected in such a way on my simplified schematic.Ground for the Holtek 02A-4 MCU is straight through to the UART side connector, so to use the TOUCH IC connector means one only needs to connect Vin (which must be 3.3v) and then one can use the Finger Detect Output, which again comes straight off the I/O pin o the 02A-5 MCU. The manufacturer confirmed that so long as the UART side connector's Vin is a nominal 3.3V, I can safely connect the TOUCH IC side's Vin to the UART side Vin, powering them both at the same time. And since the TOUCH IC side draws so little current, it's fine to keep it powered all the time. And that is why you see it connected in such a way on my simplified schematic.By the way, if you watched the unlisted videos I posted on YouTube, you will spot the benchtop power supply I used during testing. That power supply normally triggers the auto-memory wipe of the fingerprint sensor nearly every time I switch it off and then on again. But after I added the low voltage detection and power cut via PNP & NPN you saw in my schematic, the auto-wipe doesn't occur anymore -- not even when I deliberately glitch-test on my breadboard. I've tested this power supply via OFF/ON almost 100 times, so I can say that with a certainty. I don't see any glitching when I probe the output of that power supply while connected to my breadboard. The only thing I see is that it someone slowly ramps up voltage from 0v to 3.3v, which is no doubt an intentional soft start inside that power supply. So perhaps the fingerprint sensor manufacturer has setup their circuit and software to look for a certain voltage ramp? They made it clear I should not power it with 2.0v to 2.7V, but they didn't specify how long it could be in that voltage range before the auto-wipe occurs.I have also been testing at my computer using thisUSB-to-3.3V interfaceand I almost never experienced auto-wipe no matter how many times I yanked out and inserted the USB connector. Regardless, the PNP & NPN circuit shown in my most recent schematic has, in my testing thus far, eliminated the auto-wipe problem.

author: RIKRIK
author_rank: Contributor
timestamp: September 08, 2019, 10:53:04 pm
content: What a bus driver or tristate buffer?. However you would need a opamp as a voltage comparator to turn it on and off.

author: JDW
author_rank: Frequent Contributor
timestamp: September 09, 2019, 02:42:49 am
content: Quote from: forrestc on September 03, 2019, 10:06:03 amI found the following two 3-state unidirectionalnon-invertingbuffers withactive-low enableand internalESD protection:NC7SZ125P5X- ESD Human Body Model Protection: 4000V max, Operating Temp: +85°C maxNL17SH125P5T5G- ESD Human Body Model Protection: >3000V max, Operating Temp: +125°C maxDo you know if the ESD protection is on the input, the output or both? (Datasheets don't specify this.) If ESD protection is on the Output, then would the buffer alone be sufficient as shown in the modified (& simplified) schematic below? (Note the buffer on RB7 with no supplementary ESD protection.)Note in the bottom left that I also swapped out my PNP for the P-MOSFET you suggested. Not sure if R10 being 100k is too big, but turn on time isn't critical. It will be ON most of the time, so 100k would help keep wasted current consumption to a minimum.

author: JDW
author_rank: Frequent Contributor
timestamp: September 10, 2019, 08:19:18 am
content: Quote from: forrestc on September 03, 2019, 12:00:23 pmI spent the day testing theDAC, since I had never used it before. The16F1508 datasheethas 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 beenconfigured 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 be2.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 is1/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]/32Find Vdd when DACx_out = FVR(1.024v):1.024v = Vdd x 12/32Vdd = (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 small26mVdifference 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 a66mVdifference between Upper and Lower, which offers better noise immunity.If you have any thoughts on this and my previous post, please let me know.