We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi, I have a delay function that for some reason every time I included in my project it causes the micro controller to use extra power. With out the function I read 20 micro amps in total power down mode, but with the function I read 4.4 miliamps in the same mode. I use this delay function to energize a relay for about 50 miliseconds. Is there any other method I could use to replace this function with? Or even better, why is this function "I assume" causing the micro to concume so much power. Thanks. void delay (int x) small reentrant { //0 to 4,294,967,295 int i; for (i = 0; i < x; i++) { ; } }
"I use this delay function to energize a relay for about 50 miliseconds." Are you sure it's the micro and not the relay that's taking the current?!
Andy Neil, I just think it is the function, because with out this function being called in the micro, I get a reading of 20 micro amps. Also, I check the specs of the relay's coil current and that is 66.7 mili amps. The relay's coil is energized for about 50 or 80 mili seconds at most and then it is brought back to zero. This energizing process is happenning every 5 minutes. Also, when I take the micro controller out of the circuit, the current read is zero 0. So I think is the micro. What do you think? Thanks for your reponse by the way.
I think we'll have to dissect your wording a little to clear up a few things here. *) You write the current consumption goes as you include the routine into the code --- I strongly suspect that's not what actually happens. No matter what the function does, it'll only act if you actually call it, and then only while it's actually running. *) You refer to total power down mode for your current measurements --- that doesn't make sense. While that delay() function is running, you cannot possibly be in total power down mode, so you're comparing apples with oranges. *) The canonical method of achieving longer pauses without burning energy the way you're currently doing it is to use the timer --- that's why your micro has timers, essentially.
Hans-Bernhard Broeker, I excuse myself for not being clear. I meant to say that after including the delay function and calling it to energize the relay, the micro goes into total power down mode. At this point I am getting a reading of 4.25 mili amps. To troubleshoot this better I let program as it is and physically disconnected the relay from the circuit. So the micro now configures the port, sets the internal on chip osc. and calls the function where it energizes the relay's coil for about 50 msec (where the delay function is included) and then it enters Total power Down mode. I am getting a reading of almost zero (low current). How could the relay consume so much power...please do not take it the wrong way, but I do not know, but I could be almost sure now, that the relay is somehow taking this extra energy. Do you have any ideas how this could happen.
How could the relay consume so much power 4mA @ 5V is 20mW. That is VERY little power for a relay. Erik Ps how is the port pin driving the relay configured (should be OC) Erik
Erik it is not 5 volts, it's 3 v. (LPC932). I am powering the circuit with 2 AA, which will not last very long if the whole circuit is getting 4.25 ma 24/7. The pin driving the relay is configured as push-pull. What does OC mean? Thanks
OC: Open Collector?
"How could the relay consume so much power" I would agree with Erik - 4.25mA is not a lot of current to operate a relay! What relay is it? How much current did you think it should take? What did the relay Datasheet say? Now that you have the relay isolated from the circuit, have you measured how much current it takes? Another thought: You realise that a relay coil is a large inductor, and you know what happens when you suddenly turn off the current through a large inductor...?!
Andy what configuration is the one for Open Collector. Thanks
what configuration is the one for Open Collector OK it is called Open Drain and very well described in the user manual Erik
Thank you!
Got it. Thank you!