15.05.2013 Views

Mobile Device Power Monitor Manual - Monsoon Solutions

Mobile Device Power Monitor Manual - Monsoon Solutions

Mobile Device Power Monitor Manual - Monsoon Solutions

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong> <strong>Manual</strong><br />

Distributed By:<br />

<strong>Monsoon</strong> <strong>Solutions</strong>, Inc.<br />

2405 140 th Avenue NE<br />

Suite A115<br />

Bellevue, Washington 98005<br />

(425) 378-8081<br />

www.msoon.com


1<br />

Table of Contents<br />

<strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong> <strong>Manual</strong> ...................................................................... 0<br />

Revision History .............................................................................................. 2<br />

Introduction ................................................................................................... 3<br />

Hardware and Software Requirements for the Development Workstation ................ 5<br />

Installing the Software and Connecting the Hardware .......................................... 6<br />

Obtaining the Software for the <strong>Power</strong> Tool ..................................................... 6<br />

Connecting the <strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong> Hardware ................................... 7<br />

Connecting the <strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong> to a <strong>Device</strong> ...................................... 9<br />

Using the <strong>Power</strong> Tool Software ........................................................................ 10<br />

Checking the Software Revision of the <strong>Power</strong> <strong>Monitor</strong> ........................................ 11<br />

<strong>Power</strong>ing-up and <strong>Power</strong>ing-down a <strong>Mobile</strong> <strong>Device</strong> ......................................... 12<br />

Over-Current Error from the Main <strong>Power</strong> Supply ........................................... 13<br />

Protecting the Main <strong>Power</strong> Supply from an Over-Current Error .................. 14<br />

The Legend Dialog Box .................................................................................. 15<br />

Sampling Data ......................................................................................... 16<br />

Markers .................................................................................................. 16<br />

Statistics ................................................................................................. 17<br />

Zoom ................................................................................................. 18<br />

USB Pass-Through .................................................................................... 19<br />

USB Pass-Through: Modes.................................................................... 19<br />

Measuring USB <strong>Power</strong> .......................................................................... 21<br />

Using USB Markers .............................................................................. 21<br />

Auxiliary Port (Aux) .................................................................................. 22<br />

Data Importing Features of the <strong>Power</strong> <strong>Monitor</strong> ............................................. 23<br />

Data Exporting Features of the <strong>Power</strong> <strong>Monitor</strong>.............................................. 24<br />

Functional Description of the <strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong> ................................. 25<br />

APPENDIX: ........................................................................................................ 26<br />

Electrical Specifications of the <strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong> ................................ 26<br />

Main Channel ........................................................................................... 26<br />

USB Channel ........................................................................................... 27<br />

Auxiliary Channel ..................................................................................... 28<br />

<strong>Power</strong> <strong>Monitor</strong> Data and Control Protocol .......................................................... 29<br />

Command Line Operation of the <strong>Power</strong> <strong>Monitor</strong> ................................................. 29<br />

<strong>Power</strong> <strong>Monitor</strong> Exit Codes ............................................................................... 33<br />

PT4 file format .............................................................................................. 33


2<br />

Document Revision History<br />

Date Released Revision Number Notes<br />

May 2007 1.0 Initial release<br />

November 1, 2007 1.1 Updated features and added PT4 formats<br />

January 16, 2008 1.2 Updated path for <strong>Power</strong> <strong>Monitor</strong> Install<br />

directory<br />

July 15, 2008 1.3 Updated and added features<br />

November 9, 2009 1.4 Corrected web site links


3<br />

Introduction<br />

The <strong>Power</strong> Tool software and the <strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong> hardware provide a robust<br />

power measurement solution for Windows <strong>Mobile</strong> powered devices. The <strong>Power</strong> Tool software<br />

and the <strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong> hardware can analyze the power on any device that<br />

uses a single lithium (Li) battery. Electrical engineers and software developers can utilize<br />

the <strong>Power</strong> Tool software and the <strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong> hardware to optimize the<br />

design and analyze the performance of their Windows <strong>Mobile</strong> powered devices.<br />

Figure 1: Graphical user interface (GUI) for the <strong>Power</strong> Tool


4<br />

Figure 2: <strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong> hardware


5<br />

Hardware and Software Requirements for the<br />

Development Workstation<br />

A dedicated workstation is required to be used with the <strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong> to<br />

achieve the optimal performance and results.<br />

• Microsoft Windows XP SP2, Windows Vista and Windows 7 is supported<br />

• 1 GHz 32-bit (x86) or 64-bit (x64) processor<br />

• 1 GB of system memory<br />

• 40 GB hard drive with at least 15 GB of available space<br />

• Full Speed USB 1.1/USB 2.0 – integrated chipset or PCI/PCI Express add in card. USB<br />

Hubs should not be used with the <strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong>


Installing the <strong>Power</strong> <strong>Monitor</strong> Software and Connecting the<br />

Hardware<br />

Obtaining the Software for the <strong>Power</strong> Tool<br />

6<br />

To obtain the latest software version for the <strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong><br />

hardware<br />

1. Go to http://www.msoon.com/register/download/ , then click on the <strong>Power</strong><strong>Monitor</strong><br />

Software link and download <strong>Power</strong>Tool_4.x.x.zip. Uninstall any previous version of<br />

the <strong>Power</strong> <strong>Monitor</strong> Software.<br />

2. Create a new folder on the development workstation called <strong>Power</strong>Tool under the root<br />

directory (C:\).<br />

3. Copy <strong>Power</strong>Tool.zip to the development workstation.<br />

4. Extract the contents of <strong>Power</strong>Tool.zip to the C:\<strong>Power</strong>Tool folder.<br />

5. Run PMSetup.msi<br />

6. Follow the on screen prompts to Install the <strong>Power</strong> Tool Software


7<br />

Figure 3: Installation.<br />

Connecting the <strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong> Hardware<br />

To connect the <strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong> hardware<br />

1. Be sure that the power switch on the front of the <strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong> hardware<br />

is not engaged. The hardware should not be powered-up.<br />

The power switch should be in the outward position, not the inward position.<br />

2. Connect the 6 volts (V) of direct current (DC) and 5 ampere (A) power supply to the<br />

<strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong> hardware.<br />

3. Connect the 6 VDC and 5 A power supply to an alternating current (AC) power supply.<br />

4. On a development workstation that is compliant with Full-Speed USB 2.0, connect a USB<br />

cable to the USB connector on the back of the <strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong> hardware,<br />

and connect the other end of the USB cable to the development workstation.<br />

Figure 4: Back view: <strong>Power</strong> connector and USB connector<br />

5. Turn on the <strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong> hardware by engaging the power button on the<br />

front. The internal fan will briefly power-up and then power-down.<br />

Initially, the power light-emitting diode (LED) is orange, and then it turns green. The<br />

green LED is connected directly to the internal power of the <strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong><br />

<strong>Monitor</strong>.


8<br />

Figure 5: Front view: Engaged power button and powered-up green LED.<br />

Installing the <strong>Power</strong> <strong>Monitor</strong> driver on a workstation<br />

1. After running the setup program power up the <strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong> and if the<br />

<strong>Power</strong> <strong>Monitor</strong> is being installed for the first time on the workstation, the “Found New<br />

Hardware” Wizard will launch.<br />

2. On the Found New Hardware Wizard, do not choose to have the device drivers installed<br />

automatically, choose “No, not this time” and then select “Next”.<br />

3. On the next prompt of the Found New Hardware Wizard, choose “Install from a list or<br />

specific location (Advanced)”, and then select Next.<br />

4. On the next prompt of the Found New Hardware Wizard, choose “Don’t search. I will<br />

choose the driver to install” and then select “Next”.<br />

5. On the Hardware Type page, choose “Show All <strong>Device</strong>s”, and then select “Next”<br />

6. On the next prompt, choose “Have Disk”.<br />

7. From the Install from Disk window, choose the “Browse” button, and navigate to the<br />

folder where the extracted contents of <strong>Power</strong>Tool.zip were saved.<br />

8. Select the corresponding Operating System folder in C:\Program Files\<strong>Monsoon</strong><br />

<strong>Solutions</strong>, INC\, select the Mchpcdc.inf file, and select “Open”.<br />

9. Choose “OK”<br />

10. From the Found New Hardware Wizard, choose “Next”<br />

11. If a warning is received about an unsigned driver, select “Continue Anyway”<br />

12. In the Found New Hardware Wizard, select “Finish”.<br />

After installing the driver choose Finish. The <strong>Power</strong> Tool software is installed.


9<br />

Connecting the <strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong> to a <strong>Device</strong><br />

It can take 30 minutes or longer to configure a good test connection. A device that can<br />

measure voltage and resistance, such as a voltmeter/ohmmeter will be needed.<br />

Note Wear safety goggles at all times while working with exposed battery terminals<br />

and wiring.<br />

**************************************************************<br />

Connecting the <strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong> to a device to collect current<br />

measurements can be complicated and dangerous. Be sure that the area where<br />

power measurements are being conducted is protected from fire danger, do not<br />

have flammable items nearby. These measurements are at your own risk, and<br />

these procedures are not guaranteed to prevent damage or injury<br />

**************************************************************<br />

Note There is no way to guarantee a proper connection. When attaching the power<br />

measurement hardware to a device with a lithium battery, there is always a risk of<br />

damaging the device, or causing the device to heat-up, generate smoke, or catch fire.<br />

While this is unlikely, be extremely careful, and if anything gets hot, immediately<br />

remove the battery and the power source.<br />

The following guide details and outlines how to prepare the device to connect to the <strong>Mobile</strong><br />

<strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong>.<br />

http://www.msoon.com/LabEquipment/<strong>Power</strong><strong>Monitor</strong>/downloads/quickstartguide.pdf


10<br />

Using the <strong>Power</strong> Tool Software<br />

After connecting the device, power up the <strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong> and run the <strong>Power</strong><br />

Tool software (<strong>Power</strong>Tool.exe). The software should connect to the <strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong><br />

<strong>Monitor</strong>, and display the user interface (UI).<br />

Figure 6: <strong>Power</strong> Tool software UI after connecting to a device


11<br />

Checking the Software Revision of the <strong>Power</strong> <strong>Monitor</strong><br />

The revisions of the hardware (HW ver), firmware (FW ver), and software (SW ver) should<br />

be compatible for consistent and repeatable results and performance.<br />

If the <strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong> software is updated, the firmware will need to be<br />

confirmed for compatibility. The <strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong> will prompt the user to<br />

indicate that a new firmware is required to run this revision of software. If this occurs, then<br />

the firmware (FW ver) will need to be updated on the <strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong>. Please<br />

follow the instructions on updating the <strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong> at the following<br />

location: http://www.msoon.com/register/download<br />

The following table describes the various revision numbers that are displayed in the UI.<br />

Field Description<br />

HW rev <strong>Power</strong> <strong>Monitor</strong> hardware revision<br />

FW ver <strong>Power</strong> <strong>Monitor</strong> firmware version<br />

Prot ver Version of protocol specification<br />

SW ver <strong>Power</strong> Tool UI version<br />

HW rev SW ver Firmware Version<br />

B, C, D 3.0.4 12<br />

B, C, D 4.0.2, 4.0.1 17, 18<br />

B, C, D 4.0.3 19<br />

To make sure the correct software is installed, check the revision fields in the UI. Figure 7<br />

below shows the area of the UI that displays the software revision.<br />

Figure 7: Revision fields shown in the <strong>Power</strong> Tool UI.


12<br />

<strong>Power</strong>ing-up and <strong>Power</strong>ing-down a <strong>Mobile</strong> <strong>Device</strong><br />

To power-up the device, first set the Vout voltage. The voltage can be set from 2.1 V to 4.5<br />

V in .01 V increments. The maximum voltage of a lithium battery is usually 4.2 V, so set the<br />

Vout voltage somewhere between 3.3 V and 4.2 V.<br />

To enable the power, click the Vout Enable button, to disable the power, click the Vout<br />

Disable button.<br />

Figure 9: below shows the location of the Vout Enable, which toggles when it is clicked to<br />

the Vout Disable button.<br />

Figure 8: Vout Enable and Vout Disable button.<br />

The voltage at the red and black terminals is never exactly at the programmed voltage. This<br />

is because there is an internal 0.056 Ω sense resistor in series with the regulator. For<br />

example, if the device is drawing 1 A when Vout equals 3 V, expect to see (3 - 1*.056) =<br />

2.944 V. Figure 10: below shows this sense resistor in series with the regulator, in relation<br />

to the red and black terminals.<br />

Figure 9: Sense resistor in series with the regulator, in relation to the red and<br />

black terminals.<br />

There is resistance in the wiring that can lower the voltage at the device. The resistance of<br />

the wiring plus the sense resistor is similar to the resistance of the lithium battery in the<br />

device; batteries are usually about 0.12 Ω.


13<br />

The resistance of 20 gauge wire is 0.012 Ω/ft, so if the cables are 20 gauge, and 1 foot in<br />

length, that adds another 0.024 Ω, in addition to the contact resistance.<br />

Figure 10: Vout LED indicator<br />

If the power-up is successful, the green Vout LED indicator in Figure 10 above will powerup.<br />

This LED is connected directly to Vout, so the light will dim slightly if the voltage is<br />

lowered. If this LED does not power-up, then Vout did not power-up properly, so there are<br />

other problems.<br />

Over-Current Error from the Main <strong>Power</strong> Supply<br />

Sometimes an over-current error occurs when powering-up. When an over-current error<br />

occurs, the amber LED powers-up, and the green LED for Vout powers-down.<br />

An over-current error can happen when the:<br />

• <strong>Device</strong> is attached backwards.<br />

• <strong>Device</strong> is attached incorrectly.<br />

• <strong>Device</strong> has a lot of capacitance, a very high in-rush current.<br />

• <strong>Device</strong> has an unusually high run current.


14<br />

Figure 11: Amber LED indicator for over-current.<br />

Note Be sure to check for a backwards connection before overriding the over-current<br />

limits.<br />

Protecting the Main <strong>Power</strong> Supply from an Over-Current Error<br />

The main power regulator can source 3.0 A of continuous current and 4.5 A of peak current.<br />

In order to protect incorrectly connected devices from damage, a carefully controlled power<br />

up sequence is used. The default sequence is as follows:<br />

1. <strong>Power</strong> up with no current limit for 20 milliseconds<br />

2. Run for 1 second with the current limit set to 500 mA<br />

3. Run continuously with the current limit set to 4.6 A<br />

The parameters in the dialog box below are used for device under test power on.<br />

1. <strong>Power</strong> up time – This specifies the power up time when no current limit is applied to the<br />

<strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong>.<br />

2. <strong>Power</strong> up Current Limit – If the <strong>Power</strong> Up Time is set to default, this parameter will allow<br />

the selected current to be supplied to the device for 1 second.<br />

3. Run time Current Limit- This parameter specifies what the maximum current that can be<br />

sourced by the <strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong> while its sampling or in “Run” mode.<br />

If a device does not power up with this default profile, the profile may be adjusted. Click on<br />

Parameters in the UI and the dialog box shown below in Figure 12:


15<br />

The Legend Dialog Box<br />

Figure 12: Dialog box for over-current.<br />

The Legend dialog box controls which channels are displayed, and what kind of data is<br />

shown in the graph.<br />

Figure 13: Dialog box for the display Legend.


Sampling Data<br />

16<br />

To begin sampling data, click the Run button. To stop sampling, press the Stop button.<br />

Figure 14 below shows the Run button, which toggles to the Stop button once it is clicked.<br />

Figure 14: Run and Stop toggle button.<br />

The calibration indicator indicates that the unit has a valid and unexpired calibration date<br />

and functioning auto-calibration hardware. Figure 15 below shows the calibration indicator.<br />

Figure 15: Calibration indicator.<br />

The serial number displayed in the UI, and shown in Figure 16 below, is the serial number of<br />

the <strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong> hardware. It is programmed to a unique number in the<br />

factory. If the firmware is upgraded improperly in the field, the factory serial number may<br />

be incorrect. If this happens, it is advisable to contact <strong>Monsoon</strong> <strong>Solutions</strong>, Inc., because the<br />

factory calibration settings may have also been lost.<br />

Markers<br />

Figure 16: Serial number.<br />

Markers enable users to measure the delta (Time and selected data channel) between two<br />

points on the power monitor output data plot.<br />

1. Drag the red and blue arrows (indicator) to the desired position on the power monitor<br />

output data plot<br />

2.The Delta will be displayed under the Selection Statistics section.


Statistics<br />

17<br />

Figure 17: Capture statistics.<br />

Battery life, current, and power statistics for the Main channel are visible in the STATS area<br />

of the UI. The user first sets the battery capacity and then runs the <strong>Power</strong> <strong>Monitor</strong>. If there<br />

is no region selected, the statistics will be associated with the entire run as in Figure 18<br />

below.<br />

Figure 18: Capture statistics.<br />

If a smaller area is selected with the mouse on the graph, then the statistics are computed<br />

only for the selected area, as shown in Figure 19 below.


Zoom<br />

18<br />

Figure 19: Selection Statistics.<br />

Selecting a certain area with the mouse on the graph and by either double clicking or<br />

selecting the scroll mechanism on a mouse (if one is available) will zoom in on the selected<br />

area. The statistics are computed only for the selected area, as shown in Figure 20 below.<br />

Figure 20: Zoom capabilities.


USB Pass-Through<br />

USB Pass-Through: Modes<br />

19<br />

In addition to the Main channel, three other channels are sampled at the same time. One of<br />

these is used for monitoring USB power. To use the USB Pass-Through mode, connect the<br />

USB device to the <strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong>, and connect a USB cable from the <strong>Mobile</strong><br />

<strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong> to the development workstation as shown in Figure 20 below.<br />

Figure 21: USB pass-through connection


20<br />

To download code or data when testing a device, USB can be used to connect the device to<br />

the <strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong>. However, when connecting to USB, USB charges the<br />

device, which disturbs the current measurements. To remedy this, the <strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong><br />

<strong>Monitor</strong> has an Auto USB passthrough mode. Auto USB passthrough mode is useful<br />

for testing, because in Auto USB passthrough mode, the USB pass-through is<br />

disconnected whenever sampling starts. After sampling has completed, USB is reconnected<br />

automatically so that test data can be loaded to the device. The Auto USB passthrough<br />

mode setting is shown in below in Figure 22.<br />

Figure 22: USB pass-through control<br />

In addition to Auto USB passthrough mode, there are two other USB modes:<br />

• On: Setting the USB passthrough mode to On enables the USB connection and<br />

records the current flowing through the USB connector on the front of the <strong>Mobile</strong> <strong>Device</strong><br />

<strong>Power</strong> <strong>Monitor</strong>.<br />

• Off: Setting the USB passthrough mode to Off disables the USB connection.


Measuring USB <strong>Power</strong><br />

21<br />

The USB connection can be used to measure the power and current on any functioning<br />

attached USB device. For example, the current and power of a mouse can be monitored as<br />

it is used by selecting USB in the Legend dialog box, and setting the USB passthrough<br />

mode to On in the Parameters dialog box.<br />

Figure 23: Testing a USB peripheral with the <strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong><br />

Using USB Markers<br />

If synchronizing an external event is required, the <strong>Power</strong> Tool software can support that<br />

feature over USB with Markers.<br />

To use the Markers functionality:<br />

1. Set the USB passthrough mode to Off.<br />

2. Select the Markers checkbox in the <strong>Power</strong> <strong>Monitor</strong> UI.<br />

3. Connect transistor-transistor logic (TTL) signals from the device to the USB A-connector<br />

on the front of the <strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong>. An easy way to do this is to use an old<br />

USB cable and cut it.<br />

Signals that are driven on the data lines will be shown as highs (1s) or lows (0s) on the<br />

display. There are wide blue and red lines for the Markers.


Auxiliary Port (Aux)<br />

22<br />

The Aux port is connected to the bayonet Neill-Concelman (BNC) connector on the front of<br />

the <strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong>. It allows for simultaneous measurement of the current<br />

going through an external power supply.<br />

For example, suppose the LT1129 shown below in Figure 24 sits on a mobile device PCB and<br />

the current supplied to the 3.3 V supply needs to be measured.<br />

Figure 24: Schematic of the Aux port<br />

In this situation, to measure the current supplied to the 3.3 V power supply, connect a 50 Ω<br />

coaxial cable to a 0.1 Ω sense resistor and connect that coaxial cable to the <strong>Mobile</strong> <strong>Device</strong><br />

<strong>Power</strong> <strong>Monitor</strong>. When connecting a coaxial cable:<br />

• Connect the outside of the BNC connector to the high side of the sense resistor.<br />

• Connect the inside of the BNC connector to the low side of the sense resistor.<br />

In Figure 25 below, the mobile device is powered by the <strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong> and<br />

its processor core power is being monitored on the Aux port with a 0.1 Ω resistor. In the<br />

<strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong>, the data for the main supply and the core supply can be<br />

displayed and analyzed simultaneously.


23<br />

Figure 25: Example connection to the Aux port<br />

Data Importing Features of the <strong>Power</strong> <strong>Monitor</strong><br />

The data importing features of the <strong>Power</strong> <strong>Monitor</strong> allows the user to import data from the<br />

following data formats:<br />

The <strong>Power</strong> Tool software can import the file formats shown in the following table.<br />

File format Description<br />

.PT3 Binary data in exactly the same format<br />

that the <strong>Power</strong> <strong>Monitor</strong> creates, this is<br />

compatible with the current version of<br />

the protocol specification.<br />

All of these formats, when saved, are saved at the maximum time resolution, regardless of<br />

the Capture Settings.<br />

The <strong>Mobile</strong> <strong>Power</strong> <strong>Monitor</strong> will convert the imported file to a .PT4 format before displaying<br />

the output to the display box.


24<br />

Figure 26: Importing PT3 file extension<br />

Data Exporting Features of the <strong>Power</strong> <strong>Monitor</strong><br />

The data exporting features of the <strong>Power</strong> <strong>Monitor</strong> allows the user to save data for the<br />

following:<br />

• The entire power measurement run<br />

• If any data is selected with the mouse, the selected data is exported<br />

• If no data is selected with the mouse, then the data that is displayed<br />

The <strong>Power</strong> Tool software can export to the file formats shown in the following table.<br />

File format Description<br />

.PT4 Binary data in exactly the same format<br />

that the <strong>Power</strong> <strong>Monitor</strong> creates, this is<br />

compatible with the current version of<br />

the protocol specification. Please see the<br />

APPENDIX for a more detailed breakdown<br />

of the PT4 format<br />

.CSV Comma-separate values. A common<br />

format that can be used to import into<br />

spreadsheet software. The <strong>Power</strong> <strong>Monitor</strong><br />

saves only what is recorded in the<br />

current trace.<br />

.DCF A common format for exporting test<br />

data.<br />

All of these formats, when saved, are saved at the maximum time resolution, regardless of<br />

the Capture Settings.


25<br />

Functional Description of the <strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong><br />

To measure the current accurately, a dual range, self-calibrating, integrating system is<br />

used. Each channel has two current ranges with a 16-bit analog-to-digital converter (ADC),<br />

one with a high-resolution range, and the other with a low-resolution range. Software<br />

continuously calibrates each of these and selects the proper range during measurement.<br />

The dual range scheme works because mobile devices are usually in standby mode and<br />

drawing only a few millamps of current, or they are running above 100 milliamps. The<br />

<strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong> must be very accurate when the current is low, but may be<br />

less accurate as the current increases. Each sample is integrated over its 200-microsecond<br />

sample period so that even a brief high-current pulse is captures. Depending on system<br />

capacitance and other factors, the fastest transient pulses are around 20 microseconds. The<br />

integrator sums up these fast pulses so that an accurate assessment of the average current<br />

is maintained. The unit is self-calibrating. One cycle out of every 1000 cycles is used to run<br />

either a zero-current calibration or a reference-current calibration. Software uses these<br />

measurements to null out the offset and gain errors in the system. Because this is done<br />

automatically, it compensates for slow temperature changes during the measurement run.<br />

The only part not included in the self-calibration is the sense resistor. These resistors are<br />

calibrated at the factory and the calibration values may be adjusted and saved by engineers<br />

using the Parameters dialog box. The <strong>Power</strong> <strong>Monitor</strong> has an overflow buffer that can hold six<br />

packets of 128 bytes each. During transfer, if the development workstation cannot read the<br />

data fast enough then this buffer will begin to fill up, and samples may be lost. The received<br />

data is concatenated so the line appears continuous. To account for the lost samples, the<br />

protocol contains a 16-bit counter that tracks the number of lost samples. The running total<br />

of lost samples is displayed in the UI, as shown in Figure 27 below.<br />

Figure 27: Counter for dropped samples and dropped connections<br />

Because the dropped samples are less than one percent of a run, the error is minimal.<br />

Usually this loss of data is less than 0.1 percent. However, sometimes on long runs or on<br />

loaded systems the dropped sample count can exceed 65,000. When this occurs, the <strong>Power</strong><br />

Tool lost communication for more than 10 seconds. A count of dropped connections is<br />

maintained in the UI, as shown above in Figure 26. Both of these counts are reset to zero<br />

when a run is restarted. These counts are useful to determine how stable the connection is.<br />

If the dropped packets are greater than one percent of all samples, or if there are more<br />

than one or two dropped connections per hour, then it is likely that the development<br />

workstation has other applications running that are causing delays. Closing these<br />

applications or installing the <strong>Power</strong> Tool software on a clean machine should solve these<br />

issues and reduce the dropped samples and packets.


APPENDIX:<br />

26<br />

Electrical Specifications of the <strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong><br />

<strong>Monitor</strong><br />

Main Channel<br />

Component Minimum Maximum<br />

Output voltage range 2.1 V 4.5 V<br />

Continuous current 3.0 A<br />

Peak current 4.5 A<br />

Integrator cutoff<br />

frequency<br />

300 kHz<br />

Fine current scale - range 40 mA<br />

Fine current scale -<br />

resolution<br />

Fine current scale -<br />

accuracy<br />

Coarse current scale -<br />

range<br />

Coarse current scale -<br />

resolution<br />

Coarse current scale -<br />

accuracy<br />

Programmable current<br />

limit range<br />

Programmable current<br />

limit accuracy<br />

Positive temperature<br />

coefficient (PTC) hold<br />

limit at 6 V of direct<br />

current input (DCIN)<br />

2.86 uA<br />

+/- 1% or +/- 50 uA<br />

(whichever is greater)<br />

30 mA 4.5A<br />

286 uA<br />

+/- 1% or +/- 1 mA<br />

(whichever is greater)<br />

8 mA 8 A<br />

(0.7) * (current limit) (1.4) * (current limit)<br />

3 A<br />

PTC trip limit at 6 V DCIN Not applicable 6 A<br />

Fan turn on temperature 38 C<br />

Fan turn off temperature 33 C<br />

Thermal limit shutdown 50 C


USB Channel<br />

27<br />

Component Min Max<br />

Input voltage range 2.1 V 5.4 V<br />

Continuous current 1.0 A<br />

Peak current 4.5 A<br />

Integrator cutoff<br />

frequency<br />

300 kHz<br />

Fine current scale - range 40 mA<br />

Fine current scale -<br />

resolution<br />

Fine current scale -<br />

accuracy<br />

Coarse current scale -<br />

range<br />

Coarse current scale -<br />

resolution<br />

Coarse current scale -<br />

accuracy<br />

VBUS PTC current hold<br />

limit<br />

VBUS PTC current trip<br />

limit<br />

2.86 uA<br />

+/- 1% or +/- 50 uA<br />

(whichever is greater)<br />

30 mA 4.5 A<br />

286 uA<br />

+/- 1% or +/- 1 mA<br />

(whichever is greater)<br />

VBUS capacitance to GND 22uF +/- 20%<br />

0.52 A 0.85 A<br />

1.04 A 1.7 A


Auxiliary Channel<br />

28<br />

Component Min Max<br />

Input voltage range 1.0 V 5.0 V<br />

Differential input voltage 0.1 V<br />

Integrator cutoff<br />

frequency<br />

300 kHz<br />

Fine current scale - range 0 mA 12 mA<br />

Fine current scale -<br />

resolution<br />

Fine current scale -<br />

accuracy<br />

Coarse current scale -<br />

range<br />

Coarse current scale –<br />

resolution<br />

Coarse current scale -<br />

accuracy<br />

2.58 uA<br />

+/- 1% or +/- 50 uA<br />

(whichever is greater)<br />

10 mA 500 mA @ Vin = 1V<br />

100 uA<br />

+/- 1% or +/-1mA<br />

(whichever is greater)<br />

Aux + side capacitance 22uF+/- 20%<br />

1 A @ Vin = 1.8 V<br />

Aux + side input current Not applicable 1% of 0.1 Ω resistor<br />

current


29<br />

<strong>Power</strong> <strong>Monitor</strong> Data and Control Protocol<br />

All control of the <strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong> happens on the development workstation.<br />

The development workstation issues commands and the <strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong><br />

responds to the commands by completing the operation and sending back a Status packet.<br />

The Status packet contains the entire current state of the machine, except when sampling.<br />

When sampling, the <strong>Power</strong> Tool sends a Start packet to the <strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong>,<br />

and then the <strong>Power</strong> <strong>Monitor</strong> sends sample packets continuously back to the <strong>Power</strong> Tool.<br />

When sampling is to be stopped, the <strong>Power</strong> Tool UI sends a Stop packet. The <strong>Mobile</strong> <strong>Device</strong><br />

<strong>Power</strong> <strong>Monitor</strong> stops sampling and responds with a Status packet. Generally, when the<br />

<strong>Mobile</strong> <strong>Device</strong> <strong>Power</strong> <strong>Monitor</strong> is not sampling, the <strong>Power</strong> Tool requests periodic status<br />

packets in order to refresh its display.<br />

Command Line Operation of the <strong>Power</strong> <strong>Monitor</strong><br />

This applies to <strong>Power</strong>Tool version 4.0.1. Version 4.0.1 includes a console application,<br />

<strong>Power</strong>ToolCmd, for better execution in batch files/scripts.<br />

The command line format is:<br />

<strong>Power</strong>ToolCmd [fileName] [switch [switch …]]<br />

where fileName is the optional name of a PT4 file to be loaded into the buffer.<br />

Switches begin with “-“ (hyphen) or “/” (forward slash). The switches are as follows, and<br />

are case-insensitive:<br />

Switch Description<br />

/LOADFILE=file Same as fileName above<br />

/NOGUI Console mode<br />

/ISTART Sampling starts immediately<br />

/TRIGGER=string See section on trigger codes<br />

/TESTMINPOWER=value Return success if average power (mW) is >= value<br />

/TESTMAXPOWER=value Return success if average power (mW) is


30<br />

/TEMPDIR=path Override temporary directory<br />

(Default: %My Documents%\<strong>Power</strong>Tool)<br />

/USBPASSTHROUGH=mode<br />

/USB=mode<br />

USB passthrough mode: AUTO, ON, or OFF<br />

(Default: AUTO)<br />

/NOEXITWAIT Program exits without waiting for “Press any key…”<br />

/EXITCODES Lists program exit codes<br />

/?, /H, /HELP Lists command-line switches<br />

Trigger codes<br />

The following is the syntax of a trigger code:<br />

{A|Bn|Cqrn|D}[{An|Bn}]T[X]{A|Bn|Cn|Dnt|Eqrn}[An]<br />

The capital letters are literals. “n” represents a numeric quantity (in decimal), and “q”, “r”<br />

and “t” are place-holders for code letters, explained below.<br />

At the highest level, the string breaks down into:<br />

T<br />

The following table lists the possible values of :<br />

Code Meaning<br />

A <strong>Manual</strong> start<br />

Bn Start after “n” markers<br />

Cqrn Start when quantity “q” has relationship “r” with the number “n” (see below)<br />

D Start immediately<br />

The possible values of (when present) are:<br />

Code Meaning<br />

An Delay capture “n” samples after trigger<br />

Bn Capture “n” samples before trigger<br />

If is present, the value “X” indicates that a DCF file should be<br />

automatically exported when sampling stops.


31<br />

The following table lists the possible values of :<br />

Code Meaning<br />

A <strong>Manual</strong> stop<br />

Bn Stop after “n” markers<br />

Cn Stop after “n” samples<br />

Dnt Stop after “n” time units of type “t” (see “t” below)<br />

Eqrn Stop when quantity “q” has relationship “r” with the number “n” (see below)<br />

The possible values of (when present) are:<br />

Code Meaning<br />

An Capture “n” samples after trigger<br />

The possible values for the quantity code “q” are:<br />

Code Meaning<br />

A Min power<br />

B Avg power<br />

C Max power<br />

D Min current<br />

E Avg current<br />

F Max current<br />

G Min Vout<br />

H Avg Vout<br />

I Max Vout<br />

The possible values of relationship code “r” are as follows:<br />

Code Meaning<br />

A >=<br />

B


32<br />

The possible values of the time-unit code “t” are as follows:<br />

Code Meaning<br />

A Seconds (s)<br />

B Milliseconds (ms)<br />

C Microseconds (us)<br />

For example, a trigger code “CBA300A500TXC20000A500” would be interpreted as follows:<br />

Code Meaning<br />

CBA300 Start capture after average power falls below 300 mW<br />

A500 Delay capture 500 samples after trigger<br />

T Fixed delimiter<br />

X Auto-export DCF file after stop<br />

C20000 Stop capture after 20000 samples<br />

A500 Capture 500 samples after trigger<br />

The Trigger Settings dialog has a feature that shows the resulting trigger code that<br />

corresponds to the dialog settings.<br />

Capture Data Mask<br />

The capture data mask is a 16-bit quantity that specifies the data to be captured. It can be<br />

expressed either in decimal or hexadecimal (using C-style “0x” notation), but it is most<br />

naturally expressed in hex, since it is a combination of discrete bit values.<br />

The mask indicates which of the three data channels are to be captured: Main, USB, or AUX.<br />

Each channel is represented by one bit in the mask. The mask is thus the bitwise-OR of the<br />

channel(s) to be captured.<br />

The bit values for the channels are as follows:<br />

Mask Channel<br />

0x1000 Main<br />

0x2000 USB<br />

0x4000 Aux<br />

The default value is 0x1777 (the low-order twelve bits are no longer significant)


33<br />

<strong>Power</strong> <strong>Monitor</strong> Exit Codes<br />

When the <strong>Power</strong> Tool is closed, it provides an exit code that indicates why the software was<br />

closed. The exit codes include but are not limited to:<br />

• Test complete OK<br />

• Unable to find hardware<br />

• Hardware calibration failed<br />

• Disk space check fail<br />

• Capture file write error<br />

• Capture hardware error<br />

• Capture buffer overrun<br />

PT4 file format<br />

A PT4 file consists of three main sections:<br />

• A fixed-length header (212 bytes), at file offset 0<br />

• A fixed-length Status packet (60 bytes for Protocol 16), at file offset 272<br />

• Multiple occurrences of variable-length sample data, starting at file offset 1024. All<br />

samples are recorded at a frequency of 5 kHz. Each sample is an n-tuple, the<br />

content of which is selectable at run-time.<br />

Header section<br />

The first 212 bytes are the header, as follows:<br />

Name Description C# data type Bytes File<br />

offset<br />

headSize Header size int 4 0<br />

Name “<strong>Power</strong> Tool” string 20 4<br />

batterySize mAh int 4 24<br />

captureDate System.DateTime binary long 8 28<br />

serialNumber <strong>Power</strong> <strong>Monitor</strong> serial<br />

number<br />

string 20 36<br />

calibrationStatus OK (0) or FAILED (1) CalibrationStatu<br />

s enum<br />

voutSetting Typical (0), Low (1), High<br />

(2), or Custom (3)<br />

VoutSetting<br />

enum<br />

4 56<br />

4 60<br />

voutValue Main voltage output float 4 64<br />

hardwareRate Hz int 4 68<br />

softwareRate Hz float 4 72<br />

powerField Data selection for <strong>Power</strong> SelectField enum 4 76<br />

currentField Data selection for Current SelectField enum 4 80


34<br />

Name Description C# data type Bytes File<br />

offset<br />

voltageField Data selection for Voltage SelectField enum 4 84<br />

captureSetting Trigger specification string 30 88<br />

swVersion <strong>Power</strong> Tool version string 10 118<br />

runMode NoGUI (0) or GUI (1) RunMode enum 4 128<br />

exitCode Application exit code int 4 132<br />

totalCount Count of data samples long 8 136<br />

statusOffset File offset of Status Packet ushort 2 144<br />

statusSize Size (bytes) of Status<br />

Packet<br />

ushort 2 146<br />

sampleOffset File offset of Sample data ushort 2 148<br />

sampleSize Size (bytes) of each<br />

individual sample<br />

ushort 2 150<br />

initialMainVoltage See Table 6. ushort 2 152<br />

initialUsbVoltage See Table 6. ushort 2 154<br />

initialAuxVoltage See Table 6. ushort 2 156<br />

captureDataMask Mask indicating which data<br />

is being captured (see<br />

Table 3)<br />

ushort 2 158<br />

sampleCount Sample count ulong 8 160<br />

missingCount Count of missing samples ulong 8 168<br />

sumMainVoltage Sum of main output voltage<br />

(V). Divide by<br />

(sampleCount –<br />

missingCount) for Average.<br />

float 4 176<br />

sumMainCurrent Sum of main current (mA) float 4 180<br />

sumMain<strong>Power</strong> Sum of main power (mW) float 4 184<br />

sumUsbVoltage Sum of USB voltage (V) float 4 188<br />

sumUsbCurrent Sum of USB current (mA) float 4 192<br />

sumUsb<strong>Power</strong> Sum of USB power (mW) float 4 196<br />

sumAuxVoltage Sum of Aux voltage (V) float 4 200<br />

sumAuxCurrent Sum of Aux current (mA) float 4 204<br />

sumAux<strong>Power</strong> Sum of Aux power (mW) float 4 208<br />

Total length: 212<br />

Table 1: Header layout<br />

All strings are length-prefixed (one-byte), and are blank-padded to their fixed length,<br />

suitable for reading with BinaryReader.ReadString(). The lengths listed include the length<br />

byte.


35<br />

The enumerations are as follows:<br />

Enumeration Definition Description<br />

CalibrationStatus OK=0<br />

Failed=1<br />

VoutSetting Typical=0 (3.7 V)<br />

Low=1 (3.35 V)<br />

High=2 (4.2 V)<br />

Custom=3<br />

SelectField None=0x00<br />

Avg=0x01<br />

Min=0x02<br />

Max=0x04<br />

Main=0x08<br />

Usb=0x10<br />

Aux=0x20<br />

Marker=0x40<br />

RunMode NoGUI=0<br />

GUI=1<br />

Table 2: Header enumerations<br />

Status of calibration<br />

Type out Vout setting<br />

Masks describing which<br />

channel<br />

(Main,Aux1,Aux2,Marker)<br />

and statistic<br />

(Avg,Min,Max) are being<br />

recorded<br />

Whether or not <strong>Power</strong>Tool<br />

was running in GUI mode<br />

The captureDataMask can be interpreted with the following bit masks:<br />

Channel Mask<br />

Main Current 0x1000<br />

Usb Current 0x2000<br />

Aux Current 0x4000<br />

Marker 0x8000<br />

Voltage 0x0700<br />

Table 3: Channel selection masks<br />

For example, if the bitwise-Boolean expression (captureDataMask & x02000) is non-zero,<br />

then current data for the Aux1 channel is being recorded in the file. If (captureDataMask<br />

& 0x0700) is non-zero or (captureDataMask & 0x8000) is non-zero, then voltages and<br />

markers are being recorded in the file. The section on the sample data will explain this<br />

further.<br />

The file is padded with zeros until offset 272 (144+128), where a Status packet from the<br />

<strong>Power</strong> <strong>Monitor</strong> hardware is recorded, as follows:<br />

Name Description C# data type Bytes File<br />

offset<br />

packetLength Length-1 of packet (59 byte 1 272 0<br />

Packet<br />

offset


36<br />

for Protocol 16, but may<br />

expand in later<br />

protocols)<br />

packetType 0x10 for Status packet byte 1 273 1<br />

firmwareVersion Firmware version byte 1 274 2<br />

protocolVersion Protocol version byte 1 275 3<br />

mainFineCurrent Main current, fine scale short (signed) 2 276 4<br />

usbFineCurrent Usb current, fine scale short (signed) 2 278 6<br />

auxFineCurrent Aux current, fine scale short (signed) 2 280 8<br />

voltage1 Voltage of selected<br />

channel. See Table 6.<br />

mainCoarseCurrent Main current, coarse<br />

scale<br />

usbCoarseCurrent Usb current, coarse<br />

scale<br />

auxCoarseCurrent Aux current, coarse<br />

scale<br />

voltage2 Voltage of selected<br />

channel. See Table 6.<br />

outputVoltageSetting Volts = 2.0 +<br />

outputVoltageSetting *<br />

0.01<br />

ushort 2 282 10<br />

short (signed) 2 284 12<br />

short (signed) 2 286 14<br />

short (signed) 2 288 16<br />

ushort 2 290 18<br />

byte 1 292 20<br />

temperature Degrees Celsius byte 1 293 21<br />

status Bit flags (low to high):<br />

unitNotAtVoltage<br />

cannot<strong>Power</strong>Output<br />

checksumError<br />

followsLastSamplePacke<br />

t<br />

responseToStopPacket<br />

badPacketReceived<br />

byte 1 294 22<br />

reserved Unused byte 1 295 23<br />

leds Bit flags (low to high):<br />

disableButtonPressed<br />

errorLedOn<br />

fanMotorOn<br />

voltageIsAux<br />

mainFineResistor Resistor offset<br />

(ohms = 0.05 + offset *<br />

0.0001)<br />

byte 1 296 24<br />

sbyte (signed) 1 297 25<br />

serialNumber Serial number ushort 2 298 26<br />

sampleRate kHz byte 1 300 28<br />

dacCalLow DAC input for 2.5 V<br />

output<br />

ushort 2 301 29


37<br />

dacCalHigh DAC input for 4.096 V<br />

output<br />

powerUpCurrentLimit Max current during<br />

power-up<br />

(amps = 8 * ((1limit)/1023)<br />

runTimeCurrentLimit Max current during<br />

sample run (amps = 8 *<br />

((1-limit)/1023)<br />

ushort 2 303 31<br />

ushort 2 305 33<br />

ushort 2 307 35<br />

powerUpTime ms byte 1 309 37<br />

usbFineResistor Resistor offset<br />

(ohms = 0.05 + offset *<br />

0.0001)<br />

auxFineResistor Resistor offset<br />

(ohms = 0.10 + offset *<br />

0.0001)<br />

sybte (signed) 1 310 38<br />

sbyte (signed) 1 311 39<br />

initialUsbVoltage See Table 6. ushort 2 312 40<br />

initialAuxVoltage See Table 6. ushort 2 314 42<br />

hardwareRevision Hardware revision level<br />

(1=A, 2=B, 3=C, etc.)<br />

byte 1 312 44<br />

temperatureLimit Degrees Celsius byte 1 313 45<br />

usbPassthroughMode 0=off, 1=on, 2=auto byte 1 314 46<br />

mainCoarseResistor Resistor offset<br />

(ohms = 0.05 + offset *<br />

0.0001)<br />

usbCoarseResistor Resistor offset<br />

(ohms = 0.05 + offset *<br />

0.0001)<br />

auxCoarseResistor Resistor offset<br />

(ohms = 0.10 + offset *<br />

0.0001)<br />

defMainFineResistor Default resistor offset<br />

(ohms = 0.05 + offset *<br />

0.0001)<br />

defUsbFineResistor Default resistor offset<br />

(ohms = 0.05 + offset *<br />

0.0001)<br />

defAuxFineResistor Default resistor offset<br />

(ohms = 0.10 + offset *<br />

0.0001)<br />

defMainCoarseResistor Default resistor offset<br />

(ohms = 0.05 + offset *<br />

0.0001)<br />

defUsbCoarseResistor Default resistor offset<br />

(ohms = 0.05 + offset *<br />

sbyte (signed) 1 315 47<br />

sbyte (signed) 1 316 48<br />

sbyte (signed) 1 317 49<br />

sbyte (signed) 1 318 50<br />

sbyte (signed) 1 319 51<br />

sbyte (signed) 1 320 52<br />

sbyte (signed) 1 321 53<br />

sbyte (signed) 1 322 54


38<br />

0.0001)<br />

defAuxCoarseResistor Default resistor offset<br />

(ohms = 0.10 + offset *<br />

0.0001)<br />

eventCode Event code:<br />

0 = none<br />

1 = USB connection lost<br />

2 = too many dropped<br />

samples<br />

3 = reset requested by<br />

host<br />

eventData Supplementary event<br />

data (interpretation<br />

depends on eventCode)<br />

sbyte (signed) 1 323 55<br />

byte 1 324 56<br />

ushort 2 325 57<br />

checkSum Checksum byte byte 1 327 59<br />

Total length 60<br />

Table 4: Status packet layout<br />

The file is then padded with zeros up until file offset 1024, where the sample data begins.<br />

Interpreting the Sample Data<br />

Beginning at offset 1024, sample data is recorded at a rate indicated in the Status Packet.<br />

Each sample consists of up to four two-byte quantities, three of which are optional,<br />

depending on the captureDataMask field at offset 158.<br />

The total count of samples is given by the totalCount field of the header.<br />

The four quantities are the current measurements for the Main, Usb, and/or Aux channels,<br />

and a voltage for the channel indicated by the voltageIsAux bit of the leds field of the<br />

Status packet (file offset 296). If the bit is set, the voltage is the Aux channel voltage,<br />

otherwise it is the Main channel voltage.<br />

The current measurements can each be either on the Fine or Coarse scale, independently of<br />

each other, and the scale can change from one sample to the next. For fine scale<br />

measurements each tick represents 1 uA (microamp), whereas for the coarse scale, each<br />

tick represents 250 uA.<br />

A coarse measurement always has the low-order bit set. For fine measurements, the loworder<br />

bit is always clear. After determining the scale, the low-order bit should be cleared<br />

before calculating the current.<br />

For voltage, the two low-order bits are the two marker channels. The lowest bit is Marker<br />

0, the next bit is Marker 1. These bits should be masked off before calculating voltage.<br />

The layout of each sample is as follows:


39<br />

Field C# Data<br />

Type<br />

Main Current short<br />

(signed)<br />

USB Current short<br />

(signed)<br />

Aux Current short<br />

(signed)<br />

Main or Aux<br />

Voltage, and<br />

Markers<br />

ushort<br />

(unsigned)<br />

Bytes Tick value Present if:<br />

2 1 uA (fine)<br />

250 uA (coarse)<br />

2 1 uA (fine)<br />

250 uA (coarse)<br />

2 1 uA (fine)<br />

250 uA (coarse)<br />

2 See Table 6 Always<br />

Table 5: Sample layout<br />

(captureDataMask &<br />

0x1000) != 0<br />

(captureDataMask &<br />

0x2000) != 0<br />

(captureDataMask &<br />

0x4000) != 0<br />

The following table lists the value of each voltage tick in microvolts (uV), depending on the<br />

hardware revision level and the channel:<br />

Hardware<br />

Revision<br />

Main USB Aux<br />

A 62.5 uV / tick 62.5 uV / tick 62.5 uV / tick<br />

B 125 uV / tick 125 uV / tick 62.5 uV / tick<br />

C or later 125 uV / tick 125 uV / tick 125 uV / tick<br />

Missing data values<br />

Table 6: Voltage units<br />

In order to account for the time gaps caused by calibration cycles, delays in communication<br />

between the power monitor and the PC host, or other causes, the <strong>Power</strong>Tool software<br />

inserts missing data indicators. For current measurements, missing data is recorded as<br />

0x8001, while for voltage the missing value is 0xFFFF.<br />

Should a missing value be encountered within a given sample, the entire sample should be<br />

treated as missing, but the 200 us of time for the sample should be accounted for.<br />

Example C# program to process a PT4 file<br />

// ----------------------------------------------------<br />

// This C# program reads and processes each sample in a<br />

// PT4 file sequentially, from the first sample to the<br />

// last.<br />

//<br />

// The name of the file to be processed is taken from


40<br />

// the command line argument.<br />

//<br />

// Copyright (c) <strong>Monsoon</strong> <strong>Solutions</strong>, Inc.<br />

// All Rights Reserved.<br />

// ----------------------------------------------------<br />

using System;<br />

using System.IO;<br />

using System.Diagnostics;<br />

namespace SyncTest<br />

{<br />

public static class PT4<br />

{<br />

// fixed file offsets<br />

public const long headerOffset = 0;<br />

public const long statusOffset = 272;<br />

public const long sampleOffset = 1024;<br />

// bitmasks<br />

private const short coarseMask = 1;<br />

private const ushort marker0Mask = 1;<br />

private const ushort marker1Mask = 2;<br />

private const ushort markerMask = marker0Mask | marker1Mask;<br />

// missing data indicators<br />

const short missingRawCurrent = unchecked((short)0x8001);<br />

const ushort missingRawVoltage = 0xffff;<br />

// Enums for file header<br />

public enum CalibrationStatus : int<br />

{<br />

OK, Failed<br />

}<br />

public enum VoutSetting : int<br />

{<br />

Typical, Low, High, Custom<br />

}<br />

[FlagsAttribute] // bitwise-maskable<br />

public enum SelectField : int<br />

{<br />

None = 0x00,


41<br />

}<br />

Avg = 0x01,<br />

Min = 0x02,<br />

Max = 0x04,<br />

Main = 0x08,<br />

Usb = 0x10,<br />

Aux = 0x20,<br />

Marker = 0x40,<br />

All = Avg | Min | Max<br />

public enum RunMode : int<br />

{<br />

NoGUI, GUI<br />

}<br />

[FlagsAttribute] // bitwise-maskable<br />

public enum CaptureMask : ushort<br />

{<br />

chanMain = 0x1000,<br />

chanUsb = 0x2000,<br />

chanAux = 0x4000,<br />

chanMarker = 0x8000,<br />

chanMask = 0xf000,<br />

}<br />

// File header structure<br />

public struct Pt4Header<br />

{<br />

public int headSize;<br />

public string name;<br />

public int batterySize;<br />

public DateTime captureDate;<br />

public string serialNumber;<br />

public CalibrationStatus calibrationStatus;<br />

public VoutSetting voutSetting;<br />

public float voutValue;<br />

public int hardwareRate;<br />

public float softwareRate; // ignore<br />

public SelectField powerField;<br />

public SelectField currentField;<br />

public SelectField voltageField;<br />

public string captureSetting;<br />

public string swVersion;<br />

public RunMode runMode;


42<br />

}<br />

public int exitCode;<br />

public long totalCount;<br />

public ushort statusOffset;<br />

public ushort statusSize;<br />

public ushort sampleOffset;<br />

public ushort sampleSize;<br />

public ushort initialMainVoltage;<br />

public ushort initialUsbVoltage;<br />

public ushort initialAuxVoltage;<br />

public CaptureMask captureDataMask;<br />

public ulong sampleCount;<br />

public ulong missingCount;<br />

public float avgMainVoltage;<br />

public float avgMainCurrent;<br />

public float avgMain<strong>Power</strong>;<br />

public float avgUsbVoltage;<br />

public float avgUsbCurrent;<br />

public float avgUsb<strong>Power</strong>;<br />

public float avgAuxVoltage;<br />

public float avgAuxCurrent;<br />

public float avgAux<strong>Power</strong>;<br />

static public void ReadHeader(BinaryReader reader,<br />

ref Pt4Header header)<br />

{<br />

// remember original position<br />

long oldPos = reader.BaseStream.Position;<br />

// move to start of file<br />

reader.BaseStream.Position = 0;<br />

// read file header<br />

header.headSize = reader.ReadInt32();<br />

header.name = reader.ReadString().Trim();<br />

header.batterySize = reader.ReadInt32();<br />

header.captureDate =<br />

DateTime.FromBinary(reader.ReadInt64());<br />

header.serialNumber = reader.ReadString().Trim();<br />

header.calibrationStatus =<br />

(CalibrationStatus)reader.ReadInt32();<br />

header.voutSetting = (VoutSetting)reader.ReadInt32();<br />

header.voutValue = reader.ReadSingle();<br />

header.hardwareRate = reader.ReadInt32();


43<br />

}<br />

header.softwareRate = (float)header.hardwareRate;<br />

reader.ReadSingle(); // ignore software rate<br />

header.powerField = (SelectField)reader.ReadInt32();<br />

header.currentField = (SelectField)reader.ReadInt32();<br />

header.voltageField = (SelectField)reader.ReadInt32();<br />

header.captureSetting = reader.ReadString().Trim();<br />

header.swVersion = reader.ReadString().Trim();<br />

header.runMode = (RunMode)reader.ReadInt32();<br />

header.exitCode = reader.ReadInt32();<br />

header.totalCount = reader.ReadInt64();<br />

header.statusOffset = reader.ReadUInt16();<br />

header.statusSize = reader.ReadUInt16();<br />

header.sampleOffset = reader.ReadUInt16();<br />

header.sampleSize = reader.ReadUInt16();<br />

header.initialMainVoltage = reader.ReadUInt16();<br />

header.initialUsbVoltage = reader.ReadUInt16();<br />

header.initialAuxVoltage = reader.ReadUInt16();<br />

header.captureDataMask = (CaptureMask)reader.ReadUInt16();<br />

header.sampleCount = reader.ReadUInt64();<br />

header.missingCount = reader.ReadUInt64();<br />

ulong count = Math.Max(1, header.sampleCount -<br />

header.missingCount);<br />

// convert sums to averages<br />

header.avgMainVoltage = reader.ReadSingle() / count;<br />

header.avgMainCurrent = reader.ReadSingle() / count;<br />

header.avgMain<strong>Power</strong> = reader.ReadSingle() / count;<br />

header.avgUsbVoltage = reader.ReadSingle() / count;<br />

header.avgUsbCurrent = reader.ReadSingle() / count;<br />

header.avgUsb<strong>Power</strong> = reader.ReadSingle() / count;<br />

header.avgAuxVoltage = reader.ReadSingle() / count;<br />

header.avgAuxCurrent = reader.ReadSingle() / count;<br />

header.avgAux<strong>Power</strong> = reader.ReadSingle() / count;<br />

// restore original position<br />

reader.BaseStream.Position = oldPos;<br />

// Enums for status packet<br />

public enum PacketType : byte<br />

{<br />

set = 1, start, stop,<br />

status = 0x10, sample = 0x20


44<br />

}<br />

public struct Observation<br />

{<br />

public short mainCurrent;<br />

public short usbCurrent;<br />

public short auxCurrent;<br />

public ushort voltage;<br />

}<br />

[FlagsAttribute]<br />

public enum PmStatus : byte<br />

{<br />

unitNotAtVoltage = 0x01,<br />

cannot<strong>Power</strong>Output = 0x02,<br />

checksumError = 0x04,<br />

followsLastSamplePacket = 0x08,<br />

responseToStopPacket = 0x10,<br />

responseToResetCommand = 0x20,<br />

badPacketReceived = 0x40<br />

}<br />

[FlagsAttribute]<br />

public enum Leds : byte<br />

{<br />

disableButtonPressed = 0x01,<br />

errorLedOn = 0x02,<br />

fanMotorOn = 0x04,<br />

voltageIsAux = 0x08,<br />

}<br />

public enum HardwareRev : byte<br />

{<br />

revA = 1, revB, revC, revD<br />

}<br />

public enum UsbPassthroughMode : byte<br />

{<br />

off, on, auto, trigger, sync<br />

}<br />

public enum EventCode : byte<br />

{<br />

noEvent = 0,


45<br />

}<br />

usbConnectionLost,<br />

tooManyDroppedObservations,<br />

resetRequestedByHost<br />

// Statuc packet structure<br />

public struct StatusPacket<br />

{<br />

public byte packetLength;<br />

public PacketType packetType;<br />

public byte firmwareVersion;<br />

public byte protocolVersion;<br />

public Observation fineObs;<br />

public Observation coarseObs;<br />

public byte outputVoltageSetting;<br />

public sbyte temperature;<br />

public PmStatus pmStatus;<br />

public byte reserved;<br />

public Leds leds;<br />

public sbyte mainFineResistorOffset;<br />

public ushort serialNumber;<br />

public byte sampleRate;<br />

public ushort dacCalLow;<br />

public ushort dacCalHigh;<br />

public ushort powerupCurrentLimit;<br />

public ushort runtimeCurrentLimit;<br />

public byte powerupTime;<br />

public sbyte usbFineResistorOffset;<br />

public sbyte auxFineResistorOffset;<br />

public ushort initialUsbVoltage;<br />

public ushort initialAuxVoltage;<br />

public HardwareRev hardwareRevision;<br />

public byte temperatureLimit;<br />

public UsbPassthroughMode usbPassthroughMode;<br />

public sbyte mainCoarseResistorOffset;<br />

public sbyte usbCoarseResistorOffset;<br />

public sbyte auxCoarseResistorOffset;<br />

public sbyte factoryMainFineResistorOffset;<br />

public sbyte factoryUsbFineResistorOffset;<br />

public sbyte factoryAuxFineResistorOffset;<br />

public sbyte factoryMainCoarseResistorOffset;<br />

public sbyte factoryUsbCoarseResistorOffset;<br />

public sbyte factoryAuxCoarseResistorOffset;<br />

public EventCode eventCode;


46<br />

}<br />

public ushort eventData;<br />

public byte checksum;<br />

static public void ReadStatusPacket(BinaryReader reader,<br />

ref StatusPacket status)<br />

{<br />

// remember origibal position<br />

long oldPos = reader.BaseStream.Position;<br />

// move to start of status packet<br />

reader.BaseStream.Position = statusOffset;<br />

// read status packet<br />

status.packetLength = reader.ReadByte();<br />

status.packetType = (PacketType)reader.ReadByte();<br />

Debug.Assert(status.packetType == PacketType.status);<br />

status.firmwareVersion = reader.ReadByte();<br />

status.protocolVersion = reader.ReadByte();<br />

Debug.Assert(status.protocolVersion >= 16);<br />

status.fineObs.mainCurrent = reader.ReadInt16();<br />

status.fineObs.usbCurrent = reader.ReadInt16();<br />

status.fineObs.auxCurrent = reader.ReadInt16();<br />

status.fineObs.voltage = reader.ReadUInt16();<br />

status.coarseObs.mainCurrent = reader.ReadInt16();<br />

status.coarseObs.usbCurrent = reader.ReadInt16();<br />

status.coarseObs.auxCurrent = reader.ReadInt16();<br />

status.coarseObs.voltage = reader.ReadUInt16();<br />

status.outputVoltageSetting = reader.ReadByte();<br />

status.temperature = reader.ReadSByte();<br />

status.pmStatus = (PmStatus)reader.ReadByte();<br />

status.reserved = reader.ReadByte();<br />

status.leds = (Leds)reader.ReadByte();<br />

status.mainFineResistorOffset = reader.ReadSByte();<br />

status.serialNumber = reader.ReadUInt16();<br />

status.sampleRate = reader.ReadByte();<br />

status.dacCalLow = reader.ReadUInt16();<br />

status.dacCalHigh = reader.ReadUInt16();<br />

status.powerupCurrentLimit = reader.ReadUInt16();<br />

status.runtimeCurrentLimit = reader.ReadUInt16();<br />

status.powerupTime = reader.ReadByte();<br />

status.usbFineResistorOffset = reader.ReadSByte();<br />

status.auxFineResistorOffset = reader.ReadSByte();<br />

status.initialUsbVoltage = reader.ReadUInt16();


47<br />

}<br />

status.initialAuxVoltage = reader.ReadUInt16();<br />

status.hardwareRevision = (HardwareRev)reader.ReadByte();<br />

status.temperatureLimit = reader.ReadByte();<br />

status.usbPassthroughMode =<br />

(UsbPassthroughMode)reader.ReadByte();<br />

status.mainCoarseResistorOffset = reader.ReadSByte();<br />

status.usbCoarseResistorOffset = reader.ReadSByte();<br />

status.auxCoarseResistorOffset = reader.ReadSByte();<br />

status.factoryMainFineResistorOffset = reader.ReadSByte();<br />

status.factoryUsbFineResistorOffset = reader.ReadSByte();<br />

status.factoryAuxFineResistorOffset = reader.ReadSByte();<br />

status.factoryMainCoarseResistorOffset =<br />

reader.ReadSByte();<br />

status.factoryUsbCoarseResistorOffset =<br />

reader.ReadSByte();<br />

status.factoryAuxCoarseResistorOffset =<br />

reader.ReadSByte();<br />

status.eventCode = (EventCode)reader.ReadByte();<br />

status.eventData = reader.ReadUInt16();<br />

status.checksum = reader.ReadByte();<br />

// restore original position<br />

reader.BaseStream.Position = oldPos;<br />

static public long BytesPerSample(CaptureMask captureDataMask)<br />

{<br />

long result = sizeof(ushort); // voltage always present<br />

}<br />

if ((captureDataMask & CaptureMask.chanMain) != 0)<br />

result += sizeof(short);<br />

if ((captureDataMask & CaptureMask.chanUsb) != 0)<br />

result += sizeof(short);<br />

if ((captureDataMask & CaptureMask.chanAux) != 0)<br />

result += sizeof(short);<br />

return result;<br />

static public long SamplePosition(long sampleIndex,<br />

CaptureMask captureDataMask)<br />

{


48<br />

}<br />

long result = sampleOffset +<br />

BytesPerSample(captureDataMask) * sampleIndex;<br />

return result;<br />

static public long SamplePosition(double seconds,<br />

CaptureMask captureDataMask,<br />

ref StatusPacket statusPacket)<br />

{<br />

seconds = Math.Max(0, seconds);<br />

}<br />

long bytesPerSample = BytesPerSample(captureDataMask);<br />

long freq = 1000 * statusPacket.sampleRate;<br />

long result = (long)(seconds * freq * bytesPerSample);<br />

long err = result % bytesPerSample;<br />

if (err > 0) // must fall on boundary<br />

result += (bytesPerSample - err);<br />

result += sampleOffset;<br />

return result;<br />

static public long SampleCount(BinaryReader reader,<br />

CaptureMask captureDataMask)<br />

{<br />

return (reader.BaseStream.Length - sampleOffset)<br />

/ BytesPerSample(captureDataMask);<br />

}<br />

public struct Sample<br />

{<br />

public long sampleIndex; // 0...N-1<br />

public double timeStamp; // fractional seconds<br />

public bool mainPresent; // whether Main was recorded<br />

public double mainCurrent; // current in milliamps<br />

public double mainVoltage; // volts<br />

public bool usbPresent; // whether Usb was recorded<br />

public double usbCurrent; // current in milliamps<br />

public double usbVoltage; // volts


49<br />

}<br />

public bool auxPresent; // whether Aux was recorded<br />

public double auxCurrent; // current in milliamps<br />

public double auxVoltage; // volts;<br />

public bool markerPresent; // whether markers/voltages<br />

// were recorded<br />

public bool marker0; // Marker 0<br />

public bool marker1; // Marker 1<br />

public bool missing; // true if this sample was<br />

// missing<br />

static public void GetSample(long sampleIndex,<br />

CaptureMask captureDataMask,<br />

StatusPacket statusPacket,<br />

BinaryReader reader,<br />

ref Sample sample)<br />

{<br />

// remember the index and time<br />

sample.sampleIndex = sampleIndex;<br />

sample.timeStamp = sampleIndex<br />

/ (1000.0 * statusPacket.sampleRate);<br />

// intial settings for all flags<br />

sample.mainPresent =<br />

(captureDataMask & CaptureMask.chanMain) != 0;<br />

sample.usbPresent =<br />

(captureDataMask & CaptureMask.chanUsb) != 0;<br />

sample.auxPresent =<br />

(captureDataMask & CaptureMask.chanAux) != 0;<br />

sample.markerPresent = true;<br />

sample.missing = false;<br />

// abort if no data was selected<br />

long bytesPerSample = BytesPerSample(captureDataMask);<br />

if (bytesPerSample == 0)<br />

return;<br />

// remember original position<br />

long oldPos = reader.BaseStream.Position;<br />

// position the file to the start of the desired sample<br />

long newPos = SamplePosition(sampleIndex, captureDataMask);<br />

if (oldPos != newPos)


50<br />

reader.BaseStream.Position = newPos;<br />

// get default voltages (V) for the three channels<br />

sample.mainVoltage =<br />

2.0 + statusPacket.outputVoltageSetting * 0.01;<br />

sample.usbVoltage =<br />

(double)statusPacket.initialUsbVoltage * 125 / 1e6f;<br />

if (statusPacket.hardwareRevision < HardwareRev.revB)<br />

sample.usbVoltage /= 2;<br />

sample.auxVoltage =<br />

(double)statusPacket.initialAuxVoltage * 125 / 1e6f;<br />

if (statusPacket.hardwareRevision < HardwareRev.revC)<br />

sample.auxVoltage /= 2;<br />

// Main current (mA)<br />

if (sample.mainPresent)<br />

{<br />

short raw = reader.ReadInt16();<br />

}<br />

sample.missing = sample.missing ||<br />

raw == missingRawCurrent;<br />

if (!sample.missing)<br />

{<br />

bool coarse = (raw & coarseMask) != 0;<br />

raw &= ~coarseMask;<br />

sample.mainCurrent = raw / 1000f; // uA -> mA<br />

if (coarse)<br />

sample.mainCurrent *= 250;<br />

}<br />

// Aux1 current (mA)<br />

if (sample.usbPresent)<br />

{<br />

short raw = reader.ReadInt16();<br />

sample.missing = sample.missing ||<br />

raw == missingRawCurrent;<br />

if (!sample.missing)<br />

{<br />

bool coarse = (raw & coarseMask) != 0;<br />

raw &= ~coarseMask;


51<br />

}<br />

}<br />

sample.usbCurrent = raw / 1000f; // uA -> mA<br />

if (coarse)<br />

sample.usbCurrent *= 250;<br />

// Aux2 current (mA)<br />

if (sample.auxPresent)<br />

{<br />

short raw = reader.ReadInt16();<br />

}<br />

sample.missing = sample.missing ||<br />

raw == missingRawCurrent;<br />

if (!sample.missing)<br />

{<br />

bool coarse = (raw & coarseMask) != 0;<br />

raw &= ~coarseMask;<br />

sample.auxCurrent = raw / 1000f; // uA -> mA<br />

if (coarse)<br />

sample.auxCurrent *= 250;<br />

}<br />

// Markers and Voltage (V)<br />

{<br />

ushort uraw = reader.ReadUInt16();<br />

sample.missing = sample.missing ||<br />

uraw == missingRawVoltage;<br />

if (!sample.missing)<br />

{<br />

// strip out marker bits<br />

sample.marker0 = (uraw & marker0Mask) != 0;<br />

sample.marker1 = (uraw & marker1Mask) != 0;<br />

uraw &= unchecked((ushort)~markerMask);<br />

// calculate voltage<br />

double voltage = (double)uraw * 125 / 1e6f;<br />

// assign the high-res voltage, as appropriate<br />

if ((statusPacket.leds & Leds.voltageIsAux) != 0)<br />

{<br />

sample.auxVoltage = voltage;<br />

if (statusPacket.hardwareRevision


52<br />

}<br />

}<br />

}<br />

}<br />

}<br />

{<br />

}<br />

< HardwareRev.revC)<br />

sample.auxVoltage /= 2;<br />

else<br />

{<br />

sample.mainVoltage = voltage;<br />

if (statusPacket.hardwareRevision<br />

< HardwareRev.revB)<br />

{<br />

sample.mainVoltage /= 2;<br />

}<br />

}<br />

// restore original position, if we moved it earlier<br />

if (oldPos != newPos)<br />

reader.BaseStream.Position = oldPos;<br />

class Program<br />

{<br />

static void Main(string[] args)<br />

{<br />

// open the file named in the command line argument<br />

string fileName = args[0];<br />

if (!File.Exists(fileName))<br />

return;<br />

FileStream pt4Stream = File.Open(fileName,<br />

FileMode.Open,<br />

FileAccess.Read,<br />

FileShare.ReadWrite);<br />

BinaryReader pt4Reader = new BinaryReader(pt4Stream);<br />

// reader the file header<br />

PT4.Pt4Header header = new PT4.Pt4Header();<br />

PT4.ReadHeader(pt4Reader, ref header);<br />

// read the Status Packet<br />

PT4.StatusPacket statusPacket = new PT4.StatusPacket();


53<br />

}<br />

}<br />

}<br />

PT4.ReadStatusPacket(pt4Reader, ref statusPacket);<br />

// determine the number of samples in the file<br />

long sampleCount = PT4.SampleCount(pt4Reader,<br />

header.captureDataMask);<br />

// pre-position input file to the beginning of the sample<br />

// data (saves a lot of repositioning in the GetSample<br />

// routine)<br />

pt4Reader.BaseStream.Position = PT4.sampleOffset;<br />

// process the samples sequentially, beginning to end<br />

PT4.Sample sample = new PT4.Sample();<br />

for (long sampleIndex = 0;<br />

sampleIndex < sampleCount;<br />

sampleIndex++)<br />

{<br />

// read the next sample<br />

PT4.GetSample(sampleIndex, header.captureDataMask,<br />

statusPacket, pt4Reader, ref sample);<br />

}<br />

// process the sample<br />

Console.WriteLine("#{0} {1} sec {2} mA {3} V",<br />

sampleIndex,<br />

sample.timeStamp,<br />

sample.mainCurrent,<br />

sample.mainVoltage);<br />

// close input file<br />

pt4Reader.Close();

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!