I just wrote a program that is essentially an infinite loop that contains an interrupt, my question is this:
how much power does the picaxe microcontroller draw when iterating through a loop?
see psuedo code below for example:
setint %00000010, %00000010
MODE = b.1
main:
if MODE = 0 then goto loop1 else goto loop2 endif
loop1: <turn led off> pause 2000 goto main
loop2: <turn led on> pause 2000 goto main
interrupt: if MODE = 1 then MODE = 0 else MODE = 1 endif
I'm trying to run this to control a 1 amp LED, and am running off of 2 123 Lithium batteries so I only have 6V at 1000mAh. Does the picAxe chip draw much power? I dont want the running of the chip code to drain the batteries over a short period of time. Any information would be great.
I just put a meter on a 28x2 and it is drawing .02 amps. 20mA
At this rate, I would not even figure in the draw of the micro controller --the 1amp led (do you really mean 1amp?) is going to be doing all the current drawing around here. If indeed your LED draws 1 full amp, and your packs are at 1000mAh (1Ah) you are looking at a little less than an hour. In reality, it will be less than this because the picaxe or the 5v regulator will brown-out before you get all your juice out of your batteries.
Couple thoughts though. If your led is drawing an amp, we are talking about a HUGE LED. It has to be a luxen or a high output of some kind. LED’s this big usally use a driver of some sort --you need to be sure you are driving it correctly. If for some reason, it is just a HUGE regular LED, 1 amp is over what most “standard” transistors can handle (I think a 2n2222 can sink 800mA) so be sure your transistor can handle it. Second is how “psuedo” your code is. You may have just typed it quickly but as it sits now you have a couple problems: MODE=pin is not needed the intsetup takes care of the pin number. You need to reset the int and flags within the interrup subroutine and it must end in a return. Again, I am not sure how close the code you have posted is to what you are actually using.
I would love to see this 1 amp LED --You got a link?
What I’m trying to do is create a new higher powered light for my local police department.
I would like the light to run at around 200-300 lumens and have 3 modes, off, on and strobe. To do this I am trying to use a Cree R5 LED. Here it is in a pre assembled module. These usually run pre-built LED drivers that have different modes. The 7135 5 mode driver was what I based my design off of. Which seems to run at 1000mAh. If you look you can see a 8 pin picMicro in the center.
I have seen this driver used in a light and when powered on it remembers the last state it was in and iterates over the 5 different modes. However the two popular lights on the market are the Blackhawk Xiphos NT and the Insight WX150 have no on/off switch and have the modes I mentioned above. I cant help but assume that the controller chip inside the light is constantly drawing power. Hence the point to my question. I can use 2 CR123A lithium batteries that operate at 3.7 V Nominal and have 2500mAh. Thus giving a 2.5 hour max time on the light. However I would only rate the time until the lumens dropped below 115, at which point it becomes less effective.
The code I used was to the best of my memory of what i wrote last night. In my interrupt I do reset it after the input is no longer high. It compiles and simulates fine, but I was worried about power draw then the light was “off”. I could use a sleep command instead of a pause, but I’m not sure how much that would help, since the pauses I use are only 1/8th of a second.
I guess the bottom line is that I’m trying to design a circuit to run the light, and though my picaxe would be a good controller for the modes. Any suggestions to help out?
Here’s how I see it, you have 3 modes, on, off and blink. First off, like I said before, you really don’t need to figure in the power draw of the chip --at 20mA you would be talking about 125 hours on a 2500mAh pack. That being said, why do you need your micro controller running when the light is off? Simple solution: The micro controller takes care of the blink or strobe, and that is all it does. A simple 3-way switch solves your problem. Off is off, on is on and blink (the 3rd position) clicks on the micro controller and thus your blink. No reason to have the processor on when everything else is off.
If you need the controler to deal with brightness or other aspects, again the controller is simply on when the light is on. I might be missing something here but why can’t off just be off?
Ok heres what I did last night and I think it will work:
Since there are three modes off, on and blink. I just had the off mode “end”. Which should put it into an indefinite sleep. When C.1 is activated again, via a tactile switch, then the ligth goes into the “on” mode, then into “blink” on C.1 again, then “off” on C.1 again. I tried the code out on the PicAxe simulator and it worked fine, but when the “off” state was reached the simulator shut down. I’ll need to build a test circuit and try it on my project board.
In sleep mode the microcontroller should only draw about 10uA, meaning that with a 2500mAh battery, it could last for 250,000 hours. So no worries there.
I’m hoping that I can do a direct replacement of the microcontroller on the 7135 chip that I posted earlier with an 8 pin picaxe. If not I’ll have to build my own LED driver.
I’ll take what CtC said about simplifying this one step further. He suggested just using a switch to select between on/off/blink, with the microcontroller only powered on when you need to blink. My question is, why the heck do you want us use a microcontroller for this at all. A simple electronic circuit with a 555 timer chip can get you a blinking LED. There are even more simple circuits using just a few discrete components and no integrated circuit at all.
Try some google searches on ‘led flasher circuit’. I think a Picaxe is HUGE overkill for your purposes.
The reall problem isnt the circuit but the switch. I dont know of any multiway momentary micro tactile switches that are small enough for our purposes. Remember that the light is designed to mount underneath a police issue pistol. Thats only about 6-8 cm in length, most of which will be consumed by batteries and the light bezel.
Wouldn’t something like this be small enough? (http://www.nkkswitches.com/pdf/MtogglesAnglePC.pdf check page 2, bottom, there’s a picture of how big it is). Consider that if you choose to go the “discrete components way” instead of the “IC way” you’re probably gonna have some extra space available.
One other, totally personal, thing i wanted to say: i think that switches are much better for this purpose. I really dislike having to cycle through all available options (with a button) before getting to the one i want. Well…in this case it’s only 3 options, but still switching to your preferred setting is still faster then pressing a button multiple times, especially if you have to change it often.
Last thing: those kind of lamps usually have an external strip which, if pressed, activates the light, and is usually positioned on the grip. Are you planning to include this? It could make things a bit more simple (e.g.: depending on how you want it, a smaller double throw switch would be enough).
Thanks for the suggestion. I’ll answer your questions in reverse.
3. On this light there is no paddle switch. Since its a pistol light its mounted directly underneath the barrel on a 1913 Picatinny or Universal Rail. It would be possible to run a paddle switch to the grip, but thats one more thing to snag on a holster, or glue/velcro etc to the service weapon.
2. The light was designed to have 3 on modes…momentary, on, and strobe. With “off” being somewhere in the mix. The original idea was the use two momentary switched on each side of a lever paddle. If the officer pushed the paddle away from the trigger guard momentary switch A creates a direct connection and the light is on as long as the paddle depresses the switch. Pressing the paddle in also contacts a momentary switch however this activated the IC circuit modes, starting with on, then strobe, then off. The ideal design is one that an officer could use on a moments notice, without moving his finger too far away from the trigger.
1. Wow those are some small switched…i dont suppose they come in momentary?