Chicken Door Opener / 4 AA cells direct to PIC? - Page 1
Forum section: electronics / projects

author: NivagSwerdna
author_rank: Super Contributor
timestamp: May 05, 2017, 02:16:09 pm
content: I'm knocking up a gadget to add to my chicken house door which already has a door openerBasically 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

author: tszaboo
author_rank: Super Contributor
timestamp: May 05, 2017, 02:55:03 pm
content: 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?

author: Jay_Diddy_B
author_rank: Super Contributor
timestamp: May 05, 2017, 02:59:56 pm
content: 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

author: CJay
author_rank: Super Contributor
timestamp: May 05, 2017, 03:14:07 pm
content: Use an HV variant PIC?

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: May 05, 2017, 03:18:19 pm
content: More diodes to ensure it can never go over 5v. There's plenty of room to go down before it stops working.

author: Spuddevans
author_rank: Unknown
timestamp: May 05, 2017, 04:10:56 pm
content: Or use 4 Nimh rechargables, ie 4.8VTim

author: NivagSwerdna
author_rank: Super Contributor
timestamp: May 05, 2017, 04:19:53 pm
content: 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?

author: BrianHG
author_rank: Super Contributor
timestamp: May 05, 2017, 04:36:12 pm
content: 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.

author: Howardlong
author_rank: Super Contributor
timestamp: May 05, 2017, 04:52:19 pm
content: 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.

author: rob77
author_rank: Super Contributor
timestamp: May 05, 2017, 05:00:40 pm
content: 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.

author: Zero999
author_rank: Super Contributor
timestamp: May 05, 2017, 05:21:53 pm
content: Quote from: NivagSwerdna on May 05, 2017, 04:19:53 pmA 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.

author: Howardlong
author_rank: Super Contributor
timestamp: May 05, 2017, 07:54:14 pm
content: 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!

author: NivagSwerdna
author_rank: Super Contributor
timestamp: May 22, 2017, 09:29:21 am
content: 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

author: Siwastaja
author_rank: Super Contributor
timestamp: May 22, 2017, 10:30:07 am
content: Quote from: NANDBlog on May 05, 2017, 02:55:03 pmWith 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.

author: Zero999
author_rank: Super Contributor
timestamp: May 22, 2017, 10:51:08 am
content: Quote from: Siwastaja on May 22, 2017, 10:30:07 amThe 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.

author: NivagSwerdna
author_rank: Super Contributor
timestamp: May 22, 2017, 11:12:03 am
content: I'm currently using a 5V bench supply.

author: Siwastaja
author_rank: Super Contributor
timestamp: May 22, 2017, 11:35:57 am
content: Quote from: Hero999 on May 22, 2017, 10:51:08 amMaybe 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 theabsolute 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 beunlikely.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 incode.(*)http://ww1.microchip.com/downloads/en/DeviceDoc/39605F.pdf

author: NivagSwerdna
author_rank: Super Contributor
timestamp: May 22, 2017, 11:42:54 am
content: I have never exceeded 5V with this part.... seems the over-voltage police are out in force today.

author: Ian.M
author_rank: Super Contributor
timestamp: May 22, 2017, 12:01:13 pm
content: 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.

author: NivagSwerdna
author_rank: Super Contributor
timestamp: May 22, 2017, 12:13:00 pm
content: Quote from: Ian.M on May 22, 2017, 12:01:13 pmI 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???)...

author: Howardlong
author_rank: Super Contributor
timestamp: May 22, 2017, 12:17:31 pm
content: Quote from: NivagSwerdna on May 22, 2017, 09:29:21 amI 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: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).

author: Ian.M
author_rank: Super Contributor
timestamp: May 22, 2017, 12:26:13 pm
content: You cant do that.Quote from: Absolute Maximum RatingsWhen 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.

author: NivagSwerdna
author_rank: Super Contributor
timestamp: May 22, 2017, 12:30:11 pm
content: Quote from: Ian.M on May 22, 2017, 12:26:13 pmAh. 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.

author: Zero999
author_rank: Super Contributor
timestamp: May 22, 2017, 12:57:41 pm
content: Quote from: Siwastaja on May 22, 2017, 11:35:57 amThere 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.pdfhttp://ww1.microchip.com/downloads/en/DeviceDoc/39689f.pdfhttp://ww1.microchip.com/downloads/en/DeviceDoc/39758D.pdfThe 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.

author: Ian.M
author_rank: Super Contributor
timestamp: May 22, 2017, 01:16:18 pm
content: 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.

author: NivagSwerdna
author_rank: Super Contributor
timestamp: May 22, 2017, 01:17:17 pm
content: To be fair the device I am currently using is 18F1320 (which I had lying around)...Voltage on VDD with respect to VSS ... -0.3V to +5.5V

author: NivagSwerdna
author_rank: Super Contributor
timestamp: May 22, 2017, 01:18:41 pm
content: Quote from: Ian.M on May 22, 2017, 01:16:18 pmGood plan. I'll draw something up.

author: NivagSwerdna
author_rank: Super Contributor
timestamp: May 22, 2017, 02:01:33 pm
content: OK... posting my circuit (from memory)... only on the basis that you all promise to play nicely.... (I know I should probably use a LDO and sleep mode)... The gadget will be on for approx 3 hours per month.

author: Ian.M
author_rank: Super Contributor
timestamp: May 22, 2017, 02:39:28 pm
content: The kindest thing I can say about that schematic, is that the design was obviously an evolutionary process. Your choice of an optocoupler for non-isolated output is unusual and rather power-hungry.You could futz around with another 2N7000 MOSFET to disconnect the IN signal from RB1, with a pullup to Vss on the RB1 side, or even with a diode so IN can only pull the pin low, but IMHO the best option would be to ditch the relay and start over with the buttons and IN signal on interrupt capable pins so they can wake the PIC from sleep, and have it always powered and 'in the loop'. IN would need to be on an IOC capable pin (RB4 or RB5 assuming you want to keep the ICSP/ICD pins free) so you could wake on both edges, but the buttons could be on ordinary INT pins (RB0-3) as you only need to wake when they are pressed. If the wakeup was a button push it would perform whatever action you require, but if it was an IOC from the IN signal and it wasn't already performing a button action, it would simply repeat that to the OUT.We'd need a few more details about the IN and OUT signals to decide on the best interface for each . . . .

author: NivagSwerdna
author_rank: Super Contributor
timestamp: May 22, 2017, 02:56:53 pm
content: Quote from: Ian.M on May 22, 2017, 02:39:28 pmQuote from: Ian.M on May 22, 2017, 02:39:28 pmHm. The intention was that when active the output would be isolated. When the latch is latched the OUT is driven by the Opto and not connected to anything else but they do share ground. On reflection I guess that could just be a 2N7000. I didn't want to sink the current directly at the PIC since it could be >5V. I also don't know the lower bound of the door terminal so if it was very low... that might not be good for VDS in a FET solution? Ideally I would not have the shared ground.. but I wasn't sure how to do that without more switching!Quote from: Ian.M on May 22, 2017, 02:39:28 pmYeap. I was wondering that.Quote from: Ian.M on May 22, 2017, 02:39:28 pmDefinitely the simplest.. but I'm not sure exactly how to drive the outputs...Quote from: Ian.M on May 22, 2017, 02:39:28 pmOK... it's like this... the existing door opener has two terminals which connect to a timer. The timer is normally-open but goes to closed during the door closed interval. The terminals don't have any definition of their polarity and/or relation to ground or battery. With a multimeter it appears that one of the terminals is directly connected to the same terminal that the battery -ve arrives from. i.e. the door closes then the door terminal is shorted to ground.So for my gadget I have two input terminals for the timer... this is normally open but closed when the timer demands door close. On the output it seems I need only one terminal since ground is really shared... on that terminal I need to be able to short it when I want the door closed and leave it open when I want the door open.The idea of the gadget is that it holds the door open/closed as per user request until the timer matches the desired state at which point it goes to sleep.A look at the door opener circuit itself suggests that there is a positive potential on the door timer terminal which when grounded either charges up the gate of a FET or allows a current to flow and turns on a BJT... not sure which... it's a black box to me.The gadget is very rarely used... hence the desire for low to zero quiescent power demand.Thanks for the interest

author: Ian.M
author_rank: Super Contributor
timestamp: May 22, 2017, 03:47:42 pm
content: I think I get that - the existing door motor box has an input that is continuously monitored.If it transitions to grounded, the door closes then the motor shuts off. If it transitions to open, the door opens then the motor shuts off. The existing timer has volt-free contacts that shorts that input to ground when the door is scheduled to be closed.As is, even with the relay, it has to maintain its output until the timer 'catches up'. The drive current for the 4N24 is killing your power consumption. Even at only 1mA (and I suspect you are using far more,) that's equivalent to a weeks power for a PIC in sleep mode, worst case, and probably something like 6 weeks to 2 months power if the typical figures are to be believed.Interfacing to the door motor without extra quiescent current isn't a problem - a N-MOSFET can do that easily. The problem is the timer output - its grounded for the entire door closed period, so if you simply use a pullup resistor it will be drawing current whenever the door is closed. You can mitigate that by using a high value pullup, but that increases the sensitivity to noise, and although you can use a debouncing algorithm to ignore the noise, the increased average current consumption due to unwanted wakeups during the door open period could be worse than the pullup resistor consumption during door closed.If the pullup is under about 400K you'd do better to enable the watchdog timer (using SWDTEN), and use it to provide a wakeup every minute or two, during which you enable the pullup (by setting an output pin driving the other end of the pullup to '1'), poll the IN signal and then turn the pullup off (actually turn it into a pulldown, by setting its control pin to '0'), all within a few ms.

author: NivagSwerdna
author_rank: Super Contributor
timestamp: May 22, 2017, 04:07:52 pm
content: Quote from: Ian.M on May 22, 2017, 03:47:42 pmThis is actually an assumption that has always bothered me. The existing timer shorts two contacts. The definition that one is ground was by observation... ideally I would not assume that and just short or non-short two contacts without any particular reference to voltage or polarity but I don't know how to do that... I'm just ignorant in that respect. I thought an Optocoupler might be a place to start but then ended up with common grounds since I wanted the gadget off state to be pass-through and only one side was switched. (And the opto has a specific polarity).Quote from: Ian.M on May 22, 2017, 03:47:42 pmIt's a few mA which is BIG in the scheme of things but I'm also flashing the LEDs on the buttons so it is reasonably power hungry when operating. e.g. You press DOWN and the DOWN button flashes intermittently until DOWN matches timer DOWN and then it turns off. It does look nice though.I also have a stay open/shut mode.. after a long-press... which leaves the door open/shut with the respective button permanently illuminated (until another press).

author: Ian.M
author_rank: Super Contributor
timestamp: May 22, 2017, 04:45:11 pm
content: Quote from: NivagSwerdna on May 22, 2017, 04:07:52 pmIf you really need a volt-free contact output with minimal power consumption, we are back to latching relays. You couuld use a photo-MOSFET optoisolator like theTLP175Ato provide a volt-free output that doesn't mind the polarity, but it needs 5mA of drive current for its LED, not exactly ideal when it could be required to sustain it for hours.However, once you have confirmed that one terminal of the door motor box timer input is actually ground there is absolutely no reason to go the the extra expense and complexity compared to using a simple transistor output.You should measure the input current with the timer disconnected and the input terminals shorted via a DMM on mA, and also check the terminal voltage relative to battey 0V with the input open. That would give you enough to be certain of your output requirements.Quote from: NivagSwerdna on May 22, 2017, 04:07:52 pmI'd use low duty-cyle flash pattens for both. 1/10 second on every ten seconds is still highly visible, but it reduces the average current by a factor of 100. Even if you use a double flash to indicate the stay open/shut mode, that's still a factor of 50 better than just leaving the LED on all the time.

author: Zero999
author_rank: Super Contributor
timestamp: May 22, 2017, 10:33:40 pm
content: Quote from: NivagSwerdna on May 22, 2017, 01:17:17 pmBut that's the range of voltages the MCU is supposed to survive. There's no guarantee it'll work over that range. It's specified to work from 2V to 5.5V. This is because under abnormal conditions, e.g. voltage spikes on the power supply, the voltage may be outside the design range, which may cause it to fail meet its specifications, not destruction of the device.There's an error in the data sheet for the 18F1320. The absolute maximum voltage range is always wider than the operating voltage range. For example if we look at a data sheet for the 18F1330 which is very similar to the 18F1320 and manufactured using the same process, the voltage range on VDD with respect to VSS is -0.3 to +7.5V. In fact the maximum ratings for temperature, currents, power dissipation and other voltages are exactly the same as the 18F1320, the only exception being the upper bound on VDD.http://ww1.microchip.com/downloads/en/DeviceDoc/39758D.pdfSo what does this mean? Your MCU will be able to withstand 7.5V for a short period of time, even though its only designed to work up to 5.5V. It may not meet all its specifications when run above 5.5V and isn't good design practise to run it outside its specification but it won't blow up when connected to four fresh AAs via a diode.Sorry for going off on a tangent. You're currently running it of 5V, which is well within the specification.

author: NivagSwerdna
author_rank: Super Contributor
timestamp: May 22, 2017, 11:08:34 pm
content: Quote from: Ian.M on May 22, 2017, 02:39:28 pmI was out tonight but a few minutes tinkering before bed.... I added a diode at RB1 and that solves the original problem, in fact functionally it actually seems to work now.When I have time I will swap out the 4N25 for a 2N7000. Power consumption when driving ON is currently up to 25mA (there are three LEDs, one on the button, one to indicate the door and one for luck I added earlier), using a FET will probably halve that and then I can lose the extra LED at some point.I also need to reduce the duty flash cycle for forced up/down.I will probably call that Mk 1 design and give it a test in situ and see if it actually works.One issue I can foresee is power supply sag when the motor is lifting the door.

author: Ian.M
author_rank: Super Contributor
timestamp: May 22, 2017, 11:28:58 pm
content: Quote from: NivagSwerdna on May 22, 2017, 11:08:34 pmYes, that might not be so good. You could add 5.5V supercap after the diodes to keep Vdd up while the motor's running - just keep the LEDs off for long enough for full door movement so you only have to power the PIC through the brownout.

author: NivagSwerdna
author_rank: Super Contributor
timestamp: May 23, 2017, 12:16:20 pm
content: Just as well I added the diode... when in straighthrough mode the RB1 input gets connected to OUT. OUT has unknown potential...Might have to re-think this with much more isolation and perhaps a seperate supply for the gadget.

author: NivagSwerdna
author_rank: Super Contributor
timestamp: May 23, 2017, 09:58:50 pm
content: Back late... and out to the shed...I measured the voltage across the battery terminals... 6.37V... when the door is lowering it drops to 6.28V and when raising it drops to 6.20V so the sag isn't too bad.I measured across the timer outputs... it had 0.565V across it... didn't expect that. Resistance measures 27kOhms in one direction, infinity in the other... I think that is telling me something.. Open Collector Output Transistor.When the timer is across the door contacts it has a constant 0.012mA current flowing through it.I think the Mk1 door opener should work... it might have to wait until the weekend to try it in anger.... I'm already considering Mk2... perhaps a 74HC4053 and a LDOed PIC.... any other suggestions or do you think Mk1 was really optimal

author: Ian.M
author_rank: Super Contributor
timestamp: May 23, 2017, 10:52:05 pm
content: That current and measured voltages would imply the door opener probably has a 470K pullup. I think MkII can be simplified to one PIC that's in the loop all the time + a 2N7000 to interface to the door opener, with a 470K pullup on the PIC's input from the timer + any LEDs you want on separate pins. You'll be hard-put to beat the two diodes to drop the voltage as it can be difficult to find LDO regulators that have less than 10uA quiescent current even when their input voltage isn't enough to maintain the output. Its probably worth staying at a nominal 5V Vdd as going down to 3.3V would mean you'd need to replace the 2N7000 with a low Vgs threshold MOSFET.A total quiescent current of under 20uA should be possible, which would have a negligible impact on AA battery life.

author: NivagSwerdna
author_rank: Super Contributor
timestamp: May 23, 2017, 11:02:23 pm
content: Quote from: Ian.M on May 23, 2017, 10:52:05 pmThe buttons would need pull-ups (or downs)... looking at the datasheet the power budget for PORTB pull-ups is somewhere between 50 to 400 uA.... which is >>20uA... are you proposing sampling rather than wake on interrupt?

author: Ian.M
author_rank: Super Contributor
timestamp: May 23, 2017, 11:17:30 pm
content: No. because you cant control the internal pullups individually on this PIC, use external pullup resistors. Try 470K with 1nF capacitance to Vss at each pin to make them less sensitive to noise. The only pullup that will draw current continuously is the timer input one, when the timer is commanding door closed. The button pullups wont draw current unless the button is pressed so they could be 100K with no issues.Some comments on the power budget:An Energiser E91 (AA) Alkaline cell has an approximate capacity of 2800mAH, and a shelf life of 7 years to 80% remaining capacity. The self-discharge is therefore 80maH/year, which is equivalent to a 9uA drain. An extra drain that left the batteries at 50% capacity after 7 years would have negligible impact on their life in any application so you've got about 14uA to play with, or far more if you replace them at least annually with freshly purchased ones.

author: Howardlong
author_rank: Super Contributor
timestamp: May 24, 2017, 05:44:47 am
content: Not withstanding others' valuable contributions, and for fear of flogging a dead horse ;-)As I recommended above, LDO regulator MC78LC00 series. 1.1uA Iq, Vin up to 12V (note many low Iq regulators do not have a reasonably wide Vin).Using an unregulated power supply, especially relatively high internal resistance dry batteries with intermittent inductive loads and high current draw, is almost certainly going to take your PIC outside of its operating envelope (4.5-5.5V).Use the LF version and a 3.3V regulator such as the MC78LC33. This will give you sufficient headroom for voltage drop. No need for any super caps. Regulators aren't just there for voltage drop, they're there to remove excesive power input fluctuations.

author: NivagSwerdna
author_rank: Super Contributor
timestamp: May 24, 2017, 07:25:31 am
content: Quote from: Howardlong on May 24, 2017, 05:44:47 amYour horse is well alive, and your suggestions are well taken and much appreciated.I have a LM2936BM-3.3 sitting next to me, MC78LC00 looks interesting. (I also have some MCP1703A somewhere).I don't have any PIC LF types knocking about.... Might try a PIC12LF1571 although the AT Tinys (for which I don't have an ICD) look pretty interesting for this application. I think my 2N7000 will operate at the lower voltage... I've got a few of those.

author: Howardlong
author_rank: Super Contributor
timestamp: May 24, 2017, 08:35:10 am
content: You need to look at LDOs considering multiple facets, but in your application you are looking for:o Low Iq (say <2uA) for prolonged battery life. LM2936 looks about 15uA :-(o Low drop out voltage (say <200mV for your max PIC operating current)o Reasonably high Vin max (say >7V) especially as ISTR you may have an inductive load on the unregulated sideo Sufficient current (>=50mA)o Low enough output voltage to allow for operation with partially depleted batteries even when batteries under load.o Output voltage within PIC specNote that some more modern PICs in the standard F versions operate from about 2.5V to 5V. The PIC18F1320 is quite old in this respect, only operating from a fairly narrow range of 4.2 to 5.5V.The PIC12F1571 is 2.3 to 5.5V, while the PIC12LF1571 is 1.8 to 3.6V, both with a slightly higher Vmin of 2.5V for Fosc>16MHz.I would still recommend a low Iq LDO even with the PIC's extended voltage range, to mitigate voltage transient effects on an unregulated rail. Such transient effects are often very difficult to track down, you might as well deal with them ahead of time.There is a negative about using a lower PIC voltage such as 3.3V and that is that the Vgs to switch on the MOSFET might not be sufficient to fully switch on a 2N7000 depending on its load. At this point, it's time to choose an alternative MOSFET or use a bipolar transistor instead (Si bipolars switch on at ~0.7V, but check the DS for the collector/emitter leakage current when off!).(Edit: just saw Ian.M already addressed the 2N7000 Vgs issue).

author: Howardlong
author_rank: Super Contributor
timestamp: May 24, 2017, 08:37:58 am
content: Don't forget back EMF diodes across your inductive loads (i.e., relay or solenoid coils).

author: NivagSwerdna
author_rank: Super Contributor
timestamp: May 24, 2017, 09:34:28 am
content: Quote from: Howardlong on May 24, 2017, 08:35:10 amYou're not going to like this... According to the datasheet I actually think the 2N7000 would continue to provide sufficient drive even at the lower voltage.I'm open to suggestions and not fussy about through-hole versus SMD. 2N7002? BSS138?Quote from: Howardlong on May 24, 2017, 08:37:58 amI'm rapidly running out of diodes.

author: Ian.M
author_rank: Super Contributor
timestamp: May 24, 2017, 11:07:13 am
content: You definitely need a PIC that can operate well below 4.5V. However a trap for the unwary with older PICs that can run below 4.5V, as well as at 5V, is that many of them require >=4.5V for chip erase, so if you run them from a 3V battery or from a 3.3V regulator that cant tolerate its output being taken to 5V while programming (or with other non-5V tolerant devices on the same rail), then you can only program them in circuit *ONCE*. That's OK for production, but not so much fun for development. Younger players who aren't obsessive about reading the datasheet often discover this the hard way with much wailing and gnashing of teeth when something expensive on their 3.3V rail lets the holy smoke out when they attempt a chip erase with the programmer supplying target power.I would question the selection of PIC12 parts for a one-off project that isn't space or weight constrained. Although its possible to use the ICSP pins for general I/O, doing so makes it impossible to debug in-circuit (if the PIC12 in question even has built-in debug support) without an expensive debug header, so if you need more than 3 I/O pins then there is a clear case for using a debug capable PIC16 with enough pins to avoid the need to use the ICSP pins in the application circuit.@NivagSwerdna: What PICs do you actually have in stock (ignoring >28 pin ones)? You may have one with a better operatig voltage range . . . .

author: Howardlong
author_rank: Super Contributor
timestamp: May 24, 2017, 11:43:18 am
content: Quote from: Ian.M on May 24, 2017, 11:07:13 amAgreed, I am not sure it's even possible to be over-obsessive about the DS parameters, and also add to that the errata: you should at least have scanned the errata to at least be aware of any gotchas that may affect your design at an early stage.It's also not unusual to find yourself re-reading portions of the DS several times in an effort to try to make sense of things.Ignore the DS & errata parameters at your peril, the devil is in the detail.

author: NivagSwerdna
author_rank: Super Contributor
timestamp: May 24, 2017, 08:04:53 pm
content: Quote from: Ian.M on May 24, 2017, 11:07:13 amThese are the LFs I have lying around...PIC12LF1840-I/PPIC16LF18313-I/PPIC16LF1939-I/PPIC16LF1824-I/PThe PIC16LF1824 looks quite fun. Has some kind of SR LatchAnd the F'sPIC10F322-I/PPIC12F1572-I/PPIC16F1509-I/PPIC18F4450-I/PPIC16F18323-I/PPIC24F16KA101-I/PPIC16F648A-I/PPIC18F1320-I/PThat's all folks. (The others have a lot more pins)I also found a couple of MCP1703A-3302

author: Ian.M
author_rank: Super Contributor
timestamp: May 24, 2017, 08:57:47 pm
content: Quite a lot of F parts work down to 3V. e.g. PIC16F1824 has an operating range of 1.8V-5.5V. So please don't limit your list of what's on hand to just the LF parts.

author: NivagSwerdna
author_rank: Super Contributor
timestamp: May 24, 2017, 10:08:14 pm
content: Quote from: Ian.M on May 24, 2017, 08:57:47 pmUpdated list. PIC16F648A now that brings back some memories.I probably would need to check the errata on that one!

author: Ian.M
author_rank: Super Contributor
timestamp: May 24, 2017, 10:42:45 pm
content: I wouldn't go and buy a PIC16F648A new for this as there are cheaper better choices, but its plenty good enough for the job. It will run down to 3V although it cant be erased reliably below 4.5V. Its errata aren't objectionable. The only major one is EEPROM write can result in incorrect instruction execution on pre rev A5 silicon - there is a workaround and AFAIK you don't need to use the EEPROM anyway.However the PIC16F1509 is a better choice - its got an operating range of 2.3V to 5.5V, individually controllable pullups and IOC on ports A and B, and is debug capable. Also its CLC (configurable logic cell) could be used to implement pass-through of the timer output to the door controller input while the PIC stays asleep.

author: NivagSwerdna
author_rank: Super Contributor
timestamp: May 24, 2017, 11:31:57 pm
content: Quote from: Ian.M on May 24, 2017, 10:42:45 pmI feel a bit guilty putting such a capable device to such a purpose. It seems to be £1.31 so is an expensive solution if cost were important, which it isn't. I haven't used CLC before... that might be a lot of fun.... now to see if I can actually find the thing!

author: NivagSwerdna
author_rank: Super Contributor
timestamp: May 25, 2017, 11:42:19 am
content: I haven't used CLC before but this seems pretty straightforward....DEMAND = What the user wantsDRIVEN = Whether driven by user or straight throughIN = from timerOUT = out to motorDEMAND_MET = interrupt to wake PIC to tidy up after timer has caught up with demand.Logic attached

author: Ian.M
author_rank: Super Contributor
timestamp: May 25, 2017, 12:12:52 pm
content: Yes, with four cascadeable CLCs, you could probably implement most of the algorithm as logic,e.g. button inputs as Set and Reset to a clocked D type latch fed by the IN signal and generating the (inverted) OUT gate drive signal, with its clock derived from edge detecting the IN signalHowever it will be a LOT simpler to only configure the CLC for the inverting passthrough to the gate drive so you can effectively shutdown the PIC when the timer is in control. When your program needs to override the timer it can disable the CLC output (leaving it set up) using the CLxCON.LCxOE bit so it can set the desired pin state, then reenable it later when the current and timer commanded states are back in sync.Either way some exoerimental breadboarding is advisable . . . .

author: NivagSwerdna
author_rank: Super Contributor
timestamp: May 27, 2017, 09:54:24 am
content: Well this is a bit sad, and definitely a beginners question...I decided to put Mk 1 circuit in the shed as it is basically complete... (I will do Mk 2 in due course, promise!) it works fine (although out of spec at 6.5V) except.. the timer interface does not work at all... it senses that the timer is always open circuit indicating that the door should be open... this is a problem!When prototyping I had assumed the timer was a voltage free contact and this worked well on the bench but in the shed with the real timer I get no joy.I do know that when the timer wants the door open, it is open circuit, and when it wants the door closed it conducts (measurements given earlier)I don't really know the standard approach for interfacing with this timer but my assumption is that the internal pull-up isn't strong enough however due to the convoluted design that is Mk1 I also have a diode to contend with.I'm planning to try putting a 10k pull-up to (switched VCC) on the RB1 side of the diode but I would be interested to know why it doesn't work in this form.Also... on reflection I don't like this interface at all, it looks inefficient... is there a better way to interface that would take less current when in steady state? e.g. charging a capacitor and then sensing voltage rather than current?You can tell I do mostly software nowadays

author: Ian.M
author_rank: Super Contributor
timestamp: May 27, 2017, 10:56:37 am
content: Until you can identify what the timer output characteristics actually are, this whole project is dead in the water, unless you want to add a 32.768 KHz crystal and make the PIC totally replace the timer.Is the timer identifiable so maybe we can find a datasheet for it? Or is a non-destructive teardown possible?

author: NivagSwerdna
author_rank: Super Contributor
timestamp: May 27, 2017, 03:28:36 pm
content: Quote from: Ian.M on May 27, 2017, 10:56:37 amIt's a really sweet looking timer but that point is not lost on me. The project makes sense much more as a timer replacement but... keeping going for now.I removed the timer and took a few photos. The back even says Open Collector so that fits with observations. It also says 2mA... not sure of the significance of that. The timer has five pins but only pin 3 and 4 are connected; it is powerd by 2xAA that live behind the flap.I'm guessing that my issue is the pull-ups inside the PIC will not drive the timer circuit hard enough. I need to pull it up harder to +ve?Inside the timer is potted.

author: NivagSwerdna
author_rank: Super Contributor
timestamp: May 27, 2017, 05:49:44 pm
content: OK... so I put a 600k pull-up on the RB1 side just in case... and did some measuring...When the timer contacts are 'open' RB1 floats high so is logic 1... when the timer contacts are 'closed' the value drops to around 1.3V. 1.3V is not considered logic LO so I get the wrong result, the PIC thinks the timer is still 'open'. Decreasing the pull-up makes the problem worse, but surprisingly making the value much bigger doesn't seem to help much.It seems that the timer is still pretty high resistance even when in its closed state.

author: Ian.M
author_rank: Super Contributor
timestamp: May 27, 2017, 06:06:56 pm
content: Well that was difficult to find:https://gb.axt-electronic.org/uk_shop/shop/vsb/283/bs-d-digitale-batterie-zeitschaltuhr-quasianalog-zubehoer-vsbb?c=51Manual:https://gb.axt-electronic.org/media/pdf/GB-2T.pdfand about as clear as mud!Its obviously got some sort of transistor output and I'd treat that 2mA as an abs max current rating.The question is: *WHY* is the emitter brought out separately?I would expect a normal OC timer to have three connections - power, ground and OC output.Is there any voltage on the transistor E or C pins with nothing else connected to them? Test both timer output states.Try connecting a 4K7 resistor between the emitter and ground and another the same between the collector and +6V and check voltages as above. (4.7K because no matter what its under the 2mA max current).I *suspect* it wasn't pulling low enough for your PIC to detect as logic '0'Edit: confirmed.I'd still like the above measurements so we know what we are up against.

author: KL27x
author_rank: Super Contributor
timestamp: May 27, 2017, 06:36:24 pm
content: Quote from: NivagSwerdna on May 27, 2017, 05:49:44 pmThis is curious. What kind of diode are you using? If you must have a rectifier, here, perhaps the FVD is your limiting factor. Have you tried a shottky with max current rating circa 300mA or less?You didn't draw the power rails in the schematic. Longshot, but if you have them running off different power source, you didn't forget to connect the ground rails, by chance?

author: Ian.M
author_rank: Super Contributor
timestamp: May 27, 2017, 06:41:29 pm
content: I suspect the timer has something like a Darlington + series reverse polarity protection diode, with the base driven via a resistor from a rail-to-rail low power CMOS output. That could be wired as either a high side or low side load switch and would account for the high voltage drop (0.65V Vbe + Vce_sat of the driver + a possibly Schottky diode Vf drop)

author: KL27x
author_rank: Super Contributor
timestamp: May 27, 2017, 07:00:34 pm
content: ^That sounds likely. Regardless of the exact innards, a couple of transistors later and you should be back in business, no?

author: Ian.M
author_rank: Super Contributor
timestamp: May 27, 2017, 07:09:00 pm
content: Quote from: KL27x on May 27, 2017, 07:00:34 pmYes but keeping the extra current down low enough not to significantly impact battery life without making it excessively sensitive to RFI may be difficult.@NivagSwerdna: How often do you have to change the door opener batteries?To interface it to a TTL compatible logic input without incurring extra battery drainis challenging. I'd try using a Schottky diode AND moving it to RA4/T0CKI as that pin has a Schmitt trigger input with a trip point typically near 1/2 Vdd(though all the datasheet guarantees is that its between 0.2 and 0.8 of Vdd).The pin can be used to generate an interrupt on either edge - set up Timer 0 in 8 bit mode, external clock, no prescaler, preload it with 0xFF then set T0CON.T0SE for the edge you want, clear the interrupt flag INTCON.TMR0IF and finally enable the timer. However as its synced to the core clock, it wont work to wake from SLEEP mode - you'll have to settle for the lowest current (31Khz) RC_IDLE mode.

author: NivagSwerdna
author_rank: Super Contributor
timestamp: May 27, 2017, 08:22:34 pm
content: I have taken some measurements... first with a DMM first one way and then the other polarity with no other circuit attached.Then I attached to a 6V source and had two resistors as suggested... I had 38.2k to hand but I hope that is OK. (Oops I misread 4.7k as 47k so thought 38k was close... sorry, please let me know if I need to do this again)When Open there is no noticeable current... so no current... no voltage across the resistors. At 6V the voltages go... 0, 2.58, 3.42, 6.0, I also tried this at 5V and got 0, 2.12, 2.89, 5.0.I have absolutely no idea how to interpret those numbers! Thanks

author: NivagSwerdna
author_rank: Super Contributor
timestamp: May 27, 2017, 08:27:42 pm
content: Quote from: Ian.M on May 27, 2017, 07:09:00 pmThe timer has 2xAA... I'm not sure I have ever changed them.... i.e. they could be 5 years old, the Door opener has a separate 4xAA battery pack, I have changed those once every 2 years, but I think they were not flat at that time. The door is a sliding bit of Aluminium (not sure of mass) and moves about 40cm up and 40cm down each day.

author: NivagSwerdna
author_rank: Super Contributor
timestamp: May 27, 2017, 08:38:55 pm
content: Quote from: KL27x on May 27, 2017, 06:36:24 pmThe power sources are isolated in the sense that one has a 2xAA battery compartment and the other has a 4xAA one. There is no obvious common ground connection in the original set up, just two wires (pin 3 and 4 here) go between the units.

author: NivagSwerdna
author_rank: Super Contributor
timestamp: May 27, 2017, 08:42:19 pm
content: Quote from: Ian.M on May 27, 2017, 07:09:00 pmI'll dig out a Schottky tomorrow... but I'm thinking about just bodging this... when in driven mode I could just use RB1 as AN5 and point this at the ADC. Then when the value is <50% consider it a low. I need not convert very often... perhaps once every 10 seconds... and this would only be active during the override period.. the latching relay then saves the day for normal operation.

author: Ian.M
author_rank: Super Contributor
timestamp: May 27, 2017, 09:03:06 pm
content: I'd interpret them as verifying the timer output stage is a Darlington, probably without a reverse polarity protection diode, driven by a weak MOS rail-to-rail output as described. Checking with lower value resistors would probably not tell us much. One test that would be helpful would be to try a single 100K resistor between +6V and the collector and check voltages with the emitter open circuit and the timer on. Repeat with a single resistor from emitter to ground. That should pick up if there is actually a DC base drive to the output Darlington or if its actually isolated e,g. photo-darlington, or maybe something exotic like an AC coupled charge pump feeding the base.For the final design, this means the PIC input should probably be fed from the timer emitter, with a pull-down, for better compatibility with the TTL input thresholds.For now, yes bodge it - do an ADC conversion whenever a button is pressed or at periodic intervals while in override mode. You can use the watchdog timer for wakeup from SLEEP to save power - set its period to the desired LED flash rate, do a conversion and any other housekeeping tasks, delay for the desired flash duration and go back to sleep till the next flash. However it may be good enough to just amble along at just under 0.008 MIPS in 31.5KHz INTRC_RUN mode.

author: KL27x
author_rank: Super Contributor
timestamp: May 28, 2017, 05:49:40 am
content: I forgot what PIC you're using. The advantage of the comparator (if present) vs ADC is that the comparator can trigger an ISR/wake. I'm not sure the power comsumption difference without looking deeper, though.(I still don't understand why not just drive signal PFET with a 3k ohm gate resistor to signal NFET to micro input pin with internal pullup. The frequency is super low, right? Once or twice a day? And switching-speed/signal-latency isn't a factor, is it? And bodging that up is a lot faster to me than writing ADC code. But I admit I haven't looked over all the schemmies.)

author: Ian.M
author_rank: Super Contributor
timestamp: May 28, 2017, 06:08:21 am
content: I believe N.S. is currently using a PIC18F1320, so no comparator. It does have low voltage detect with an external input capability other than Vdd, but the reference threshold for that is 1.2V and its interrupt is falling edge only so its no help.If he sticks to the current plan MK2 will be a PIC16F1509 part with CLC and comparators, however if possible it will be desirable to avoid using the comparator for the timer interface due to the increased quiescent current from having that module and its reference active.

author: KL27x
author_rank: Super Contributor
timestamp: May 28, 2017, 06:24:50 am
content: ^Ahh, yeah.. I thought of that while you were posting. If this is just once or twice a day, comparator watching all day is a waste...But ADC can't wake PIC.For minimum consumption, you could sleep the PIC and wake it up with the watchdog timer, every twice a second,* take and ADC reading, and go back to sleep.*plus or minus, depending on what kind of latency is acceptable.But I still don't see how this would necessarily beat 2 FETs and wake on IOC.And compared to the drain of the motor and relays, isn't all of this academic? I'm assuming this is why 4xAA cells are used... or is there a third power supply for this stuff?

author: Ian.M
author_rank: Super Contributor
timestamp: May 28, 2017, 06:39:35 am
content: That depends on the PIC's power source. Currently it draws from the 6V door motor battery pack. However it it can be miniaturised enough to fit in the spare space in the timer enclosure, putting all the controls in one place, it would make more sense to draw from the timer battery, and as that's changed far less often, getting the quiescent drain down to the same sort of level as the self-discharge will be fairly important.

author: KL27x
author_rank: Super Contributor
timestamp: May 28, 2017, 07:05:42 am
content: Ok, but if you use two FET (or BJT PNP, since you're gonna run off 3V and have -1.6 gate/base drive) and IOC... and if frequency is once or twice a day... and if you go crazy and once woke you turn off the pullup and only intermittently turn it back on to check until signal is gone.... isn't current drain going to be nearly nothing?

author: Ian.M
author_rank: Super Contributor
timestamp: May 28, 2017, 07:25:28 am
content: N.S. said the timer uses 2x AA and they've (probably) lasted 5 years. That means the timer's draw must be less than 55uA. It would be a PITA to have to change the timer batteries more frequently than annually so there is an upper limit of about 220uA average current to play with. If two year battery life is a requirement, the power budget is only 80uA. As it will be in timer pass-through mode most of the time, the timer interface and PIC quiescent current are likely to be the two main contributors to the quiescent current.

author: KL27x
author_rank: Super Contributor
timestamp: May 28, 2017, 07:33:34 am
content: QuoteAnd if this is the case... instead of doing ADC readings throughout all this time, which each draw a little current, you could have PIC sleeping the entire time on lowest clock setting. Waiting for IOC.The 2 trannies will have zero quiescent current until the open collector output is switched on. And only need very little draw while the signal is active. Just a trickle of the base of the small signal PNP. And a trickle thru the pulldown for the small signal NFET. And essentially nothing thru the drain of the NFET, if you turn off the pullup after wake. And still, this is simpler on the code end.You could even put the emitter of the signal PNP to an output pin on the PIC, and turn the entire thing off after wake.

author: Ian.M
author_rank: Super Contributor
timestamp: May 28, 2017, 07:56:44 am
content: The timer doesn't provide separate open and close pulses. instead its output is on ALL the time the door is to be closed for. The ON time of the timer is therefore a significant contribution to the average quiescent current Assuming its being used with a light sensor on the main unit so is only on from 4AM to 9AM to keep the chickens in in the morning till everyone's up and about, averaged over 24H, that's still 21% of its on-state current.That's why I suggested testing if its possible to drive the PIC input off the timer emitter - the levels should be compatible on a TTL digital input pin, and the pull-down resistor can be large enough that the quiescent current is lower than running the watchdog to poll the pin.

author: KL27x
author_rank: Super Contributor
timestamp: May 28, 2017, 08:02:47 am
content: QuoteK, I didn't think of it like that. I was thinking it was on only when the door was opening/closing, or whatnot. I see where you are coming from on that end, and I agree with the reasoning.

author: Ian.M
author_rank: Super Contributor
timestamp: May 28, 2017, 08:14:12 am
content: Its worse if N.S. isn't using the photosensor. Average hours of darkness over the year will be 12, and you'll want to extend that in the morning a bit so it could be as much as 60% of the on-state current.The idea was to make the PIC CLC handle the pass-through. The PIC stays asleep and you avoid the cost and complexity of the latching relay and its drivers. That means you dont have much power budget for the interface between the timer and the PIC.

author: KL27x
author_rank: Super Contributor
timestamp: May 28, 2017, 08:30:04 am
content: Hmm, that CLC sounds too cool. I have to get my hands on these newer PIC. Yeah, sorry I just edited last post. I see where you are already 2 steps ahead of the whole relay idea. But yeah, as usual, I end up learning something in the end.

author: Ian.M
author_rank: Super Contributor
timestamp: May 28, 2017, 08:50:53 am
content: Yes, its fairly cool - each can do a lot of four input logic functions, including several typoes of flipflop, with invert/non invert options for all signals. However now Microchip have Atmel's programmable logic designs, if we are lucky we may yet see an enhanced midrange core paired with a GAL equivalent RAM based logic fabric

author: NivagSwerdna
author_rank: Super Contributor
timestamp: May 28, 2017, 05:49:49 pm
content: So... swapped the diode for another one I had lying around (not sure if it was shottky)... no significant change....... anyway... changed the software to use AN5 and ADC... it does a conversion and then has 1.5s of conversion quiet time during which no conversions are done and then converts again. Conversions only occur when in active mode. The 1.5s polling interval is not an issue.I've also changed the LED flashing as per suggestions.Works nicely.That was meant to be an afternoon project... it's taken me weeks! Thanks for your help. I will add Mk2 to the projects list... really looking forward to try the CLC approach.(For the record.... the PIC is definitely out of spec here... the diode drop doesn't get you down to 5.5V so therefore a regulator should really be used, this could be added to this design to give Mk 1.5. Ultimately the LDO and CLC design makes much more sense as the latching relay and ancillary components add significant cost/complexity. Finally in retrospect the actual functional requirement seems a bit off... it would make much more sense to just buy/build a new timer with the override functionality, the LCD glass and UI on the existing timer is really nice though, direct LCD drive is something PICs do well)

author: NivagSwerdna
author_rank: Super Contributor
timestamp: May 28, 2017, 06:18:15 pm
content: Quote from: Ian.M on May 28, 2017, 08:14:12 amI don't use a photo-sensor. Although the principal is roughly day light hours in practice you want it a bit after dawn and then around dusk. During spring you want to delay opening to avoid foxes that are up and about a bit latter than dawn during cub season.