Swapping out a NiMh for a LiPo?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • EasyGoing1
    Shock Therapist
    • Sep 2016
    • 977
    • USA

    #61
    Re: Swapping out a NiMh for a LiPo?

    Update:

    Got the re-designed PCBs and this is the first complete build...






    Addedd access to two of the softSerial pins for easy inquiry and for setting the RTC.





    Got rid of that microscopic piece of crap cap and put a real cap on there ...











    And a video ...

    Maybe it's my imagination but the green PCBs seem to be of a higher quality than the blue ones.

    I'm gonna have 8 PCBs leftover and a lot of extra parts too ... it's a decent circuit for switching AC off and on up to 240V at 2 amps ... if anyone would like a PCB I can just put one in an envelope, stick a stamp on it and it gets there when it gets there ... if you want components, just pay my cost and ill include those as well ... up to what I have anyways.
    sigpic

    Comment

    • stj
      Great Sage 齊天大聖
      • Dec 2009
      • 30964
      • Albion

      #62
      Re: Swapping out a NiMh for a LiPo?

      i hate those battery holders - you often hit the battery on something while trying to slide it out.
      i use the type on pc's where you just drop the battery in past a latch

      Comment

      • EasyGoing1
        Shock Therapist
        • Sep 2016
        • 977
        • USA

        #63
        Re: Swapping out a NiMh for a LiPo?

        Originally posted by stj
        i hate those battery holders - you often hit the battery on something while trying to slide it out.
        i use the type on pc's where you just drop the battery in past a latch
        Yeah for whatever reason, this holder was the best one I could find at the time on Amazon. Then I had to create the object for EasyEDA and I had holes placed in the PCB where the three small studs or whatever stick out from the holder, but after seeing how it all works, I think those might have been meant to rest against the PCB and give it support. ALSO, don't hold onto any of the metal when you're soldering it to the board ... just an FYI on that! lol

        I forgot to mention earlier that these batteries ... are everything there are advertised to be... I had to use a towel on my tongue after trying it out...



        Last edited by EasyGoing1; 05-08-2021, 03:05 AM.
        sigpic

        Comment

        • stj
          Great Sage 齊天大聖
          • Dec 2009
          • 30964
          • Albion

          #64
          Re: Swapping out a NiMh for a LiPo?

          umm....
          that label is meant to be informative, not a challenge!!!

          Comment

          • EasyGoing1
            Shock Therapist
            • Sep 2016
            • 977
            • USA

            #65
            Re: Swapping out a NiMh for a LiPo?

            Originally posted by stj
            umm....
            that label is meant to be informative, not a challenge!!!
            My motto is ... question EVERYTHING! :-)
            sigpic

            Comment

            • stj
              Great Sage 齊天大聖
              • Dec 2009
              • 30964
              • Albion

              #66
              Re: Swapping out a NiMh for a LiPo?

              lol
              like the youtube guy "project farm",
              he reads package claims and says "we're gonna test that!"
              #

              Comment

              • EasyGoing1
                Shock Therapist
                • Sep 2016
                • 977
                • USA

                #67
                Re: Swapping out a NiMh for a LiPo?

                Originally posted by stj
                lol
                like the youtube guy "project farm",
                he reads package claims and says "we're gonna test that!"
                #
                Gotta love it when someone is that dedicated to science!
                sigpic

                Comment

                • sam_sam_sam
                  Badcaps Legend
                  • Jul 2011
                  • 6030
                  • USA

                  #68
                  Re: Swapping out a NiMh for a LiPo?

                  Originally posted by EasyGoing1
                  Gotta love it when someone is that dedicated to science!
                  Either that or just mad —> or just dose not have anything else to do

                  Comment

                  • EasyGoing1
                    Shock Therapist
                    • Sep 2016
                    • 977
                    • USA

                    #69
                    Re: Swapping out a NiMh for a LiPo?

                    Here's an update on this project...

                    The new board design is working out well with one exception. It turns out that the ATTINY85 chip wouldn't start running it's code until I had first applied power to the circuit, then press the reset button. So I did some poking around and someone on the Arduino forum suggested putting a cap between the top of R4 and ground, but that didn't work, so I just removed R4 all together and that actually did the trick. So now the code starts running as soon as power is applied.

                    The way I know that the code is running, is I have it flash the lights a few times in the setup() routine.

                    As far as the code for the ATTINY, that was a little tricky. The chip cant store much code, so I had to use one program to set the DS3232 RTC to the correct date and time. then use a different program for actual daily use.

                    So I decided on doing the battery charge refresh once every six weeks (refresh cycle is three hours) and I use the ATTINY's EEPROM to store the Unix time code, which wasn't easy because each EEPROM storage location is not large enough to store a long datatype so I had to concatenate sequential addresses to be able to store the whole timecode. And the timecode is actually a future date.

                    The main loop periodically pulls down the current Unix timecode from the DS3232 and compares it with the future date in EEPROM, and if the current timecode is larger than the one stored in the EEPROM AND ALSO if the current hour is 8 AM, then it starts a refresh cycle. And that cycle, when it starts, calculates another six weeks and stores that back into EEPROM, and then it cuts power to the unit for two hours and that's about the gist of it all.

                    In order to kick off the first recording of the future date, when I burn the code to the chip, I first burn a bootloader, then the code, that way the initial reading of the EEPROM will be either 0 or -1, then when the code starts, it looks for a value less than 1000 or whatever and when it sees that, it starts the first refresh cycle which then calculates six weeks into the future, writes that to EEPROM and its all good.

                    The initial refresh worked fine ... so I won't actually know if the six-week thing works until it happens and if I'm around to see it.

                    Here it is installed in the unit ...



                    Last edited by EasyGoing1; 05-29-2021, 11:07 PM.
                    sigpic

                    Comment

                    • EasyGoing1
                      Shock Therapist
                      • Sep 2016
                      • 977
                      • USA

                      #70
                      Re: Swapping out a NiMh for a LiPo?

                      I was actually able to get rid of the portion of the code that relied on the EEProm being 0 or -1 by tweaking things a little bit...

                      The SoftwareSerial library takes almost 50% of the entire code memory on the ATTINY, but now, when you burn the code to the chip, you simply connect it to a serial interface, and then you can set the time if it's not already set and you can tell it to start a refresh cycle the next time 8 AM happens.

                      This code takes 97% of the memory available for code storage.

                      Here is the sketch if anyone is interested:

                      Code:
                      #include <Arduino.h>
                      #include <TimeLib.h>
                      #include <DS3232RTC.h>
                      #include <EEPROM.h>
                      #include <BlockNot.h>
                      #include <SoftwareSerial.h>
                      
                      #define Rx 3
                      #define Tx 1
                      #define RELAY 4
                      
                      SoftwareSerial serial(Rx,Tx);
                      BlockNot checkTimer(300, SECONDS); //Five Minutes
                      
                      long THREE_HOURS = 10800;
                      long SIX_WEEKS = 3628800;
                      
                      int NEXT_REFRESH = 0;
                      
                      time_t rightNow;
                      
                      
                      void printDigits(int digits){
                        serial.print(":");
                        if(digits < 10)
                          serial.print('0');
                        serial.print(digits);
                      }
                      
                      void digitalClockDisplay(){
                        serial.print(hour());
                        printDigits(minute());
                        printDigits(second());
                        serial.print(" ");
                        serial.print(day());
                        serial.print(" ");
                        serial.print(month());
                        serial.print(" ");
                        serial.print(year());
                        serial.println();
                      }
                      
                      void powerOFF() { digitalWrite(RELAY, LOW); }
                      
                      void powerON() { digitalWrite(RELAY, HIGH); }
                      
                      void flash() {
                        for(int x=0; x<4; x++) {
                          powerON();
                          delay(750);
                          powerOFF();
                          delay(500);
                        }
                      }
                      
                      void writeEE(int address, long value){
                        byte four = (value & 0xFF);
                        byte three = ((value >> 8) & 0xFF);
                        byte two = ((value >> 16) & 0xFF);
                        byte one = ((value >> 24) & 0xFF);
                        EEPROM.write((address * 4), four);
                        EEPROM.write((address * 4) + 1, three);
                        EEPROM.write((address * 4) + 2, two);
                        EEPROM.write((address * 4) + 3, one);
                      }
                      
                      long readEE(int address){
                        long four = EEPROM.read((address * 4));
                        long three = EEPROM.read((address * 4) + 1);
                        long two =  EEPROM.read((address * 4) + 2);
                        long one =  EEPROM.read((address * 4) + 3);
                        return ((four << 0) & 0xFF) + ((three << 8) & 0xFFFF) + ((two << 16) & 0xFFFFFF) + ((one << 24) & 0xFFFFFFFF);
                      }
                      
                      void doRefresh() {
                        powerOFF();
                        static long now;
                        static BlockNot refreshTimer(60, SECONDS);
                        now = (long) rightNow;
                        long startTime = now;
                        long nextRefresh = now + (SIX_WEEKS - THREE_HOURS);
                        writeEE(NEXT_REFRESH,nextRefresh);
                        bool keepRunning = (now - startTime) < THREE_HOURS;
                        while(keepRunning) {
                          if (refreshTimer.TRIGGERED) {
                            now = (long) RTC.get();
                            keepRunning = (now - startTime) < THREE_HOURS;
                            powerOFF();
                          }
                        }
                        powerON();
                      }
                      
                      void processSerial() {
                        String in = serial.readString();
                        String first = in.substring(0,1);
                        if (first.equals("?")) {
                          serial.println(F("TXXXXXX to set time, use 'date +T%s' to get time\nG - shows the time from the RTC\nF - Sets next refresh to happen when the hour is 8 AM"));
                        }
                        else if(first.equals("T")) {
                          long num = in.substring(1).toInt();
                          time_t t = num + 2;
                          if (t > 100) {
                            RTC.set(t);  // set the RTC and the system time to the received value
                            setTime(t);
                            adjustTime(-25200);
                            serial.println(F("Time Set!"));
                          }
                        }
                        else if(first.equals("G")) {
                          digitalClockDisplay();
                        }
                        else if(first.equals("F")) {
                          long now = (long) RTC.get();
                          writeEE(NEXT_REFRESH,now);
                          serial.println(F("Done!"));
                        }
                        while(serial.available()) serial.read();
                      }
                      
                      void setup() {
                        serial.begin(9600);
                        delay(5000);
                        setSyncProvider(RTC.get);  // the function to get the time from the RTC
                        delay(200);
                        adjustTime(-25200);
                        pinMode(RELAY,OUTPUT);
                        flash();
                        powerON();
                        delay(6000);
                      }
                      
                      void loop() {
                        static long nextRefresh;
                        static long now;
                        if (checkTimer.TRIGGERED) {
                          rightNow = RTC.get();
                          now = (long) rightNow;
                          nextRefresh = readEE(NEXT_REFRESH);
                          if ((now > nextRefresh) && (hour(rightNow) == 8)) {
                            doRefresh();
                          }
                          else {
                            powerON();
                          }
                        }
                        if (serial.available()) processSerial();
                        delay(500);
                      }
                      Last edited by EasyGoing1; 05-30-2021, 12:00 AM.
                      sigpic

                      Comment

                      • eccerr0r
                        Solder Sloth
                        • Nov 2012
                        • 8688
                        • USA

                        #71
                        Re: Swapping out a NiMh for a LiPo?

                        microcontroller flash is always full.
                        It's gotten so bad that I end up making all textual output as terse as possible to save all those bytes of flash I can...
                        One of the projects I was working on was a power supply, it too was 97% full on 4K of flash. I ripped out so much of the serial interface and relied only on LCD and front panel control.
                        1200 lines of .c code with comments... but it's the libc library functions that killed flash memory. The AVR I was using didn't have a hardware multiplier so it had to link in the software multiplier...

                        ... and that RAM I wasted on the CLI buffer... had to chop that down too... I think I had it down to 16 characters command "line" so I could allocate more RAM for the PID controller state.
                        Last edited by eccerr0r; 05-30-2021, 12:25 AM.

                        Comment

                        • stj
                          Great Sage 齊天大聖
                          • Dec 2009
                          • 30964
                          • Albion

                          #72
                          Re: Swapping out a NiMh for a LiPo?

                          just change up the mcu for a bigger flash one with the same pinout.

                          Comment

                          • eccerr0r
                            Solder Sloth
                            • Nov 2012
                            • 8688
                            • USA

                            #73
                            Re: Swapping out a NiMh for a LiPo?

                            It'll be full again in no time!

                            Comment

                            • EasyGoing1
                              Shock Therapist
                              • Sep 2016
                              • 977
                              • USA

                              #74
                              Re: Swapping out a NiMh for a LiPo?

                              Originally posted by stj
                              just change up the mcu for a bigger flash one with the same pinout.
                              I thought about that ... but that's as far as that went ... I figured if an attiny85 cant toggle a relay for three hours once every six weeks ... then really ... what's the world coming to!
                              sigpic

                              Comment

                              • stj
                                Great Sage 齊天大聖
                                • Dec 2009
                                • 30964
                                • Albion

                                #75
                                Re: Swapping out a NiMh for a LiPo?

                                i would have used asm, no libs

                                Comment

                                • EasyGoing1
                                  Shock Therapist
                                  • Sep 2016
                                  • 977
                                  • USA

                                  #76
                                  Re: Swapping out a NiMh for a LiPo?

                                  Originally posted by stj
                                  i would have used asm, no libs
                                  Because .... you like pain?
                                  sigpic

                                  Comment

                                  • stj
                                    Great Sage 齊天大聖
                                    • Dec 2009
                                    • 30964
                                    • Albion

                                    #77
                                    Re: Swapping out a NiMh for a LiPo?

                                    you have no high level coms running afaik, just talking to an RTC.
                                    so what pain? your just reading some registers and running some loops.

                                    as a halfway, you could copy the library's and rename them.
                                    then delete every function from the library's that you arent actually using.

                                    Comment

                                    • EasyGoing1
                                      Shock Therapist
                                      • Sep 2016
                                      • 977
                                      • USA

                                      #78
                                      Re: Swapping out a NiMh for a LiPo?

                                      Originally posted by stj
                                      you have no high level coms running afaik, just talking to an RTC. so what pain? your just reading some registers and running some loops.
                                      Using I2C protocol …

                                      Originally posted by stj
                                      as a halfway, you could copy the library's and rename them. then delete every function from the library's that you arent actually using.
                                      Have you ever actually done this? With a library that has deep roots into other libraries? Cause man … I think I'd rather get root canal before doing that again.
                                      sigpic

                                      Comment

                                      • eccerr0r
                                        Solder Sloth
                                        • Nov 2012
                                        • 8688
                                        • USA

                                        #79
                                        Re: Swapping out a NiMh for a LiPo?

                                        What the... didn't even see you used a i2c rtc in the design... I would have just did the RTC in software and omitted a chip since it doesn't even need to be that accurate.

                                        Other thing is that I probably would have added an LED that blinks while it's self-testing. Then the user wouldn't wonder why the light was on unexpectedly...

                                        Comment

                                        • stj
                                          Great Sage 齊天大聖
                                          • Dec 2009
                                          • 30964
                                          • Albion

                                          #80
                                          Re: Swapping out a NiMh for a LiPo?

                                          some mcu's have an rtc,
                                          most have hardware i²c so you dont need a bitbang library!

                                          Comment

                                          Related Topics

                                          Collapse

                                          • Tarot Superstars
                                            Short Circuit tester
                                            by Tarot Superstars
                                            Hello.
                                            I have seen a short circuit tester made with 3 * 9V batteries, a voltage limiter component and a resistor connected to the probes of a multimeter.
                                            The theory is that the meter becomes sensitive enough to read very low resistances and the lowest resistance to ground on a circuit is likely to be a short circuit in that area.

                                            Link
                                            The Amazing $1 Short Finder Upgraded! Convert ... - YouTube
                                            https://www.youtube.com/watch?v=0eixDdCpiO4

                                            My multimeter isn't normally sensitive to very small resistance, but when I put a 1 mega ohm resistor...
                                            09-25-2023, 09:11 AM
                                          • M1NEBLANK SHOW
                                            MSI B250 Gaming M3 Short circuit in CPU power supply circuit
                                            by M1NEBLANK SHOW
                                            Hello. MSI B250 Gaming M3 board, short-circuit on the power supply. Found a problematic mosfet VQ1
                                            (N-PK616BA_PDFN8-HF) soldered it out - short circuit is gone. I replaced VQ1 + VQ5 (N-PK632BA_PDFN8-HF). VQ1 was replaced with PK618. After starting attempt VQ1 is lit again. What can be the problem? In the driver?

                                            Schematic and Boardview here
                                            ...
                                            04-04-2025, 03:57 PM
                                          • прямо
                                            Viper22A 5VSB circuit
                                            by прямо
                                            So I have a cheap non working ATX PSU that I was learning to repair a decade ago. At the time, it blew the main fuse, bridger rectifier, NTC, and primary 9A 900V MOSFET. Replaced all except the MOSFET. 5VSB came back online. Then I poked around in it so much, measuring components one by one to a point I accidentally made the 5VSB circuit primary side went bang. Blown the AP8022 (Viper22A) PWM chip, along with a low resistance resistor and the PC817 opto isolator. I replaced them all.

                                            In the process of poking around, I also lost a zener diode that stabilize the voltage coming from...
                                            01-13-2024, 07:05 PM
                                          • chth96
                                            Is ESR value different between on Circuit and off Circuit?
                                            by chth96
                                            A few days ago, I purchased MESR-100 ESR meter, and When I measured a SMD capacitor on circuit,MESR-100 showed ESR value of 30, But I managed to desolder this SMD capacitor from circuit and measured it then MESR-100 showed ESR value of 18.
                                            I also measured it with Mega328 Transistor Tester, and It showed ESR value of 17.
                                            Is my MESR-100 defective, if the ESR value is different between on Circuit and off Circuit?
                                            11-19-2022, 04:32 AM
                                          • vrasp
                                            Issues in PWM circuit with LC filter to drive Peltier
                                            by vrasp
                                            Hi,

                                            I've been trying to build a Peltier circuit that I can control with arduino and create cooling ramps. I've never built a circuit before and only have a basic knowledge of electronics.

                                            I've been researching how to do this and attempted to build it. My circuit is basically a PWM signal sent to a motor driver with an LC filter to smoothen the signal. Since very low temperatures are required, I added another Peltier on top of the first one. The top Peltier needs to be driven at a lower voltage to limit the amount of heat produced and effectively lower the temperature....
                                            10-27-2022, 08:11 PM
                                          • Loading...
                                          • No more items.
                                          Working...