Announcement

Collapse
No announcement yet.

Running a microcontroller in car - power supply aspects

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

    #21
    Re: Running a microcontroller in car - power supply aspects

    Here I am again. I messed around with KiCad and after a very long time (KiKad not being the most user-friendly out there), I managed to put together the schematic for the project...hope I didn't leave anything out. Not sure about what diode should go across L1, but other than that, it works on the breadboard the way it is, without L1 for now.
    Attached Files
    Last edited by Dannyx; 07-09-2019, 04:07 AM.
    Wattevah...

    Comment


      #22
      Re: Running a microcontroller in car - power supply aspects

      hmmm..

      5,1v zeners are a bit close, should go up a step.
      and why reference the window switches to the battery?
      if you reference them to vcc or better yet use the ground, you can dump the opto couplers.

      Comment


        #23
        Re: Running a microcontroller in car - power supply aspects

        Originally posted by stj
        5,1v zeners are a bit close, should go up a step.
        A bit close to what ? Go up, as in to 6v ?
        Originally posted by stj
        and why reference the window switches to the battery?
        In order to keep the harness as stock as possible - that part is already wired into the car. I COULD start chopping stuff, which was my initial idea, but I wanted to simplify the project.........which is not really simplifying anything, but anyway I want this thing to be as PnP as possible, because I don't have a garage to work in - I have to do it all out in the parking lot with my gas soldering iron, so keeping modifications to the car's harness to a minimum is a must

        EDIT: the micro MCU1 in the schematic is a Nano, but I'll be using a ProMini. KiKad didn't have the exact part and it was too trivial to waste time drawing it myself. The pinning also differs from the actual project.
        Last edited by Dannyx; 07-09-2019, 06:53 AM.
        Wattevah...

        Comment


          #24
          Re: Running a microcontroller in car - power supply aspects

          well zeners - good ones are 5%
          so they will start conducting at 5.05v and your atmel has internal resistors that may not like that.

          as the mcu is o.k. upto atleast 5.5v i would use 5v6

          Comment


            #25
            Re: Running a microcontroller in car - power supply aspects

            So you're saying the zener value is too LOW and you suggested a higher value ? 5.1 is lower than 5.6, isn't it ?
            Wattevah...

            Comment


              #26
              Re: Running a microcontroller in car - power supply aspects

              yes, the zener value is too low - they will conduct earlier than you expect.

              Comment


                #27
                Re: Running a microcontroller in car - power supply aspects

                Originally posted by stj View Post
                they will conduct earlier than you expect.
                I see. I'm guessing I do not need to tweak those 1k'ers though.
                Wattevah...

                Comment


                  #28
                  Re: Running a microcontroller in car - power supply aspects

                  hmm...
                  you shouldnt have zeners on the opto's

                  you shouldnt have 5v1 across the regulator output either - it will be destroyed.

                  Comment


                    #29
                    Re: Running a microcontroller in car - power supply aspects

                    Originally posted by stj View Post
                    you shouldnt have zeners on the opto's
                    Why ? I can't just send battery voltage straight into the optos (even with a resistor), so that's my way of stepping it down.

                    Originally posted by stj View Post
                    you shouldnt have 5v1 across the regulator output either - it will be destroyed.
                    What would get destroyed here ? The zener or the diode ? That's for safety only - it should only conduct in case the switching DC-DC converter somehow fails. That's right - don't forget that's a switching converter and I only pictured it as a 3-leg device out of convenience...not sure if that's what made you worry there.
                    Wattevah...

                    Comment


                      #30
                      Re: Running a microcontroller in car - power supply aspects

                      The schematic looks really good for first time in KiCad.

                      Some things to maybe consider:
                      Put the switches after the fuse, because switch/door wiring always shorts out.

                      The zeners on the opto's don't help for +ve overvoltages. The opto LED is about 1.2V and will clamp hard first, so the 5.1V zener will never turn on. A dropping resistor and 1N4148 reverse-diode will work fine, you don't need anything else. The opto LED would see (11 to 14V - 1.2V)/1k or ~10mA which is OK, I prefer 5mA 2k. For spikes, the LED max. is 1A(!) so a 1k resistor still good for hundreds of volts for a short transient <100usec.

                      The opto-coupler is not isolating because the same ground is on input and output sides. You didn't use one for IGN, LockSignal inputs etc. so what is with that.

                      You can turn on internal pullup resistors in the Arduino, about 20kΩ and 50kΩ to save parts (the 10k parts R5-R8).
                      pinMode(right_window_up_pin, INPUT); // set pin to input
                      digitalWrite(right_window_up_pin, HIGH); // turn on pullup resistors

                      I find C6 is better 220-680uF for the cheap LM2596 ripoffs from china, but make sure the fuse can take inrush current. This whole thing draws maybe 20mA from 5V?

                      The input inductor and diode, my automotive buddy says he added a bunch of crap, reverse-mosfet and stuff with it to his ECM designs.
                      I think you need something like a ferrite bead at least to stop EMI from the power supply going into back the car. I can draw something later.

                      Comment


                        #31
                        Re: Running a microcontroller in car - power supply aspects

                        Originally posted by Dannyx View Post
                        Why ? I can't just send battery voltage straight into the optos (even with a resistor)
                        of course you can,
                        your running an led from 12v through a current limiting resistor - that's how it's done.

                        Originally posted by Dannyx View Post
                        What would get destroyed here ? The zener or the diode ? That's for safety only - it should only conduct in case the switching DC-DC converter somehow fails. That's right - don't forget that's a switching converter and I only pictured it as a 3-leg device out of convenience...not sure if that's what made you worry there.
                        i know what your thinking, i'v done it myself.
                        but firstly as i said, 5v1 is riding the line.
                        second, if the switcher output rises the diode will clamp what - 500mW?
                        it will burn-up.
                        you need a 5w zener atleast and you need it not false-trigering - so 5v6 or higher.
                        so when it clamps, it draws enough current to blow the fuse - not itself.
                        in the old days when clamps where common, it was usually done with the zener triggering a thyrister to short the rails.

                        Comment


                          #32
                          Re: Running a microcontroller in car - power supply aspects

                          Why do you have 82 Ohms in series with load, which also feeding the 5.1V ZENER? Vdrops on that resistor will vary with the load current.
                          Last edited by budm; 07-09-2019, 05:35 PM.
                          Never stop learning
                          Basic LCD TV and Monitor troubleshooting guides.
                          http://www.badcaps.net/forum/showthr...956#post305956

                          Voltage Regulator (LDO) testing:
                          http://www.badcaps.net/forum/showthr...999#post300999

                          Inverter testing using old CFL:
                          http://www.badcaps.net/forum/showthr...er+testing+cfl

                          Tear down pictures : Hit the ">" Show Albums and stories" on the left side
                          http://s807.photobucket.com/user/budm/library/

                          TV Factory reset codes listing:
                          http://www.badcaps.net/forum/showthread.php?t=24809

                          Comment


                            #33
                            Re: Running a microcontroller in car - power supply aspects

                            I think the worry is the 5V buck-converter could fail and overvoltage everything, roast Arduino for dinner.

                            Arduino Pro Mini (5V version) uses MIC5205 LDO and even 5.1V input is enough for 5V out, but the input max. of 16V is not enough for a car because of transients.
                            OP could run the LM2596 into the Mini Vin and that would cover overvoltage from damaging things?

                            Comment


                              #34
                              Re: Running a microcontroller in car - power supply aspects

                              Let's review this. I redid the schematic following your suggestions:
                              Put the switches after the fuse, because switch/door wiring always shorts out.
                              There is a fuse there already, I just didn't include it because it will not be part of the PCB - a 30A one from the car's actual fuse box, because the part before the switches is in place already and running the windows directly, so it sucks a lot of current. I will probably swap it for a small 5A one after the mod, since the switches will no longer run the motors directly and don't require the full 30A.

                              Now this part threw me off a bit:
                              The zeners on the opto's don't help for +ve overvoltages. The opto LED is about 1.2V and will clamp hard first, so the 5.1V zener will never turn on.
                              So the LEDs clamp BEFORE the diode actually starts regulating ? I didn't think it worked that way when I "designed" it - I just thought of the classic zener regulator instead of doing this
                              A dropping resistor and 1N4148 reverse-diode will work fine, you don't need anything else. The opto LED would see (11 to 14V - 1.2V)/1k or ~10mA which is OK, I prefer 5mA 2k.
                              I know you can run LEDs off 12v just fine with the appropriate resistor, which is how I was going to do it at first, ironically, but it seemed better to have a zener in there....turns out it wasn't a great idea and I should go with the simpler idea after all. Not sure I put the diodes in the right place though, but my basic electronics knowledge tells me there's no reason they should be in parallel across the optos since there's no inductive kickback there to supress, correct ? Should I add a cap across the opto as well ?

                              The opto-coupler is not isolating because the same ground is on input and output sides. You didn't use one for IGN, LockSignal inputs etc. so what is with that.
                              The idea behind the opto's was to prevent battery voltage from shooting into the Mini's pins if anything went wrong. Then again, you could indeed argue that the other pins you mentioned do not use opto's at all. That was actually the original design (zener+resistor on each pin), but then someone suggested dropping an optoisolator in there too in another post about this project, where I was asking for advice on how to step down car voltage to MCU voltage.

                              You can turn on internal pullup resistors in the Arduino, about 20kΩ and 50kΩ to save parts (the 10k parts R5-R8).
                              pinMode(right_window_up_pin, INPUT); // set pin to input
                              digitalWrite(right_window_up_pin, HIGH); // turn on pullup resistors
                              Not a bad idea actually. Must admit I did not know how to do that at the time, that's why I did it the old fashioned way. I mean I knew about internal pull-ups, but didn't know how to use them. I thought using (digitalWrite X, HIGH) on an INPUT pin keeps the pin "on" all the time, thus making a LOW reading on it impossible. I'll have to try it out. Should I still keep the caps on those pins though ?

                              This whole thing draws maybe 20mA from 5V?
                              Precisely - I actually measured it a while ago. It's even lower than that in fact (around 15mA when an opto is "on" - button pressed), which is what I want. I'll probably also try out tweaking the code to enable those low-power states of the arduino to lower current draw even further...

                              Why do you have 82 Ohms in series with load, which also feeding the 5.1V ZENER?
                              I set the DC-DC converter to around 6v output so it's slightly higher than Vz of that diode and chose that seemingly random 82ohm value mostly based on practical tests than math. I know the various formulae and calculations of zener regulators, but I did it the practical way by measuring the output of that zener regulator dropped after the DC-DC converter with different value resistors. I started at 1k and it was WAY too high - the Mini simply didn't run or stopped working whenever I hit a button and the voltage drop increased even more. I measured the voltage at VCC and it was like 3v - way too low. I began dropping the resistor's value more and more until I got an acceptable 4.8v which is still a bit too low, but works....for now at least. It's fed straight into the VCC pin, not the RAW pin, since I removed the on-board regulator of the Mini.

                              The input inductor and diode, my automotive buddy says he added a bunch of crap, reverse-mosfet and stuff with it to his ECM designs.
                              I think you need something like a ferrite bead at least to stop EMI from the power supply going into back the car. I can draw something later.
                              Yeah, this part was a bit impromptu and needs a bit of work, because so far I've been running it on the bench with a wall-wart or even a SLA battery sometimes, so I'll have to design the input part a bit better.
                              Attached Files
                              Wattevah...

                              Comment


                                #35
                                Re: Running a microcontroller in car - power supply aspects

                                Here are two common ways to run digital inputs to an MCU. The hassle is protecting for overvoltage spikes from static electricity or switching inductive loads, like blower, wiper motor, ignition etc.
                                A 12V car the old test standard is pulses for -150V 0.1usec (at 10kHz), -100V 2 msec, +50V 50usec to represent ignition noise, DC brushes arcing etc. I left out the big surge caused by a bad battery connection "load dump" because it's hard to deal with.

                                The opto: 1N4148 clamps any -ve spikes from the switches and wiring. An LED is easily damaged by reverse voltages. +ve spikes overcurrent the LED but this OK. A +200V spike would put in 100mA. The opto LED is rated 50mA for a long term and 1A for fast <100usec overload.
                                You put the diode in series but a 1N4148 avalanches past 100V so it is not enough.

                                Using resistors, 20k and 10k give 9V minimum and 4.5V maximum for logic high/low, so a dead car battery can still work. The 20k limits current into the MCU. A +/-200V spike would put in 10mA to an MCU input pin, after the capacitor charges, so a long term spike would not damage things.

                                The capacitor helps with noise from cell phones which get picked up by a car's wiring. It's low current and high frequency, so the opto does not pass it but resistors will.
                                Attached Files

                                Comment


                                  #36
                                  Re: Running a microcontroller in car - power supply aspects

                                  Can you clarify the schematic a bit: is it meant to represent two possible implementations on the right there ?

                                  So the diode was supposed to go parallel to the LED in the opto after all...

                                  I shall upload the KiCad file so you can all mess with it. I just don't have it on my PC right now and it's too late and I'm too lazy to get up
                                  Wattevah...

                                  Comment


                                    #37
                                    Re: Running a microcontroller in car - power supply aspects

                                    Yes it suppose to go that way so you clamp the reverse voltage off of a coil or a motor a very common thing to when you want to have a pin from a micro controller to control a outside device to use a optic sensor
                                    Last edited by sam_sam_sam; 07-11-2019, 06:46 PM.
                                    9 PC LCD Monitor
                                    6 LCD Flat Screen TV
                                    30 Desk Top Switching Power Supply
                                    10 Battery Charger Switching Power Supply for Power Tool
                                    6 18v Lithium Battery Power Boards for Tool Battery Packs
                                    1 XBox 360 Switching Power Supply and M Board
                                    25 Servo Drives 220/460 3 Phase
                                    6 De-soldering Station Switching Power Supply 1 Power Supply
                                    1 Dell Mother Board
                                    15 Computer Power Supply
                                    1 HP Printer Supply & Control Board * lighting finished it *


                                    These two repairs where found with a ESR meter...> Temp at 50*F then at 90*F the ESR reading more than 10%

                                    1 Over Head Crane Current Sensing Board ( VFD Failure Five Years Later )
                                    2 Hem Saw Computer Stack Board

                                    All of these had CAPs POOF
                                    All of the mosfet that are taken out by bad caps

                                    Comment


                                      #38
                                      Re: Running a microcontroller in car - power supply aspects

                                      I was showing two possible ways to go for the inputs.
                                      If the 1N4148 was replaced by a 5.1V zener, you see the LED will turn on first at 1.3V and the zener can never see 5.1V

                                      Resistors are OK. 20k and 10k, or higher like 50k and 25k. Just so the MCU

                                      The LM2596, there are so many chinese fake IC's in those I would not trust them so much.

                                      Comment


                                        #39
                                        Re: Running a microcontroller in car - power supply aspects

                                        Here's the schematic in KiCad I made...you can mess around with it if you have KiCad installed. It's easier to pass the same project back and forth.
                                        Attached Files
                                        Wattevah...

                                        Comment


                                          #40
                                          Re: Running a microcontroller in car - power supply aspects

                                          THIS is how it should look, with the diodes flipped around, in parallel to the LEDs.
                                          Attached Files
                                          Wattevah...

                                          Comment

                                          Working...
                                          X