Announcement

Collapse
No announcement yet.

How to calculate current in R2 with an LM317

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

    #21
    Re: How to calculate current in R2 with an LM317

    Careful almost all Digipots are only good to 5V max, so the LM317 max. output voltage would be 6.25V as R2 can see 5V max. There are HV ones.
    Some Arduino's MCU has a DAC output. Most PWM solutions are an extra op-amp, not too complex.

    MCU-controlled battery charging is a bit risky, if your code crashes or hangs you want it to be safe.
    You can setup the Vreg hardware to output the highest safe voltage possible and then use the MCU to only lower that with software control.

    Comment


      #22
      Re: How to calculate current in R2 with an LM317

      any mcu used in a risky way needs a watchdog circuit.

      Comment


        #23
        Re: How to calculate current in R2 with an LM317

        A watchdog doesn't work unless you know what you are doing.
        One engineer had a 100Hz real-time interrupt (RTI) for timing things in his firmware, seconds counters etc. and he put the watchdog reset code there. Of course, his main software hung and the RTI kept happening, the product did not reboot- despite being hung up

        My buddy doing automotive ECU drive-by-wire code, one of (many) techniques is for every important subroutine, increment a counter everytime it's executed.
        He has a supervisory routine that looks at all the counters, if a count gets stuck you know the routine is dead or hung. Then you can attempt to restart it (that task/routine). If the counts are OK, kick the watchdog. The ECU you don't really want a reboot, that is a separate H/W chip doing that.

        Comment


          #24
          Re: How to calculate current in R2 with an LM317

          dammit write good software from the get go, not expect firmware updates to save you after something goes up in flames...

          Comment


            #25
            Re: How to calculate current in R2 with an LM317

            you dont reset a watchdog from a damned interrupt - you do it from the main program loop!

            Comment


              #26
              Re: How to calculate current in R2 with an LM317

              Originally posted by sam_sam_sam View Post
              Or use a Servo to control the rheostat type of POT.
              This is actually a great idea ... I had not thought of using a servo to control a pot ... I mean ... setting aside the obvious - COMPLETE impracticality of such a design ... but then again Im not wanting to do the project to mass produce ... they sell chips for less than 50 cents that will charge an 18650 ... this is just for the satisfaction of actually doing it.


              Originally posted by sam_sam_sam View Post
              the LG 1.5 amp hour ( I have a use for these batteries for another project) that are in it right now these batteries are not bad but every three of four days I have to charge them which is not convenient for me
              LiIon batteries thrive when they are topped off ... meaning it's perfectly OK to recharge them once they are down to only 90% charged. Unlinke NiMh batteries, which thrive on the deep cycle charges ... LiIon batteries will actually not last as long if you let them drain too much between charges...

              So why not just throw the batteries on the charger every night after you're done working?

              Comment


                #27
                Re: How to calculate current in R2 with an LM317

                Those online calculators never give you the current through the R2!

                I've actually written an LM317 calculator in Java ... with everything graphically laid out, you fill in the values you know it figures out what you don't know ... what I really like about it is that I can tell it that I want it to give me a list of values for R2 when I pre-select R1 then tell it I want the LM317 to have a specific voltage range... it will tell me what values of R2 will satisfy the sweep so I can pick the POT accordingly.

                It does some other stuff too ... once I've got the program complete, I was gonna see if anyone in here wanted to check it out and maybe even offer some ideas for improving it.

                Comment


                  #28
                  Re: How to calculate current in R2 with an LM317

                  In my LM317 calculator spreadsheet, I did extra math so there are three possible equations:
                  Given Vout, R1, solve for R2
                  Given Vout, R2, solve for R1
                  Given R1, R2, solve for Vout
                  Also included the resistor's power dissipation calc and load, and what if the REF is high 1.30V or low 1.20V I think over temperature that is the case.

                  Comment


                    #29
                    Re: How to calculate current in R2 with an LM317

                    Originally posted by R_J View Post
                    This is not what you were asking about in your original post but have you seen this, "Control an LM317T with a PWM signal": https://www.edn.com/control-an-lm317...-a-pwm-signal/
                    No, I haven't seen that before. Very interesting... I'll have to play with it and see how it works.

                    Comment

                    Working...
                    X