Announcement

Collapse
No announcement yet.

Running a microcontroller in car - power supply aspects

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

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

    I am curious as to why the OPTO LED's side are not running of the regulator in your circuit. It looks like you are using OPTO as level shifter.
    Last edited by budm; 07-17-2019, 09:44 AM.
    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


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

      Originally posted by budm View Post
      I am curious as to why the OPTO LED's side are not running of the regulator in your circuit
      This
      Originally posted by budm View Post
      It looks like you are using OPTO as level shifter.
      It's mostly out of commodity and to keep the car's circuit as stock as possible. 12v is present at the switches already, so to run off 5v, I'd have to cut the incoming power wires from the car's system to the switches and wire in my 5v line there, which of course would work, but I just don't want to alter that part. It's not a pleasure working on the wires in that dash - very tight in there, with wires going everywhere, so it has to be as plug and play as possible: connect it up then get out of there as quickly as possible
      Wattevah...

      Comment


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

        I see, trying to keep wiring as original.
        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


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

          Originally posted by budm View Post
          I see, trying to keep wiring as original.
          Precisely.
          Wattevah...

          Comment


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

            Had another look over the schematic and made another change: the lock/unlock signals on the right now also have optoisolators (PC5 and PC6). This is actually how the circuit is currently set up on the breadboard, but I omitted those two for some reason. Trouble is, I can't add a protection diode there because those pins swing low/high when locking/unlocking. Basically those two wires I labeled there run from the ECU to the 4 actuators in the doors and 1 in the trunk and I need to somehow tap into them to trigger certain functions on the Arduino. It's a simple H-bridge inside the ECU that does this I THINK: when you lock the car, the LOCK pin gets 12v on it and the UNLOCK pin stays low. When you UNLOCK the car, the reverse happens: U/L pin gets 12v on it and the L pin stays LOW. I measured this to confirm. Adding a diode there would create a short, yet I still need to have some sort of protection there, since linear actuators create a ton of inductive kickback which overtime can kill those LEDs. A capacitor perhaps ?
            Attached Files
            Wattevah...

            Comment


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

              Why would Low (Grounded) signal be problem? The MCU signals are ref. to GND. Am I missing something?
              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


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

                Originally posted by budm View Post
                Why would Low (Grounded) signal be problem? The MCU signals are ref. to GND. Am I missing something?
                Actually you're right. I was thinking the pin would short out through the diode, because for some reason I mistakenly assumed the diode would go between the L and U/L pins themselves, which is not correct - it would go between EACH pin and GND, so when the pin is pulled high, the diode is reversed-biased and doesn't conduct and when it stays low, it's essentially GND, so no current flow either.

                Another thing that confused me is the way those L/UL rails are laid out they look very similar to a split-rail supply, with GND being in the middle, L being let's say + and U/L being -, although it's nothing of the sorts, so that's another thing that threw me off, so you're right: diode across each of those LEDs and I should be good. Can't believe I screwed up on such a simple electronics circuit
                Wattevah...

                Comment


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

                  Updated schematic. Added D6 and D7, plus a simple plot of the lock/unlock pins.
                  Attached Files
                  Wattevah...

                  Comment


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

                    Alright gents (and ladies, if there's any watching ), since I'm on my winter break and I have some spare time on my hands, I thought I'd go back on this project which should've been finished last year

                    Here's what I've been up to: as you guys suggested, I went with 2k resistors for the LEDs of the optocouplers instead of having the zener diode as well. I tested and it works, so I rolled with it.

                    Pullup resistors: you guys suggested using the internal pullups on the digital pins so I wouldn't have to use external ones, but I could not get this to work - either I'm doing something wrong (most likely, since we all know I'm a bit of noob at this stuff ), or simply changing the pinMode in the beginning is not enough and I have to tweak the rest of the code as well. What happens is I do pinMode(x, INPUT_PULLUP) and measuring with a multimeter shows the pin does indeed go high after pulling the 10k pullup resistor off the breadboard, but when I push the button and the optocoupler turns on and pulls that pin low, the action related to that button being pressed gets stuck on and runs continuously. If I understand correctly, it should work the same, with no other changes....

                    Current sensors: I played around with the "analogRead" and a current sensor and I think I got this one right: I used the serial monitor to read the values the pin was giving me at different voltage inputs, from 0 when fully grounded, all the way to 1024 (I think) when pulled all the way to 5v. The current sensor I got (which I can't remember for the life of me what model it is right now), outputs a value between 2.5v at 0A and 8v! at 30A! (if I remember the datasheet correctly). My car window motor draws precisely 15a when the motor is stalled, so to test this on the bench, I paralleled two 10w low-ish value resistors to drop their resistance even more, wired this setup in series with my current sensor and put the whole thing on my power supply. I began cranking the voltage and observing the values the sensor gave me at different currents. It's approximately 3.8v at 15A, so I took a note of the value the serial monitor was giving me and I'll use this to tell the program to stop the H-bridge when it detects this value consistently for 1-2 seconds to prevent false triggers from the inrush current...at least that's the theory...
                    Wattevah...

                    Comment


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

                      It looks pretty good so far
                      R5 1k is a bit low, I would use 10k for less heat. If ZD5 is a good size, you could get rid of D1/L1, they can be awkward. D1 could be smaller 1N4004, or just in series with power and no L1.
                      Arduino Atmega328 pull up resistors are about 36k ohm, PC817 transistor even really hot 90C has 1uA leakage current. So you should not be having problems with that, here is code I use for pusbutton only w/pullup:

                      Code:
                      //------ I / O  P i n  A s s i g n m e n t s ----- U N O ------------
                      #define battery_voltsPin A3 
                      #define PushButtonPin 6 
                      #define LowBatteryLampPin 5  
                      #define LEDPin 13  
                      //*************************************************************************
                      void setup() {
                       
                        digitalWrite(LEDPin,LOW) ;  // led off if low
                        pinMode(LEDPin, OUTPUT);   // sets the digital pin as output
                        //------------------------------------
                        pinMode(battery_voltsPin, INPUT);	// sets the analog pin as input, no pullup 
                        analogReference(INTERNAL);	// A/D Vref is 1.1V full-scale
                        //------------------------------------
                        digitalWrite(LowBatteryLampPin,OFF);	// Low Fuel Lamp off
                        pinMode(LowBatteryLampPin, OUTPUT);		// sets the digital pin as output
                        //------------------------------------
                        pinMode(PushButtonPin, INPUT_PULLUP);   // sets the digital pin as input w/pullup
                        //------------------------------------
                      } 
                      //*************************************************************************

                      Comment


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

                        Yeah, I did this too: pinMode(PushButtonPin, INPUT_PULLUP); but got the unwanted result of the output being stuck on all the time after the first push, as if the button was held down...does this work on the ProMini as well ? It should, after all, the microcontroller's the same on all of them, or very close....
                        Wattevah...

                        Comment


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

                          all 328 boards are the same - just more or less psu and programming crap on them.

                          you may want to see if the opto's are leaky by probing or scoping the outputs during testing.

                          Comment


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

                            Could be down to the optocouplers somehow, since it doesn't turn on right away - it takes one trigger to get stuck, so I imagine the optocoupler turns on, pulls the pin low, but then it doesn't go back high again for some reason....
                            Wattevah...

                            Comment


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

                              It's not your hardware, I think. There must be other code using the same I/O pins as an output pin. I would look at the software more. I've never seen a digitalRead() work once and then stuck.
                              Unless the opto capacitor makes the rise time slow and not a Schmitt trigger input, or they are analog input pins.

                              The motor control should have a timeout of say 10 seconds to not cook the motor, in addition to the monitoring motor current and the switches. Chevy and Toyota had problems with recalls after people left a window cracked open and rain got in the switches and the motor stayed on.

                              Comment


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

                                Originally posted by redwire View Post
                                The motor control should have a timeout of say 10 seconds to not cook the motor, in addition to the monitoring motor current and the switches. Chevy and Toyota had problems with recalls after people left a window cracked open and rain got in the switches and the motor stayed on.
                                I have that. No matter what happens, the motor cuts out after 15s if something goes wrong and it doesn't stop for some reason. My switches are on the dash under the headunit, so water can't possibly get there, but still.

                                As for the code, I probably missed something. I might try it again....maybe there's more to it than just replacing INPUT with INPUT_PULLUP. When I switched back to INPUT and added my resistor again, it worked perfectly once again, so I don't know, maybe I'm doing something wrong....I'd show you the code, but it's a mess, so I'd rather not

                                I also happened to come across the perfect connector for the job: these things which I didn't even know could exist can carry both a high current input and some control signals, so they're perfect, albeit a bit pricey.
                                Last edited by Dannyx; 12-19-2019, 04:30 AM.
                                Wattevah...

                                Comment


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

                                  Still on this VERY slow project, just in case someone is still watching this thread and would be kind enough to reply back, I started laying it down on a piece of veroboard PCB to hopefully get one step closer to the final version. I now started looking at motor control, since it's equally important for this purpose: I initially wanted to go with THIS thing, but then I read about it more carefully and amongst other things I learned is that apparently you can't just hit it with a steady DC voltage on the control pins and let it run continuously - there has to be a switching PWM wave on the input pins there, with a duty cycle of up to 98%. Read the last post HERE.

                                  I also have to be careful how I power it, since you can fry the microcontroller if you're not careful, since the power input for the motor itself is also tied to the V+ header pin which you'd assume is separate and should be used to power the low-voltage control part, but it's not, so you can easily send 12v into the I/O pins of your micro Same for the EN pins. Good thing I read that up HERE !

                                  I also have THIS one in my shopping cart, since it's slightly cheaper. I'd need to provide my own heatsink though. It also handles less current and this is where it can get a bit ambiguous, since the first one doesn't precisely mention the current - it just says 0-30A, so I can only assume that's PEAK current and by no means continuous ! The "bare" one gives 10A as the continuous current and 30A as peak, though those values are probably "optimistic" ones and they're lower in reality. I actually measured the current draw on my car window: it's around 5-7A when the motor is running freely (depending on the temperature and how much crud is on the rubbers) and around 15A when the window reaches the end of travel and the motor stalls, so either of them should handle it if properly cooled (which might actually be a problem in the summer ! !). If those specs are anything to go by, the cheaper one can be driven up to 99% duty cycle, though I'm sure that's borderline irrelevant, so....yeah....not sure what to go with :|
                                  Last edited by Dannyx; 02-19-2020, 11:01 AM.
                                  Wattevah...

                                  Comment


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

                                    Back on this project, being stuck at home for the moment, more or less against my own will. I had a look at my schematic and though I could drop the 82 ohm R9 entirely and just put a fuse between the output of the regulator and the micro. The thinking behind this is that if the output ever overshoots, ZD7 conducts and blows that fuse anyway, since I'd put a very low current one - 200mA or thereabout I reckon should be low enough....not sure how fast it'd act and whether it'd save the micro from getting toast though...
                                    Attached Files
                                    Wattevah...

                                    Comment


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

                                      i'm not sure what r9 is even there for,
                                      but i know c5 should be directly across the regulator - how the hell can it stabilise the output with 87ohms in the way!

                                      Comment


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

                                        Originally posted by stj View Post
                                        i'm not sure what r9 is even there for,
                                        but i know c5 should be directly across the regulator - how the hell can it stabilise the output with 87ohms in the way!
                                        See posts 32-34. That resistor has been a common discussion topic ever since I made the schematic It was just a thought I came up with.
                                        Wattevah...

                                        Comment


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

                                          Originally posted by Dannyx View Post
                                          The thinking behind this is that if the output ever overshoots, ZD7 conducts and blows that fuse anyway, since I'd put a very low current one - 200mA or thereabout I reckon should be low enough....not sure how fast it'd act and whether it'd save the micro from getting toast though...
                                          One typically puts a transistor in series with a fuse to PROTECT THE FUSE!

                                          (i.e., fuses take an eternity to blow)

                                          Comment

                                          Working...
                                          X