Battery Develop Utility under Windows

From LEXWiKi

(Difference between revisions)
Jump to: navigation, search
(The binary file you can download from)
Current revision (16:46, 11 February 2025) (edit) (undo)
(The binary file you can download from)
 
(11 intermediate revisions not shown.)
Line 21: Line 21:
Sample binary file(64 bit): [https://drive.google.com/file/d/1C8pfA5wB1D_T-v6lb7jLrxfPCvxVc4fn/view?usp=sharing GPIO_DLL_SAMPLE_Bin_v1.0.3.5_x64]
Sample binary file(64 bit): [https://drive.google.com/file/d/1C8pfA5wB1D_T-v6lb7jLrxfPCvxVc4fn/view?usp=sharing GPIO_DLL_SAMPLE_Bin_v1.0.3.5_x64]
-
 
+
-->
<FTP>
<FTP>
-
DLL file(64 bit): [ftp://ftp.lex.com.tw/Engineer/SoftSupport/AP_Module/GPIOUtilityDll/Windows/GPIOUtilityDll_v1.7.20.29.zip GPIOUtilityDll_v1.7.20.29]
+
DLL file(64 bit): [ftp://ftp.lex.com.tw/Engineer/SoftSupport/AP_Module/PW_Utility_DLL/PW_Utility_DLL_v2.5.22.51_x64.zip PW_Utility_DLL_v2.5.22.51_x64]
-
Sample source file(64 bit): [ftp://ftp.lex.com.tw/Engineer/SoftSupport/AP_Module/GPIOUtilityDll/Windows/GPIO_DLL_SAMPLE_Src_v1.0.3.5.zip GPIO_DLL_SAMPLE_Src_v1.0.3.5]
+
Sample source file(64 bit): [ftp://ftp.lex.com.tw/Engineer/SoftSupport/AP_Module/PW_Utility_DLL/PWUtilityDll_Sample_Src.zip PWUtilityDll_Sample_Src]
-
Sample binary code: [ftp://ftp.lex.com.tw/Engineer/SoftSupport/AP_Module/GPIOUtilityDll/Windows/GPIO_DLL_SAMPLE_Bin_v1.0.3.5.zip GPIO_DLL_SAMPLE_Bin_v1.0.3.5]
+
Sample binary code: [ftp://ftp.lex.com.tw/Engineer/SoftSupport/AP_Module/PW_Utility_DLL/PWUtilityDll_Sample_Bin_x64.zip PWUtilityDll_Sample_Bin_x64]
-
-->
+
 
 +
DLL User Guide: [ftp://ftp.lex.com.tw/Engineer/SoftSupport/AP_Module/PW_Utility_DLL/PWUtilityDll_Guide.zip PWUtilityDll_Guide]
== DLL files descreption ==
== DLL files descreption ==
Line 45: Line 46:
== How to use DLL ==
== How to use DLL ==
-
'''*Step1.''' Unzip DLL zip file and put files to your programe.<br />
+
'''*Step1.''' Unzip DLL zip file and put files to your program.<br />
Line 57: Line 58:
PW_MODULE_PW407,
PW_MODULE_PW407,
PW_MODULE_PW601,
PW_MODULE_PW601,
-
PW_MODULE_NUM,
+
PW_MODULE_NUM, //Used to record the number of modules
};
};
Line 71: Line 72:
PWUTILITYDLL_API int PW_InstallPwModule(int nModule);
PWUTILITYDLL_API int PW_InstallPwModule(int nModule);
 +
Example :
 +
if( PW_InstallPwModule(PW_MODULE_PW407) == TRUE )
 +
TRACE(_T("Initial module resource succeed. \n"));
 +
else
 +
TRACE(_T("Initial module resource failed! \n"));
-
'''*Step3.''' If you want control GPIO pin, setup DI pin and DO pin in CIO port.<br />
 
-
'''GPIO_CIO_PORT_E''' defined in '''GPIOUtilityDll.h'''<br />
+
'''*Step3.''' If power board module initialize succeed, you could call PW_CheckPWModuleExist() to check device is still exist or not.<br />
-
Setup DI pin and DO pin. Use 1 byte to indicate the status of the Pins.<br />
+
-
Digital output pin bit is 1; Digital input pin bit is 0.<br />
+
-
(DI-0 is bit0, DI-1 is bit1, DI-2 is bit2 and DI-3 is bit3).<br />
+
-
(DO-0 is bit4, DO-1 is bit5, DO-3 is bit6 and DO-3 is bit7).<br />
+
-
Ex: Setup CIO is 4I/4O. bDIOBits = 0xF0 (1111 0000) => (OOOO IIII).<br />
+
//------------------------------------------------------------------------------
-
Ex: Setup CIO is 2I/2O. bDIOBits = 0x30 (0011 0000) => (OOII IIII).<br />
+
// Name : PW_CheckPWModuleExist
-
 
+
// Description : Check specific PW module exist or not.
-
enum GPIO_CIO_PORT_E
+
-
{
+
-
GPIO_CIO_1 = 1,
+
-
GPIO_CIO_2,
+
-
GPIO_CIO_3,
+
-
GPIO_CIO_4,
+
-
};
+
-
 
+
-
//--------------------------------------------------------------------------
+
-
// Name : GPIODLL_AddControlModuleToWatchList
+
-
// Description : Add GPIO device module to watch dog list.
+
// Arguments :
// Arguments :
-
// nModule [in] : GPIO device module. Enum of MODULE_GPIO_LIST_E.
+
// nModule [in] : PW module. Enum of PW_MODULE_E.
-
// nSwPort [in] : Enum of GPIO_CIO_PORT_E
+
-
// bDIOBits [in] : DI/DO bits. (Output bit is 1; Input bit is 0)
+
-
// nFilterDO [in] : Filter DO signal from GPIO module (default: TRUE)
+
// Return :
// Return :
-
// TRUE : Success
+
// TRUE : PW module exist
-
// FALSE : Failed
+
// FALSE : PW module does not exist
-
//--------------------------------------------------------------------------
+
//------------------------------------------------------------------------------
-
GPIOUTILITYDLL_API int GPIODLL_AddControlModuleToWatchList(int nModule, int nSwPort, BYTE bDIOBits, int nFilterDO = TRUE);
+
PWUTILITYDLL_API int PW_CheckPWModuleExist(int nModule);
 +
Example :
 +
if( PW_CheckPwModuleExist(PW_MODULE_PW407) == TRUE )
 +
TRACE(_T("Specific PW module device exist. \n"));
 +
else
 +
TRACE(_T("Specific PW module device do not exist \n"));
-
'''*Step4.''' If you want Send DO signal once. Use 1 byte to indicate the digital output pins to be triggered.<br />
 
-
Digital output pin bit is 1; Digital input pin bit is 0.<br />
+
'''*Step4.''' If power board module initialize succeed, you could call PW_GetBatteryAllInfo() to get based battery information at the power board.<br />
-
(DO-0 is bit4, DO-1 is bit5, DO-3 is bit6 and DO-3 is bit7).<br />
+
-
Ex: Send CIO DO-0、DO-1、DO-2、DO-3 DO signal. bDOVal = 0xF0 (1111 0000) => (OOOO xxxx).<br />
+
'''BT_CHARGE_STATUS_E''' defined in '''PWUtilityDll.h'''<br />
-
Ex: Send CIO DO-0、DO-3 DO signal. bDOVal = 0x90 (1001 0000) => (OxxO xxxx).<br />
+
-
//--------------------------------------------------------------------------
+
enum BT_CHARGE_STATUS_E
-
// Name : GPIODLL_SendDOValueToControlModule
+
{
-
// Description : Send digital out value to GPIO device module
+
BT_CHARGE_STATUS_NONE = 0,
-
// Arguments :
+
BT_CHARGE_STATUS_CHARGE,
-
// nModule [in] : GPIO device module. Enum of MODULE_GPIO_LIST_E.
+
BT_CHARGE_STATUS_DISCHARGE,
-
// nSwPort [in] : Enum of GPIO_CIO_PORT_E
+
BT_CHARGE_STATUS_FULL_CHARGE,
-
// bDOVal [in] : Digital out value
+
};
-
// Return :
+
-
// TRUE : Success
+
-
// FALSE : Failed
+
-
//--------------------------------------------------------------------------
+
-
GPIOUTILITYDLL_API int GPIODLL_SendDOValueToControlModule(int nModule, int nSwPort, BYTE bDOVal);
+
 +
'''BATTERY_INFO_ST''' structure content please refer to '''PWUtilityDll DLL Function Guide'''<br />
-
'''*Step5.''' If you want receive DI signal once. Use 1 byte to indicate the digital input pins status.<br />
+
typedef struct _BATTERY_INFO_ST
 +
{
 +
int nBtExist; //Battery is connected or not
 +
TCHAR tcBatteryName[32]; //Power board module name
 +
int nPwModule; //Power board module, Enum of PW_MODULE_E
 +
int nChargeStatus; //Battery chare status, Enum of BT_CHARGE_STATUS_E
 +
LONGLONG llTimestampSec; //The system time point at which the information is obtained, (seconds since Jan 1, 1970).
 +
float fTemperature; //Battery temperature, (Unit: Kelvin)
 +
float fCurrent; //Battery current (Unit: mA)
 +
float fVoltage; //Battery voltage (Unit: mV)
 +
float fOutputVoltage; //Battery output voltage (Unit: mV) (PW601 Only)
 +
int nChargePercent; //Left capacity of battery (Unit: %)
 +
long lBtLeftMins; //Alive time of battery (Unit: Minute). If battery is charging, left time value is '0xFFFF'.
 +
long lWarnBits;
 +
int nCycleCount; //Battery cycle count
 +
int nIsShutdown;
 +
long lBatteryStatus;
 +
long lSafetyStatus;
 +
long lSafetyAlert;
 +
long lGaugingStatus;
 +
long lOperationStatus;
 +
long lPFStatus;
 +
long lPFAlert;
 +
} BATTERY_INFO_ST;
-
If digital input pin trigger, bit is 1; Else bit is 0. Digital output pin bit is always 1.<br />
+
//------------------------------------------------------------------------------
-
(DI-0 is bit0, DI-1 is bit1, DI-2 is bit2 and DI-3 is bit3).
+
// Name : PW_GetBatteryAllInfo
-
 
+
// Description : Get All of battery information
-
Ex: Receive bDIVal = 0xFF. If DI/DO is 0xF0 (OOOO IIII), then DI-0、DI-1、DI-2、DI-3 are triggered.<br />
+
-
Ex: Receive bDIVal = 0xF9. If DI/DO is 0xF0 (OOOO IIII), then DI-0、DI-3 are triggered.<br />
+
-
 
+
-
//--------------------------------------------------------------------------
+
-
// Name : GPIODLL_GetDIValueFromControlModule
+
-
// Description : Get digital in value from GPIO device module
+
// Arguments :
// Arguments :
-
// nModule [in] : GPIO device module. Enum of MODULE_GPIO_LIST_E.
+
// nModule [in] : PW module
-
// nSwPort [in] : Enum of GPIO_CIO_PORT_E
+
// pValStruct [out] : Battery information structure. (BATTERY_INFO_ST)
-
// bDIVal [out] : Digital in value
+
// Return :
// Return :
// TRUE : Success
// TRUE : Success
// FALSE : Failed
// FALSE : Failed
-
//--------------------------------------------------------------------------
+
//------------------------------------------------------------------------------
-
GPIOUTILITYDLL_API int GPIODLL_GetDIValueFromControlModule(int nModule, int nSwPort, BYTE &bDIVal);
+
PWUTILITYDLL_API int PW_GetBatteryAllInfo(int nModule, void* pValStruct);
-
'''*Step6.''' If you want enable WDT coutdown function and trigger shutdone after few seconds later.<br />
+
'''*Step5.''' If you want to get individual information about the battery, call the corresponding function.<br />
-
You could update the trigger time by calling GPIODLL_StartWatchDogTimer() repeatedly.\n");
+
All function content and sample please refer to '''PWUtilityDll DLL Function Guide'''<br />
-
//--------------------------------------------------------------------------
+
Example :
-
// Name : GPIODLL_StartWatchDogTimer
+
//------------------------------------------------------------------------------
-
// Description : Start running watch dog timer in device module.
+
// Name : PW_GetBatteryCurrentInfo
 +
// Description : Get current of battery information
// Arguments :
// Arguments :
-
// nModule [in] : GPIO device module. Enum of MODULE_GPIO_LIST_E.
+
// nModule [in] : PW module
-
// nUnit [in] : Time unit (0: 1sec, 1: 60 sec)
+
// fCurrent [out] : Battery current
-
// nCount [in] : Watch dog timer range.(0~255)
+
// Return :
// Return :
// TRUE : Success
// TRUE : Success
// FALSE : Failed
// FALSE : Failed
-
//--------------------------------------------------------------------------
+
//------------------------------------------------------------------------------
-
GPIOUTILITYDLL_API int GPIODLL_StartWatchDogTimer(int nModule, int nUnit, int nCount);
+
PWUTILITYDLL_API int PW_GetBatteryCurrentInfo(int nModule, float &fCurrent);
-
 
+
//------------------------------------------------------------------------------
-
'''*Step7.''' If you want to know WDT countdown remaining seconds.<br />
+
// Name : PW_GetBatteryVoltageInfo
-
 
+
// Description : Get voltage of battery information
-
//--------------------------------------------------------------------------
+
-
// Name : GPIODLL_GetWatchDogCountdownSeconds
+
-
// Description : Get watch dog timer countdown time in device module.
+
// Arguments :
// Arguments :
-
// nModule [in] : GPIO device module. Enum of MODULE_GPIO_LIST_E.
+
// nModule [in] : PW module
-
// nTimerSec [out] : Countdown time seconds.(0~255)
+
// fVoltage [out] : Battery voltage (Unit: mV)
// Return :
// Return :
// TRUE : Success
// TRUE : Success
// FALSE : Failed
// FALSE : Failed
-
//--------------------------------------------------------------------------
+
//------------------------------------------------------------------------------
-
GPIOUTILITYDLL_API int GPIODLL_GetWatchDogCountdownSeconds(int nModule, int& nTimerSec);
+
PWUTILITYDLL_API int PW_GetBatteryVoltageInfo(int nModule, float &fVoltage);
-
'''*Step8.''' If you want disable WDT coutdown function.<br />
+
'''*Final Step.''' Release power board resource before leaving your program.
-
 
+
-
//--------------------------------------------------------------------------
+
-
// Name : GPIODLL_StopWatchDogTimer
+
-
// Description : Stop watch dog timer in device module.
+
-
// Arguments :
+
-
// nModule [in] : GPIO device module. Enum of MODULE_GPIO_LIST_E.
+
-
// Return :
+
-
// TRUE : Success
+
-
// FALSE : Failed
+
-
//--------------------------------------------------------------------------
+
-
GPIOUTILITYDLL_API int GPIODLL_StopWatchDogTimer(int nModule);
+
-
 
+
-
 
+
-
'''*Final Step.''' Release GPIO resource before leaving your program.
+
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
-
// Name : GPIODLL_FreeControlModule
+
// Name : PW_FreePwModule
-
// Description : Free DLL supported GPIO device module.
+
// Description : Release PW module resource
// Arguments :
// Arguments :
-
// nModule [in] : GPIO device module. Enum of MODULE_GPIO_LIST_E.
+
// nModule [in] : PW module. Enum of PW_MODULE_E.
// Return :
// Return :
// TRUE : Success
// TRUE : Success
// FALSE : Failed
// FALSE : Failed
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
-
GPIOUTILITYDLL_API int GPIODLL_FreeControlModule(int nModule);
+
PWUTILITYDLL_API int PW_FreePwModule(int nModule);
 +
 
 +
Example :
 +
if( PW_FreePwModule(PW_MODULE_PW407) == TRUE )
 +
TRACE(_T("Release module resource succeed. \n"));
 +
else
 +
TRACE(_T("Release module resource failed! \n"));

Current revision


Contents

[hide]

Introduction

Power Board Develop Utility can help you to develop tool to control LEX power board device.


Support power board module

PW405、PW407、PW601.


The binary file you can download from

<FTP>

DLL file(64 bit): PW_Utility_DLL_v2.5.22.51_x64

Sample source file(64 bit): PWUtilityDll_Sample_Src

Sample binary code: PWUtilityDll_Sample_Bin_x64

DLL User Guide: PWUtilityDll_Guide

DLL files descreption

PWUtilityDll.dll: Contains code and data about PWUtilityDll function.

PWUtilityDll.h: Header about PWUtilityDll function.

PWUtilityDll.lib: Import library that link to PWUtilityDll.dll.

LexIo64.dll、LexIo64.sys: Based on WinIO that provids DLL to read hardware data. For x64.


How to use DLL

*Step1. Unzip DLL zip file and put files to your program.


*Step2. Initialize power board module resource.

PW_MODULE_E defined in PWUtilityDll.h

 enum PW_MODULE_E
 {
     PW_MODULE_PW405 = 0,
     PW_MODULE_PW407,
     PW_MODULE_PW601,
     PW_MODULE_NUM,  //Used to record the number of modules
 };
 //------------------------------------------------------------------------------
 // Name        : PW_InstallPwModule
 // Description : Initial PW module resource
 // Arguments   : 
 //   nModule     [in]  : PW module. Enum of PW_MODULE_E.
 // Return      : 
 //   TRUE  : Success
 //   FALSE : Failed
 //------------------------------------------------------------------------------ 
 PWUTILITYDLL_API int PW_InstallPwModule(int nModule);

Example :

 if( PW_InstallPwModule(PW_MODULE_PW407) == TRUE )
   TRACE(_T("Initial module resource succeed. \n"));
 else
   TRACE(_T("Initial module resource failed! \n"));


*Step3. If power board module initialize succeed, you could call PW_CheckPWModuleExist() to check device is still exist or not.

 //------------------------------------------------------------------------------
 // Name        : PW_CheckPWModuleExist
 // Description : Check specific PW module exist or not.
 // Arguments   : 
 //   nModule [in] : PW module. Enum of PW_MODULE_E.
 // Return      : 
 //   TRUE  : PW module exist
 //   FALSE : PW module does not exist
 //------------------------------------------------------------------------------ 
 PWUTILITYDLL_API int PW_CheckPWModuleExist(int nModule);

Example :

 if( PW_CheckPwModuleExist(PW_MODULE_PW407) == TRUE )
     TRACE(_T("Specific PW module device exist. \n"));
 else
     TRACE(_T("Specific PW module device do not exist \n"));


*Step4. If power board module initialize succeed, you could call PW_GetBatteryAllInfo() to get based battery information at the power board.

BT_CHARGE_STATUS_E defined in PWUtilityDll.h

 enum BT_CHARGE_STATUS_E
 {
     BT_CHARGE_STATUS_NONE = 0,
     BT_CHARGE_STATUS_CHARGE,
     BT_CHARGE_STATUS_DISCHARGE,
     BT_CHARGE_STATUS_FULL_CHARGE,
 };

BATTERY_INFO_ST structure content please refer to PWUtilityDll DLL Function Guide

 typedef struct _BATTERY_INFO_ST
 {
     int nBtExist;             //Battery is connected or not
     TCHAR tcBatteryName[32];  //Power board module name
     int nPwModule;            //Power board module, Enum of PW_MODULE_E
     int nChargeStatus;        //Battery chare status, Enum of BT_CHARGE_STATUS_E
     LONGLONG llTimestampSec;  //The system time point at which the information is obtained, (seconds since Jan 1, 1970). 
     float fTemperature;       //Battery temperature, (Unit: Kelvin)
     float fCurrent;           //Battery current (Unit: mA)
     float fVoltage;           //Battery voltage (Unit: mV)
     float fOutputVoltage;     //Battery output voltage (Unit: mV) (PW601 Only)
     int nChargePercent;       //Left capacity of battery (Unit: %)
     long lBtLeftMins;         //Alive time of battery (Unit: Minute). If battery is charging, left time value is '0xFFFF'.
     long lWarnBits;
     int nCycleCount;          //Battery cycle count
     int nIsShutdown;
     long lBatteryStatus;
     long lSafetyStatus;
     long lSafetyAlert;
     long lGaugingStatus;
     long lOperationStatus;
     long lPFStatus;
     long lPFAlert;
 } BATTERY_INFO_ST;
 //------------------------------------------------------------------------------
 // Name        : PW_GetBatteryAllInfo
 // Description : Get All of battery information
 // Arguments   : 
 //   nModule     [in]  : PW module
 //   pValStruct  [out] : Battery information structure. (BATTERY_INFO_ST)
 // Return      : 
 //   TRUE  : Success
 //   FALSE : Failed
 //------------------------------------------------------------------------------ 
 PWUTILITYDLL_API int PW_GetBatteryAllInfo(int nModule, void* pValStruct);


*Step5. If you want to get individual information about the battery, call the corresponding function.

All function content and sample please refer to PWUtilityDll DLL Function Guide

Example :

 //------------------------------------------------------------------------------
 // Name        : PW_GetBatteryCurrentInfo
 // Description : Get current of battery information
 // Arguments   : 
 //   nModule  [in]  : PW module
 //   fCurrent [out] : Battery current
 // Return      : 
 //   TRUE  : Success
 //   FALSE : Failed
 //------------------------------------------------------------------------------ 
 PWUTILITYDLL_API int PW_GetBatteryCurrentInfo(int nModule, float &fCurrent);
 //------------------------------------------------------------------------------
 // Name        : PW_GetBatteryVoltageInfo
 // Description : Get voltage of battery information
 // Arguments   : 
 //   nModule     [in]  : PW module
 //   fVoltage    [out] : Battery voltage (Unit: mV)
 // Return      : 
 //   TRUE  : Success
 //   FALSE : Failed
 //------------------------------------------------------------------------------ 
 PWUTILITYDLL_API int PW_GetBatteryVoltageInfo(int nModule, float &fVoltage);


*Final Step. Release power board resource before leaving your program.

 //------------------------------------------------------------------------------
 // Name        : PW_FreePwModule
 // Description : Release PW module resource
 // Arguments   : 
 //   nModule     [in]  : PW module. Enum of PW_MODULE_E.
 // Return      : 
 //   TRUE  : Success
 //   FALSE : Failed
 //------------------------------------------------------------------------------ 
 PWUTILITYDLL_API int PW_FreePwModule(int nModule);

Example :

 if( PW_FreePwModule(PW_MODULE_PW407) == TRUE )
   TRACE(_T("Release module resource succeed. \n"));
 else
   TRACE(_T("Release module resource failed! \n"));
Personal tools