Power Monitor Python API Documentation Version 1

Power Monitor Python API Documentation Version 1.0

Table of Contents

INTRODUCTION: .................................................................................................... 4

COMPATIBILITY: .................................................................................................... 4

INSTALLATION INSTRUCTIONS: ............................................................................ 4

USING PIP .............................................................................................................. 4 USING THE INSTALLER ................................................................................................ 4 DEPENDENCIES: ....................................................................................................... 4 PREPARING YOUR ENVIRONMENT: ................................................................................... 5

EXAMPLES: ............................................................................................................. 6

SAMPLING FROM THE MAIN CHANNEL:............................................................................... 6 SAMPLING FROM THE USB AND AUX CHANNELS:.................................................................. 6 GETTING SAMPLES BACK AS A PYTHON LIST INSTEAD OF A CSV OUTPUT: ...................................... 7 REFLASHING FIRMWARE: ............................................................................................. 7

CALIBRATIONDATA.PY ........................................................................................... 9

CLASS CALIBRATIONDATA(CALSTOKEEP=10)..................................................................... 9 clear() .............................................................................................................. 9 getRefCal(Coarse) .............................................................................................. 9 getZeroCal(Coarse) ............................................................................................ 9 addRefCal(value, Coarse) .................................................................................... 9 addZeroCal(value, Coarse) .................................................................................. 9

HVPM.PY AND LVPM.PY ........................................................................................ 10

FIELDS:............................................................................................................... 10 SETVOUT(VALUE): .................................................................................................. 10 SETPOWERUPTIME(VALUE): ........................................................................................ 10 SETPOWERUPCURRENTLIMIT(VALUE): ............................................................................ 10 SETRUNTIMECURRENTLIMIT(VALUE):............................................................................. 11 SETUSBPASSTHROUGHMODE(USBPASSTHROUGHCODE): .................................................... 11 SETVOLTAGECHANNEL(VOLTAGECHANNELCODE): .............................................................. 11 GETVOLTAGECHANNEL(): .......................................................................................... 11 FILLSTATUSPACKET():.............................................................................................. 11 STARTSAMPLING(CALTIME=1250,MAXTIME=0XFFFFFFFF): ................................................ 11 STOPSAMPLING():................................................................................................... 11 BULKREAD(): ........................................................................................................ 11 PACKET FORMAT:.................................................................................................... 12 SWIZZLEPACKET(PACKET): ......................................................................................... 13

OPERATIONS.PY................................................................................................... 14

CLASS OPCODES: ................................................................................................... 14 CLASS CONTROL_CODES: .......................................................................................... 16 CLASS CONVERSION: ............................................................................................... 16

FLOAT_TO_INT ................................................................................................ 16 CLASS USB_PASSTHROUGH: ...................................................................................... 16 CLASS VOLTAGECHANNEL: ......................................................................................... 16 CLASS STATUSPACKET: ............................................................................................. 16

firmwareVersion: .............................................................................................. 17 protocolVersion: ............................................................................................... 17 temperature: ................................................................................................... 17 serialNumber: .................................................................................................. 17 powerupCurrentLimit: ....................................................................................... 17 runtimeCurrentLimit: ........................................................................................ 17 powerupTime:.................................................................................................. 17 temperatureLimit: ............................................................................................ 17 usbPassthroughMode: ....................................................................................... 17 Scales............................................................................................................. 17 Zero Offsets: ................................................................................................... 17 Resistor Offsets ................................................................................................ 17 CLASS BOOTLOADERCOMMANDS:.................................................................................. 18 CLASS BOOTLOADERMEMORYREGIONS: .......................................................................... 18 CLASS HEXLINETYPE: ............................................................................................... 18 CLASS SAMPLETYPE(OBJECT): ..................................................................................... 18

PMAPI.PY ............................................................................................................. 19

CLASS USB_PROTCOL:............................................................................................. 19 sendCommand(operation, value): ....................................................................... 19 stopSampling(): ............................................................................................... 19 startSampling(calTime, maxTime): ..................................................................... 19 getValue(operation,valueLength): ....................................................................... 19

REFLASH.PY ......................................................................................................... 20

CLASS BOOTLOADERMONSOON(OBJECT): ........................................................................ 20 setup_usb(): ................................................................................................... 20 writeFlash(hex):............................................................................................... 20 getHeaderFromFWM(filename): .......................................................................... 20 getHexFile(filename):........................................................................................ 20 verifyHeader(headers): ..................................................................................... 20

SAMPLEENGINE.PY............................................................................................... 21

CLASS CHANNELS: ................................................................................................... 21 CLASS SAMPLEENGINE(BULKPROCESSRATE):.................................................................... 21

startSampling(samples=5000, granularity = 1): ................................................... 21 ConsoleOutput(bool):........................................................................................ 21 enableChannel(channel): ................................................................................... 21 disableChannel(channel): .................................................................................. 21 enableCSVOutput(filename): .............................................................................. 21 disableCSVOutput(): ......................................................................................... 22 getSamples():.................................................................................................. 22

Introduction:

The Monsoon python project is an open source Python implementation of the Monsoon Power Monitor protocol. This project supports two hardware versions, the Low-Voltage Power Monitor (LVPM, Part number FTA22J, has a white case) and the High-Voltage Power Monitor (HVPM, Part number AAA10F, has a black case).

This document solely covers information related to the python implementation of the Power Monitor API. For hardware information and GUI instructions, refer to the Power Monitor End User Manual. For instructions about the use of the C# GUI, refer to the Power Monitor Developer API Guide. Both documents are available at

Compatibility:

This script has been tested on Windows 10, RHEL 7.3, and macOS Sierra, 10.12.2, using Python 2.7 and Python 3.5.

During development, we have found that pure Python is often not fast enough to keep up with real-time sampling, and lacks the multi-threading capabilities that would be necessary to properly fix this. Users may find large numbers of measurements being dropped during sampling. We are continuing development on a solution that maintains universal compatibility and is fast enough to allow measurements to be taken in real time. Currently, the only workarounds are to use a workstation with a higher single-core clock speed, or to collect and then process measurements separately.

Installation Instructions:

Using pip

Use the command:

`Pip install monsoon'

Using the installer

Download the Python installer from - unzip the contents and find setup.py. From there, use the command:

`Python setup.py install'

Dependencies:

The following Python libraries are used with this library, and will need to be installed before use.

Numpy: or install using 'pip install numpy'

pyUSB:

or install using 'pip install pyusb'

libusb 1.0: or install using 'pip install libusb1'

Note: pyUSB also supports libusb 0.1 and OpenUSB as backends, but those haven't been tested with this script and are not officially supported by Monsoon

Preparing your environment:

1. On windows, for any device to be detected by libusb, you will need to install a libusb filter. This can be downloaded from . This step can be skipped for Linux and MacOS users.

2. For LVPM users, the firmware on your device will probably not be compatible with the script. Older firmware uses a serial port emulator to communicate with the PC, while the newer firmware uses a full USB interface. A firmware update is available in the /firmware folder of the source package (for pip users, this will also be present in %python%/Lib/sitepackages/Monsoon/Firmware. See the reflash example later in this document for instructions on how to reflash your unit's firmware.

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download