Author Topic: Chicken Door Opener / 4 AA cells direct to PIC?  (Read 17656 times)

0 Members and 1 Guest are viewing this topic.

Offline NivagSwerdnaTopic starter

  • Super Contributor
  • ***
  • Posts: 2495
  • Country: gb
Chicken Door Opener / 4 AA cells direct to PIC?
« on: May 05, 2017, 02:16:09 pm »
I'm knocking up a gadget to add to my chicken house door which already has a door opener

Basically I am just going to intercept the timer wires and add a manual override with an UP and DOWN button.
This could probably have been achieved with a bit of logic but I have loads of bits and pieces in the junk box so I have decided to use...
a PIC18F1320 in conjunction with a 2-coil latching relay and a couple of switches. (The idea being that in normal operation the gadget is off and out of circuit with the normal behaviour through the relay, pressing a button wakes it up, latches the relay and powers the circuit until it turns itself off again some time later)

I'm proposing to just attach the PIC et al direct to the existing battery supply (4xAA) of the chicken door with a protection diode (also giving a voltage drop)

Is this reasonable or should every microcontroller have a voltage regulator?

Thanks in advance
« Last Edit: May 26, 2017, 05:28:52 pm by NivagSwerdna »
 

Offline tszaboo

  • Super Contributor
  • ***
  • Posts: 7377
  • Country: nl
  • Current job: ATEX product design
Re: 4 AA cells direct to PIC?
« Reply #1 on: May 05, 2017, 02:55:03 pm »
4AA is up to 6V, diode drop is not 0,6V but depends on how much current there is, down to 0V. So technically no. Realistically, your PIC will never break, because it works up to 5.5V and to get it damaged, you need power, so some current. Is there any chance it will get the full 6V through a GPIO?
 

Offline Jay_Diddy_B

  • Super Contributor
  • ***
  • Posts: 2733
  • Country: ca
Re: 4 AA cells direct to PIC?
« Reply #2 on: May 05, 2017, 02:59:56 pm »
Hi,

Can you tap the battery? That is run the uP from three cells and any power stuff from 4? You may need level shifters (transistors or MOSFETs).

Regards,

Jay_Diddy_B
 

Offline CJay

  • Super Contributor
  • ***
  • Posts: 4136
  • Country: gb
Re: 4 AA cells direct to PIC?
« Reply #3 on: May 05, 2017, 03:14:07 pm »
Use an HV variant PIC?
 

Offline mikeselectricstuff

  • Super Contributor
  • ***
  • Posts: 13747
  • Country: gb
    • Mike's Electric Stuff
Re: 4 AA cells direct to PIC?
« Reply #4 on: May 05, 2017, 03:18:19 pm »
More diodes to ensure it can never go over 5v. There's plenty of room to go down before it stops working.
Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 

Offline Spuddevans

  • Supporter
  • ****
  • Posts: 68
  • Country: gb
Re: 4 AA cells direct to PIC?
« Reply #5 on: May 05, 2017, 04:10:56 pm »
Or use 4 Nimh rechargables, ie 4.8V

Tim
 

Offline NivagSwerdnaTopic starter

  • Super Contributor
  • ***
  • Posts: 2495
  • Country: gb
Re: 4 AA cells direct to PIC?
« Reply #6 on: May 05, 2017, 04:19:53 pm »
The part, PIC18F1320 is rated to 5.5V.  I don't really want to change the batteries with are currently Alkaline.

One thing I hadn't considered was voltage sag when the door motor is raising... I'll have to measure that otherwise I might be looking at Brownouts.

I thought a diode would drop 0.6V... is that too simplistic/wrong?
 

Offline BrianHG

  • Super Contributor
  • ***
  • Posts: 7733
  • Country: ca
Re: 4 AA cells direct to PIC?
« Reply #7 on: May 05, 2017, 04:36:12 pm »
Fresh brand new alkalines are as high as 1.7v.  That's 6.8v.  For my similar projects, I use 2 silicon diodes in series, 1N400x series, to power my PIC, which runs at 5.5v on the nose with 4 brand new batteries.  Remember, the PIC will run even below 2.5v and as your batteries drain to 1v each, total of 4v, the PIC will still be working receiving 2.6v.
 
The following users thanked this post: NivagSwerdna

Offline Howardlong

  • Super Contributor
  • ***
  • Posts: 5319
  • Country: gb
Re: 4 AA cells direct to PIC?
« Reply #8 on: May 05, 2017, 04:52:19 pm »
Perhaps you could use an ultra low current linear regulator like the MC78LC00 series, and use a PIC18LF1320 at 3.3V, with your power electronics direct from the batteries?

The MC78LC00 series have a typical quiescent current of 1.1uA, which is about 200 years on a bank of series AAs.
 

Offline rob77

  • Super Contributor
  • ***
  • Posts: 2085
  • Country: sk
Re: 4 AA cells direct to PIC?
« Reply #9 on: May 05, 2017, 05:00:40 pm »
i would use 1 cell + MCP1624/1640 boost converter for the micro and keep the 4 cells for the IO. linear regulator has a higher quiescent current, so i wouldn't go that way. those mcp1624/1640 were developed for powering PIC MCUs.
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19520
  • Country: gb
  • 0999
Re: 4 AA cells direct to PIC?
« Reply #10 on: May 05, 2017, 05:21:53 pm »
The part, PIC18F1320 is rated to 5.5V.  I don't really want to change the batteries with are currently Alkaline.

One thing I hadn't considered was voltage sag when the door motor is raising... I'll have to measure that otherwise I might be looking at Brownouts.

I thought a diode would drop 0.6V... is that too simplistic/wrong?
A diode will drop is less than 0.6V at low currents or high operating temperatures, look up the diode equation.

The MCU is rated to operate up to 5.5V, so irrespective of whether specified or not on the datasheet, it can withstand higher voltages, without any damage. Even more so, if you're not planning to operate it anywhere near the maximum temperature rating of 125oC. Running close to or slightly above the maximum specified voltage rating, might not be ideal and could potentially shorten its life slightly but this is only a hobby project and not a high reliability application then it will be fine.
 

Offline Howardlong

  • Super Contributor
  • ***
  • Posts: 5319
  • Country: gb
Re: 4 AA cells direct to PIC?
« Reply #11 on: May 05, 2017, 07:54:14 pm »
Note the specs for F version of the device are 4.2-5.5V, which is why I was suggesting a low Iq 3.3V LDO instead of a diode and the LF version which runs at 2.0 to 5.5V, although you need to take care of the clock speed limitations at lower voltages, not a problem I'd have thought in this application.

My concern is over running power electronics with an MCU on an unregulated supply, as glitches on the supply can cause a lot of unwanted headaches. I learned that lesson sometime in the mid 70s when a voltage regulator was a week's pocket money, so I tried without, and it scarred me for life!
 

Offline NivagSwerdnaTopic starter

  • Super Contributor
  • ***
  • Posts: 2495
  • Country: gb
Re: 4 AA cells direct to PIC?
« Reply #12 on: May 22, 2017, 09:29:21 am »
It was going quite well... I have the switching relay working and with a 100uF capacitor to keep the PIC alive long enough to fully switch the relay off it can turn itself off.

However, I have a slight unexpected problem and I'm a bit stuck at how to solve it (and I apologise in advance to all those who thought I should keep the PIC alive but in sleep)

The circuit basically has two in contacts that lead to two out contacts.  The in contacts are connected to a timer which is open most of the time but closed some of the time to close the door, my circuit effectively goes in between.

When asleep the idea of my circuit was that it would be completely out of circuit however I have one point where I ran out of switch contacts... the door sense input pin is permanently wired from the input to RB1.

I did a test where the output was connected to an LED via a limiting resistor to the +ve rail, it works perfectly BUT when the circuit is in straight through mode there should be zero current and the LED should be off (I think the actual output goes into a part of the door opener that charges a capacitor that operates a FET), however instead there is a very faint glow.  It appears that a very small current is going through RB1 to ground even though the PIC is powered off.  (PORTB had pin-ups enabled and RB1 was configured as an input when the PIC lost power)

300k into 5V... is actually quite a big current... 17uA? 

Any suggestions on how I could reduce this leakage current or do I need to go back to the drawing board?

Thanks in advance
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 8172
  • Country: fi
Re: 4 AA cells direct to PIC?
« Reply #13 on: May 22, 2017, 10:30:07 am »
4AA is up to 6V

With fresh alkaline batteries, significantly more, you should design for at least 1.65V/cell = 6.60V, which is way over the absolute maximum rating even with a single series diode, and I wouldn't rely on the DCR of the AA cells combined with increased leakage in the PIC before the destruction; fresh, high-quality cells can and definitely will damage a 5.5V rated PIC except by pure luck.

Was there a problem using 3 AA cells? That would be the standard way. Otherwise, a bunch of series diodes (normal PN diodes, not schottkys) can be pretty much trusted to drop at least about 0.3-0.4V each, even at miniscule currents caused by leakages. So you need absolute minimum of three, preferably four.

But a simple 3V3 LDO may be easier and cheaper than four diodes in series.
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19520
  • Country: gb
  • 0999
Re: 4 AA cells direct to PIC?
« Reply #14 on: May 22, 2017, 10:51:08 am »
4AA is up to 6V

With fresh alkaline batteries, significantly more, you should design for at least 1.65V/cell = 6.60V, which is way over the absolute maximum rating even with a single series diode, and I wouldn't rely on the DCR of the AA cells combined with increased leakage in the PIC before the destruction; fresh, high-quality cells can and definitely will damage a 5.5V rated PIC except by pure luck.
The over voltage might explain the increased leakage but you're be very unlucky if you destroy the PIC. It will be able to withstand 6.5V and the diode will drop some voltage, even at low currents. Perhaps if it's operating at its maximum temperature rating, whilst being subjected to the absolute maximum voltage, then there's a real risk of damage, otherwise it's highly unlikely.
 

Offline NivagSwerdnaTopic starter

  • Super Contributor
  • ***
  • Posts: 2495
  • Country: gb
Re: 4 AA cells direct to PIC?
« Reply #15 on: May 22, 2017, 11:12:03 am »
I'm currently using a 5V bench supply.
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 8172
  • Country: fi
Re: 4 AA cells direct to PIC?
« Reply #16 on: May 22, 2017, 11:35:57 am »
The over voltage might explain the increased leakage but you're be very unlucky if you destroy the PIC. It will be able to withstand 6.5V and the diode will drop some voltage, even at low currents. Perhaps if it's operating at its maximum temperature rating, whilst being subjected to the absolute maximum voltage, then there's a real risk of damage, otherwise it's highly unlikely.

Maybe we are reading different datasheets, but the one in front of me(*) says +5.5V on the Vdd pin respect to the Vss pin is the absolute maximum rating.

And in my experience, exceeding datasheet absolute maximum ratings, often even slightly, have the tendency to blow the parts up very quickly, or worse, do some sneaky damage that will cause undefined, hard to debug behavior later on.

Maybe this particular part is different for one reason or another, I don't know, but extraordinary claims require extraordinary evidence, and without such evidence, I would not speak about blowing it up would be unlikely.

In any case, trusting the prior experience on particular PIC parts surviving and working properly even after severely exceeding absolute maximum ratings is a stupid engineering decision, since the manufacturing process for the parts can change at any point of time without prior notice. This is especially dangerous advice for a noob, since noobs will have enough strange issues to solve in the vast world of MCUs already; overvoltage damage is easy to avoid by not applying overvoltage on purpose.

Get the power supply within specs with ample margin, decouple with a lossy electrolytic, and apply proper ceramic decoupling right next to the MCU power pins, take basic ESD precautions, and you can expect that any strange behavior is most likely due to bugs in code.

(*) http://ww1.microchip.com/downloads/en/DeviceDoc/39605F.pdf
« Last Edit: May 22, 2017, 11:39:53 am by Siwastaja »
 
The following users thanked this post: janoc

Offline NivagSwerdnaTopic starter

  • Super Contributor
  • ***
  • Posts: 2495
  • Country: gb
Re: 4 AA cells direct to PIC?
« Reply #17 on: May 22, 2017, 11:42:54 am »
I have never exceeded 5V with this part.... seems the over-voltage police are out in force today.
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: 4 AA cells direct to PIC?
« Reply #18 on: May 22, 2017, 12:01:13 pm »
Make sure external /MCLR and INTOSCIO (if available) are enabled in the CONFIG. Power the PIC with 5.0V +/-5%.  Jumper /MCLR to Vss to hold the PIC in reset.  That forces all I/O pins to be inputs.  If the leakage current for any of them is greater than the maximum limit in the datasheet electrical characteristics section, AND the pin voltage is between the Vdd and Vss rails (inclusive) the PIC is damaged, probably due to ESD.   If the problem goes away when the PIC is held in reset, there's something wrong with your code . . . .

I'm with those who say NEVER over-voltage a MCU.  Although there are anecdotes about PICs surviving excessive voltage up to maybe 12V and apparently working afterwards, you never see a proper followup where the PIC was tested to see if it still met its datasheet specs etc.   They are the MCU equivalent of a "Man bites Dog" news story.  A low power 5V LDO regulator isn't grossly expensive, you need Vdd decoupling anyway, so with its input cap its only two extra parts for in-spec Vdd and peace of mind.
 
The following users thanked this post: NivagSwerdna

Offline NivagSwerdnaTopic starter

  • Super Contributor
  • ***
  • Posts: 2495
  • Country: gb
Re: 4 AA cells direct to PIC?
« Reply #19 on: May 22, 2017, 12:13:00 pm »
If the leakage current for any of them is greater than the maximum limit in the datasheet electrical characteristics section
I assume the datasheet limits are intended for when the device is powered?  So in my case the PIC isn't powered (except via the protection diodes???)...
 

Offline Howardlong

  • Super Contributor
  • ***
  • Posts: 5319
  • Country: gb
Re: 4 AA cells direct to PIC?
« Reply #20 on: May 22, 2017, 12:17:31 pm »
It appears that a very small current is going through RB1 to ground even though the PIC is powered off.  (PORTB had pin-ups enabled and RB1 was configured as an input when the PIC lost power)

300k into 5V... is actually quite a big current... 17uA? 

I may well have misunderstood, but if the PIC's not powered but there is voltage on a non-power pin, the protection diodes on that pin will effectively supply power the PIC.

Having said that, RB1 is also an analogue pin so there may not be a Vdd protection diode. This doesn't mean you should ever apply a voltage above Vdd or below Vss except in very specific case like programming.

From the datasheet:

Code: [Select]
Voltage on any pin with respect to VSS (except VDD, MCLR and RA4) .......................................... -0.3V to (VDD + 0.3V)

Apologies if I've misunderstood what's happening here.

(Edit: sorry, I started writing this about 90 mins ago, others have since jumped in).
« Last Edit: May 22, 2017, 12:19:06 pm by Howardlong »
 
The following users thanked this post: NivagSwerdna

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: 4 AA cells direct to PIC?
« Reply #21 on: May 22, 2017, 12:26:13 pm »
You cant do that.
Quote from: Absolute Maximum Ratings
Voltage on all other pins with respect to VSS ......................................... -0.3V to (VDD + 0.3V)
When unpowered, Vdd=Vss=0V, so voltages on I/O pins *MUST* be limited to +/- 0.3V.

If you need to turn a PIC 'off' while maintaining logic levels on input pins, you need to use SLEEP mode.   Done right, the quiescent current consumption is negligible - e.g a CR2032 coin cell could power a sleeping PIC till the end of its shelf life and still have charge left.  Done wrong (unnecessary peripherals left enabled,  outputs loaded or floating inputs), it could drain the same coin cell in days or weeks.
 
The following users thanked this post: NivagSwerdna

Offline NivagSwerdnaTopic starter

  • Super Contributor
  • ***
  • Posts: 2495
  • Country: gb
Re: 4 AA cells direct to PIC?
« Reply #22 on: May 22, 2017, 12:30:11 pm »
When unpowered, Vdd=Vss=0V, so voltages on I/O pins *MUST* be limited to +/- 0.3V.
Ah.  Now that could be a problem.  Vdd is flapping in the breeze.  RB1 is at the end of the current limiting resistor so being pulled up (not sure how far).
So... back to the drawing board... or put a common drain source follower in front??  I need some way of isolating RB1 as an input when the PIC is unpowered.
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19520
  • Country: gb
  • 0999
Re: 4 AA cells direct to PIC?
« Reply #23 on: May 22, 2017, 12:57:41 pm »
The over voltage might explain the increased leakage but you're be very unlucky if you destroy the PIC. It will be able to withstand 6.5V and the diode will drop some voltage, even at low currents. Perhaps if it's operating at its maximum temperature rating, whilst being subjected to the absolute maximum voltage, then there's a real risk of damage, otherwise it's highly unlikely.

Maybe we are reading different datasheets, but the one in front of me(*) says +5.5V on the Vdd pin respect to the Vss pin is the absolute maximum rating.

And in my experience, exceeding datasheet absolute maximum ratings, often even slightly, have the tendency to blow the parts up very quickly, or worse, do some sneaky damage that will cause undefined, hard to debug behavior later on.

Maybe this particular part is different for one reason or another, I don't know, but extraordinary claims require extraordinary evidence, and without such evidence, I would not speak about blowing it up would be unlikely.

In any case, trusting the prior experience on particular PIC parts surviving and working properly even after severely exceeding absolute maximum ratings is a stupid engineering decision, since the manufacturing process for the parts can change at any point of time without prior notice. This is especially dangerous advice for a noob, since noobs will have enough strange issues to solve in the vast world of MCUs already; overvoltage damage is easy to avoid by not applying overvoltage on purpose.

Get the power supply within specs with ample margin, decouple with a lossy electrolytic, and apply proper ceramic decoupling right next to the MCU power pins, take basic ESD precautions, and you can expect that any strange behavior is most likely due to bugs in code.

(*) http://ww1.microchip.com/downloads/en/DeviceDoc/39605F.pdf
There must be an error in the datasheet. They specify it to work up to 5.5V, yet also state it's the absolute maximum rating. Making the maximum operating voltage equal to the maximum rating would be a very bad idea and is generally not done. In light of this information, we need to refer to another datasheets for another PICs in the same family, which will be made using the same process therefore have the same tolerance to over-voltage.

http://ww1.microchip.com/downloads/en/DeviceDoc/39632e.pdf
http://ww1.microchip.com/downloads/en/DeviceDoc/39689f.pdf
http://ww1.microchip.com/downloads/en/DeviceDoc/39758D.pdf

The all say 7.5V as the absolute maximum voltage applied between VSS and VDD. I only guessed 6.5V because it's what the older 5.5V parts such as the old 12F509 are rated to.
 
The following users thanked this post: pelud

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: 4 AA cells direct to PIC?
« Reply #24 on: May 22, 2017, 01:16:18 pm »
Lets see a schematic of what you have so far.
I suspect the mistake is trying to power down the PIC without also powering down *EVERYTHING* connected to it.  As its max quiescent current is under 5uA (in SLEEP mode, all peripherals shut down etc.), if you leave it powered, it will  use under 2% of the capacity of a battery of Alkaline AA cells in their 7 year shelf life - negligible compared to the expected 20% self-discharge.

 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf