Arduino current sensing (in car)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dannyx
    CertifiedAxhole
    • Aug 2016
    • 3912
    • Romania

    #101
    Re: Arduino current sensing (in car)

    Is CTR sort of like the hFe in a tranny ? I see 300 and 500 there at 5v.
    Wattevah...

    Comment

    • Andyy
      Member
      • Aug 2016
      • 28
      • Australia

      #102
      Re: Arduino current sensing (in car)

      Originally posted by Dannyx
      Is CTR sort of like the hFe in a tranny ? I see 300 and 500 there at 5v.
      Yep, it is exactly the optocoupler equivalent of hFe transistor current gain. CTR = Current Transfer Ratio. For an example of a high gain optocoupler, look at the datasheet CTR for a 6N138.

      Incidentally, you can replicate the darlington in the 6n138 by connecting an external transistor to a conventional opto.

      Comment

      • Dannyx
        CertifiedAxhole
        • Aug 2016
        • 3912
        • Romania

        #103
        Re: Arduino current sensing (in car)

        Given that it takes very little current to trigger an Arduino pin, I reckon it will work with the lower "gain" of the CTs I'm using...mostly because I found those on hand and I'm trying to keep it as budget as possible

        That's another thing I'm thinking of: do I just connect the optocoupler's collector to the arduino pin (along with a pull-up resistor) and the emitter to GND, or do I need a cap there somewhere as well to keep the thing from oscillating and reading multiple successive presses ?
        Last edited by Dannyx; 05-26-2018, 08:05 AM.
        Wattevah...

        Comment

        • eccerr0r
          Solder Sloth
          • Nov 2012
          • 8658
          • USA

          #104
          Re: Arduino current sensing (in car)

          The question to answer is: does it matter?

          Comment

          • Dannyx
            CertifiedAxhole
            • Aug 2016
            • 3912
            • Romania

            #105
            Re: Arduino current sensing (in car)

            Originally posted by eccerr0r
            The question to answer is: does it matter?
            Switch "bounce" ? Well, sort of...while not critical as in other projects, I certainly don't want to tap the button and have the window stop after 1 second
            Wattevah...

            Comment

            • eccerr0r
              Solder Sloth
              • Nov 2012
              • 8658
              • USA

              #106
              Re: Arduino current sensing (in car)

              Leaving it as an exercise to the reader as a thought provoking question for this particular situation...

              Comment

              • sam_sam_sam
                Badcaps Legend
                • Jul 2011
                • 6018
                • USA

                #107
                Re: Arduino current sensing (in car)

                Originally posted by Dannyx
                Switch "bounce" ? Well, sort of...while not critical as in other projects, I certainly don't want to tap the button and have the window stop after 1 second
                I do not know how you do that with an Arduino
                But with a Basic Stamp can either use what called a switch ( button) command or what I like doing is have command that I would use as a counter that counts for so many mill seconds then latches your output or while you have the button pushed

                Comment

                • Dannyx
                  CertifiedAxhole
                  • Aug 2016
                  • 3912
                  • Romania

                  #108
                  Re: Arduino current sensing (in car)

                  Originally posted by sam_sam_sam
                  a counter that counts for so many mill seconds then latches your output or while you have the button pushed
                  My code already does that: you know how on most modern cars the window latches up/down after holding the button for a while and you can let go of it - I implemented this feature also: tap the button to nudge the window up/down to where you want it; press and HOLD the button for 800ms (tweakable of course - just a random amount that seemed appropriate) and the window goes up/down on its own until you press it again to turn it off....it works perfectly on the breadboard with two relays to simulate the outputs that would later go into the H-bridge command pins, so hopefully it operates well on the car as well I was thinking of posting the code here, but it's not quite done yet and I'll probably have the code gurus criticizing me again for not doing "this" or "that" right and I also want to keep it a bit of a trade secret for now....maybe offer to install this gizmo on other cars without "smart windows" and launch a new line of products to make some money
                  Wattevah...

                  Comment

                  • sam_sam_sam
                    Badcaps Legend
                    • Jul 2011
                    • 6018
                    • USA

                    #109
                    Re: Arduino current sensing (in car)

                    Originally posted by Dannyx
                    I was thinking of posting the code here, but it's not quite done yet and I'll probably have the code gurus criticizing me again for not doing "this" or "that" right and I also want to keep it a bit of a trade secret for now....maybe offer to install this gizmo on other cars without "smart windows" and launch a new line of products to make some money
                    [ I tried a few times to use a current sensing IC chip and a Basic Stamp Controller and could not get it to work constantly and never completed the the project it was for what is below

                    I have a milling machine that I basically use it cut circuit boards but it has a big problem with blowning two amp fuses a real pain in the A** ] so I do not use it very much

                    But now I have found a solution for this problem with something I found about a month ago
                    If anyone is interested in this just let me know and I will post it

                    One note I have for you is to test your code to see if you can get it to hang or worse go out of control

                    Here is how I test a program code that I write
                    One while it running I kill the power to it then repower it right away and see how it ack
                    And basically torture test it to see if I can make it fail

                    You be surprised what can happen

                    Go for it if you have time for it

                    I made a pool timer awhile back that did not care if you lost power you never had a clock to set it was controlled by a Basic Stamp Controller

                    The setup was really different than anything I could find commercially

                    It used a green LED as a light sensor and when the sun was out playing
                    It would start a two hour counting timer then would stay off for three hours and keep repeating until the sun when to sleep it also has a summer and a winter mode the winter mode had shorter running time

                    It worked great for three or four years and then I had problems with the pool which I have not fixed yet so this pool timer controller has not been working for about three years now
                    Last edited by sam_sam_sam; 05-26-2018, 06:52 PM.

                    Comment

                    • Dannyx
                      CertifiedAxhole
                      • Aug 2016
                      • 3912
                      • Romania

                      #110
                      Re: Arduino current sensing (in car)

                      Originally posted by sam_sam_sam
                      One note I have for you is to test your code to see if you can get it to hang or worse go out of control
                      I also do that: mash buttons and stuff to see if I can get it to fail. I tried writing the code as fail-proof as possible. For instance, in this particular scenario of the electric window conversion of mine, the UP/DOWN commands must never operate simultaneously - makes sense, it would blow the H-bridge. Even though the rockers physically prevent you from pressing both up and down at the same time, I inserted a simple line of code that ensures this doesn't happen anyway. So imagine on the breadboard right now I got two individual push-buttons which can easily be pressed simultaneously and cause issues. When one is pressed, the other is ignored - simple.

                      Same goes for the current detection (though I haven't implemented this yet): I won't rely strictly on the current sensors to tell the micro when to stop the windows, I'll also add an universal timer, so if something goes wrong and the micro tries to keep cranking the window even after reaching the top/bottom, it won't drain the battery and burn itself out - it will stop after X seconds, regardless of what the current sensor is reporting....fail-safe I'd call it.

                      I hope I'll have more luck in implementing the current sensing feature than you did...seems simple enough on paper, especially since the current difference between run and stall states are fairly great in my case: around 6A when running and 15A when stalled, so precision is not that critical - it should be able to pick up a clear difference between the two states.
                      Wattevah...

                      Comment

                      • sam_sam_sam
                        Badcaps Legend
                        • Jul 2011
                        • 6018
                        • USA

                        #111
                        Re: Arduino current sensing (in car)

                        That is the kind of testing I like to see

                        Comment

                        • eccerr0r
                          Solder Sloth
                          • Nov 2012
                          • 8658
                          • USA

                          #112
                          Re: Arduino current sensing (in car)

                          But is it enough?

                          Comment

                          • sam_sam_sam
                            Badcaps Legend
                            • Jul 2011
                            • 6018
                            • USA

                            #113
                            Re: Arduino current sensing (in car)

                            I do not know but it might be a good question to ask
                            What do you got in mind
                            What are you think
                            What do you think was missed
                            Last edited by sam_sam_sam; 05-27-2018, 08:40 PM.

                            Comment

                            • eccerr0r
                              Solder Sloth
                              • Nov 2012
                              • 8658
                              • USA

                              #114
                              Re: Arduino current sensing (in car)

                              We don't know, that's the problem
                              Who knows where the corner cases are...

                              Comment

                              • budm
                                Badcaps Legend
                                • Feb 2010
                                • 40746
                                • USA

                                #115
                                Re: Arduino current sensing (in car)

                                Since electrical noise environment in cars can be really bad, how does it perform in that situation?
                                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

                                • Dannyx
                                  CertifiedAxhole
                                  • Aug 2016
                                  • 3912
                                  • Romania

                                  #116
                                  Re: Arduino current sensing (in car)

                                  Originally posted by budm
                                  Since electrical noise environment in cars can be really bad, how does it perform in that situation?
                                  That's my main concern ATM...it works on a breadboard, but how about in a car ? Still waiting for my buck converters to arrive...
                                  Wattevah...

                                  Comment

                                  • sam_sam_sam
                                    Badcaps Legend
                                    • Jul 2011
                                    • 6018
                                    • USA

                                    #117
                                    Re: Arduino current sensing (in car)

                                    When I said this earlier I was meaning with it installed in the car to this type of testing

                                    β€œHere is how I test a program code that I write
                                    One while it running I kill the power to it then repower it right away and see how it ack
                                    And basically torture test it to see if I can make it fail

                                    You be surprised what can happen ”

                                    Comment

                                    • Dannyx
                                      CertifiedAxhole
                                      • Aug 2016
                                      • 3912
                                      • Romania

                                      #118
                                      Re: Arduino current sensing (in car)

                                      I shall, of course. It's not easy without a garage to work in - I have to do it all in the parking lot which sucks big time, especially when you realize you forgot a tool you need...
                                      Wattevah...

                                      Comment

                                      • Dannyx
                                        CertifiedAxhole
                                        • Aug 2016
                                        • 3912
                                        • Romania

                                        #119
                                        Re: Arduino current sensing (in car)

                                        Ok chaps, back on this project, so I hope you're still around and subscribed to the thread

                                        It's been on hold because I've been rather busy obtaining my master's degree and writing the thesis and stuff, so everything else has been irrelevant/unimportant.

                                        It's coming along nicely and I wasn't too far from completion when I left it, but as I was mucking about with the breadboard and testing stuff, I thought about one other thing: current consumption. Since this project is going to get installed in a car, maximum energy efficiency is important. Even though a car battery's capacity is huge compared to the "tiny" current draw of a microcontroller and it would take it thousands of hours to drain its voltage to the point where the car would no longer start, it's still a good idea to minimize said current consumption as much possible, so what can be done ?

                                        For one, I read around that it is possible to tweak the arduino (it's a Mini in case you're wondering) and make it "sleep". Haven't tried it so far, but I heard it IS possible to make it enter a very low power state while still listening to the pins, so feel free to correct me or shed light on this.


                                        Now: is there any significant difference in current between using active high or active low for reading the pins ? My mind would tell me that an "active LOW" setup draws "more" current than an "active HIGH" setup, though this could very well be incorrect or irrelevant:

                                        -in an "active LOW" setup, to read the pin as "ON", you pull it to GND ; to turn it back "OFF", you pull it to VCC.
                                        -in an "active HIGH" setup, to read the pin as "ON", you pull it to VCC ; to turn it back "OFF", you pull it to GND....the complete opposite

                                        For the most part, the pins are "OFF" in my active LOW setup below, so they are pulled to VCC via 10k resistors. There's a "debounce" capacitor in parallel with the pin to GND.


                                        Even though the 10K value is rather high and the current draw is probably below the measurable limit of my meter it IS there, drawing power, whereas with an "active HIGH" setup, the pins are permanently pulled to GND, drawing no current....again, this is probably bogus, but I don't claim to know anything, so I am open to suggestions and criticism What do you guys think ?
                                        Wattevah...

                                        Comment

                                        • sam_sam_sam
                                          Badcaps Legend
                                          • Jul 2011
                                          • 6018
                                          • USA

                                          #120
                                          Re: Arduino current sensing (in car)

                                          Originally posted by Dannyx
                                          Ok chaps, back on this project, so I hope you're still around and subscribed to the thread

                                          It's been on hold because I've been rather busy obtaining my master's degree and writing the thesis and stuff, so everything else has been irrelevant/unimportant.
                                          So how did your studies go for you

                                          Comment

                                          Working...