public abstract class STPM3x
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected boolean |
debug |
static byte |
DFE_CR1_0 |
static byte |
DFE_CR1_1 |
static byte |
DFE_CR2_0 |
static byte |
DFE_CR2_1 |
static byte |
DSP_CR10 |
static byte |
DSP_CR11 |
static byte |
DSP_CR12 |
static byte |
DSP_CR3_0 |
static byte |
DSP_CR3_1 |
static byte |
DSP_CR4 |
static byte |
DSP_CR5 |
static byte |
DSP_CR6 |
static byte |
DSP_CR7 |
static byte |
DSP_CR8 |
static byte |
DSP_CR9 |
static byte |
DSP_REG1 |
static byte |
DSP_REG14 |
static byte |
DSP_REG15 |
static byte |
DSP_REG16 |
static byte |
DSP_REG17 |
static byte |
DSP_REG18 |
static byte |
DSP_REG19 |
static byte |
DSP_SR1 |
static byte |
DSP_SR2 |
static byte |
DUMMY |
boolean |
firstReadEnergy |
static int |
FRAME_LENGTH_WITH_CRC |
static int |
MD_CURRENT |
static int |
MD_VOLTAGE |
static byte |
NULL |
static int |
OFFSET_POWER |
protected int |
overflowCounter |
static byte |
PH1_REG1 |
static byte |
PH1_REG5 |
static byte |
PH2_REG1 |
static byte |
PH2_REG5 |
static byte |
POWER_REGISTER |
static int |
RET_KO |
static int |
RET_OK |
protected Spi |
spi |
static int |
SPI_DEFAULT_FREQUENCY |
static int |
SPI_DEFAULT_MODE |
static int |
SPI_DEFAULT_TIMEOUT |
static int |
SPI_DEFAULT_USE_CS |
long[] |
totalEnergy |
Constructor and Description |
---|
STPM3x() |
Modifier and Type | Method and Description |
---|---|
abstract float |
calcCurrent(int value)
Returns current in A.
|
abstract double |
calcEnergy(double value)
Returns Energy in Ws.
|
abstract float |
calcPower(int value)
Returns power in W.
|
int |
calculateAndPutCRC(byte[] buffer) |
abstract float |
calcVoltage(int value)
Returns voltage in V.
|
void |
calibration() |
protected void |
debugLog(java.lang.String message) |
int |
extendSign(int bitsize,
int val) |
float |
getCurrent(int chan) |
double |
getEnergy(int chan) |
float |
getPeriod(int chan) |
float |
getPhase(int chan) |
float |
getPower(int chan) |
float |
getVoltage(int chan) |
void |
initSequence()
Default initialization sequence of the STPM3x
|
int |
readRegister(byte address) |
void |
reset() |
void |
resetSequence()
Default reset sequence of the STPM3x sensor.
|
byte[] |
sendFrame(byte readAddress,
byte writeAddress,
byte dataLSB,
byte dataMSB) |
void |
setCalibration(short value,
int chan,
int mode) |
abstract void |
setChipSelectState(boolean enabled) |
abstract void |
setEnableState(boolean enabled) |
abstract void |
setSynchroState(boolean enabled) |
int |
startPowerAcquisition() |
int |
writeRegister16(byte address,
short value) |
int |
writeRegister32(byte address,
int value) |
public static final int SPI_DEFAULT_FREQUENCY
public static final int SPI_DEFAULT_MODE
public static final int SPI_DEFAULT_USE_CS
public static final int SPI_DEFAULT_TIMEOUT
public static final int FRAME_LENGTH_WITH_CRC
public static final byte DUMMY
public static final byte NULL
public static final int RET_OK
public static final int RET_KO
public static final int MD_VOLTAGE
public static final int MD_CURRENT
public static final int OFFSET_POWER
public static final byte POWER_REGISTER
public static final byte DSP_CR3_0
public static final byte DSP_CR3_1
public static final byte PH1_REG1
public static final byte PH2_REG1
public static final byte PH1_REG5
public static final byte PH2_REG5
public static final byte DSP_REG1
public static final byte DSP_REG14
public static final byte DSP_REG15
public static final byte DSP_REG16
public static final byte DSP_REG17
public static final byte DSP_REG18
public static final byte DSP_REG19
public static final byte DFE_CR1_0
public static final byte DFE_CR1_1
public static final byte DFE_CR2_0
public static final byte DFE_CR2_1
public static final byte DSP_SR1
public static final byte DSP_SR2
public static final byte DSP_CR4
public static final byte DSP_CR5
public static final byte DSP_CR6
public static final byte DSP_CR7
public static final byte DSP_CR8
public static final byte DSP_CR9
public static final byte DSP_CR10
public static final byte DSP_CR11
public static final byte DSP_CR12
protected int overflowCounter
protected boolean debug
protected Spi spi
public long[] totalEnergy
public boolean firstReadEnergy
public void initSequence()
public void resetSequence()
public void reset()
public void setCalibration(short value, int chan, int mode)
value
- new calibration value, between -2048 and +2047chan
- channel on the STPM3x (1 or 2)mode
- 0 for voltage, 1 for currentpublic void calibration()
public int readRegister(byte address)
public int writeRegister16(byte address, short value)
public int writeRegister32(byte address, int value)
public int calculateAndPutCRC(byte[] buffer)
public float getPower(int chan)
public float getVoltage(int chan)
public float getCurrent(int chan)
public float getPeriod(int chan)
public float getPhase(int chan)
public double getEnergy(int chan)
public byte[] sendFrame(byte readAddress, byte writeAddress, byte dataLSB, byte dataMSB)
public int startPowerAcquisition()
protected void debugLog(java.lang.String message)
public abstract float calcPower(int value)
value
- raw data from the STPM3xcalcCurrent
,
calcVoltage
public abstract double calcEnergy(double value)
value
- raw data from the STPM3xcalcPower
public abstract float calcCurrent(int value)
value
- raw data from the STPM3xpublic abstract float calcVoltage(int value)
value
- raw data from the STPM3xpublic int extendSign(int bitsize, int val)
public abstract void setSynchroState(boolean enabled)
public abstract void setChipSelectState(boolean enabled)
public abstract void setEnableState(boolean enabled)