Mindstorms 3rd Party ROBOTC Drivers RobotC
[Home] [Download] [Submit a bug/suggestion] [ROBOTC Forums] [Blog] [Support this project]
Files | Defines | Functions | Variables

Power Meter Sensor
[Mindsensors]

Files

file  mindsensors-powermeter.h
 

Mindsensors Power Meter Sensor.


Defines

#define MSPM_I2C_ADDR   0x12
#define MSPM_CMD_REG   0x41
#define MSPM_PCURRENT   0x42
#define MSPM_PVOLTAGE   0x44
#define MSPM_CAPUSED   0x46
#define MSPM_TIME   0x56

Functions

int MSPMreadCurrent (tSensors link, ubyte address=MSPM_I2C_ADDR)
int MSPMreadVoltage (tSensors link, ubyte address=MSPM_I2C_ADDR)
bool MSPMreadVoltageCurrent (tSensors link, int &voltage, int &current, ubyte address=MSPM_I2C_ADDR)
long MSPMreadTime (tSensors link, ubyte address=MSPM_I2C_ADDR)
bool MSPMresetCounters (tSensors link, ubyte address=MSPM_I2C_ADDR)
bool _MSPMsendCommand (tSensors link, byte command, ubyte address)

Variables

tByteArray MSPM_I2CRequest
tByteArray MSPM_I2CReply

Detailed Description

Power Meter Sensor


Define Documentation

#define MSPM_CAPUSED   0x46

Capacity used since last reset in mAh - 2 bytes

Definition at line 50 of file mindsensors-powermeter.h.

#define MSPM_CMD_REG   0x41

Register used for issuing commands

Definition at line 46 of file mindsensors-powermeter.h.

#define MSPM_I2C_ADDR   0x12

I2C address used by the PM

Definition at line 45 of file mindsensors-powermeter.h.

#define MSPM_PCURRENT   0x42

Present current reading in mA - 2 bytes

Definition at line 48 of file mindsensors-powermeter.h.

#define MSPM_PVOLTAGE   0x44

Present current reading in mV - 2 bytes

Definition at line 49 of file mindsensors-powermeter.h.

#define MSPM_TIME   0x56

Time since last reset in ms - 4 bytes (long)

Definition at line 51 of file mindsensors-powermeter.h.


Function Documentation

bool _MSPMsendCommand ( tSensors  link,
byte  command,
ubyte  address 
)

This function sends a command to the Power Meter.

Note: this is an internal function and should not be called directly.

Parameters:
linkthe sensor port number
commandthe command to be sent
addressthe I2C address to use, optional, defaults to 0x12
Returns:
true if no error occured, false if it did

Definition at line 81 of file mindsensors-powermeter.h.

int MSPMreadCurrent ( tSensors  link,
ubyte  address 
)

Return the present current measured.

Parameters:
linkthe MSPM port number
addressthe I2C address to use, optional, defaults to 0x12
Returns:
the present current measured or -1 if an error occurred.

Definition at line 97 of file mindsensors-powermeter.h.

long MSPMreadTime ( tSensors  link,
ubyte  address 
)

Return the time elapsed in ms since the last reset.

Parameters:
linkthe MSPM port number
addressthe I2C address to use, optional, defaults to 0x12
Returns:
the time elapsed in ms since the last reset.

Definition at line 161 of file mindsensors-powermeter.h.

int MSPMreadVoltage ( tSensors  link,
ubyte  address 
)

Return the present voltage measured.

Parameters:
linkthe MSPM port number
addressthe I2C address to use, optional, defaults to 0x12
Returns:
the present voltage measured or -1 if an error occurred.

Definition at line 117 of file mindsensors-powermeter.h.

bool MSPMreadVoltageCurrent ( tSensors  link,
int &  voltage,
int &  current,
ubyte  address 
)

Return the present voltage and current measured. This is a much more efficient method of fetching both.

Parameters:
linkthe MSPM port number
voltagepresent voltage being measured
currentpresent current being measured
addressthe I2C address to use, optional, defaults to 0x12
Returns:
the present voltage measured or -1 if an error occurred.
Examples:
mindsensors-powermeter-test1.c.

Definition at line 140 of file mindsensors-powermeter.h.

bool MSPMresetCounters ( tSensors  link,
ubyte  address 
)

Reset all the counters.

Parameters:
linkthe MSPM port number
addressthe I2C address to use, optional, defaults to 0x12
Returns:
true if no error occured, false if it did

Definition at line 182 of file mindsensors-powermeter.h.


Variable Documentation

Array to hold I2C reply data

Definition at line 54 of file mindsensors-powermeter.h.

Array to hold I2C command data

Definition at line 53 of file mindsensors-powermeter.h.