Category: Tech, Code & AI

  • The truth about power banks

    The truth about power banks

    Ever wondered why your 4,000mAh may not even charge your 1,570mAh iPhone 5S twice? Here’s why: –

    Devices consume power (“P”) and that is measured in watts. To derive watts, we need to multiply the amperage (“I”) by voltage (“V”).

    P = I x V

    * Also note: 1A = 1,000mA

    The 4,000mAh rating of the power bank refers to the charge capacity of Lithium-ion cells in the power bank, and that is different from what comes out of the USB port because both operate at different voltages.

    Lithium-ion batteries operate between 3.2-4.2V (stable at 3.7V) while USB devices operate at 5V.

    This means that: –

    • The power bank can only deliver 4Ah x 3.7V = 14.8Wh
    • It will only charge a 5V USB device to 14.8Wh / 5V = 2.96Ah or 2,960Ah

    Now, you must be thinking: “Hey, my phone also uses a lithium-ion cell, so it should convert (back) to the same”.

    It is partially correct to assume that, but power reduction process will likely result in losses (usually in the form of heat) so it is not a 100% efficient process.

    The power bank itself would also be stepping down (or stepping up, depending on  design) its voltage. If it’s cells are wired in 2 series, it would need to step down from 3.7V x 2 = 7.4V to the USB output voltage of 5V before you can use it to charge your phone.

    With two devices stepping down power (Power bank > USB > Phone > Phone Battery) the efficiency can be as low as 64% (80% x 80%).

    So as an example, to charge a 1,570mAh battery in the iPhone 5S, we will need a constant 1.57A x 4.2V (charging voltage of li-ion) = 6.594 watts.

    Assuming both the power bank and phone are only 80% efficient at converting the power, this would mean that the power bank must deliver at least:

    6.594W x 1/(0.8 x 0.8) = 10.3W

    10.3W / 3.7V = 2,784mAh power bank is required to charge an iPhone 5S

    Also remember that while charging your phone, the phone is likely to consume some power during the process even if it is completely powered off because it has to regulate the charging process, alternating between charging and measuring the charge state of the battery. This is required to protect the battery in your phone from over-charging.

    Another thing to know about is charge rate (“C”). The higher the charge rate, the faster it charges. At 1C, a battery will be fully charged in an hour. At 2C, it will be charged in half an hour.

    Most phones are designed to charge between 0.5C to 1C to ensure maximum lifespan of the battery. This means it will take between 1 to 2 hours to charge. Charging lithium-ion batteries above 1C may shorten its lifespan (and that’s why you should not use cheap docking chargers or avoid “quick” chargers.)

    Why should you care since the phone is already regulating the charge rate for you? That’s because the charge rate affects the current draw on the power bank.

    If a 4,000mAh power bank claims to provide a 1A USB charging port, it means it should deliver 1A x 5V = 10W of power constantly.

    To charge an iPhone 5S @ 1C would require at least 1.57A x 4.2V = 6.59W (before efficiency losses). If we factor in efficiency losses @ 80% for both the power bank and the phone then 6.59W / (0.8 x 0.8) = 10.3W. That’s approximately 1A!

    For a bigger device like a Samsung Note 3 with a 3,200mAh battery, it is likely to be charged at 0.5C. Quick calculation yields (3.2A x 4.2V x 0.5C) / (0.8 x 0.8) = 10.5W which is also just above 1A.

    As you can see most devices require around 1A to charge, but if you are going to be using your phone while charging then the current draw may well exceed 1A and you will need a power bank capable of delivering more. If you use an underrated power bank you may damage (overheat) its internal voltage regulators.

    Lastly, if you are charging your phone, try not to use it at the same time as doing so might also put too much current through the phone’s voltage regulator causing it to fail prematurely. This is especially common on bigger phones. If you feel your phone getting hot, it’s a sign to stop. Depending on phone design, you may have to change the entire logic board.

  • What to do with old computers

    What to do with old computers

    The staffs in the office got new laptops last year (thanks to the government’s PIC grant) but the stockpile of old hardware became an eyesore. What should I do with them?

    I found out that one of my friend’s a volunteer worker and needed computers for needy families, so I decided to spend my NDP weekend sorting out them out. I thought it was going to be an easy job, but turned out it burned my entire weekend.

    Me and my wife started late Saturday afternoon and missed the National Day Parade. We worked till 12:30am and decided to continue again on Sunday (today), and it’s still not yet done. There’s still two more computers in the queue.

    donation1
    Piecing together parts from an old “beige box” 2U server and desktop to make a working computer.

    The problem was that the computers left sitting started to degrade — CD/DVD drives, hard drives, motherboards, graphic cards all started to fail. So the tip here is that if you have a computer you do not want any more, wipe it ASAP and donate. Some of these computers are over 10 years old (Pentium 3!), so it was amazing to see them still working.

    The inside of a 14 year old HP desktop (manufactured in 2000). Not a speck of rust.
    The inside of a 14 year old HP desktop (manufactured in 2000). Not a speck of rust.

    I was also impressed by how well the old HP desktops held up after 14 years. These thick, sturdy steel cases must have been galvanized because there’s not a single speck of rust on them. Machines (including servers) these days are no longer made to such high standards and feel flimsy.

    There were also old networking equipment up for grabs, but I could not see how a needy family would need a 24-port switch, so I found another friend who might have a use for it by sending it to schools in Cambodia.

    Old 3Com Superstack switches, hopefully to be donated to schools in Cambodia.
    Old 3Com Superstack switches, hopefully to be donated to schools in Cambodia.

    The last problem I need to solve would be to get working software into these machines. Some of the PCs had OEM Windows XP (luckily we kept all the original CDs).

    Update: The list of hardware to be donated have been distributed and they have been collected, albeit slowly. But it definitely feels good to know that it is going to somebody who needs it, rather than a karang-guni man who will probably just scrap it for parts.

  • Building another Joomla or WordPress site?

    Looking to build a website for your business? You have been warned.

    Somebody I know had her company’s site done by one of those companies selling Joomla or WordPress ‘packages’. When she saw the end result, she face-palmed. When I saw it, my reaction was pretty much the same. The site was riddled with horrid mix of serif and sans-serif font, bad alignment, varying font sizes, etc.

    For about $2,000-$3,000 dollars you can have these people build you a Joomla or WordPress site, but you really pay only about $800 for it because the government is helping you pay the other 60%, or about $1,200 via the Productivity and Innovation Credit (PIC).

    No, this is not a blog entry to advertise the PIC. There’s rampant abuse of the PIC scheme, and it has actually created a lot of crappy work (and IMHO, crappy jobs). Not to mention photocopiers selling for $15,000 with “cashback”.

    A lot of these web “design” companies are selling you nothing but pre-built templates reused over and over again. No surprise all their client’s websites look pretty much the same. With some changes to color and images, bingo! They’ve transformed the template into your website.

    But wait… it still looks like crap. Why?

    A lot of ‘designers’ are really just ‘developers’. Designers come from art school. Developers come from IT school. A lot of these designer-developers don’t even understand basic typography, let alone color theory, or help you with illustration or photography. And if they aren’t good in English, expect your site to be riddled with grammatical and spelling errors.

    When you engage a proper web design firm you actually are paying for a lot of things. A good company will actually advise you on the kind of content or site structure you should have, and also be able to provide additional services like copywriting, photography, illustration, etc. A proper design firm needs to hire both designers and developers, and they’ll also need somebody to manage these two very different groups of people and ensure they don’t kill each other.

    If you are really looking for a cheap solution you can actually buy beautiful templates off sites like Template Monster for a fraction of the money, then engage a freelancer to help you add content and deploy it to a hosting provider.

    You’ll want to choose a template with the similar color theme and typography as your corporate brand. You don’t want to mess with colors or fonts — that’s a job for designers.

    Nowadays the first impression people have of your company is through your website. Don’t underestimate the impact a website might have on your business. Messing a website up is as good as messing with the signboard and interior design of a retail shop.

    One final word of advise — make sure you get a company that can support you through upgrades and security patches of the CMS you use (WordPress, Joomla, Drupal, etc.) preferably one that provides hosting service as part of the package. Most people with Joomla sites built a few years back would have had their site ‘hacked’ by now due to security issues (I’ve dealt with a lot of these cases). If you must, choose WordPress. It’s better than Joomla in terms of security.

    It’s really 一分钱一分货.

  • Peer to peer car sharing in Singapore – is it really working?

    I’ve always wanted to make car sharing possible – there are two ways to go about it.

    First method: I would announce my travel plans and pick somebody going the same way as I am. In return I will get paid a token sum to ferry my passengers. I call this “Taxi style”.

    Second method: I rent my car out for profit. In short, it’s plain old private car rental. This is actually working in the US, see RelayRides.

    One problem with private car rental in Singapore is legislative restriction. At present, private car rental is only allowed on weekends or public holidays.

    The other problem is insurance coverage. Both methods of car sharing I described are classified as using the car for hire or reward. Hire/reward is explicitly prohibited on almost, if not all, private car insurance policies.

    Believe it or not, I called almost every insurance company in Singapore trying to see if rental coverage was possible. The answer was NO. Some did cover rental fleets, but the fleet size had to be considerable and it had to be a business.

    iCarsclub collaborated with DirectAsia to get the insurance problem resolved, so it is really very interesting.

    I decided to conduct an experiment.

    I signed up as a car owner. I did some research, and listed my car up at a very reasonable rate – $7 per hour, or $55 per day.

    My friend wanted to rent my car for the weekend, so he had it for 3 days on this long weekend (May 24 to May 26).

    The catch is this – fuel costs are borne by the car owner. iCarsclub in return charges the renter for mileage ($0.30/km). The renter also needs to pay for insurance coverage ($0.40/km).

    At the end of the rental, the bill came up to $326.83. The breakdown as follows:

    • Mileage traveled: 232 km
    • Booking fee: $2.00
    • Rental fee: $165.00 ($55/day x 3)
    • Mileage charges: $69.60
    • Insurance: $86.80
    • GST: $3.43

    iCarsclub takes a 20% commission from the rental fee.

    Insurance premiums are paid to DirectAsia.

    As a car owner I would only receive rental + mileage = $201.60.

    I also had to pay for the fuel, estimated to be about $60.

    On top of that, I have to pay for the SIM card in my car tracking device. That costs $39/mth.

    The result?

    • Car owner earns: $102.60 (31%)
    • Petrol company earns: $60.00 (18%)
    • Telco company earns: $39.00 (12%)
    • Insurance company earns: $86.80 (27%)
    • iCarsclub earns: $35.00 (11%)
    • Government earns: $3.43 (1%)

    It seems like businesses are the ultimate winners here. The owner actually receives less than a third of the amount.

    As a renter, there’s no price advantage. My car is already priced very low. My friend could have rented a similar car from a rental company for equal or less without worrying about the mileage based charges killing him.

    And because of the fixed mileage charges, it gives the renter no incentive to save fuel. He could go full throttle on the car all the time, or even abuse the fuel card.

    As a car owner, I am not sure if the amount risks I expose myself to would justify the $100+.

    Every car owner would have to sign a 2-year contract with iCarsclub, so my car would remain in their inventory for another 2 years. There is also a refundable deposit of $300 I had to pay. Breaking the contract would forfeit my deposit.

    Right now I think the pricing scheme needs to be tweaked. I am trying to get in touch with them to see how it can be improved. I am also hoping LTA’s announcement to liberalize private car rental on weekdays would come true.

    I am not discouraged yet and will continue to rent my car out to see how this whole scheme works out.

  • Oppa PHP Style

    It’s been some time ever since I’ve done much serious coding and decided to get myself updated… with Korean music.

    Just joking.

    I’ve been doing some research on PHP frameworks. My primary requirements were that the framework supported MVC (most do), is capable of friendly URLs, is simple/easy to use, provides basic wrappers around security (such as XSS and SQL Injection) and most importantly it must have good online support and resources.

    I pay particular attention to documentation as it plays an important part to help developers quickly learn/adopt a new framework.

    I spent many hours over the weekend reading documentation, installation guides and watching tutorials and eventually settled for CodeIgniter. I found it quite complete and particularly easy to learn. It is well documented, has a good tutorials and did not require that I learn a new template syntax. Above all it deploys really quickly with minimal configuration.

    I would like to bring your attention to the Style Guide in the CodeIgniter User Guide. It is very detailed and contains a lot of good coding practices, especially on how braces should be (opening on a new line instead of on the same line) and how PHP tags should be opened (and not necessarily closed). I suggest that PHP developers follow this style guide.

    There’s also an add-on to CodeIgniter that I would recommend and that is Grocery CRUD (Create, Retrieve, Update, Delete). Grocery CRUD makes it extremely easy to create a simple maintenance screen for back-end data, especially for short-term projects. It’s certainly better than sending users to phpMyAdmin.

    Finally, just to share, here’s my version of .htaccess file that I use to remove index.php from the URL. It is largely similar to the example by CodeIgniter with an additional exception for CSS and JavaScript files.

    RewriteEngine on
    RewriteCond $1 !^(index\.php|images|user_guide|robots\.txt|(.*)\.css|(.*)\.js)
    RewriteRule ^(.*)$ /projects/ci201210/index.php/$1 [L]

    That said, I have only done research and not actually used the framework on a full project yet. I’d love to hear any comments and/or recommendations you have.

  • Power Hungry

    Somebody once told me: Once you’ve driven a more powerful car, you won’t turn back. I guess thats really quite true.

    I’ve gone from my first car — a Nissan March (Micra in other countries) 1.0L to a new 1.5L Nissan and then to my current 2.0L BMW. I also used to drive my dad’s 2.4L Volvo when I first got my driving license. Power was never enough.

    The feeling of a vehicle with power on the tap is hard to describe. Many who have not driven a more powerful car may not understand and relate power with the need for speed. Of course I’m not talking about a Ferrari or a Bugatti but a normal road vehicle with sufficient power pulls you away safely in situations when you need it. In general, my personal figure is at least 100hp/tonne or more.

    I was in Melbourne a few years earlier where I rented a Holden SV6 3.6L V6 to drive up the Great Ocean Road. There were four of us and a boot full of luggages easily adding up to about 400 kilos but the car was still simply amazing to drive. It goes around the mountain roads effortlessly and merges with freeway traffic with ease.

    I specifically remember an exit from a farm road to the main freeway where I had to make a right turn (RHD in AU — which means I had to go across one direction of traffic before merging with the other). There was no way I could have waited for the right time to get on the freeway if I had been driving a 1.6L Toyota as there was simply too much traffic going at 100kph on the freeway. I waited for several minutes and found an opportunity where there was a gap in the traffic caused by a slow moving truck. I simply got on the gas and the car went right off and made the turn to merge with the traffic.

    I’ve had the opportunity to drive serveral new cars recently, namely the Audi A4 1.8T, VW Scirocco 1.4T, VW Polo 1.2T, Mini Cooper S 1.6T and the BMW 320i (F30) 2.0T. These are all amazing cars with turbocharged engines and they have loads of torque almost immediately off idle and are such a joy to drive even in our city traffic. In my opinion, there’s no reason not to consider these modern TC engines over the NA ones except for long-term reliability.

    Given the power improvements AND fuel economy, these turbo engines will be the future until a more efficient energy source after fossil fuel is found. At this point we have squeezed almost every bit of energy from gasoline and diesel. Hybrid or pure EV cars aren’t very practical yet IMHO. The need to wait a considerable amount of time to charge a battery makes it pointless. Some may argue: that’s nature and nature takes time to regenate (just like land for growing crops), but I am not at all convinced that electrical power generation is efficient given that most parts of the world still rely on some form of fossil fuel for electrical energy and the carbon footprint of setting up the entire electrical distribution infrastructure isn’t likely “CO2 friendly” either.

    Speaking of long-term reliability, modern NA engines are made of lightweight aluminium or magnesium alloys and they tend to give way under stress and heat. Weight plays a critical part in fuel economy since basic physics defines Force = Mass x Acceleration. There’s only so much force a gallon of fuel can provide and apart from reducing any frictional losses, the next step is to reduce the weight (mass) of a car. The engine is sometimes the heaviest thing in a car after the passengers (LOL) so auto manufactuers do put considable effort into reducing weight.

    The good news is that some of these modern TC engine blocks (especially VW/Audi) are still made from traditional cast iron and that might help them last longer. I am not entirely sure at this point but it seems that the BMW N20 2.0 TC engine found in 20i and 28i models of 2012 BMW vehicles (possibly also Mini Cooper S “Prince” engine) seem to be made of aluminium alloy. If that’s the case then that may be bad news given the history of the aluminium N46 engines developing gasket leaks past 60,000 kms.

    Nevertheless, most people don’t really keep their car past 5 years so auto manufacturers don’t emphasize on long term reliability like they used to in the good old 80s. Long term reliability is quite different from short term reliability. A simple example would be a transmission that could withstand loads of torque (short term) but rusts and leaks after some time (long term).

    Sometimes I wonder if all the talk about green technology gets defeated by consumerism.

    That said, one of my dream car is an old 1987+ BMW E30 320i. If I had time and money, I would almost certainly buy one and have it nicely done up. Unfortunately the car would be frowned upon by my government and I will be slapped with a 50% increase in annual road tax. Given the current COE prices, looks like I may never get to buy one unless maybe… I move out!