Latching push button circuit, need help with some things... - Page 1
Forum section: electronics / beginners

author: davekra
author_rank: Contributor
timestamp: September 04, 2015, 11:51:47 am
content: Gday!I'm trying to build an on/off circuit to use in my radio control gliders.I found one that looks simple, low power and only one active component.http://tinyurl.com/pehanxpI'd like it to work with voltages from 2v - 10v and have next to zero current draw in the off state.Current capacity should be around 3 amps...and if it's not too much trouble a recommendation for a FET that could handle 15 to 20 amps with the same supply voltages.For low voltage they recommended IRF7317 Mosfethttp://www.irf.com/product-info/datasheets/data/irf7317.pdfIt looks like it starts turning on at .7 volts and its max current is 4.3 to 6.6 amps.I'd like it to be in the ON state when power is applied and the circuit shows an option for that.One last thing that's not in the circuit is I'd like to use a magnet to turn it on/off.Could someone help with a Hall sensor selection?I found some interesting digital Hall sensors that read like they could accomplish everything I wanted on their own, but the current draw in the off state was too much.Is there a sensor that simply acts like a physical switch? I thought about a reed switch but I didn't think it would be appropriate for the environment. I was concerned about vibration affecting the reed switch.Any help would be appreciated.Let me know if there are any questions.Thanks,davidkUpdated link to circuit diagram so it points to the correct circuit.

author: davekra
author_rank: Contributor
timestamp: September 04, 2015, 02:22:40 pm
content: Thanks, that gives a good explanation of how the circuit functions.I hope the circuit I linked to will function the same. I've already ordered the mosfet. If it doesn't I can build up Dave's and play with the values and still use the same mosfet.In Dave's circuit, if you wanted to replace the mechanical switch with a magnetic switch, could it be done and still maintain the near zero or zero current draw when off?What would be an appropriate hall effect switch?Thanks again,davidk

author: Cliff Matthews
author_rank: Unknown
timestamp: September 05, 2015, 01:54:52 am
content: A magnetic reed switch (just like a momentary SPST switch) is a simple solution.http://www.sensorsmag.com/hall-effect/top-five-advantages-reed-switch-technology-low-power-16411https://www.sparkfun.com/products/8642If you're in hurry or have trouble finding one, they're used inside many door alarm circuits.

author: davekra
author_rank: Contributor
timestamp: September 05, 2015, 10:36:38 pm
content: Yes, a reed switch would do exactly what's needed but I'm concerned about vibration causing a problem.The max vibration on one I looked at is 20g. What does 20g look like?This would be used in a glider so there wouldn't be the vibration of a motor but I may want to use it in a motorized plane.I wouldn't use a glass one but the plastic molded ones might work...but again, I'm concerned about inadvertent triggering.Is there no solid state magnetic switch that would work?Thanks,davidk

author: Cliff Matthews
author_rank: Unknown
timestamp: September 06, 2015, 12:28:05 pm
content: Don't worry about the glass composition, small ones are tough enough they test them at 1000 G for contact failure. I'm not into physics much but 100 G appears beyond your requirements:http://www.thp-systems.com/imv-corporation-demonstrate-100g-11-ms-shock-test-utilising-their-high-velocity-shock-software/Littelfuse selection guide:http://www.littelfuse.com/~/media/electronics/application_guides/littelfuse_hamlin_reed_switching_selection_guide.pdfShock and Vibration documents:http://www.hamlin.com/technical-detail-reed-switch.cfmThis one's half an inch long, costs $1.22 at mouser, and withstands 100ghttp://www.mouser.com/ds/2/240/FLEX-14-274815.pdf

author: davekra
author_rank: Contributor
timestamp: September 06, 2015, 03:50:25 pm
content: Thank you so much for the links. I wasn't finding good explanations or examples of vibrations tests and what those types of loads looked like.The documents from Hamlin were also helpful.I think I'll get a few switches and rig up some tests. If they survive I'll feel better about integrating them into the design.Thanks again,davidk

author: davekra
author_rank: Contributor
timestamp: September 09, 2015, 01:51:27 pm
content: Are we sure there aren't any solid state switches that would work?I see that the reed switch is simple and can be reliable but the cost is several times that of some hall sensors.The small surface mount reed switches start at $2.70 and go over $4. At the quantity I'd like that adds up quick.Are there any solid state options that could be implemented at a lower cost and still maintain the next to zero current draw when off?Thanks,davidk

author: LukeW
author_rank: Frequent Contributor
timestamp: September 09, 2015, 03:32:58 pm
content: Quote from: Cliff Matthews on September 04, 2015, 01:39:09 pmIn the final circuit Dave demonstrates, what is initially pulling the P-channel pass element low to turn on the load initially when it starts up?Maybe it's because it's late, but bugger if I know.Also, this one is simpler - only uses one transistor other than the power transistor.http://www.mosaic-industries.com/embedded-systems/_detail/microcontroller-projects/electronic-circuits/push-button-switch-turn-on/latching-high-side-push-on-push-off-toggle-switch-circuit.png?id=microcontroller-projects:electronic-circuits:push-button-switch-turn-on:latching-toggle-power-switch

author: Cliff Matthews
author_rank: Unknown
timestamp: September 09, 2015, 04:09:27 pm
content: Quote from: davekra on September 09, 2015, 01:51:27 pmAt 3 amps, hall effect will need support circuitry which is counter productive in a glider. You mentioned an SMT reed switch (good luck with 10amp surges), so you'd still need at least a resistor and low RDS FET. You'll have to measure quiescent currents in both setups and compare with weight-complexity trade-offs. I don't know costs on hybrid modules, but you're likely to pay more than a simple reed switch.Honeywell Hall Effect Sensing and Application -http://sensing.honeywell.com/index.php?ci_id=47847Honeywell Magnetic Sensors Line Guide -http://sensing.honeywell.com/honeywell-sensing-magnetic-sensor-line-guide-005894-16-en.pdfSolid-state Relay Handbook (234pgs) -http://www.galco.com/techdoc/crdm/ckrd4830_crdmh1.pdfImages spark ideas toohttps://www.google.ca/search?q=Reed-Relay-Coupled+SSR&safe=on&tbm=isch&tbo=u&source=univ

author: davekra
author_rank: Contributor
timestamp: September 10, 2015, 05:09:47 pm
content: The link from Luke is the same place I got the push on/hold off circuit.I've successfully built that using the IRF7317 which is fully on below the voltages I'm designing for.I think there's some confusion on what I'm trying to do. I'm not trying to switch the current with the reed or hall switch.The magnetic switch is used to toggle the FET on/off. The magnetic switch would only see micro-amps.The goal is to have a way to turn on the gliders electronics without having to open it up.Wave a magnet over a spot and it turns on. The hold off feature would ensure its not accidentally turned off.For this first version the current requirements are within the 5.3amps maximum of the FET. This version is to work at lower voltages like one lipo cell.For higher current versions the voltages would be higher by default so a different FET could be chosen.The hall sensors I've found were much less in cost at quantity than the reed switches. The problem is the standby current was too high ( In the mA range rather than uA) and the upper voltage limit was too low.Also after looking some more I'm also not sure if there is actually a hall switch that could be incorporated in the circuit without additional components. I'd still like to explore the possibility though.Someone is already producing a magnetic switch for this very purpose so I know it can be done. Their switch is over $20 and I knew I could build it for less (not charging for my labor..or yours). I plan on building enough for me and my friends and be able to build more in the future.Thanks for sticking with me on this.davidk

author: davekra
author_rank: Contributor
timestamp: September 15, 2015, 11:50:46 am
content: So, after testing I find that the reed switches I purchased from Digikey are not up to the task.They will sometimes not release and need to be knocked on a hard surface.The contacts should be annealed and not easy to magnetize but that doesn't seem to be the case.I will continue my search for a hall sensor.

author: Cliff Matthews
author_rank: Unknown
timestamp: September 15, 2015, 01:34:47 pm
content: Quote from: davekra on September 15, 2015, 11:50:46 amYou mentioned surface mount reed, so I'd assume a FET was the final drive. Did you use them as per spec? Blade orientation or a strong magnet could have over stressed..

author: Zero999
author_rank: Super Contributor
timestamp: September 16, 2015, 08:17:34 am
content: Here's the simplest circuit I know of.

author: davekra
author_rank: Contributor
timestamp: September 16, 2015, 01:19:33 pm
content: I used a few different magnets, one of them a 1/8" cylinder neodymium. Much stronger than needed.I won't always be able to control what magnet is used or how close it will be to the device so my testing needed to be done to the lowest common denominator.Yes, a FET is being used. As stated in my first post it's the IRF7317. A P and N FET in one package. The circuit was also referenced but I've attached a picture.If I were to add a voltage regulator I could provide a lower voltage to the hall sensor which would make selecting one easier.Honeywell SL353LT is an omnipolar sensor that has an average current draw of 1.8uA and needs 2.2v minimum. A small 2.3v to 2.5v regulator could be used.Would the voltage regulator draw its own current with the circuit in the off state?The regulators have an on/off control input. I'm not sure if that could be used because with it off it wouldn't be supplying voltage to the sensor which is the only input to turn it on. Right?I have an idea on how to integrate the regulator but would be open to direction.Thanks,davidk

author: Cliff Matthews
author_rank: Unknown
timestamp: September 16, 2015, 08:45:54 pm
content: Davekra, you are a new member here and I'm a little surprised at the lack-luster response on this one.Luck of the draw, I guess.Perhaps those clicking-in saw the reed switch and judged "not meaty enough" but I find your application has become more and more interesting. I was wondering, with the reeds low cost, weight and simplicity, if it's worth exploring the prospect of a magnetic shunt (or something to limit flux). Pity I can't help much there, but keep posting, there are undoubtedly some very courteous and amazing minds here...

author: C
author_rank: Super Contributor
timestamp: September 17, 2015, 01:26:23 am
content: Looking at your last circuitWhen the reed closes you do not limit the current through the reed.Try putting a resistor in series with the reed to limit the max current.C

author: davekra
author_rank: Contributor
timestamp: September 17, 2015, 04:29:47 am
content: Thanks guys.The reed switches aren't exactly low cost (at least from Digikey in the quantity I plan on buying) making the hall sensors more attractive. Add in a voltage regulator and you still end up cheaper, smaller and more robust than reeds.The smaller reed switches start at $2.70 whereas hall sensors are $1.48 + $.39 for the regulator. The regulator needs only .2volts more than the output so it still meets my low voltage requirements.I was thinking...If I need a regulator for the sensor, can the circuit be adapted so the latching portion is independent from the power FET? That would allow a simple FET change to give different voltage/amp capacities.That could mean two simple transistors for the switch turning on a separate FET. That would be acceptable even if it was slightly more $ than the original concept because it yields more flexibility.I like the idea of a resistor in front of the switch. That would also affect the hold off time, right? I assumed a small amount of current but putting a limit to it is a good idea.Thanks again,davidk

author: Cliff Matthews
author_rank: Unknown
timestamp: September 17, 2015, 04:40:28 pm
content: Quote from: C on September 17, 2015, 01:26:23 amDoes this mean current through it is damaging it? The return path for the switched load is not not shown.. (general ground)Update: Oops sorry, the schematic is small. I thought the final resistor was 100 ohm - so this just an RC delay.

author: davekra
author_rank: Contributor
timestamp: September 17, 2015, 08:59:00 pm
content: Isn't the switch draining the 10uf capacitor till the voltage is low enough to turn off the N-FET?I didn't think much current was going through the switch. I'll see if I can measure the current through the switch.

author: davekra
author_rank: Contributor
timestamp: September 17, 2015, 10:25:04 pm
content: With my dmm I'm measuring a max of .4mA through the switch.I think I'm heading back to the circuit Cliff posted first. That seems to separate the latching from the power handling.More testing tonight.

author: C
author_rank: Super Contributor
timestamp: September 17, 2015, 11:43:41 pm
content: .Reed switches are sensitive to arc wielding.When you short a cap you have max current flow.You have the gate cap & the 0.1 uf caps preventing a change while the switch is connecting the other side to ground.With a 10 volt supply, what is the initial current across the switch?With a 1 ohm path you get 10 amps for a very short time.Just a little resistance does a great job of protecting the switch from these very high current transients.With A 10 ohm resistor in series and 10 volt supply the peak current drops down to 1 amp,The reed switch specification I read said a 0.5 amp max switching current.Now what should be the min value with max supply voltage.C

author: KL27x
author_rank: Super Contributor
timestamp: September 18, 2015, 02:34:35 am
content: Another way to do it is with...gasp...a microcontroller. Sleep 99+% of the time. Wake up 50 times a second to power on the hall effect sensor, take a reading, debounce/flip/flop as necessary. Small, low parts count, cheap, vibration-proof, and very low power consumption, if implemented correctly.The 10V maximum makes ultra low power consumption a lot more challenging, though, with the micro.

author: Cliff Matthews
author_rank: Unknown
timestamp: September 18, 2015, 03:34:53 am
content: Quote from: KL27x on September 18, 2015, 02:34:35 amIf I recall correctly, there are nano power MCU's with code programmable gate arrays that can manage sleep mode + source/sink >40ma on 6 pins or so (as small as SO-14 or 16). Fancy pantsy as Dave says..

author: KL27x
author_rank: Super Contributor
timestamp: September 18, 2015, 06:10:57 am
content: I edited my post to remove the part about the shunt regulator. I was thinking a part like PIC 8 bit high voltage "H" parts with built-in shunt regulator that can be setup for 15V. But if I'm understanding correctly how a shunt regulator works, it would defeat the purpose of any fancy coding.Anyhow, I'm one of those guys. When I need a push button to toggle power for my homespun lab equipment that doesn't already use a micro, I throw in a 12F508 +FET circuit that sleeps except when there's a GPIO interrupt. Nothing too fancy, but it works well enough, and when you have a box of hammers on your bench... My li ion batteries don't die when unused (sometimes for over a year at a time), anyway. This is actually cheaper and smaller than a physical push button toggle switch, last I checked from major parts suppliers, and you can rig a momentary tac switch just about anywhere that is convenient.I don't recommend that specific part, though. You can do better on sleep current with many more modern micros. But to get the most out of that nanowatt stuff, you'd probably have to use the WDT to wake the micro to turn on the internal pullups for a brief bit, every few seconds, just enough to keep the pin above logic hi.Sorry for the tangent, OP.

author: davekra
author_rank: Contributor
timestamp: September 18, 2015, 05:30:03 pm
content: No worries, all ideas are welcome. I'm very open to scrapping what's been done and head off in another direction but not to diminish the help already provided.I hadn't been thinking of a PIC because I assumed the route I was going would consume less power.Having a quick search for nanowatt microcontrollers shows many options that are measured in nA instead of uA.I'm even more of a beginner when it comes to microcontrollers. My first use of one was to control the backlight of my carpc. I used a PICaxe.Then I got a few Arduino Nano's to build transmitter modules for the ProtoX quadcopter.All this was with copious direction from helpful people like you.If we were to do this with a micro would you guys be able to help with selection?In simple terms, we'd have the micro, hall sensor and a FET? We'd want an N-channel FET? Because it's on when held high and in the on state I'm not too concerned about the circuits power consumption (It's going to be low enough by default I'm guessing).The voltage requirements of the device will exceed the maximums of the components so that again is a concern as you mention.I hate to come right out and ask but could someone spoon feed me on this new direction?Many many thanks,davidk

author: KL27x
author_rank: Super Contributor
timestamp: September 18, 2015, 07:56:05 pm
content: QuoteAFAIK, this doesn't necessarily matter. Hi rail, low rail, doesn't matter where the gate of the FET is sitting.For switching a voltage greater than Vdd of the control circuit, things slightly more messy, though. There are some minor pros and cons to switching hi or lo side on the final switch, regarding drive and pcb layout. But because this is a simple manual toggle, not high frequency, and you generally can't stick a magnet on a plane while it's flying, you shouldn't need anything fancy to drive the FET.I would suggest two stages, anyhow. A PFET for the final switch and an NFET or NPN tranny for the drive, because this conveniently solves the issue of where the rail to be switched is greater in voltage than the control circuitry Vdd while keeping a single ground plane. A simple pullup on the PFET gate would be used to turn it off, drawing no current while off. When switched on, that bit of current would be tacked on to your energy bill.As for the micro, well... hmm. Even though this is maybe 30 lines of assembly code, it's quite a long journey by spoon feeding. This is lots of RTFM for the specific micro and probably some trial and error, even for someone with experience, and most definitely a good chuck of time optimizing with test equipment. That's after sourcing the parts and reading those datasheets.PICAXE or ARDUINO probably can't pull off the "full monty" with the pulsing/reading of the hall effect while asleep. PICAXE for sure, no. ARDUINO might be able to do a simple external wakeup, if you're ok with leaving the hall effect sensor on all the time. You mentioned quite a low draw on this part.For spoon feeding1. Use a micro, at all... PICAXE or ARDUINO perhaps.2. Use a bare micro, figuring out use the compiler/IDE, learning how to configure all the peripherals and whatnot. This is 90% of the uphill battle.3. Play with the WDT and/or for simpler version just sleep and I/O wakeup.Or hire someone like me to make this for you.edit: Actually, if you're in it for the learning process, for the long haul, and if you happen to be interested in PIC micros, I can recommend you go to Microchip website and download their "low pin count tutorial" and play with this starter example code and work through the lessons. You can view the schematic for the dev board and make your own pcb or just breadboard it. Or you can buy that, too.In addition to the free stuff you can find on the web, I can also recommend Googlium PIC tutorials if you are interested in using any PIC assembly. I have purchased more than a few of them, and they are well written and easy to follow. I learned a few very useful tricks about using the MPLAB IDE through these tutorials. The writer is very experienced. If I had known what I know now, I would have probably started here and saved a lot of headaches I ran into down the road by using less practical fee tutorials and even physical ($$) books (I think Mike Predco probably forgot more than I know, but unfortunately, he forgot a lot of important things for a beginner). By the time I found these, I had already learned most of the content the PAINFUL way. These Googlium tutorials are hands down the best, most practical, most comprehensive I have seen for learning bare PIC assembly. You can probably find a free torrent somewhere, but don't do that. These tutorials are a bargain, already, and the writer obviously spent years thinking them through and laying them out.

author: C
author_rank: Super Contributor
timestamp: September 18, 2015, 08:17:55 pm
content: Quote from: davekra on September 17, 2015, 10:25:04 pmHow do you measure a short time current with a DMM?Switches bounce when closing, to see this you need a scope. The current spike is in the transition of what is seen on a scope.A magnet reed switch has all kind of properties. Being sensitive to very low magnetic fields is not normally one of the properties.Some hall sensors are used as a compass. Could be a problem or not.If you look at the properties of the last P channel fet you were using as a power switch you will see that the gate has limits, X to start turning on but do not exceed Y voltage to gate. So for higher battery voltages, your circuit needs to prevent this from happening or you have to lower the max battery voltage. The source to drain also has limits.When you use a N channel fet to control your positive rail, the gate how needs to go higher then the positive rail. A gate source of 8 to 12 volts is common.If you look at Dave's videoHe has a working circuit, what are the limits?2N3904 Vceo Collector-Emitter Voltage of 40Volts is oneThe P channel max gate voltage is lower here so it would set max battery voltage.What is the off state current?Two off 2n3904's and a cap.The other circuits have the same limits of max gate voltage setting the input voltage limits.Your circuit adds a lot of parts compared to Hero999, What did you gain, what problems added? How does it work different from what you have?What is the off state current?I would suggest that you build both Dave's and Herro999's circuits and getting them the function properly with your reed switch. Add a Series resistor 40 ohms or more is series with the reed.Then take each change you are thinking of and block out the needed changes to make each of the two circuits function.Unless you can find a hull switch that can work with higher then max battery voltage, you have to add a voltage regulator. A voltage regulator needs some current to operate so this change would increase off current. You have to do this properly or destroy parts.QuoteThis suggests to me that this would be a better change for a later revision.This has some advantages but most come from being great at programming.You could use a hull sensor in place of a hull switch but this requires better programming.You could sleep at low power most of time, again more good programming.In place of a hull switch, you could use a light sensor.Build something and use it while you are working on a better version.C

author: davekra
author_rank: Contributor
timestamp: September 19, 2015, 03:24:48 am
content: I'm sorry, spoon feeding is more with component selection and tweaking the circuit. Didn't mean to sound so desperate.With renewed enthusiasm I ripped up everything and started with a spare PICaxe 14m2. Using the examples in the docs to connect the hall sensor, then took the dual FET from the old circuit and connected it to one of the outputs with a pull up resistor on the P-channel FET.I put a few LED's on the controllers output and both FET's drains.I'll try to put together a circuit diagram on what I have so far. A week of vacation is going to interrupt things next week.The code was pretty simple but it took a while to get the for:next and do stuff in the right order.https://youtu.be/QoPCXNjV6GgIt's working as planned:Apply power and its ON.With it on, a quick swipe across the sensor does nothing.Hold the magnet over the sensor for .5 seconds and it turns off. Continue to hold the magnet over the sensor does not change the off state.Remove the magnet and swipe it over the sensor and it turns on. If the magnet is held over the sensor the on state doesn't changeThe code may not be the most efficient and there aren't any power saving things but it gets me started.Code:high b.1let b3=1main:if b3=1 and pinb.2=1 then goto mainif b3=0 and pinb.2=0 then goto onnif b3=1 and pinb.2=0 then goto waitngoto mainwaitn:for w1=1 to 400if b3=1 and pinb.2!=0 then goto mainnextofff:low b.1:let b3=0if pinb.2=0 then goto offfgoto mainonn:high b.1:let b3=1if pinb.2=0 then goto onngoto mainAs it is right now the current draw fluctuates around .6 and 1mA in the off state.With the hall sensor needing power to work it will need to be powered all the time. The spec sheet says 1.8uA in sleep mode.I've yet to test the voltage regulator and how much current it draws. The voltage limits for the hall are 2.2v - 5v.Your right, of course, about measuring spikes with a DMM with the old circuit.I'm in this for the long haul. I really enjoy doing this stuff. If I wanted I could buy one of these ready made for about $30. For what I've spent so far I could have bought three of them. I've been playing with using the toner transfer process too.It gets overwhelming looking through Digikey with the thousands of parts. Getting advice on what to look for really helps narrow things down.Thanks guys,davidk

author: davekra
author_rank: Contributor
timestamp: September 19, 2015, 05:10:32 am
content: Searching Digikey I found this microcontrollerPIC10F202T-I/OThttp://ww1.microchip.com/downloads/en/DeviceDoc/40001239F.pdfIt's got 3 I/O pins which is enough and currents are measured in uA. If I'm reading the datasheet correct the WDT current is about 1uA.This looks promising.Now I've got to look over those Googlium tutorials and figure out how to program this.The PICaxe are easy to program. If I'm correct, they already have a bootloader on them and can be programmed via a simple serial port.I've bricked a couple Arduino by using an ISP (I think). Reading on the problem if I could figure out the fuses or the the right clock speed I could make them work.I've not successfully programmed a bare chip except for the PICaxe.Fun stuff!davidk

author: C
author_rank: Super Contributor
timestamp: September 19, 2015, 06:20:42 am
content: Ok got a micro running.Think about off and off sleepDo you really need to be fast?If you have to hold magnet for 5 sec thenwaking up once a second could cause holding for 5-6 sec.The less you wake up the more power saved.Also if the hull sensor uses a lot of power you could use one of the micro's I/O pins to turn off power to hull. May need to wait a time for hull to be operational doing this.Note that even with a scope you can have trouble seeing things. I have found that if think of extremes while looking at a part you think of something you first missed. If that cap was 100,000 mf you would think of time and high current and worry. Still happens with small cap, just less and smaller.A 1000 feet of wire gets you thinking of resistance, time, signal loss, signal echo and other things. A motor drive could be ok with a few inches of wire connecting motor, if it's 25 feet it's a different game.With your micro, every thing takes time.C

author: KL27x
author_rank: Super Contributor
timestamp: September 19, 2015, 08:22:10 am
content: Congrats on the circuit. And good luck with the next step.I quickly tired of PICAXE, but I spent an embarrassingly long time figuring out my first PIC. In addition to the AWESOME Googlium tutorials, I suggest you get, say, a 12F508, because you can use this with the Microchip Low Pin Count Demo/Lessons and the Googlium tutorials for the BASELINE pic family, which is the easiest place to start. Scratch that... maybe use a 12F629 and start with the Midrange tutorials, because the 508 has a stupid osccal issue and no EEPROM to play with. You're not skipping ahead too much to start with Midrange.So you will also need a programmer to use bare PICs. I suggest a PICKit2, because it is simple software and very reliable. And to use the free assembler, I suggest you use MPLAP IDE 8.xxx. Not MPLAB X IDE, which did not exist when the Googlium tutorials were written.You will spend a long time just finding and installing all the software and figuring out how to begin to use it. Pretty painful road. Enjoy.

author: Cliff Matthews
author_rank: Unknown
timestamp: September 19, 2015, 02:04:59 pm
content: This is catchy.. I got a damaged Pickit3 and fixed it a while ago, but still kept playing with AVR's. On persistence of forum posters hailing the virtues of PIC and Googlium, I bought-in.And it didn't break the bank (PIC and mini dev board below were $6, and $20 CDN for the whole tutor pack). My journey begins - Thanks guys!

author: davekra
author_rank: Contributor
timestamp: September 28, 2015, 12:30:54 pm
content: I've started reading the Gooligum tutorials and find them quite good. It will give a good understanding on how these little buggers operate.I've also been searching for low power ideas. One I came across has the hall sensor powered by an output of the microcontroller.The controller is asleep most of the time but wakes up every so often, powers up the hall sensor, reads it then goes back to sleep.Powering the sensor from the controller was a lightbulb moment. The only thing drawing power when off will be the microcontroller and that should be in the nano-amps.The only thing I'm missing now is regulated power. All the examples I'm finding talking about low power are using a battery with voltages within the controllers limits.I need something to regulate 3 - 12 volts but draw next to nothing. The 2.5v regulator I have draws 100uA with nothing connected.It does have an enable pin the controller could use to shut it down but that would be its last action as there would be no power to wake up with.In sleep mode the controller would be waking up every 1/2 second just long enough to read the sensor.My simple thinking wonders if a capacitor could be used on the output of the regulator to sustain the controller in sleep and provide enough to turn the regulator on when it wakes up?Are there other ways I'm missing to provide a lower voltage than the battery and not consume more than 1 or 2 uA?Thanks guys,davidk

author: KL27x
author_rank: Super Contributor
timestamp: September 28, 2015, 07:17:27 pm
content: QuoteThat's a great idea. I hope you didn't have to search too hard.QuoteI picture a very small shunt regulator. E.g. Vbat>>series resistor >>Vdd>> 5.1V Zener >> ground. And a good size filter cap that would reach 90% charge by the time the micro wakes up for the next cycle, maybe on the order of 10-100uF. Enough power for the hall effect and to switch a digital output pin and charge a FET gate without dropping VDD too much. Maybe even have the PIC go back to sleep for a cycle before switching the FET, so it doesn't power the hall effect and switch the small signal FET in the same cycle. Most 8 bit PICs will run from 5 V all the way down to 2.5V, so you have some leeway, there. With a very high impedance power source as this, I would even be curious to try pushing the peak up to 5.5V. Get the firmware working as intended and optimized, then start choking off the regulator with series resistance to see what you end up with at the point of brown-out under all operating conditions. Then take your minimums and double or triple the current and the caps. If you can smooth out the power requirements enough and be able to handle some dips on the line, the shunt could theoretically be just a fail safe, with zero shunt current flowing under normal circumstances (at least for a specific Vbat). The simple series resistor and filter cap would act as an unregulated buck converter, with the power consumption carefully matched. The zener would be there to handle varying Vbat.The game would be to see how tiny a straw your little micro can breathe through, after slowing down its metabolism as low as possible and spreading out surge requirements to avoid too fast/deep of a ripple on the line.*Edit Hmm. The problem with a shunt is where Vsupply approaches Vdd. To account for this, you have to "open the flood gates" a bit, which will toast the efficiency at higher Vsupply. So to cover the entire range you're looking at, you might be best off with a buck converter, afterall. Maybe an active buck converter for a one-size-fits-all solution. Maybe a passive shunt regulator where you select the series resistor according to Vbat, for highest efficiency.

author: Cliff Matthews
author_rank: Unknown
timestamp: September 29, 2015, 01:23:01 am
content: ... Still can't help wondering why some pacemakers and ICD's (implantable cardioverter-defibrillator) use reed switches. According to abstract*, they have been tested in MRI fields at 3 Tesla.http://onlinelibrary.wiley.com/doi/10.1046/j.1460-9592.2002.01419.x/abstractPolling with the MCU is certainly interesting, but it's still not the primary switch. Granted, I know squat about materials physics, but I hall sensors can be damaged by strong fields as well. Since your zero power option was not justly explored, can I suggest a second thread in projects specifically on reed lead-forming, handling, and magnetic stress/shunting?

author: davekra
author_rank: Contributor
timestamp: September 29, 2015, 01:56:12 am
content: A mechanical switch would be easier of course. And reed switches have a long life...if treated with respect.The little bit of testing I did with magnets on hand showed they could be damaged.And I would agree, the circuit I was using had a capacitor shorting across the switch albeit a small one. This could damage the contacts as well, but I experienced failure almost immediately.I'm not sure I agree with a strong magnetic field damaging a hall sensor.A snip from the Allegro website-": Can a very strong magnetic field damage a Hall-effect device?A: No. A very strong field will not damage an Allegro Hall-effect device nor will such a field add additional switchpoint hysteresis (other than the designed hysteresis)."Honeywell also corroborates that a strong field will only drive the sensor into saturation.So, a hall sensor is more robust. As I won't be able to control the end environment having it be more reliable is more important than a few uA of current when off.As I said before, someone already has a product that works with the voltage range I've mentioned and has a current draw of about 5uA.I'm heading to Kansas next week where I'll be meeting with someone who has one of these switches. I plan on taking some tools to map out the circuit and try to figure out how they are doing this.As frustrating as this seems to be I still find it rewarding to try to figure this out.Thanks for the input.davidk

author: Cliff Matthews
author_rank: Unknown
timestamp: September 29, 2015, 02:43:02 am
content: Since few people carry around magnets, have you given thought to field energy from a close proximity key FOB? It could be like 2 or 3 button presses (one to wake, and another within another 3 seconds to analyze an RF envelope shape to toggle power state). Add one more internal pcb button to get the MCU into program in new key FOB mode. I don't know if there's enough compute in a PIC for precision (say between one Ford key FOB and another), but perhaps it's enough to count >8 packet bursts from a close-up key FOB from background RF pulses at 315Mhz? This also comes closer to your zero power ideal, since only a few antenna/filter components would connect to the ADC pin. Cheers!http://www.greenhybrid.com/forums/f10/some-key-fob-experiments-19844/

author: davekra
author_rank: Contributor
timestamp: October 05, 2015, 01:53:53 am
content: I got to look at the switch you can buy and I'm happy to say the hall sensor they used is the same one I bought. It draws 2.5uA.The circuit is pretty simple. It goes regulator, sensor, something then the FET.The total current draw when off is 4.2uA so whatever regulator they are using it's drawing much less on its own than the one I bought.The regulator, FET and mystery component are labeled but the first search didn't come up with anything.The regulator is marked with "HGRA" . It's a SOT-23 and is 3volt.The FET is an SO08 and is marked:4136BAA (triangle)w25BWhat I think is a microcontroller is an SOT-23-5 marked "H80R"The regulator is the one I'd really like to identify. The microcontroller is somewhat less importan but it would be cool to find that one as well just to see what they are using.So, again, I'm hoping you can help with help with identifying the markings on these components.Thanks guys,davidk

author: KL27x
author_rank: Super Contributor
timestamp: October 05, 2015, 02:23:14 am
content: My guess is the sot23-3 is a 3V voltage reference IC. And the SOT23- 5 is a CMOS flip flop. The numbers on SOT23 parts is useless to anyone outside the manufacturing plant. Even to the manufacturer, it may be useless once taken out of context.

author: davekra
author_rank: Contributor
timestamp: October 05, 2015, 03:48:39 am
content: Bummer.I think I found a regulator. Rather than having circuitry to enable/disable the regulator a simple dumb regulator might have a lower draw.The XC6201 series looks to have a 2uA draw.http://www.torexsemi.com/products/detail.php?id=363With no quiescent current to quote the only current draw is the device.The switch operates a little different than what I expected. Rather than having to hold it for a few seconds before it turns off it seems to simply toggle on/off with a wave of the magnet.That could mean a flip flop is what is being used. I'll start looking at that but I kinda like the microcontroller idea.With the controller I can turn everything off and the regulator/microcontroller would be the only things drawing current. Couple that with it only checking for a magnet every .5 seconds could mean less current draw.I'm going to continue down the microcontroller path (cause I want to learn assembly language) but a couple days looking at flip flops wont be wasted.Thanks guys.

author: davekra
author_rank: Contributor
timestamp: November 05, 2015, 02:47:08 pm
content: Ok, so I lied. I don't want to learn assembler. C is proving to be enough of a challenge.Using the Microchip PIC10f322 and MPlab xc8 I've got something that's almost working but I'm unsure of a few things in my code.The SLEEP command on this midrange PIC should wake up and continue where it left off (I think). When it wakes up I'd like it to restart the main for loop.Does the 'return();' after the SLEEP restart the main loop as I hope? It's not leaving the loop hanging where after time it would create a stack overrun?Do the other returns go back to the main loop?Do the initializations immediately after 'void main' only run once? The LATA=0 setting all outputs low should only run once. Subsequent loops should not set all outputs low.I'd appreciate any suggestions or opinions on what I've got so far.Thanks,davidkCode:/** File: newmain.c* Author: davekra** Created on October 21, 2015, 6:30 PM*/#include <xc.h>// #pragma config statements should precede project file includes.// Use project enums instead of #define for ON and OFF.// CONFIG#pragma config FOSC = INTOSC // Oscillator Selection bits (INTOSC oscillator: CLKIN function disabled)#pragma config BOREN = OFF // Brown-out Reset Enable (Brown-out Reset disabled)#pragma config WDTE = ON // Watchdog Timer Enable (WDT enabled)#pragma config PWRTE = ON // Power-up Timer Enable bit (PWRT enabled)#pragma config MCLRE = OFF // MCLR Pin Function Select bit (MCLR pin function is digital input, MCLR internally tied to VDD)#pragma config CP = ON // Code Protection bit (Program memory code protection is enabled)#pragma config LVP = OFF // Low-Voltage Programming Enable (High-voltage on MCLR/VPP must be used for programming)#pragma config LPBOR = OFF // Brown-out Reset Selection bits (BOR disabled)#pragma config BORV = HI // Brown-out Reset Voltage Selection (Brown-out Reset Voltage (Vbor), high trip point selected.)#pragma config WRT = ALL // Flash Memory Self-Write Protection (000h to 1FFh write protected, no addresses may be modified by PMCON control)#define _XTAL_FREQ 32000 //Declare clock speed for __delay_ macroint dely; //Declare array for countingvoid turnon(void); //Declare functionvoid turnoff(void); //Declare functionvoid main(){OSCCONbits.LFIOFR=1; //Low freq internal oscillator enableOSCCONbits.IRCF=0b000; //Frequency select bitsANSELAbits.ANSA0=0; //RA0 - set as digital i/oANSELAbits.ANSA1=0; //RA1 - set as digital i/oANSELAbits.ANSA2=0; //RA2 - set as digital i/oTRISAbits.TRISA0=0; //RA0 - output power to HallTRISAbits.TRISA1=0; //RA1 - output unusedTRISAbits.TRISA2=0; //RA2 - output to FETLATA = 0; // start with all output pins lowWDTCONbits.WDTPS=01001; //Watchdog set to 512ms//*** Main loopfor (;;){LATAbits.LATA0=1; //Turn on power to Hall__delay_ms(10); //Wait for Hall to initializeif (PORTAbits.RA3==1) //Check if magnet present high=no, low=yes{LATAbits.LATA0=0; //Magnet not present, turn off power to HallSLEEP(); //Sleep for 256msreturn; //Return to beginning of loop}if (PORTAbits.RA2==0) //if FET is off, go to code to turn it onturnon(); //Call turnon functionelse //FET must be on, go to code to turn it offturnoff(); //call turnoff function}}void turnon(void) //turn on function{LATAbits.LATA2=1; //Turn FET onfor (dely=0;dely<=20;dely++) //Start loop to test for button release{CLRWDT(); //Clear watchdog timer__delay_ms(20); //Wait 20ms then..if (PORTAbits.RA3==0) //If Hall still low..dely=0; //Reset count and loop again}return; //Return to main and start over}void turnoff(void) //turn off function{for (dely=0;dely<=254;dely++) //Start loop for 'button hold to turn off'{CLRWDT(); //Clear watchdog timer__delay_ms(5); //Wait 5ms then..if (PORTAbits.RA3==1) //If button released before end of loop, cancel 'turnoff'return; //Return to main and start over}LATAbits.LATA2=0; //'Button hold' loop success, turn off FETreturn; //Return to main and start over}