Monday, May 13, 2019

How to choose a better maintenance free car battery

Car battery is a consumable product that will eventually fail over time. When we say a better car battery, the most important point is that it can last longer and degrade slower.

Below are some of the criteria to look for in selecting a better car battery.

1. Brand

The lifespan of battery is affected by high temperature. Certain brand of battery is manufactured for use in hot equatorial areas, such as Amaron, Exide, etc.

 

2. Size

The battery for normal passenger car is normally of NS40, NS60 or NS70. NS60 is more powerful than NS40, and NS70 is more powerful than NS60.

However, choosing the right size of battery that match with your car's alternator is important. If you car's alternator is generating smaller current and designed to work with NS40 type of battery, it is better for you to stick to NS40 or at most upgrade to NS60 but not beyond.

This is because if the charge supplied from alternator is not sufficient to make the battery fully charged, the battery will suffer premature death and therefore has a shorter life span.

In addition, bigger battery will cause heavier workload to the alternator, which might also reduce the life span of the alternator.

Regardless of the size of the battery, if the charging system is unstable, the battery will die fast.


3. Performance Rating

A battery number looks like this: 46B24L

The first 2 digit is its overall performance rating. The higher the better.

The alphabet after the first 2 digit is an indicator of the battery's width and height. This alphabet can be from A to H. Smaller alphabet indicates smaller width and height.

The number after the alphabet is its length in centimeter. For the battery number 46B24L, its length is 24cm.

The final alphabet indicates the position of its positive terminal. L means it is on the left, and R means it is on the right.



4. Amp Hour (AH)

Amp Hour is an indicator of how much energy is stored in a battery.

It is the energy a 12 volts battery can deliver continuously for 20 hours (C20) at 80°F (26.7°C) without falling below 10.5 volts.

The state when the battery's energy fall below 1.75 volts per cell (or 10.5 volts in a 6-cells 12 volts battery) is considered as "fully discharged".

There are several C-rating given to the batteries in relation to its AH, by giving the battery a specific load to discharge:
  • C3 means the battery will be fully discharged over a period of 3 hours.
  • C5 means the battery will be fully discharged over a period of 5 hours.
  • C8 means the battery will be fully discharged over a period of 8 hours.
  • C10 means the battery will be fully discharged over a period of 10 hours.
  • C20 means the battery will be fully discharged over a period of 20 hours.
  • C100 means the battery will be fully discharged over a period of 100 hours.
In normal practice, C20 is used to measure the AH of vehicle batteries.

The AH value among batteries with same size varies, and you should look for the one with higher AH value.


5. Reserve Capacity (RC)

RC is a general indicator of how long a fully charged new battery can continue to operate the vehicle's essential accessories when the alternator or fan belt fails.

It identifies how many minutes the battery can deliver a constant current of 25 amps at 80°F (26.7°C) without falling below the minimum voltage of 1.75 volts per cell in order to keep the vehicle running.

The higher the RC rating, the longer your vehicle can operate in the event your alternator or fan belt is faulty.


6. Cold Cranking Amps (CCA)

CCA is a rating used to define the battery's ability to start an engine in cold temperatures. It refers to the number of amps a 12-volt battery can deliver at 0°F (-17.8°C) for 30 seconds while maintaining a voltage of at least 7.2 volts.

The higher the CCA rating, the greater the starting power of the battery.

Battery starting power deteriorates as the battery ages. Therefore, a battery with higher starting power should give you more confidence over time.

Replacing a battery with one that has a lower CCA than the original may result in poor performance.


7. Price

Normally, the branded battery that suit with your car's alternator, with high performance rating, high AH, high RC and high CCA, will also come with a high price tag.

As such, you might want to strike a balance between the battery's price and its performance. Choose the above average battery, and it can probably last for at least 2 years.



Friday, May 3, 2019

DSN-less access to Microsoft SQL Server from Raspberry Pi Raspbian Stretch

Accessing Microsoft SQL Server (including SQL Server Express and Azure SQL Database) from Linux isn't that straightforward.

Microsoft does provide free connection library for Linux to access to SQL Server, but the library will not work for Raspbian OS in Raspberry Pi due to conflicting type definition with other essential library in the system.

Below is the easiest way I found out to access SQL Server from Raspberry Pi.

You need to enable and allow TCP/IP access to the SQL Server.

The SQL client to use is FreeTDS through unixODBC.

First of all, make sure the required FreeTDS and unixODBC components are installed in the Raspberry Pi:

sudo apt install freetds-bin freetds-dev tdsodbc unixodbc unixodbc-bin unixodbc-dev

If you are using Python to access the SQL Server, also need to install the following components:

sudo apt install python-pymssql python-pyodbc python-sqlalchemy

If you are using PHP to access the SQL Server, then need to install the following components:

sudo apt install php7.0-odbc

Since we are going to use the DSN-less method to access to the SQL Server, it is not necessary to configure the DSN settings. However, there is still minimal configuration needs to be made.

sudo nano /etc/odbc.ini

[FreeTDS]
Description = SQL Server
Driver = FreeTDS
Trace = No
TDS_Version = 7.0


For the TDS Version, if you are unsure about the version of your SQL Server, then set the TDS Version to 7.0.

You can set the TDS Version according to the following:

  • TDS Ver. 7.0 for SQL Server 7.0
  • TDS Ver. 7.1 for SQL Server 2000
  • TDS Ver. 7.2 for SQL Server 2005
  • TDS Ver. 7.3 for SQL Server 2008
  • TDS Ver. 7.4 for SQL Server 2012, 2014, 2016 or 2017
Lower TDS version has more compatibility but less feature in SQL command and less supported data types.

Another file you need to edit is odbcinst.ini.

sudo nano /etc/odbcinst.ini

[FreeTDS]
Description = FreeTDS unixODBC Driver
Driver = /usr/lib/arm-linux-gnueabihf/odbc/libtdsodbc.so
Setup =  /usr/lib/arm-linux-gnueabihf/odbc/libtdsS.so
fileusage=1
dontdlclose=1
UsageCount=1


Now you should be ready to access to your SQL Server from this Raspberry Pi.

Python test script:

import pyodbc

server = 'your_SQL_Server_IP_address'
database = 'your_database'
user = 'database_user'
password = 'database_user_password'
query = 'SELECT * FROM INFORMATION_SCHEMA.TABLES;'   # your SQL query

conn = pyodbc.connect('DRIVER={FreeTDS};SERVER='+server+';PORT=1433;DATABASE='+database+';UID='+user+';PWD='+password+';')
cursor = conn.cursor()
cursor.execute(query)
for row in cursor.fetchall():
        print row


PHP test script:

$server = 'your_SQL_Server_IP_address';
$database = 'your_database';
$user = 'database_user';
$password = 'database_user_password';
$query = 'SELECT * FROM INFORMATION_SCHEMA.TABLES;';   // your SQL query


if ($db = odbc_connect('DRIVER={FreeTDS};SERVER='.$server.';PORT=1433;DATABASE='.$database.';',$user,$password)) {
        $res = odbc_exec($db, $query);

        while( $row = odbc_fetch_array($res) ) {
                print_r($row);
        }

        odbc_close($db);
}





Monday, April 29, 2019

dnGrep - Free GUI "grep" and "sed" tool for Windows

If you are familiar with UNIX/Linux operating system, you must be using a lot of "grep" command to search for string inside text files, and "sed" command to find and replace string in the text files.

There are identical command in Windows such as "find", "findstr" or even the PowerShell "Select-String", but they are just not as easy to use as "grep" in UNIX/Linux.

There are also GUI tools for Windows which aim to perform the "grep" and "sed" function, majority of the good ones need you to pay for it, except dnGrep which is licensed under GNU GPL v2 and is therefore free for use.


dnGrep is indeed a very powerful find and/or replace tool for Windows. It can not only search for text or keywords inside the target file(s), but also able to perform a text replace action in target text file(s).

Beside normal text files, it is also able to search inside MS Word documents and PDF files. It can also search inside archived file.

You can perform your search by plain text input, or XPath query language, or regular expression (regex), or even phonetic.

You can also specify to search for files in a folder (and sub-folders) within a particular date range in which they are created or last modified.

The search result is displayed with yellow background highlight, together with the line number in the target document. Double click on the search result will open up the target document for further action.

The beauty of its replace function is that, the replace action can be undone.

You can also create "bookmarks" to store frequently used search keywords and conditions.

dnGrep is lightweight, fast in action, powerful and free for use. It is an essential 3-party tool in your Windows computers.

Click here to go to the download page of dnGrep.

Hint: Click on the "Older Posts" link to continue reading, or click here for a listing of all my past 3 months articles.