Electronics > Projects, Designs, and Technical Stuff
Low Voltage Detection & Power Cut IC
forrestc:
--- Quote from: JDW on September 03, 2019, 10:12:59 am ---
--- Quote from: forrestc on September 03, 2019, 10:06:03 am ---I 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...
--- End quote ---
Oh, my... You're right. Beautiful observation!
--- End quote ---
The 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.
JDW:
--- Quote from: forrestc on September 03, 2019, 10:06:03 am ---...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.
--- End quote ---
Once 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.
The problem is 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 the video I made here (turn up the volume to hear my audio commentary):
https://youtu.be/cVNaPSZ4-eA
I would appreciate hearing your thoughts in light of what you see in my video.
NOTE: IanM., I thank you for your reply.
JDW:
--- Quote from: GeorgeOfTheJungle on September 04, 2019, 08:52:10 am ---That's line noise, it's flipping @60Hz.
--- End quote ---
If 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.
forrestc:
--- Quote from: JDW on September 04, 2019, 10:03:21 am ---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.
--- End quote ---
See 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.
forrestc:
--- Quote from: JDW on September 04, 2019, 07:57:04 am ---Once 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).
--- End quote ---
Try dropping the divider down by a couple decades. 10K and 5.6K. You may find you have to re-adjust the divider.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version