PDA

View Full Version : Silly MCLR question



kevj
- 10th November 2007, 02:10
This must be on page one of a data sheet someplace, but am I to assume....

- Whenever the MCLR pin is pulled low, the Pic will reset and start it's code execution again - fresh start, from the top "reboot" like?

I'm powering the pic with a 3.3 v supply from a volt pump - when I disable the pump, the supply will drop back to 1.5v (AA battery) - the min voltage for the pic (16F677) is 2.0, so I'm assuming it'll "die" and start from the top when the volt pump is re-activated and the voltage supply comes back up to 3.3v - but I want to make sure.

If I set the rest of the design to pull the MCLR low at the same time the volt pump is turned off, and held low until it's turned back on - this should allow a clean "restart" of the PIC each time.... right?

Seemed obvious, but figured I'd ask before building it. :)

sayzer
- 10th November 2007, 09:30
I am not sure whether you would be able to do it at the same time.

But if it does not happen as you expected, try the following idea.

Assuming you will have enough time to bring your supply voltage back to 3.3V before the super cap goes below 2.0V, this circuit, at least the idea, will be good enough to overcome your issue.

Depending on the time your V+ comes back to 3.3.V, you may not need a super cap.
May be, just a regular 10,000uF / 10v will be good enough.

<img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=2127&stc=1&d=1194686618">

kevj
- 10th November 2007, 19:10
Thanks - that helps.

I'm really asking if bringing MCLR low can cause any problems with the code in the pic. How much does it "reset"? I understand I need to supply 13v to put it into programming mode - I just want to make sure holding the MCLR low over a long period won't cause corruption to the code, and if I'm correct in assuming this will insure a "reboot" when I next start the pic.



Actually, what I'm trying to do is create a single momentary tact switch that turns the whole system on and off. A very small draw during "off" is fine, but I want to shut down as many current consuming devices as possible.

My volt pump draws about .08 mA idle with no load and the sleeping pic draws almost nothing (nano-watt model).

1. My first thought was to just sleep the PIC when the power button is held for 1 second, turn off all the LED's and main components, then just let the volt pump continue to feed the PIC it's sleeping current, which will draw down the battery but will take weeks to do so, which isn't a major problem with this application.

But then I wanted to get creative and see if I could shut down more....

2. My volt pump has a SHDN pin - bring it low and it stops pumping, and draws almost zero current, the output however drops back to 1.5v (single cell battery) rather than going to zero. I assume 1.5 v is enough to shut the PIC all the way down, but I want to make sure it really totally resets for the next power-up.


I don't have the schematic to post, but I'm feeding the compoenents temporarily via a diode line that comes off my tact switch, once the PIC powers back up, it'll power it's own reset pin and the hold the SHDN pin of the volt pump high, and brace all of this with a small cap so there's no dips and spurratic resets.

When "power down" happens, I'll just turn off this "life line" pin then sleep the following instruction - in theory, the brace cap should discharge causing the volt pump to shut down (it's SHDN pin pulls low), and the same line now pulls MCLR on the pic low to insure it's "reset" for the next power up.

Maybe that's over complicated, but that's the best solution I could come up with for using a single tact switch to function as a "power" for the whole system.

BrianT
- 10th November 2007, 20:20
Low Voltage.
I suggest you very carefully experiment and verify what your PIC will do with a 1.5 volt supply. The datasheets are silent about such operation. I had a bunch of data loggers where the 3.7 volt battery went completely flat and the processor code was all erased - not scrambled - erased. The first 60 +/- bytes looked valid but from there to top of memory all locations read FF. Normally my loggers come back while the 3.7 volt Lithium Thionyl still has some charge left but I was shocked to find that all 6 loggers with the flat batteries had erased the program code and scrambled the same three EEROM locations as well. Fortunately the data stored in the external flash memory was intact. There must be a low voltage erase mechanism in the 18F4620 as the only voltage source in my loggers is the 3.7 volt button cell. LVP was turned off in the config fuses but the pin was floating.

Current draw.
Getting the "nano-watt technology" to draw nanowatts is quite a challenge. So many registers must be set/cleared and powering down the peripherals like external memory must be sequenced just right or you lose data or get excessive current spikes.
My data loggers have a PIC18LF4620 with two M25P64 for 16 MByte storage plus an ECG amplifier, accelerometer, pressure transducer, RTC and temperature sensor. The RTC and PIC are permanently powered up but the M25P64, amplifier and other sensors are power switched through PNP transistors. The PIC has a 4 MHz crystal.

The lowest current draw I can get down to is a sleep at around 3 microamps or about 10 microwatts. Processor, amplifiers and peripheral current is 3 mA and during the flash write to the M25P64 the current jumps to 12 mA for less than a second. Hardly nanowatts by my definition.

If your logger draws less curent I would like to know how you did it.

Cheers
Brian

kevj
- 10th November 2007, 20:52
Low Voltage.
I suggest you very carefully experiment and verify what your PIC will do with a 1.5 volt supply. The datasheets are silent about such operation. I had a bunch of data loggers where the 3.7 volt battery went completely flat and the processor code was all erased - not scrambled - erased.


Hmm.... that's disturbing. Anyone else have that happen?

I can't imagine they'd design a pic that would zap itself just from a dead battery - I'd imagine all kinds of electronics "dying" all of a sudden just becase a battery went dead, but I guess anything is possible.

Is the idea then to make sure and power the pic *all the way* down - zero volts, power rail tied to ground? That seems a bit extreme to make sure it's totally de-powered, but maybe it's a good idea. I'd expect there are thousands of devices out there where the pic sees some residual voltage from a capacitor or something.

We're going to run a batch of quite a few of these things where the design will be hard to change after the fact, so if they do start to die due to the low voltage, it'll be a major problem to fix them.

BrianT
- 11th November 2007, 03:12
Hello KevJ,
I am not saying Microchip have a problem but they are not specifying anything below 2.0 volts. I will now have to experiment with my loggers on the bench with a resistor across the battery to hasten its decay and see what happens as the voltage falls and the internal impedance of the battery goes up. Just dropping the supply voltage to simulate a decaying battery will not cut it as the real battery internal impedance will vary considerably as the battery decays and I won't see that by just winding down the supply voltage from a bench supply.

It would be nice if any of the PICs had a bandgap reference that the programmer could access. That way you could calculate the battery voltage and put in a software halt before the battery collapsed. I can't see how to measure battery volts via a direct connect PIC ADC referenced off Vdd. There needs to be a voltage reference somewhere in the circuit. The Brownout Detector can flag a 2.0 volt dip so there must be a reference buried inside the PIC somewhere - I just can't see where to find it.

At 1.5 volts you are off the data sheet and will have to build your own maps of what works and what does not.

Cheers
Brian