Thursday, December 17, 2009

USB port AA NiMH and NiCd Battery Charger by IC 393

USB port  AA NiMH and NiCd Battery Charger by  IC 393

I Find circuit Chartger battery AA NiMH for USB port.
I see to Good WEB : http://www.stefanv.com/electronics/

Detail :
In a recent blog entry, I complained about all the chargers and wall warts I need to carry with me when going on a trip. This project, which can charge a pair of AA Nickel Metal Hydride (NiMH) or Nickel Cadmium (NiCd) cells using a laptop’s USB port for power, arose to address part of that problem. (By the way, if you want to lighten your laptop load, take a look at the MoGo Mouse.)




Any USB port can supply 5V at up to 500mA. The USB standard specifies that a device may not use more than 100mA until it has negotiated the right to use 500mA, but apparently no USB ports enforce that requirement. This makes the USB port a convenient source of power for devices such as this charger.

There are commercially available USB AA charging solutions available, but they each have some drawbacks:

*

The USBCell is a 1300mAh AA NiMH Cell with a removable top that allows it to be plugged directly into a USB port. No separate charger is needed. Unfortunately, the cell capacity is very low (most NiMH AA cells are 2500mAh these days), and each cell requires its own port.
*

There is a two cell USB powered AA charger available, sold under a variety of names, but it charges at a very low 100mA rate. The distributor calls it an “overnight charger”, but at 100mA, a 2500mA cell would take about 40 hours to charge (40 instead of 25 due to the inefficiencies of charging at low currents).
*

I found a 2/4 cell charger that can be powered by a USB port, auto adapter, or wall wart, but it is as large as the wall charger I’m trying to replace. Different ones can be found here and here, but these take 10 to 12 hours to charge 2500mAh cells.

The charger in this project is designed to charge two AA NiMH or NiCd cells of any capacity (as long as they are the same) at about 470mA. It will charge 700mAh NiCds in about 1.5 hours, 1500mAh NiMHs in about 3.5 hours, and 2500mAh NiMHs in about 5.5 hours. The charger incorporates an automatic charge cut-off circuit based on cell temperature, and the cells can be left in the charger indefinitely after cut-off.

Monday, December 14, 2009

Remove X menu C#

private const int SC_CLOSE = 0xF060;

private const int MF_GRAYED = 0x1;



[DllImport("user32.dll")]

private static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);



[DllImport("user32.dll")]

private static extern int EnableMenuItem(IntPtr hMenu, int wIDEnableItem, int wEnable);



EnableMenuItem(GetSystemMenu(this.Handle, false), SC_CLOSE, MF_GRAYED);

Disable Close X button in Winforms using C#

Demo code on how to disable the X button in menu bar in a window. I found a lot of posts on this in VB, but none for C#. So if you are a C# fan like me, this is for you...

1. There is no direct way to disbale the X button, like there is a property for Maximize button called MaximizeBox = false.

2. This is implemented by importing unmanaged dll "user32" and calling it's functions.

3. Before you use this code, make sure to add a Close button in your form so that you can close your app. See the attached screen shot Disabled.jpg. Below is the code for this form.

Add the following library

using System.Runtime.InteropServices;

Declare the following as class level variable

const int MF_BYPOSITION = 0x400;

[DllImport("User32")]

private static extern int RemoveMenu(IntPtr hMenu, int nPosition, int wFlags);

[DllImport("User32")]

private static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);

[DllImport("User32")]

private static extern int GetMenuItemCount(IntPtr hWnd);

In the Form_Load() event, write the following code:

private void Form1_Load(object sender, EventArgs e)

{

IntPtr hMenu = GetSystemMenu(this.Handle, false);

int menuItemCount = GetMenuItemCount(hMenu);

RemoveMenu(hMenu, menuItemCount - 1, MF_BYPOSITION);

}

4. Run it. Voila! you are done. If you know of a ay to do it without calling unmanaged code, please do let me know.