Announcement

Collapse
No announcement yet.

Swapping out a NiMh for a LiPo?

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

    #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.

    Comment


      #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


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

        Originally posted by stj View Post
        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.

        Comment


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

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

          Comment


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

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

            Comment


              #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


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

                Originally posted by stj View Post
                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!

                Comment


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

                  Originally posted by EasyGoing1 View Post
                  Gotta love it when someone is that dedicated to science!
                  Either that or just mad —> or just dose not have anything else to do
                  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


                    #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.

                    Comment


                      #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.

                      Comment


                        #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


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

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

                          Comment


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

                            It'll be full again in no time!

                            Comment


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

                              Originally posted by stj View Post
                              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!

                              Comment


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

                                i would have used asm, no libs

                                Comment


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

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

                                  Comment


                                    #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


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

                                      Originally posted by stj View Post
                                      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 View Post
                                      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.

                                      Comment


                                        #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


                                          #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

                                          Working...
                                          X