Re: Swapping out a NiMh for a LiPo?
It'll be full again in no time!
Swapping out a NiMh for a LiPo?
Collapse
X
-
Re: Swapping out a NiMh for a LiPo?
just change up the mcu for a bigger flash one with the same pinout.Leave a comment:
-
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.Leave a comment:
-
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.Leave a comment:
-
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.Leave a comment:
-
-
-
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!"
#Leave a comment:
-
-
Re: Swapping out a NiMh for a LiPo?
umm....
that label is meant to be informative, not a challenge!!!Leave a comment:
-
Re: Swapping out a NiMh for a LiPo?
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.Leave a comment:
-
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 latchLeave a comment:
-
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.Leave a comment:
-
Re: Swapping out a NiMh for a LiPo?
Certainly, in high-frequency circuits, trace layout could mean the difference between success and failure... but in raw DC switching applications? BAH!Leave a comment:
-
-
Re: Swapping out a NiMh for a LiPo?
Also, sharp angles are no good for high frequency signals, so traces that must carry them are usually curved around corners instead of angled.Leave a comment:
-
Re: Swapping out a NiMh for a LiPo?
One comment I have is that what I have read about doing circuit traces is that should have rounded curves and not square edges that come to a point
For the life of I can not remember the exact reason for this isLeave a comment:
-
Re: Swapping out a NiMh for a LiPo?
you used an smd electrolytic - you terrorist!!!!
Leave a comment:
-
Re: Swapping out a NiMh for a LiPo?
An update on this thread ...
One of the circuit boards I ordered recently was the one to do this project... Though I screwed up on the schematic and cross-connected the input to the relay so I had to cut traces and jumper across to make it right.
Also, R5 ended up not being needed at all ... it was choking the voltage at the relay input and I learned a very important lesson in this venture ... SURFACE MOUNT COMPONENTS CAN REALLY SUCK SOMETIMES!
C1 is so friggin tiny, that I can't even pick it up with my fingers ... I must have lost 10 of them just trying to get one on the board ... I ended up just using the oven with some solder paste which actually worked out well.
Here are some pics ...
And this is the re-design ... got rid of that damn microcap and put a real cap in there ... fixed the leads to the relay, fattened up the traces a bit ... dumped R5 and its cap and bigger resistors cause they're easier to work with also added the ability to connect to serial on the ATTINY ...
OH, and those connector blocks ... are REALLY REALLY NICE ... they have some kind of mechanism in them so that when you pull on the wire, it somehow gets tighter ... I tried with all my might to rip the wire out once it was latched in there and it wasn't budging AT ALL. I have so many of them because of the required minimums but I think I had to purchase 50 of them at like 2 cents each or something ridiculous like that .... if anyone is interested in trying them, PM me your mailing address, and I'll send you a few ... they're pretty slick.Last edited by EasyGoing1; 04-24-2021, 12:15 PM.Leave a comment:
Related Topics
Collapse
-
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... -
by AlimashHi,
I am repairing a ups which doesn't turn on ,it has the following ICs:
SG3525 used to drive inverter mosfets.
couple of uc3483, one for the power supply and another to drive a big mosfet at the output stage(i think the technique is called boost)
A LM358 and TL074 for control mechanism and of course the uController.
The SG3525 is shutting down every time the ups is turned on.
I want your help to know the function of LM358 and TL074 in the system.
I reverse engineered the LM358 circuit and i think that one of the block(A) is used for battery level...1 Photo -
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 -
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...3 Photos -
by chth96A 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?-
Channel: General Capacitor Questions & Issues
-
- Loading...
- No more items.
Leave a comment: