public class TiPWM extends Object
Modifier and Type | Field and Description |
---|---|
static int |
CAPTURE_CUMULATIVE
Input capture cumulative
|
static int |
CAPTURE_INSTANTANEOUS
Input capture instantaneous
|
static int |
CAPTURE_STOP
Input capture stop
|
static int |
INPUT_BOTHEDGE
Input both edge mode
|
static int |
INPUT_FALLING
Input falling edge mode
|
static int |
INPUT_RISING
Input rising edge mode
|
static int |
OUTPUT
Output mode
|
Modifier and Type | Method and Description |
---|---|
void |
captureFreqAndDuty(int capture)
Capture frequency and duty
|
void |
close()
Close the port of current object
|
double |
getDutyCycle(int channelID)
Gets the duty cycle
NOTE1: if the mode is OUTPUT, this is the duty cycle of the output pulse NOTE2: if the mode is INPUT, this is the duty cycle of the capture pulse |
int |
getFrequency()
Gets the frequency
NOTE1: if the mode is OUTPUT, this is the frequency of the output pulse NOTE2: if the mode is INPUT, this is the frequency of the capture pulse |
int |
getPort()
Gets the port id of current object
|
static TiPWM |
open(int portID,
int... channelIDs)
Open the TiPWM port by port id and the channel list, and return the
object
NOTE: remapID is 0, that is default location |
static TiPWM |
openRemap(int portID,
int remapID,
int... channelIDs)
Open the TiPWM port by port id, remap id and the channel list, and return the
object
|
static int |
portNumber()
Maximum number of port supported
|
void |
setDutyCycle(int channelID,
double duty)
Set the duty cycle
NOTE: only for OUTPUT mode, this is the duty cycle of the output pulse The above settings will not take effect until updateFreqAndDuty
is called |
void |
setFrequency(int freqValue)
Set the frequency
NOTE: only for OUTPUT mode, this is the frequency of the output pulse The above settings will not take effect until updateFreqAndDuty
is called |
void |
setNStateParameters(boolean enable,
int deadTime,
boolean brake)
Set the NState(that is complementary) parameters
|
void |
setWorkMode(int channelID,
int mode)
Set the channel work mode
|
void |
updateFreqAndDuty()
Update frequency and duty
|
public static final int CAPTURE_CUMULATIVE
public static final int CAPTURE_INSTANTANEOUS
public static final int CAPTURE_STOP
public static final int INPUT_BOTHEDGE
public static final int INPUT_FALLING
public static final int INPUT_RISING
public static final int OUTPUT
public void captureFreqAndDuty(int capture) throws IOException
capture
- capture control code,IOException
- If a TiPWM error occurspublic void close() throws IOException
IOException
- If a TiPWM error occurspublic double getDutyCycle(int channelID) throws IOException
channelID
- channel idIOException
- If a TiPWM error occurspublic int getFrequency() throws IOException
IOException
- If a TiPWM error occurspublic int getPort()
public static TiPWM open(int portID, int... channelIDs) throws IOException
portID
- port idchannelIDs
- channel id use, id range:0-15IOException
- If a TiPWM error occurspublic static TiPWM openRemap(int portID, int remapID, int... channelIDs) throws IOException
portID
- port idremapID
- the remap Id, range:0-3channelIDs
- channel id use, id range:0-15IOException
- If a TiPWM error occurspublic static int portNumber()
public void setDutyCycle(int channelID, double duty) throws IOException
updateFreqAndDuty
is calledchannelID
- the channelduty
- duty cycle, range:0-1, that is 0% - 100%IOException
- If a TiPWM error occurspublic void setFrequency(int freqValue) throws IOException
updateFreqAndDuty
is calledfreqValue
- frequency, unit:HzIOException
- If a TiPWM error occurspublic void setNStateParameters(boolean enable, int deadTime, boolean brake) throws IOException
enable
- enable or not, false:defaultdeadTime
- dead time, unit:nsbrake
- enable or notIOException
- If a TiPWM error occurspublic void setWorkMode(int channelID, int mode) throws IOException
channelID
- the channel id, range:0-15mode
- work mode,IOException
- If a TiPWM error occurspublic void updateFreqAndDuty() throws IOException
IOException
- If a TiPWM error occurs