Mobile Device Power Monitor Manual



Similar documents
Mobile Device Power Monitor Manual Ver 1.15

Mobile Device Power Monitor Battery Connection Quick Start Guide

Universal Simple Control, USC-1

Page 1 S5.5 Monitoring Software Manual Rev 1.2 for Software Ver 1.0

MAX6683 Evaluation System/Evaluation Kit

How To Use An Easymp Network Projector On A Computer Or Network Projection On A Network Or Network On A Pc Or Mac Or Ipnet On A Laptop Or Ipro Or Ipo On A Powerbook On A Microsoft Computer On A Mini

Transmitter Interface Program

InventoryControl for use with QuoteWerks Quick Start Guide

Centurion PLUS CPC4 Download Guide

File Management Utility. T u t o r i a l

USB Edition TM-STD30 User Guide

User Manual. Thermo Scientific Orion

Data Logging Software and Cable Bundle Model DL-SC3 User Manual. Overview

L5354 ControlNet Communications Interface

10 Thomas, Irvine, CA USA Tel: (949) Fax: (949) Toll Free: (800) 23 FUTEK

Modbus RTU (RS-485) TCP/IP (Ethernet)

How To Use An Easymp Network Projection Software On A Projector On A Computer Or Computer

ebus Player Quick Start Guide

AIM SOFTWARE AND USB DRIVER INSTALLATION PROCEDURE

Hydras 3 LT Quick Start

EasyMP Network Projection Operation Guide

OPERATION MANUAL. MV-410RGB Layout Editor. Version 2.1- higher

User Manual Software for DSL Digital Speed Switch

Quick Start Using DASYLab with your Measurement Computing USB device

Troubleshooting Guide

Gigabyte Management Console User s Guide (For ASPEED AST 2400 Chipset)

Building a Simulink model for real-time analysis V Copyright g.tec medical engineering GmbH

Additional Requirements for ARES-G2 / RSA-G2. One Ethernet 10 Base T/100 Base TX network card required for communication with the instrument.

Instructions for Setting the T560 Digital Delay Generator for the Target Delay

isppac-powr1220at8 I 2 C Hardware Verification Utility User s Guide

Model 288B Charge Plate Graphing Software Operators Guide

Installing S500 Power Monitor Software and LabVIEW Run-time Engine

Release Notes. R&S ZVH4/ZVH8 Cable and Antenna Analyzer

Guide to Installing BBL Crystal MIND on Windows 7

Centran Version 4 Getting Started Guide KABA MAS. Table Of Contents

Ultra Thin Client TC-401 TC-402. Users s Guide

B Robo Claw 2 Channel 5A Motor Controller Data Sheet

Aperio Online. Aperio. Online Programming Application Manual. Aperio Online Quick Installation Guide, Document No: ST A, Date: 8 juli 2013

Capacitive Touch Lab. Renesas Capacitive Touch Lab R8C/36T-A Family

Troubleshooting Sprint Mobile Broadband USB Modem by Novatel Wireless TM (Ovation TM U727)

ODBC Client Driver Help Kepware, Inc.

MANUAL FOR RX700 LR and NR

STIM202 Evaluation Kit

3.5 EXTERNAL NETWORK HDD. User s Manual

[F/T] [5] [KHz] [AMP] [3] [V] 4 ) To set DC offset to -2.5V press the following keys [OFS] [+/-] [2] [.] [5] [V]

AXIS Camera Station Quick Installation Guide

StrikeRisk v6.0 IEC/EN Risk Management Software Getting Started

Software User Guide UG-461

How To Use Mview On A Powerline 2.2 (Powerline) On A Pc Or Macbook 2 (Powerplst) On An Iphone Or Ipa 2 (Aldo) On Your Iphon 2 (

OPENUPS. 6-30V Intelligent Uninterruptible Power Supply. Installation Guide. Version 1.0f P/N OPENUPS-06

JVC Monitor Calibration 2 User's Guide

USB 2.0 VGA ADAPTER USER MANUAL

BTMPico Data Management Software

TECHNICAL BULLETIN. Configuring Wireless Settings in an i-stat 1 Wireless Analyzer

Lenovo IdeaCentre Q180 Series

OPTAC Fleet Viewer. Instruction Manual

SA-9600 Surface Area Software Manual

FAS Asset Accounting FAS CIP Accounting FAS Asset Inventory SQL Server Installation & Administration Guide Version

Contents. Hardware Configuration Uninstalling Shortcuts Black...29

ACU-1000 Manual Addendum Replacement of CPM-2 with CPM-4

@ptitude Observer. Installation Manual. Part No Revision G

1. SAFETY INFORMATION

NAVICO Software Upgrade Tool. English sw Document no: Doc Revision: D Date: January 2010

Keep it Simple Timing

Monitoring Network DMN

GUARD1 PLUS SE Administrator's Manual

There are numerous ways to access monitors:

SPC-1. Single Point Controller. Operation Manual

ComTool Tool for managing parametric controllers

User s Manual C R Y S T A L. engineering corporation

EMF16 and Model 201 Graphics Software for Win 98/NT/ME/2K/XP/Vista/Win7/Win8 and Win10

OPTAC Fleet Viewer. Instruction Manual

COBRA 18R2 Wired Reprogramming Instructions

DAS202Tools v1.0.0 for DAS202 Operating Manual

QIAsymphony Management Console User Manual

Installing, upgrading and troubleshooting your CLIO system under the Windows environment.

Getting Started with Vision 6

webkpi SaaS ETL Connector Installation & Configuration Guide

User's Guide DylosLogger Software Version 1.6

How To Use A Watt Saver On A Microcontroller (Watt Saver) On A Cell Phone Or Mp3 Player

October Rev. B Page 1

SAFEPATH 4 Telephone Zone Controller

13-1. This chapter explains how to use different objects.

BASLER ACE QUICK INSTALLATION GUIDE

User Manual WatchPower

13 Managing Devices. Your computer is an assembly of many components from different manufacturers. LESSON OBJECTIVES

The Autolab control command is located in the Measurement General group of commands.

DataLINE Data Retrieval

RGK60 RGK50 RGAM10 RGAM20 RGAM4 Generator set control units

LOVELINK III- Process Monitoring, Logging, Graphing, & Configuration

c. Securely insert the Ethernet cable from your cable or DSL modem into the Internet port (B) on the WGT634U. Broadband modem

Device Installer User Guide

Introduction 1-1 Installing FAS 500 Asset Accounting the First Time 2-1 Installing FAS 500 Asset Accounting: Upgrading from a Prior Version 3-1

LEN s.r.l. Via S. Andrea di Rovereto 33 c.s CHIAVARI (GE) Tel Fax mailto: len@len.it url: http//

VM-8 USB Desktop Audio Device Installation Guide

TFA. KlimaLogg Pro. User Manual. Revision: 0.1

In-System Programmer USER MANUAL RN-ISP-UM RN-WIFLYCR-UM

AC-115 Compact Networked Single Door Controller. Installation and User Manual

Installing Windows XP Professional

OWNERS MANUAL. Status Monitor. for Windows 95, 98, ME, NT 4, 2000 & XP. SIGNALCRAFTERS TECH, INC.

Transcription:

Mobile Device Power Monitor Manual Distributed By: Monsoon Solutions, Inc. 2405 140 th Avenue NE Suite A115 Bellevue, Washington 98005 (425) 378-8081 www.msoon.com

Table of Contents Mobile Device Power Monitor Manual... 0 Revision History... 2 Introduction... 3 Hardware and Software Requirements for the Development Workstation... 5 Installing the Software and Connecting the Hardware... 6 Obtaining the Software for the Power Tool... 6 Connecting the Mobile Device Power Monitor Hardware... 7 Connecting the Mobile Device Power Monitor to a Device... 9 Using the Power Tool Software... 10 Checking the Software Revision of the Power Monitor... 11 Powering-up and Powering-down a Mobile Device... 12 Over-Current Error from the Main Power Supply... 13 Protecting the Main Power Supply from an Over-Current Error... 14 The Legend Dialog Box... 15 Sampling Data... 16 Markers... 16 Statistics... 17 Zoom... 18 USB Pass-Through... 19 USB Pass-Through: Modes... 19 Measuring USB Power... 21 Using USB Markers... 21 Auxiliary Port (Aux)... 22 Data Importing Features of the Power Monitor... 23 Data Exporting Features of the Power Monitor... 24 Functional Description of the Mobile Device Power Monitor... 25 APPENDIX:... 26 Electrical Specifications of the Mobile Device Power Monitor... 26 Main Channel... 26 USB Channel... 27 Auxiliary Channel... 28 Power Monitor Data and Control Protocol... 29 Command Line Operation of the Power Monitor... 29 Power Monitor Exit Codes... 33 PT4 file format... 33 1

Document Revision History Date Released Revision Number Notes May 2007 1.0 Initial release November 1, 2007 1.1 Updated features and added PT4 formats January 16, 2008 1.2 Updated path for Power Monitor Install directory July 15, 2008 1.3 Updated and added features November 9, 2009 1.4 Corrected web site links 2

Introduction The Power Tool software and the Mobile Device Power Monitor hardware provide a robust power measurement solution for Windows Mobile powered devices. The Power Tool software and the Mobile Device Power Monitor hardware can analyze the power on any device that uses a single lithium (Li) battery. Electrical engineers and software developers can utilize the Power Tool software and the Mobile Device Power Monitor hardware to optimize the design and analyze the performance of their Windows Mobile powered devices. Figure 1: Graphical user interface (GUI) for the Power Tool 3

4 Figure 2: Mobile Device Power Monitor hardware

Hardware and Software Requirements for the Development Workstation A dedicated workstation is required to be used with the Mobile Device Power Monitor to achieve the optimal performance and results. Microsoft Windows XP SP2, Windows Vista and Windows 7 is supported 1 GHz 32-bit (x86) or 64-bit (x64) processor 1 GB of system memory 40 GB hard drive with at least 15 GB of available space Full Speed USB 1.1/USB 2.0 integrated chipset or PCI/PCI Express add in card. USB Hubs should not be used with the Mobile Device Power Monitor 5

Installing the Power Monitor Software and Connecting the Hardware Obtaining the Software for the Power Tool To obtain the latest software version for the Mobile Device Power Monitor hardware 1. Go to http://www.msoon.com/register/download/, then click on the PowerMonitor Software link and download PowerTool_4.x.x.zip. Uninstall any previous version of the Power Monitor Software. 2. Create a new folder on the development workstation called PowerTool under the root directory (C:\). 3. Copy PowerTool.zip to the development workstation. 4. Extract the contents of PowerTool.zip to the C:\PowerTool folder. 5. Run PMSetup.msi 6. Follow the on screen prompts to Install the Power Tool Software 6

Figure 3: Installation. Connecting the Mobile Device Power Monitor Hardware To connect the Mobile Device Power Monitor hardware 1. Be sure that the power switch on the front of the Mobile Device Power Monitor hardware is not engaged. The hardware should not be powered-up. The power switch should be in the outward position, not the inward position. 2. Connect the 6 volts (V) of direct current (DC) and 5 ampere (A) power supply to the Mobile Device Power Monitor hardware. 3. Connect the 6 VDC and 5 A power supply to an alternating current (AC) power supply. 4. On a development workstation that is compliant with Full-Speed USB 2.0, connect a USB cable to the USB connector on the back of the Mobile Device Power Monitor hardware, and connect the other end of the USB cable to the development workstation. Figure 4: Back view: Power connector and USB connector 5. Turn on the Mobile Device Power Monitor hardware by engaging the power button on the front. The internal fan will briefly power-up and then power-down. Initially, the power light-emitting diode (LED) is orange, and then it turns green. The green LED is connected directly to the internal power of the Mobile Device Power Monitor. 7

Figure 5: Front view: Engaged power button and powered-up green LED. Installing the Power Monitor driver on a workstation 1. After running the setup program power up the Mobile Device Power Monitor and if the Power Monitor is being installed for the first time on the workstation, the Found New Hardware Wizard will launch. 2. On the Found New Hardware Wizard, do not choose to have the device drivers installed automatically, choose No, not this time and then select Next. 3. On the next prompt of the Found New Hardware Wizard, choose Install from a list or specific location (Advanced), and then select Next. 4. On the next prompt of the Found New Hardware Wizard, choose Don t search. I will choose the driver to install and then select Next. 5. On the Hardware Type page, choose Show All Devices, and then select Next 6. On the next prompt, choose Have Disk. 7. From the Install from Disk window, choose the Browse button, and navigate to the folder where the extracted contents of PowerTool.zip were saved. 8. Select the corresponding Operating System folder in C:\Program Files\Monsoon Solutions, INC\, select the Mchpcdc.inf file, and select Open. 9. Choose OK 10. From the Found New Hardware Wizard, choose Next 11. If a warning is received about an unsigned driver, select Continue Anyway 12. In the Found New Hardware Wizard, select Finish. After installing the driver choose Finish. The Power Tool software is installed. 8

Connecting the Mobile Device Power Monitor to a Device It can take 30 minutes or longer to configure a good test connection. A device that can measure voltage and resistance, such as a voltmeter/ohmmeter will be needed. Note Wear safety goggles at all times while working with exposed battery terminals and wiring. ************************************************************** Connecting the Mobile Device Power Monitor to a device to collect current measurements can be complicated and dangerous. Be sure that the area where power measurements are being conducted is protected from fire danger, do not have flammable items nearby. These measurements are at your own risk, and these procedures are not guaranteed to prevent damage or injury ************************************************************** Note There is no way to guarantee a proper connection. When attaching the power measurement hardware to a device with a lithium battery, there is always a risk of damaging the device, or causing the device to heat-up, generate smoke, or catch fire. While this is unlikely, be extremely careful, and if anything gets hot, immediately remove the battery and the power source. The following guide details and outlines how to prepare the device to connect to the Mobile Device Power Monitor. http://www.msoon.com/labequipment/powermonitor/downloads/quickstartguide.pdf 9

Using the Power Tool Software After connecting the device, power up the Mobile Device Power Monitor and run the Power Tool software (PowerTool.exe). The software should connect to the Mobile Device Power Monitor, and display the user interface (UI). Figure 6: Power Tool software UI after connecting to a device 10

Checking the Software Revision of the Power Monitor The revisions of the hardware (HW ver), firmware (FW ver), and software (SW ver) should be compatible for consistent and repeatable results and performance. If the Mobile Device Power Monitor software is updated, the firmware will need to be confirmed for compatibility. The Mobile Device Power Monitor will prompt the user to indicate that a new firmware is required to run this revision of software. If this occurs, then the firmware (FW ver) will need to be updated on the Mobile Device Power Monitor. Please follow the instructions on updating the Mobile Device Power Monitor at the following location: http://www.msoon.com/register/download The following table describes the various revision numbers that are displayed in the UI. Field HW rev FW ver Prot ver SW ver Description Power Monitor hardware revision Power Monitor firmware version Version of protocol specification Power Tool UI version HW rev SW ver Firmware Version B, C, D 3.0.4 12 B, C, D 4.0.2, 4.0.1 17, 18 B, C, D 4.0.3 19 To make sure the correct software is installed, check the revision fields in the UI. Figure 7 below shows the area of the UI that displays the software revision. Figure 7: Revision fields shown in the Power Tool UI. 11

Powering-up and Powering-down a Mobile Device To power-up the device, first set the Vout voltage. The voltage can be set from 2.1 V to 4.5 V in.01 V increments. The maximum voltage of a lithium battery is usually 4.2 V, so set the Vout voltage somewhere between 3.3 V and 4.2 V. To enable the power, click the Vout Enable button, to disable the power, click the Vout Disable button. Figure 9: below shows the location of the Vout Enable, which toggles when it is clicked to the Vout Disable button. Figure 8: Vout Enable and Vout Disable button. The voltage at the red and black terminals is never exactly at the programmed voltage. This is because there is an internal 0.056 Ω sense resistor in series with the regulator. For example, if the device is drawing 1 A when Vout equals 3 V, expect to see (3-1*.056) = 2.944 V. Figure 10: below shows this sense resistor in series with the regulator, in relation to the red and black terminals. Figure 9: Sense resistor in series with the regulator, in relation to the red and black terminals. There is resistance in the wiring that can lower the voltage at the device. The resistance of the wiring plus the sense resistor is similar to the resistance of the lithium battery in the device; batteries are usually about 0.12 Ω. 12

The resistance of 20 gauge wire is 0.012 Ω/ft, so if the cables are 20 gauge, and 1 foot in length, that adds another 0.024 Ω, in addition to the contact resistance. Figure 10: Vout LED indicator If the power-up is successful, the green Vout LED indicator in Figure 10 above will powerup. This LED is connected directly to Vout, so the light will dim slightly if the voltage is lowered. If this LED does not power-up, then Vout did not power-up properly, so there are other problems. Over-Current Error from the Main Power Supply Sometimes an over-current error occurs when powering-up. When an over-current error occurs, the amber LED powers-up, and the green LED for Vout powers-down. An over-current error can happen when the: Device is attached backwards. Device is attached incorrectly. Device has a lot of capacitance, a very high in-rush current. Device has an unusually high run current. 13

Figure 11: Amber LED indicator for over-current. Note Be sure to check for a backwards connection before overriding the over-current limits. Protecting the Main Power Supply from an Over-Current Error The main power regulator can source 3.0 A of continuous current and 4.5 A of peak current. In order to protect incorrectly connected devices from damage, a carefully controlled power up sequence is used. The default sequence is as follows: 1. Power up with no current limit for 20 milliseconds 2. Run for 1 second with the current limit set to 500 ma 3. Run continuously with the current limit set to 4.6 A The parameters in the dialog box below are used for device under test power on. 1. Power up time This specifies the power up time when no current limit is applied to the Mobile Device Power Monitor. 2. Power up Current Limit If the Power Up Time is set to default, this parameter will allow the selected current to be supplied to the device for 1 second. 3. Run time Current Limit- This parameter specifies what the maximum current that can be sourced by the Mobile Device Power Monitor while its sampling or in Run mode. If a device does not power up with this default profile, the profile may be adjusted. Click on Parameters in the UI and the dialog box shown below in Figure 12: 14

Figure 12: Dialog box for over-current. The Legend Dialog Box The Legend dialog box controls which channels are displayed, and what kind of data is shown in the graph. Figure 13: Dialog box for the display Legend. 15

Sampling Data To begin sampling data, click the Run button. To stop sampling, press the Stop button. Figure 14 below shows the Run button, which toggles to the Stop button once it is clicked. Figure 14: Run and Stop toggle button. The calibration indicator indicates that the unit has a valid and unexpired calibration date and functioning auto-calibration hardware. Figure 15 below shows the calibration indicator. Figure 15: Calibration indicator. The serial number displayed in the UI, and shown in Figure 16 below, is the serial number of the Mobile Device Power Monitor hardware. It is programmed to a unique number in the factory. If the firmware is upgraded improperly in the field, the factory serial number may be incorrect. If this happens, it is advisable to contact Monsoon Solutions, Inc., because the factory calibration settings may have also been lost. Figure 16: Serial number. Markers Markers enable users to measure the delta (Time and selected data channel) between two points on the power monitor output data plot. 1. Drag the red and blue arrows (indicator) to the desired position on the power monitor output data plot 2.The Delta will be displayed under the Selection Statistics section. 16

Figure 17: Capture statistics. Statistics Battery life, current, and power statistics for the Main channel are visible in the STATS area of the UI. The user first sets the battery capacity and then runs the Power Monitor. If there is no region selected, the statistics will be associated with the entire run as in Figure 18 below. Figure 18: Capture statistics. If a smaller area is selected with the mouse on the graph, then the statistics are computed only for the selected area, as shown in Figure 19 below. 17

Figure 19: Selection Statistics. Zoom Selecting a certain area with the mouse on the graph and by either double clicking or selecting the scroll mechanism on a mouse (if one is available) will zoom in on the selected area. The statistics are computed only for the selected area, as shown in Figure 20 below. Figure 20: Zoom capabilities. 18

USB Pass-Through USB Pass-Through: Modes In addition to the Main channel, three other channels are sampled at the same time. One of these is used for monitoring USB power. To use the USB Pass-Through mode, connect the USB device to the Mobile Device Power Monitor, and connect a USB cable from the Mobile Device Power Monitor to the development workstation as shown in Figure 20 below. Figure 21: USB pass-through connection 19

To download code or data when testing a device, USB can be used to connect the device to the Mobile Device Power Monitor. However, when connecting to USB, USB charges the device, which disturbs the current measurements. To remedy this, the Mobile Device Power Monitor has an Auto USB passthrough mode. Auto USB passthrough mode is useful for testing, because in Auto USB passthrough mode, the USB pass-through is disconnected whenever sampling starts. After sampling has completed, USB is reconnected automatically so that test data can be loaded to the device. The Auto USB passthrough mode setting is shown in below in Figure 22. Figure 22: USB pass-through control In addition to Auto USB passthrough mode, there are two other USB modes: On: Setting the USB passthrough mode to On enables the USB connection and records the current flowing through the USB connector on the front of the Mobile Device Power Monitor. Off: Setting the USB passthrough mode to Off disables the USB connection. 20

Measuring USB Power The USB connection can be used to measure the power and current on any functioning attached USB device. For example, the current and power of a mouse can be monitored as it is used by selecting USB in the Legend dialog box, and setting the USB passthrough mode to On in the Parameters dialog box. Figure 23: Testing a USB peripheral with the Mobile Device Power Monitor Using USB Markers If synchronizing an external event is required, the Power Tool software can support that feature over USB with Markers. To use the Markers functionality: 1. Set the USB passthrough mode to Off. 2. Select the Markers checkbox in the Power Monitor UI. 3. Connect transistor-transistor logic (TTL) signals from the device to the USB A-connector on the front of the Mobile Device Power Monitor. An easy way to do this is to use an old USB cable and cut it. Signals that are driven on the data lines will be shown as highs (1s) or lows (0s) on the display. There are wide blue and red lines for the Markers. 21

Auxiliary Port (Aux) The Aux port is connected to the bayonet Neill-Concelman (BNC) connector on the front of the Mobile Device Power Monitor. It allows for simultaneous measurement of the current going through an external power supply. For example, suppose the LT1129 shown below in Figure 24 sits on a mobile device PCB and the current supplied to the 3.3 V supply needs to be measured. Figure 24: Schematic of the Aux port In this situation, to measure the current supplied to the 3.3 V power supply, connect a 50 Ω coaxial cable to a 0.1 Ω sense resistor and connect that coaxial cable to the Mobile Device Power Monitor. When connecting a coaxial cable: Connect the outside of the BNC connector to the high side of the sense resistor. Connect the inside of the BNC connector to the low side of the sense resistor. In Figure 25 below, the mobile device is powered by the Mobile Device Power Monitor and its processor core power is being monitored on the Aux port with a 0.1 Ω resistor. In the Mobile Device Power Monitor, the data for the main supply and the core supply can be displayed and analyzed simultaneously. 22

Figure 25: Example connection to the Aux port Data Importing Features of the Power Monitor The data importing features of the Power Monitor allows the user to import data from the following data formats: The Power Tool software can import the file formats shown in the following table. File format.pt3 Description Binary data in exactly the same format that the Power Monitor creates, this is compatible with the current version of the protocol specification. All of these formats, when saved, are saved at the maximum time resolution, regardless of the Capture Settings. The Mobile Power Monitor will convert the imported file to a.pt4 format before displaying the output to the display box. 23

Figure 26: Importing PT3 file extension Data Exporting Features of the Power Monitor The data exporting features of the Power Monitor allows the user to save data for the following: The entire power measurement run If any data is selected with the mouse, the selected data is exported If no data is selected with the mouse, then the data that is displayed The Power Tool software can export to the file formats shown in the following table. File format.pt4.csv.dcf Description Binary data in exactly the same format that the Power Monitor creates, this is compatible with the current version of the protocol specification. Please see the APPENDIX for a more detailed breakdown of the PT4 format Comma-separate values. A common format that can be used to import into spreadsheet software. The Power Monitor saves only what is recorded in the current trace. A common format for exporting test data. All of these formats, when saved, are saved at the maximum time resolution, regardless of the Capture Settings. 24

Functional Description of the Mobile Device Power Monitor To measure the current accurately, a dual range, self-calibrating, integrating system is used. Each channel has two current ranges with a 16-bit analog-to-digital converter (ADC), one with a high-resolution range, and the other with a low-resolution range. Software continuously calibrates each of these and selects the proper range during measurement. The dual range scheme works because mobile devices are usually in standby mode and drawing only a few millamps of current, or they are running above 100 milliamps. The Mobile Device Power Monitor must be very accurate when the current is low, but may be less accurate as the current increases. Each sample is integrated over its 200-microsecond sample period so that even a brief high-current pulse is captures. Depending on system capacitance and other factors, the fastest transient pulses are around 20 microseconds. The integrator sums up these fast pulses so that an accurate assessment of the average current is maintained. The unit is self-calibrating. One cycle out of every 1000 cycles is used to run either a zero-current calibration or a reference-current calibration. Software uses these measurements to null out the offset and gain errors in the system. Because this is done automatically, it compensates for slow temperature changes during the measurement run. The only part not included in the self-calibration is the sense resistor. These resistors are calibrated at the factory and the calibration values may be adjusted and saved by engineers using the Parameters dialog box. The Power Monitor has an overflow buffer that can hold six packets of 128 bytes each. During transfer, if the development workstation cannot read the data fast enough then this buffer will begin to fill up, and samples may be lost. The received data is concatenated so the line appears continuous. To account for the lost samples, the protocol contains a 16-bit counter that tracks the number of lost samples. The running total of lost samples is displayed in the UI, as shown in Figure 27 below. Figure 27: Counter for dropped samples and dropped connections Because the dropped samples are less than one percent of a run, the error is minimal. Usually this loss of data is less than 0.1 percent. However, sometimes on long runs or on loaded systems the dropped sample count can exceed 65,000. When this occurs, the Power Tool lost communication for more than 10 seconds. A count of dropped connections is maintained in the UI, as shown above in Figure 26. Both of these counts are reset to zero when a run is restarted. These counts are useful to determine how stable the connection is. If the dropped packets are greater than one percent of all samples, or if there are more than one or two dropped connections per hour, then it is likely that the development workstation has other applications running that are causing delays. Closing these applications or installing the Power Tool software on a clean machine should solve these issues and reduce the dropped samples and packets. 25

APPENDIX: Electrical Specifications of the Mobile Device Power Monitor Main Channel Component Minimum Maximum Output voltage range 2.1 V 4.5 V Continuous current Peak current 3.0 A 4.5 A Integrator cutoff frequency 300 khz Fine current scale - range 40 ma Fine current scale - resolution Fine current scale - accuracy Coarse current scale - range Coarse current scale - resolution Coarse current scale - accuracy Programmable current limit range Programmable current limit accuracy Positive temperature coefficient (PTC) hold limit at 6 V of direct current input (DCIN) 2.86 ua +/- 1% or +/- 50 ua (whichever is greater) 30 ma 4.5A 286 ua +/- 1% or +/- 1 ma (whichever is greater) 8 ma 8 A (0.7) * (current limit) (1.4) * (current limit) 3 A PTC trip limit at 6 V DCIN Not applicable 6 A Fan turn on temperature Fan turn off temperature 38 C 33 C Thermal limit shutdown 50 C 26

USB Channel Component Min Max Input voltage range 2.1 V 5.4 V Continuous current Peak current 1.0 A 4.5 A Integrator cutoff frequency 300 khz Fine current scale - range 40 ma Fine current scale - resolution Fine current scale - accuracy Coarse current scale - range Coarse current scale - resolution Coarse current scale - accuracy VBUS PTC current hold limit VBUS PTC current trip limit 2.86 ua +/- 1% or +/- 50 ua (whichever is greater) 30 ma 4.5 A 286 ua +/- 1% or +/- 1 ma (whichever is greater) 0.52 A 0.85 A 1.04 A 1.7 A VBUS capacitance to GND 22uF +/- 20% 27

Auxiliary Channel Component Min Max Input voltage range 1.0 V 5.0 V Differential input voltage 0.1 V Integrator cutoff frequency 300 khz Fine current scale - range 0 ma 12 ma Fine current scale - resolution Fine current scale - accuracy Coarse current scale - range Coarse current scale resolution Coarse current scale - accuracy 2.58 ua +/- 1% or +/- 50 ua (whichever is greater) 10 ma 500 ma @ Vin = 1V 100 ua +/- 1% or +/-1mA (whichever is greater) 1 A @ Vin = 1.8 V Aux + side capacitance 22uF+/- 20% Aux + side input current Not applicable 1% of 0.1 Ω resistor current 28

Power Monitor Data and Control Protocol All control of the Mobile Device Power Monitor happens on the development workstation. The development workstation issues commands and the Mobile Device Power Monitor responds to the commands by completing the operation and sending back a Status packet. The Status packet contains the entire current state of the machine, except when sampling. When sampling, the Power Tool sends a Start packet to the Mobile Device Power Monitor, and then the Power Monitor sends sample packets continuously back to the Power Tool. When sampling is to be stopped, the Power Tool UI sends a Stop packet. The Mobile Device Power Monitor stops sampling and responds with a Status packet. Generally, when the Mobile Device Power Monitor is not sampling, the Power Tool requests periodic status packets in order to refresh its display. Command Line Operation of the Power Monitor This applies to PowerTool version 4.0.1. Version 4.0.1 includes a console application, PowerToolCmd, for better execution in batch files/scripts. The command line format is: PowerToolCmd [filename] [switch [switch ]] where filename is the optional name of a PT4 file to be loaded into the buffer. Switches begin with - (hyphen) or / (forward slash). The switches are as follows, and are case-insensitive: Switch /LOADFILE=file /NOGUI /ISTART /TRIGGER=string /TESTMINPOWER=value /TESTMAXPOWER=value /SAVEFILE=file Description Same as filename above Console mode Sampling starts immediately See section on trigger codes Return success if average power (mw) is >= value Return success if average power (mw) is <= value Save capture buffer to this file /CAPTUREDATAMASK=value See section on capture data mask /NOHARDWARE /SERIAL=value /KEEPPOWER /VOUT=value View-only mode; don t connect to a device Connect to a specific device (Default: first device found) Leave Vout enabled on exit Vout voltage value (Default: 3.70V) 29

/TEMPDIR=path /USBPASSTHROUGH=mode /USB=mode /NOEXITWAIT /EXITCODES Override temporary directory (Default: %My Documents%\PowerTool) USB passthrough mode: AUTO, ON, or OFF (Default: AUTO) Program exits without waiting for Press any key Lists program exit codes /?, /H, /HELP Lists command-line switches Trigger codes The following is the syntax of a trigger code: A Bn Cqrn D[An Bn]T[X]A Bn Cn Dnt Eqrn[An] The capital letters are literals. n represents a numeric quantity (in decimal), and q, r and t are place-holders for code letters, explained below. At the highest level, the string breaks down into: <start_code><optional_start_qualifier>t<optional_export_flag><stop_code><o ptional_stop_qualifier> The following table lists the possible values of <start_code>: Code Meaning A Bn Cqrn D Manual start Start after n markers Start when quantity q has relationship r with the number n (see below) Start immediately The possible values of <optional_start_qualifier> (when present) are: Code Meaning An Bn Delay capture n samples after trigger Capture n samples before trigger If <optional_export_flag> is present, the value X indicates that a DCF file should be automatically exported when sampling stops. 30

The following table lists the possible values of <stop_code>: Code Meaning A Bn Cn Dnt Eqrn Manual stop Stop after n markers Stop after n samples Stop after n time units of type t (see t below) Stop when quantity q has relationship r with the number n (see below) The possible values of <optional_stop_qualifier> (when present) are: Code Meaning An Capture n samples after trigger The possible values for the quantity code q are: Code Meaning A B C D E F G H I Min power Avg power Max power Min current Avg current Max current Min Vout Avg Vout Max Vout The possible values of relationship code r are as follows: Code Meaning A >= B <= C D Rises above Falls below 31

The possible values of the time-unit code t are as follows: Code Meaning A B C Seconds (s) Milliseconds (ms) Microseconds (us) For example, a trigger code CBA300A500TXC20000A500 would be interpreted as follows: Code Meaning CBA300 Start capture after average power falls below 300 mw A500 T X C20000 A500 Delay capture 500 samples after trigger Fixed delimiter Auto-export DCF file after stop Stop capture after 20000 samples Capture 500 samples after trigger The Trigger Settings dialog has a feature that shows the resulting trigger code that corresponds to the dialog settings. Capture Data Mask The capture data mask is a 16-bit quantity that specifies the data to be captured. It can be expressed either in decimal or hexadecimal (using C-style 0x notation), but it is most naturally expressed in hex, since it is a combination of discrete bit values. The mask indicates which of the three data channels are to be captured: Main, USB, or AUX. Each channel is represented by one bit in the mask. The mask is thus the bitwise-or of the channel(s) to be captured. The bit values for the channels are as follows: Mask Channel 0x1000 Main 0x2000 USB 0x4000 Aux The default value is 0x1777 (the low-order twelve bits are no longer significant) 32

Power Monitor Exit Codes When the Power Tool is closed, it provides an exit code that indicates why the software was closed. The exit codes include but are not limited to: Test complete OK Unable to find hardware Hardware calibration failed Disk space check fail Capture file write error Capture hardware error Capture buffer overrun PT4 file format A PT4 file consists of three main sections: A fixed-length header (212 bytes), at file offset 0 A fixed-length Status packet (60 bytes for Protocol 16), at file offset 272 Multiple occurrences of variable-length sample data, starting at file offset 1024. All samples are recorded at a frequency of 5 khz. Each sample is an n-tuple, the content of which is selectable at run-time. Header section The first 212 bytes are the header, as follows: Name Description C# data type Bytes File offset headsize Header size int 4 0 Name Power Tool string 20 4 batterysize mah int 4 24 capturedate System.DateTime binary long 8 28 serialnumber Power Monitor serial number string 20 36 calibrationstatus OK (0) or FAILED (1) CalibrationStatu s enum 4 56 voutsetting Typical (0), Low (1), High (2), or Custom (3) VoutSetting enum 4 60 voutvalue Main voltage output float 4 64 hardwarerate Hz int 4 68 softwarerate Hz float 4 72 powerfield Data selection for Power SelectField enum 4 76 currentfield Data selection for Current SelectField enum 4 80 33

Name Description C# data type Bytes File offset voltagefield Data selection for Voltage SelectField enum 4 84 capturesetting Trigger specification string 30 88 swversion Power Tool version string 10 118 runmode NoGUI (0) or GUI (1) RunMode enum 4 128 exitcode Application exit code int 4 132 totalcount Count of data samples long 8 136 statusoffset File offset of Status Packet ushort 2 144 statussize Size (bytes) of Status Packet ushort 2 146 sampleoffset File offset of Sample data ushort 2 148 samplesize Size (bytes) of each individual sample ushort 2 150 initialmainvoltage See Table 6. ushort 2 152 initialusbvoltage See Table 6. ushort 2 154 initialauxvoltage See Table 6. ushort 2 156 capturedatamask Mask indicating which data is being captured (see Table 3) ushort 2 158 samplecount Sample count ulong 8 160 missingcount Count of missing samples ulong 8 168 summainvoltage Sum of main output voltage (V). Divide by (samplecount missingcount) for Average. float 4 176 summaincurrent Sum of main current (ma) float 4 180 summainpower Sum of main power (mw) float 4 184 sumusbvoltage Sum of USB voltage (V) float 4 188 sumusbcurrent Sum of USB current (ma) float 4 192 sumusbpower Sum of USB power (mw) float 4 196 sumauxvoltage Sum of Aux voltage (V) float 4 200 sumauxcurrent Sum of Aux current (ma) float 4 204 sumauxpower Sum of Aux power (mw) float 4 208 Total length: 212 Table 1: Header layout 34 All strings are length-prefixed (one-byte), and are blank-padded to their fixed length, suitable for reading with BinaryReader.ReadString(). The lengths listed include the length byte.

The enumerations are as follows: Enumeration Definition Description CalibrationStatus OK=0 Failed=1 Status of calibration VoutSetting Typical=0 (3.7 V) Low=1 (3.35 V) High=2 (4.2 V) Custom=3 Type out Vout setting SelectField RunMode None=0x00 Avg=0x01 Min=0x02 Max=0x04 Main=0x08 Usb=0x10 Aux=0x20 Marker=0x40 NoGUI=0 GUI=1 Masks describing which channel (Main,Aux1,Aux2,Marker) and statistic (Avg,Min,Max) are being recorded Whether or not PowerTool was running in GUI mode Table 2: Header enumerations The capturedatamask can be interpreted with the following bit masks: Channel Main Current Usb Current Aux Current Marker Voltage Mask 0x1000 0x2000 0x4000 0x8000 0x0700 Table 3: Channel selection masks For example, if the bitwise-boolean expression (capturedatamask & x02000) is non-zero, then current data for the Aux1 channel is being recorded in the file. If (capturedatamask & 0x0700) is non-zero or (capturedatamask & 0x8000) is non-zero, then voltages and markers are being recorded in the file. The section on the sample data will explain this further. The file is padded with zeros until offset 272 (144+128), where a Status packet from the Power Monitor hardware is recorded, as follows: Name Description C# data type Bytes File offset Packet offset packetlength Length-1 of packet (59 byte 1 272 0 35

for Protocol 16, but may expand in later protocols) packettype 0x10 for Status packet byte 1 273 1 firmwareversion Firmware version byte 1 274 2 protocolversion Protocol version byte 1 275 3 mainfinecurrent Main current, fine scale short (signed) 2 276 4 usbfinecurrent Usb current, fine scale short (signed) 2 278 6 auxfinecurrent Aux current, fine scale short (signed) 2 280 8 voltage1 maincoarsecurrent usbcoarsecurrent auxcoarsecurrent voltage2 Voltage of selected channel. See Table 6. Main current, coarse scale Usb current, coarse scale Aux current, coarse scale Voltage of selected channel. See Table 6. ushort 2 282 10 short (signed) 2 284 12 short (signed) 2 286 14 short (signed) 2 288 16 ushort 2 290 18 outputvoltagesetting Volts = 2.0 + outputvoltagesetting * 0.01 byte 1 292 20 temperature Degrees Celsius byte 1 293 21 status Bit flags (low to high): unitnotatvoltage cannotpoweroutput checksumerror followslastsamplepacke t responsetostoppacket badpacketreceived byte 1 294 22 reserved Unused byte 1 295 23 leds mainfineresistor Bit flags (low to high): disablebuttonpressed errorledon fanmotoron voltageisaux Resistor offset (ohms = 0.05 + offset * 0.0001) byte 1 296 24 sbyte (signed) 1 297 25 serialnumber Serial number ushort 2 298 26 samplerate khz byte 1 300 28 36 daccallow DAC input for 2.5 V output ushort 2 301 29

daccalhigh powerupcurrentlimit runtimecurrentlimit DAC input for 4.096 V output Max current during power-up (amps = 8 * ((1- limit)/1023) Max current during sample run (amps = 8 * ((1-limit)/1023) ushort 2 303 31 ushort 2 305 33 ushort 2 307 35 poweruptime ms byte 1 309 37 usbfineresistor auxfineresistor Resistor offset (ohms = 0.05 + offset * 0.0001) Resistor offset (ohms = 0.10 + offset * 0.0001) sybte (signed) 1 310 38 sbyte (signed) 1 311 39 initialusbvoltage See Table 6. ushort 2 312 40 initialauxvoltage See Table 6. ushort 2 314 42 hardwarerevision Hardware revision level (1=A, 2=B, 3=C, etc.) byte 1 312 44 temperaturelimit Degrees Celsius byte 1 313 45 usbpassthroughmode 0=off, 1=on, 2=auto byte 1 314 46 maincoarseresistor Resistor offset (ohms = 0.05 + offset * 0.0001) sbyte (signed) 1 315 47 usbcoarseresistor Resistor offset (ohms = 0.05 + offset * 0.0001) sbyte (signed) 1 316 48 auxcoarseresistor Resistor offset (ohms = 0.10 + offset * 0.0001) sbyte (signed) 1 317 49 defmainfineresistor Default resistor offset (ohms = 0.05 + offset * 0.0001) sbyte (signed) 1 318 50 defusbfineresistor Default resistor offset (ohms = 0.05 + offset * 0.0001) sbyte (signed) 1 319 51 defauxfineresistor Default resistor offset (ohms = 0.10 + offset * 0.0001) sbyte (signed) 1 320 52 defmaincoarseresistor Default resistor offset (ohms = 0.05 + offset * 0.0001) sbyte (signed) 1 321 53 37 defusbcoarseresistor Default resistor offset (ohms = 0.05 + offset * sbyte (signed) 1 322 54

defauxcoarseresistor eventcode eventdata 0.0001) Default resistor offset (ohms = 0.10 + offset * 0.0001) Event code: 0 = none 1 = USB connection lost 2 = too many dropped samples 3 = reset requested by host Supplementary event data (interpretation depends on eventcode) sbyte (signed) 1 323 55 byte 1 324 56 ushort 2 325 57 checksum Checksum byte byte 1 327 59 Total length 60 Table 4: Status packet layout The file is then padded with zeros up until file offset 1024, where the sample data begins. Interpreting the Sample Data Beginning at offset 1024, sample data is recorded at a rate indicated in the Status Packet. Each sample consists of up to four two-byte quantities, three of which are optional, depending on the capturedatamask field at offset 158. The total count of samples is given by the totalcount field of the header. The four quantities are the current measurements for the Main, Usb, and/or Aux channels, and a voltage for the channel indicated by the voltageisaux bit of the leds field of the Status packet (file offset 296). If the bit is set, the voltage is the Aux channel voltage, otherwise it is the Main channel voltage. The current measurements can each be either on the Fine or Coarse scale, independently of each other, and the scale can change from one sample to the next. For fine scale measurements each tick represents 1 ua (microamp), whereas for the coarse scale, each tick represents 250 ua. A coarse measurement always has the low-order bit set. For fine measurements, the loworder bit is always clear. After determining the scale, the low-order bit should be cleared before calculating the current. For voltage, the two low-order bits are the two marker channels. The lowest bit is Marker 0, the next bit is Marker 1. These bits should be masked off before calculating voltage. The layout of each sample is as follows: 38

Field C# Data Type Bytes Tick value Present if: Main Current short (signed) 2 1 ua (fine) 250 ua (coarse) (capturedatamask & 0x1000)!= 0 USB Current short (signed) 2 1 ua (fine) 250 ua (coarse) (capturedatamask & 0x2000)!= 0 Aux Current short (signed) 2 1 ua (fine) 250 ua (coarse) (capturedatamask & 0x4000)!= 0 Main or Aux Voltage, and Markers ushort (unsigned) 2 See Table 6 Always Table 5: Sample layout The following table lists the value of each voltage tick in microvolts (uv), depending on the hardware revision level and the channel: Hardware Revision Main USB Aux A 62.5 uv / tick 62.5 uv / tick 62.5 uv / tick B 125 uv / tick 125 uv / tick 62.5 uv / tick C or later 125 uv / tick 125 uv / tick 125 uv / tick Table 6: Voltage units Missing data values In order to account for the time gaps caused by calibration cycles, delays in communication between the power monitor and the PC host, or other causes, the PowerTool software inserts missing data indicators. For current measurements, missing data is recorded as 0x8001, while for voltage the missing value is 0xFFFF. Should a missing value be encountered within a given sample, the entire sample should be treated as missing, but the 200 us of time for the sample should be accounted for. Example C# program to process a PT4 file // ---------------------------------------------------- // This C# program reads and processes each sample in a // PT4 file sequentially, from the first sample to the // last. // // The name of the file to be processed is taken from 39

// the command line argument. // // Copyright (c) Monsoon Solutions, Inc. // All Rights Reserved. // ---------------------------------------------------- using System; using System.IO; using System.Diagnostics; namespace SyncTest public static class PT4 // fixed file offsets public const long headeroffset = 0; public const long statusoffset = 272; public const long sampleoffset = 1024; // bitmasks private const short coarsemask = 1; private const ushort marker0mask = 1; private const ushort marker1mask = 2; private const ushort markermask = marker0mask marker1mask; // missing data indicators const short missingrawcurrent = unchecked((short)0x8001); const ushort missingrawvoltage = 0xffff; // Enums for file header public enum CalibrationStatus : int OK, Failed public enum VoutSetting : int Typical, Low, High, Custom [FlagsAttribute] // bitwise-maskable public enum SelectField : int None = 0x00, 40

Avg = 0x01, Min = 0x02, Max = 0x04, Main = 0x08, Usb = 0x10, Aux = 0x20, Marker = 0x40, All = Avg Min Max public enum RunMode : int NoGUI, GUI [FlagsAttribute] // bitwise-maskable public enum CaptureMask : ushort chanmain = 0x1000, chanusb = 0x2000, chanaux = 0x4000, chanmarker = 0x8000, chanmask = 0xf000, // File header structure public struct Pt4Header public int headsize; public string name; public int batterysize; public DateTime capturedate; public string serialnumber; public CalibrationStatus calibrationstatus; public VoutSetting voutsetting; public float voutvalue; public int hardwarerate; public float softwarerate; // ignore public SelectField powerfield; public SelectField currentfield; public SelectField voltagefield; public string capturesetting; public string swversion; public RunMode runmode; 41

public int exitcode; public long totalcount; public ushort statusoffset; public ushort statussize; public ushort sampleoffset; public ushort samplesize; public ushort initialmainvoltage; public ushort initialusbvoltage; public ushort initialauxvoltage; public CaptureMask capturedatamask; public ulong samplecount; public ulong missingcount; public float avgmainvoltage; public float avgmaincurrent; public float avgmainpower; public float avgusbvoltage; public float avgusbcurrent; public float avgusbpower; public float avgauxvoltage; public float avgauxcurrent; public float avgauxpower; static public void ReadHeader(BinaryReader reader, ref Pt4Header header) // remember original position long oldpos = reader.basestream.position; // move to start of file reader.basestream.position = 0; // read file header header.headsize = reader.readint32(); header.name = reader.readstring().trim(); header.batterysize = reader.readint32(); header.capturedate = DateTime.FromBinary(reader.ReadInt64()); header.serialnumber = reader.readstring().trim(); header.calibrationstatus = (CalibrationStatus)reader.ReadInt32(); header.voutsetting = (VoutSetting)reader.ReadInt32(); header.voutvalue = reader.readsingle(); header.hardwarerate = reader.readint32(); 42

header.softwarerate = (float)header.hardwarerate; reader.readsingle(); // ignore software rate header.powerfield = (SelectField)reader.ReadInt32(); header.currentfield = (SelectField)reader.ReadInt32(); header.voltagefield = (SelectField)reader.ReadInt32(); header.capturesetting = reader.readstring().trim(); header.swversion = reader.readstring().trim(); header.runmode = (RunMode)reader.ReadInt32(); header.exitcode = reader.readint32(); header.totalcount = reader.readint64(); header.statusoffset = reader.readuint16(); header.statussize = reader.readuint16(); header.sampleoffset = reader.readuint16(); header.samplesize = reader.readuint16(); header.initialmainvoltage = reader.readuint16(); header.initialusbvoltage = reader.readuint16(); header.initialauxvoltage = reader.readuint16(); header.capturedatamask = (CaptureMask)reader.ReadUInt16(); header.samplecount = reader.readuint64(); header.missingcount = reader.readuint64(); ulong count = Math.Max(1, header.samplecount - header.missingcount); // convert sums to averages header.avgmainvoltage = reader.readsingle() / count; header.avgmaincurrent = reader.readsingle() / count; header.avgmainpower = reader.readsingle() / count; header.avgusbvoltage = reader.readsingle() / count; header.avgusbcurrent = reader.readsingle() / count; header.avgusbpower = reader.readsingle() / count; header.avgauxvoltage = reader.readsingle() / count; header.avgauxcurrent = reader.readsingle() / count; header.avgauxpower = reader.readsingle() / count; // restore original position reader.basestream.position = oldpos; // Enums for status packet public enum PacketType : byte set = 1, start, stop, status = 0x10, sample = 0x20 43

public struct Observation public short maincurrent; public short usbcurrent; public short auxcurrent; public ushort voltage; [FlagsAttribute] public enum PmStatus : byte unitnotatvoltage = 0x01, cannotpoweroutput = 0x02, checksumerror = 0x04, followslastsamplepacket = 0x08, responsetostoppacket = 0x10, responsetoresetcommand = 0x20, badpacketreceived = 0x40 [FlagsAttribute] public enum Leds : byte disablebuttonpressed = 0x01, errorledon = 0x02, fanmotoron = 0x04, voltageisaux = 0x08, public enum HardwareRev : byte reva = 1, revb, revc, revd public enum UsbPassthroughMode : byte off, on, auto, trigger, sync public enum EventCode : byte noevent = 0, 44

usbconnectionlost, toomanydroppedobservations, resetrequestedbyhost // Statuc packet structure public struct StatusPacket public byte packetlength; public PacketType packettype; public byte firmwareversion; public byte protocolversion; public Observation fineobs; public Observation coarseobs; public byte outputvoltagesetting; public sbyte temperature; public PmStatus pmstatus; public byte reserved; public Leds leds; public sbyte mainfineresistoroffset; public ushort serialnumber; public byte samplerate; public ushort daccallow; public ushort daccalhigh; public ushort powerupcurrentlimit; public ushort runtimecurrentlimit; public byte poweruptime; public sbyte usbfineresistoroffset; public sbyte auxfineresistoroffset; public ushort initialusbvoltage; public ushort initialauxvoltage; public HardwareRev hardwarerevision; public byte temperaturelimit; public UsbPassthroughMode usbpassthroughmode; public sbyte maincoarseresistoroffset; public sbyte usbcoarseresistoroffset; public sbyte auxcoarseresistoroffset; public sbyte factorymainfineresistoroffset; public sbyte factoryusbfineresistoroffset; public sbyte factoryauxfineresistoroffset; public sbyte factorymaincoarseresistoroffset; public sbyte factoryusbcoarseresistoroffset; public sbyte factoryauxcoarseresistoroffset; public EventCode eventcode; 45

public ushort eventdata; public byte checksum; static public void ReadStatusPacket(BinaryReader reader, ref StatusPacket status) // remember origibal position long oldpos = reader.basestream.position; // move to start of status packet reader.basestream.position = statusoffset; // read status packet status.packetlength = reader.readbyte(); status.packettype = (PacketType)reader.ReadByte(); Debug.Assert(status.packetType == PacketType.status); status.firmwareversion = reader.readbyte(); status.protocolversion = reader.readbyte(); Debug.Assert(status.protocolVersion >= 16); status.fineobs.maincurrent = reader.readint16(); status.fineobs.usbcurrent = reader.readint16(); status.fineobs.auxcurrent = reader.readint16(); status.fineobs.voltage = reader.readuint16(); status.coarseobs.maincurrent = reader.readint16(); status.coarseobs.usbcurrent = reader.readint16(); status.coarseobs.auxcurrent = reader.readint16(); status.coarseobs.voltage = reader.readuint16(); status.outputvoltagesetting = reader.readbyte(); status.temperature = reader.readsbyte(); status.pmstatus = (PmStatus)reader.ReadByte(); status.reserved = reader.readbyte(); status.leds = (Leds)reader.ReadByte(); status.mainfineresistoroffset = reader.readsbyte(); status.serialnumber = reader.readuint16(); status.samplerate = reader.readbyte(); status.daccallow = reader.readuint16(); status.daccalhigh = reader.readuint16(); status.powerupcurrentlimit = reader.readuint16(); status.runtimecurrentlimit = reader.readuint16(); status.poweruptime = reader.readbyte(); status.usbfineresistoroffset = reader.readsbyte(); status.auxfineresistoroffset = reader.readsbyte(); status.initialusbvoltage = reader.readuint16(); 46

status.initialauxvoltage = reader.readuint16(); status.hardwarerevision = (HardwareRev)reader.ReadByte(); status.temperaturelimit = reader.readbyte(); status.usbpassthroughmode = (UsbPassthroughMode)reader.ReadByte(); status.maincoarseresistoroffset = reader.readsbyte(); status.usbcoarseresistoroffset = reader.readsbyte(); status.auxcoarseresistoroffset = reader.readsbyte(); status.factorymainfineresistoroffset = reader.readsbyte(); status.factoryusbfineresistoroffset = reader.readsbyte(); status.factoryauxfineresistoroffset = reader.readsbyte(); status.factorymaincoarseresistoroffset = reader.readsbyte(); status.factoryusbcoarseresistoroffset = reader.readsbyte(); status.factoryauxcoarseresistoroffset = reader.readsbyte(); status.eventcode = (EventCode)reader.ReadByte(); status.eventdata = reader.readuint16(); status.checksum = reader.readbyte(); // restore original position reader.basestream.position = oldpos; static public long BytesPerSample(CaptureMask capturedatamask) long result = sizeof(ushort); // voltage always present if ((capturedatamask & CaptureMask.chanMain)!= 0) result += sizeof(short); if ((capturedatamask & CaptureMask.chanUsb)!= 0) result += sizeof(short); if ((capturedatamask & CaptureMask.chanAux)!= 0) result += sizeof(short); return result; static public long SamplePosition(long sampleindex, CaptureMask capturedatamask) 47

long result = sampleoffset + BytesPerSample(captureDataMask) * sampleindex; return result; static public long SamplePosition(double seconds, CaptureMask capturedatamask, ref StatusPacket statuspacket) seconds = Math.Max(0, seconds); long bytespersample = BytesPerSample(captureDataMask); long freq = 1000 * statuspacket.samplerate; long result = (long)(seconds * freq * bytespersample); long err = result % bytespersample; if (err > 0) // must fall on boundary result += (bytespersample - err); result += sampleoffset; return result; static public long SampleCount(BinaryReader reader, CaptureMask capturedatamask) return (reader.basestream.length - sampleoffset) / BytesPerSample(captureDataMask); public struct Sample public long sampleindex; public double timestamp; // 0...N-1 // fractional seconds public bool mainpresent; // whether Main was recorded public double maincurrent; // current in milliamps public double mainvoltage; // volts public bool usbpresent; // whether Usb was recorded public double usbcurrent; // current in milliamps public double usbvoltage; // volts 48

public bool auxpresent; // whether Aux was recorded public double auxcurrent; // current in milliamps public double auxvoltage; // volts; public bool markerpresent; // whether markers/voltages // were recorded public bool marker0; // Marker 0 public bool marker1; // Marker 1 public bool missing; // true if this sample was // missing static public void GetSample(long sampleindex, CaptureMask capturedatamask, StatusPacket statuspacket, BinaryReader reader, ref Sample sample) // remember the index and time sample.sampleindex = sampleindex; sample.timestamp = sampleindex / (1000.0 * statuspacket.samplerate); // intial settings for all flags sample.mainpresent = (capturedatamask & CaptureMask.chanMain)!= 0; sample.usbpresent = (capturedatamask & CaptureMask.chanUsb)!= 0; sample.auxpresent = (capturedatamask & CaptureMask.chanAux)!= 0; sample.markerpresent = true; sample.missing = false; // abort if no data was selected long bytespersample = BytesPerSample(captureDataMask); if (bytespersample == 0) return; // remember original position long oldpos = reader.basestream.position; // position the file to the start of the desired sample long newpos = SamplePosition(sampleIndex, capturedatamask); if (oldpos!= newpos) 49

reader.basestream.position = newpos; // get default voltages (V) for the three channels sample.mainvoltage = 2.0 + statuspacket.outputvoltagesetting * 0.01; sample.usbvoltage = (double)statuspacket.initialusbvoltage * 125 / 1e6f; if (statuspacket.hardwarerevision < HardwareRev.revB) sample.usbvoltage /= 2; sample.auxvoltage = (double)statuspacket.initialauxvoltage * 125 / 1e6f; if (statuspacket.hardwarerevision < HardwareRev.revC) sample.auxvoltage /= 2; // Main current (ma) if (sample.mainpresent) short raw = reader.readint16(); sample.missing = sample.missing raw == missingrawcurrent; if (!sample.missing) bool coarse = (raw & coarsemask)!= 0; raw &= ~coarsemask; sample.maincurrent = raw / 1000f; // ua -> ma if (coarse) sample.maincurrent *= 250; // Aux1 current (ma) if (sample.usbpresent) short raw = reader.readint16(); sample.missing = sample.missing raw == missingrawcurrent; if (!sample.missing) bool coarse = (raw & coarsemask)!= 0; raw &= ~coarsemask; 50

sample.usbcurrent = raw / 1000f; if (coarse) sample.usbcurrent *= 250; // ua -> ma // Aux2 current (ma) if (sample.auxpresent) short raw = reader.readint16(); sample.missing = sample.missing raw == missingrawcurrent; if (!sample.missing) bool coarse = (raw & coarsemask)!= 0; raw &= ~coarsemask; sample.auxcurrent = raw / 1000f; // ua -> ma if (coarse) sample.auxcurrent *= 250; // Markers and Voltage (V) ushort uraw = reader.readuint16(); sample.missing = sample.missing uraw == missingrawvoltage; if (!sample.missing) // strip out marker bits sample.marker0 = (uraw & marker0mask)!= 0; sample.marker1 = (uraw & marker1mask)!= 0; uraw &= unchecked((ushort)~markermask); // calculate voltage double voltage = (double)uraw * 125 / 1e6f; // assign the high-res voltage, as appropriate if ((statuspacket.leds & Leds.voltageIsAux)!= 0) sample.auxvoltage = voltage; if (statuspacket.hardwarerevision 51

< HardwareRev.revC) sample.auxvoltage /= 2; else sample.mainvoltage = voltage; if (statuspacket.hardwarerevision < HardwareRev.revB) sample.mainvoltage /= 2; // restore original position, if we moved it earlier if (oldpos!= newpos) reader.basestream.position = oldpos; class Program static void Main(string[] args) // open the file named in the command line argument string filename = args[0]; if (!File.Exists(fileName)) return; FileStream pt4stream = File.Open(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); BinaryReader pt4reader = new BinaryReader(pt4Stream); // reader the file header PT4.Pt4Header header = new PT4.Pt4Header(); PT4.ReadHeader(pt4Reader, ref header); // read the Status Packet PT4.StatusPacket statuspacket = new PT4.StatusPacket(); 52

PT4.ReadStatusPacket(pt4Reader, ref statuspacket); // determine the number of samples in the file long samplecount = PT4.SampleCount(pt4Reader, header.capturedatamask); // pre-position input file to the beginning of the sample // data (saves a lot of repositioning in the GetSample // routine) pt4reader.basestream.position = PT4.sampleOffset; // process the samples sequentially, beginning to end PT4.Sample sample = new PT4.Sample(); for (long sampleindex = 0; sampleindex < samplecount; sampleindex++) // read the next sample PT4.GetSample(sampleIndex, header.capturedatamask, statuspacket, pt4reader, ref sample); // process the sample Console.WriteLine("#0 1 sec 2 ma 3 V", sampleindex, sample.timestamp, sample.maincurrent, sample.mainvoltage); // close input file pt4reader.close(); 53