battery overdischarge protection circuit

githublink: contains eagle files, arduino sketch code, python code, etc.

When dealing with rechargeable batteries, one faces two voltage limits: over-charge limit, over-discharge limit. When it comes to charging, most battery charging ICs out in the market will deal with it and frankly, I haven’t yet ran into a situation where I need to delicately control the voltage limit when the charging should stop. The battery charging ICs has a few variants when it comes to overcharge limits: 4V, 4.1V, 4.2V are some examples that I’ve seen in the datasheets.

However, when it comes to over-discharge protection the limits are set very low: 2.7V or 3V. Even these protections are only supported in not just “battery charging” chips but in “battery management” chips which tend to be much more expensive. However, what if you want to cut off battery power when the battery voltage gets lower than a voltage limit that is higher than the over-discharge cut-off voltage supported by the battery management chips? Continue reading “battery overdischarge protection circuit”

Advertisements

auto file renaming based on folder and creation time

0. Why I made it

The background for making this simple program is a bit embarassing… I am a man with needs so I guess I collect sexy images from time to time. The problem is, that some pictures are sequenced and mostly, I just cram a few sequences of images in one folder. When I save the images, I don’t bother with the filename because its too frustrating to change them everytime I download it. But if I don’t, the order of images is sure to get mixed up and the sequence isn’t properly ordered in the order when I downloaded it.

I tried a few programs that changed multiple filenames at once, but those were still a bit uncomfortable to use because it still needed a lot of handy work. I mean, all I wanted to do was simple: in a given directory with a few folders, each containing a sequence of images, rename the images as ‘foldername’+’sequence number’ and then move all the images in subdirectories back to the original directory.

So I just decided to make a program of it myself, by using Python. I used Python 3.3 so don’t mistake the version for 2.x. I tried to convert this program to “.exe” but I failed to do so because I couldn’t get the cx_freeze working… So if you want to use this program, you’ll need to install python 3.x from python.org and then double click my program.

1. HOW IT WORKS

I’ll just show you an example of how to use this file. Then you’ll know exactly what this will do.
(click on the images to zoom in)

I’ve made a directory with three folders in it. I just freshly created them so they’re named “new folder” 1,2,3.

Inside each folder is are a few images. In this example, folder 1 contains a bunch of ‘blue’ images, folder 2 has ‘red’ images, and folder 3 has ‘green’ images. In real cases, these images would be a sequences of images which I would have downloaded in chronological order.

So what I want to do is
1. as a preliminary step, I would like to rename the three folders in incremental alphabets(a,b,c,d …) depending on their creation time. So, the first folder(‘newfolder1’) would be renamed as ‘a’.
2. in each folder, rename all the files with an incremental number(0,1,2,3,…) depending on the creation time. So, the first image that I saved should be named ‘0’.
3. I would also like the filename to contain the folder’s name. So, within a folder the filenames should be like ‘a-01’, ‘a-02’, ‘a-03’.
4. Finally, I would like to move all the files contained inside each folder outside to the original folder and then delete the three now-’empty’ folders.

I’ve made a python code and here’s a download link.

Now I’ll show you what do with it.

put the python file in the folder with the bunch of sub-folders containing the images. Then double click the python file to execute it.

After a brief appearance of a black console window, you’ll see that all the files inside each subdirectories has been extracted to the main directory after the renaming process. And the three empty folders are deleted.

 notice that the order of files are different from the order when they were in their own separate folders. This result is the ‘real’ chronological order depending on their creation(downloaded) time.

2. COMMENTS ON PYTHON CODE

I’ve used python because I wanted to learn about it and they were really intuitive & easy to use. I used to learn C++ in school but although this was really good, it required extreme preciseness. And the IDE kit was heavy too. Python is free and easy to install. Plus python users have created a bunch of cool and efficient libraries that will make your job done much easier.

in my case, I used the .os and .shutil library. These two are installed by default. Check out the code yourself and modify some parts it you want.

I also wanted to create an ‘.exe’ version of it for it would make the program available for people who don’t have python 3.x installed. Unfortunately, I failed to convert this python code to ‘.exe’ through a python program called ‘cx_freeze’ for some error that I can’t figure out. I just got frustrated and I gave up. Someday I’ll try again…