Announcement

Collapse
No announcement yet.

Running a microcontroller in car - power supply aspects

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Re: Running a microcontroller in car - power supply aspects

    lol
    i'v seen an arduino power-up and run through it's own pullup resistors/protection diodes.

    Comment


      Re: Running a microcontroller in car - power supply aspects

      The power LED glows faintly on the Mini even with no power connected to the VCC pin, if a CH341 programmer is attached and plugged into an USB port. I ran into this issue a couple of times when I was playing around with this project and thought it died because the code would not upload, but then noticed the 5v power brick was not connected to my breadboard
      Wattevah...

      Comment


        Re: Running a microcontroller in car - power supply aspects

        Originally posted by stj View Post
        lol
        i'v seen an arduino power-up and run through it's own pullup resistors/protection diodes.
        Yes, but very low power devices are now commonplace. In the 70's, they weren't. You burned power to do damn near anything! A dinky little 1702 (256x8 EPROM) consumed 300mW! The idea that a "signal" could power a circuit was (obviously) anathema to us.

        Comment


          Re: Running a microcontroller in car - power supply aspects

          Progress

          It works and draws 4mA without the Arduino plugged into the headers and without the current sensors (wanted to make sure it actually generates 5v there before I plug anything in...come to think of it, I should probably make the current sensors removable too...

          Back to the bench now
          Attached Files
          Wattevah...

          Comment


            Re: Running a microcontroller in car - power supply aspects

            With no MCU, 4mA drain seems a bit odd? LP2951 uses 0.1mA and I did not see anything else in your circuit using current.

            Comment


              Re: Running a microcontroller in car - power supply aspects

              Originally posted by redwire View Post
              With no MCU, 4mA drain seems a bit odd? LP2951 uses 0.1mA and I did not see anything else in your circuit using current.
              Caps perhaps ? Maybe some leakage on those diodes and optocouplers ? It'd sure be great if I could trim down the power draw even more...
              Wattevah...

              Comment


                Re: Running a microcontroller in car - power supply aspects

                It just seems weird, I would go after it because it's high.
                You can try pull IC's out of their sockets and see if that narrows it down? But remember the cap has a charge before putting the IC back in. The diode under the Arduino, if it's 5.1V zener maybe or the tantalum is leaky?
                The big 680uF cap would have mA leakage if it's a CapXon lol.

                Comment


                  Re: Running a microcontroller in car - power supply aspects

                  Originally posted by redwire View Post
                  The diode under the Arduino, if it's 5.1V zener maybe or the tantalum is leaky?
                  The diode is indeed 5.1v, though the voltage across it (the VCC of the Arduino) is 5v exactly and I heard zeners actually take a bit more than their nominal value to break down and start conducting. I could try pulling it off to see if it makes a difference, though it's soldered in really well...it will be a nightmare to do. Same goes for all the other non-socketed parts thanks to my "patented" method of bending the leads to form tracks - it's one of the huge downfalls of this idea >_>

                  Originally posted by redwire View Post
                  The big 680uF cap would have mA leakage if it's a CapXon lol.
                  It's a 1000uF Samwha WL series, now that you mention it...not sure what to say about it. I read it's slightly "over" the RD series, but inferior to the WF series, if this is at all correct or relevant...
                  Wattevah...

                  Comment


                    Re: Running a microcontroller in car - power supply aspects

                    Just try pull the Vreg IC out of the socket, then you can see if it is ahaed or after, the current drain.
                    I find chinese electrolytics have high leakage currents.

                    Comment


                      Re: Running a microcontroller in car - power supply aspects

                      Originally posted by redwire View Post
                      Just try pull the Vreg IC out of the socket, then you can see if it is ahaed or after, the current drain.
                      I find chinese electrolytics have high leakage currents.
                      I'll remove the IC and supply 5v directly with an adapter or something and measure the current draw on that. It'd be great if it's just the cap, since I can easily remove it and replace it (hopefully with something better quality)....
                      Wattevah...

                      Comment


                        Re: Running a microcontroller in car - power supply aspects

                        it's probably going through the pullup-resistors

                        Comment


                          Re: Running a microcontroller in car - power supply aspects

                          Originally posted by stj View Post
                          it's probably going through the pullup-resistors
                          Yes, but they aren't connected to the Arduino ATM (because it's not inserted)...unless the optocoupler + the ceramic cap has leakage, which is to be expected...
                          Last edited by Dannyx; 05-09-2020, 03:40 AM.
                          Wattevah...

                          Comment


                            Re: Running a microcontroller in car - power supply aspects

                            I came up with an idea to try and track down the part that's drawing spurious current without having to tear the traces apart: I started by removing the IC and optocouplers from their sockets, since it was the easiest thing to do. I then supplied 5v to the "regulated" output of the IC from an external PSU and measured the current draw on that - 4mA are still there, so it's not the IC, nor something on the 12v side.

                            I then tried out each type of component individually with the power supply, by using an identical one from my parts bin and placing it in series with the bench supply and my ammeter, including the three types of caps and the 5.1v zener diode. None drew any current at all. The zener diode starts breaking down at around 5.5v, as a side note, which is great news because that's the maximum the Arduino's VCC pin can take.

                            I then supplied 5v after those pull-up resistors, to confirm whether it's those ceramic caps that draw current, since they were the only part remaining on the board, but no they're not: I get no current draw here at all ! With all said and done, my money is on the small 10uF electrolytic or tantalum cap on the 5v rail (on the output pin of the IC), although I tested these individually and neither drew any current at all ! I must admit the idea of placing two types of caps of the same value (10uF) on the output of the IC is an undocumented/unfounded idea of mine that I came up with on my own, fearing a single electrolytic may fail due to the hot environment and result in the output overshooting (having seen what the IC does with NO cap at all >> 10v on the output !), so the more professional folks out there may be quick to pan this, but hey - learning
                            Wattevah...

                            Comment


                              Re: Running a microcontroller in car - power supply aspects

                              Sorted. It turns out the zener diode ZD7 was clamping too low for some reason, causing excess current drain. I removed it and replaced it and it's now working as it should

                              I also installed the polyfuse, so this whole thing is ready to be tested on the car now
                              Attached Files
                              Wattevah...

                              Comment


                                Re: Running a microcontroller in car - power supply aspects

                                Ahhh much better current drain You need that extra 4mA for the MCU

                                I made a car key-off timer with ATtiny85 with LP2951, to charge phone or listen to stereo for 3hrs if you push a button or key-off. If I stall and restart my engine, it would always reboot the stereo (which takes a long time) so I wanted a battery-power feed to stop that. IGN wire always cuts out when you crank.

                                What I do is wake up the MCU when the ignition key goes on, and after, I wait 30 seconds and put the MCU to sleep. This saved a lot of current. The A/D I don't use but that section draws a lot of current so I switch it off.
                                MCU running at 1MHz (A/D off) it was 2mA (plus LED) and going to sleep 0.02mA plus the LP2951, which gives 0.12mA when sleeping. I mention it because it could be something to consider adding to your code, the sleep function. Or shutting off the A/D and Hall sensors when you are not using them.
                                But maybe your current drain numbers will be good enough. Just giving ideas.

                                Comment


                                  Re: Running a microcontroller in car - power supply aspects

                                  I'm planning on using the sleep feature as well. This thing is listening for a lock/unlock signal and acting accordingly, so why not have the MCU sleep when it's doing nothing ? I hope it can be done, that is, "wake" the MCU when one of its pins acts (car is locked/unlocked).
                                  Wattevah...

                                  Comment


                                    Re: Running a microcontroller in car - power supply aspects

                                    it's in the cpu, not sure if arduino language has it - but it probably does.
                                    or just hit the registers directly to lower the clock or shutdown sections of the chip

                                    Comment


                                      Re: Running a microcontroller in car - power supply aspects

                                      Here are snippets of my Arduino code. There is an AVR sleep library.
                                      First, I have a pin change interrupt (on IGN and pushbutton input) to allow wakeup even though the MCU is asleep.

                                      To go to sleep, I shut off the A/D and analog comparator to save power, and enable the pin change interrupt.

                                      Code:
                                      #include <avr/sleep.h>
                                      // these snippets for ATtiny85
                                      
                                      //------------------------------------------------------------------------
                                      ISR(PCINT0_vect) { // Pin Change Interrupt
                                      // GIFR automatically cleared here; hope timers don't use them
                                      // clear the pin change interrupts and turn them off
                                      // good to wake and run now; or no change during normal interrupt
                                      
                                       GIMSK &= (0 << PCIE); // no more Pin Change interrupts; mask them off
                                       sleep_disable(); // now that we've woken up, stay up; 
                                       DEBUG_PRINTLN("**int WAKE ***");
                                       state=sWAKE_FROM_SLEEP; // duplicate - in case we (return) wake up in lala land
                                      }
                                      
                                      //------------------------------------------------------------------------
                                      void SleepSession(void) {
                                        
                                       // configure and enter sleep mode, only pin change interrupt (ign switch or pushbutton press) wakes us
                                       ADCSRA &= ~_BV(ADEN); // disable ADC and save power ~0.3mA at 5V; _BV is a macro
                                       // not sure if BOD (fuse) is used, analog comparator if used may need to disconnect too to save power.
                                      
                                       // config pin change interrupts 
                                       cli(); // disable global interrupts as we are reconfiguring them
                                       PCMSK = 0b00011000;  // unmask pin change interrupts on pins PB3, PB4- the switch inputs
                                       GIMSK |= (1 << PCIE); // unmask Pin Change interrupts; Interrupt source
                                       // not sure if timer interrupts happen on Arduino with Attiny85, leave otehrs alone
                                      
                                       set_sleep_mode(SLEEP_MODE_PWR_DOWN);
                                       sleep_enable();
                                       sei();         // re-enable global interrupts, sleep is set up now
                                       sleep_cpu(); // go to sleep
                                       
                                       //---------------------- W A K E ---------
                                       /* Upon waking, the program will continue from here. */
                                       state=sWAKE_FROM_SLEEP; // ensure we go to the correct next state
                                      }
                                      //------------------------------------------------------------------------

                                      Comment


                                        Re: Running a microcontroller in car - power supply aspects

                                        Looks awfully complex...haven't looked into it yet, so maybe I'll pull it off...registers and in-depth stuff go a bit over my head
                                        Wattevah...

                                        Comment


                                          Re: Running a microcontroller in car - power supply aspects

                                          It is easier to write software by breaking it down into little pieces. You can write out pseudo-code as it is called, just to nail down the big picture.
                                          Then, you drill down into each piece, and do the hard work of coding a little chunk at a time. (in all truth, I only use 'state-machine' code for all Arduino projects now, it's what the pro's use, so much less pain)

                                          Comment

                                          Working...
                                          X