PDA

View Full Version : A note on power reduction when using the END statement on a BS2



metron9
04-12-2007, 12:01 PM
If you have a circuit connected to the basic stamp and you have pins set to OUTPUT your stamp can leak current.
Set all pin directions to input before using the END command.

I noticed this when I was measuring the current on an SRAM 32k x 8 chip. It takes .7uA in standby to retain data but when I used END to turn off the stamp I noticed the current start going up. The leaking was from the address input pins on the SRAM while the stamps pins connected to them were set to output.

If the above information is not correct please correct it but setting the pins to input did drop the current to .7uA at 5V

This is similar to most other processors I have worked with when putting them in sleep mode.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think Inside the box first and if that doesn't work..
Re-arrange what's inside the box then...
Think outside the BOX!

Mike Green
04-12-2007, 12:29 PM
Actually, the opposite is true. If you set all the pins to input and they're connected to inputs, the lines will float and, in particular, will float across the switching threshold in response to induced noise in the signal lines and cause the input MOSFETs to go into their linear conduction region and draw more current. You may do better setting any normally output pins to low outputs. Any strobe or chip select pins that are active low should be set to high outputs.

If you read pretty much any CMOS datasheets, particularly for discrete devices, they'll say that unused inputs should be connected to either ground or Vdd rather than being allowed to float. Some input circuitry is designed to be allowed to float, but usually this will be stated explicitly in a datasheet.

metron9
04-12-2007, 02:01 PM
Mike, I guess I should read the PIC datasheet, but I'm not talking about a floating pin, I am talking about a pin that could sink current after the stamp has issued an END statement. If you have a pin set to input LOW connected to a device current can flow from the device to the stamp pin.

I thought it was odd though to see the current start going up as these pins were connected to the input address ports on the SRAM. It looked like current from the SRAM was flowing into the stamp, so I thought it best to turn them to inputs assuming the END command turned off the input buffers, apparently it does not as you suggest.

I tested the current again both ways output low and input and now I don't get any increase in current either way, perhaps my meter was fooling me.

The thing I am working on is taking a regular SRAM chip and a mega16L to accept data from the stamp using 2 pins shiftout and shiftin commands to store external data. I am designing routines to push and pop all 26 bytes so variables can be used by selecting banks of memory as well as storing up to 32K of data. I plan to use a backup battery and one of the ADC pins to monitor the battery in the same way the more expensive SRAM chips do that have their own internal backup battery. 100 ns write times so no delay and no wearing out of memory.

I have it connected using 15 pins on the stamp for testing so I only have 4 bit address to test but it works like they say in the art of electronics "like falling off a log"

Thanks for the information on the floating inputs, now I know why they say ground unused pins on devices but I don't think one should do that on a stamp as an inadvertent HIGH signal would not be good as well as a LOW if connected to VDD. Better to just disconnect the battery when not in use I would think.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think Inside the box first and if that doesn't work..
Re-arrange what's inside the box then...
Think outside the BOX!

Mike Green
04-12-2007, 09:43 PM
For just the reason you mentioned (accidently setting a pin to output high), you never ground or connect to Vdd an I/O pin. The pins to ground or to Vdd are the input-only pins.

Tracy Allen
04-13-2007, 01:15 AM
I would just second everything that Mike said. The conditions to achieve minimum power should be carefully analyzed and tested. The effects of floating inputs are sometimes not immediately apparent, and the state of neighboring pins and the condition of a circuit boad (clean? moist? hot?) and even a wave of the hand in the air nearby can affect the result.

This statement "Better to just disconnect the battery when not in use I would think." is not true if there are several power supplies involved, such as battery backup or self-powered sensors or where part of a system remains active. For example, if an SRAM needs battery backup but the processor connects to it powers down, special consideration has to be given to the chip select on the memory. Or, if a BASIC Stamp powers down but external inputs do not, careful attention has to be given to possible sources of parasitic power. Also, when the Stamp executes END, any pins configured as outputs will blip to inputs once every two seconds or so, and any devices such as power supplies or actuators have to be set up to tolerate that.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com (http://www.emesystems.com)