Table of Contents

Class PWM1Configs

Namespace
CTRE.Phoenix6.Configs
Assembly
Phoenix6.Hardware.dll

Configs related to the CANdi™ branded device's PWM interface on the Signal 1 input (S1IN)

All the configs related to the PWM interface for the CANdi™ branded device on S1, including absolute sensor offset, absolute sensor discontinuity point and sensor direction.
public class PWM1Configs : IParentConfiguration, ISerializable, ICloneable
Inheritance
PWM1Configs
Implements
Inherited Members

Fields

AbsoluteSensorDiscontinuityPoint

The positive discontinuity point of the absolute sensor in rotations. This determines the point at which the absolute sensor wraps around, keeping the absolute position (after offset) in the range [x-1, x).

  • Setting this to 1 makes the absolute position unsigned [0, 1)
  • Setting this to 0.5 makes the absolute position signed [-0.5, 0.5)
  • Setting this to 0 makes the absolute position always negative [-1, 0)

Many rotational mechanisms such as arms have a region of motion that is unreachable. This should be set to the center of that region of motion, in non-negative rotations. This affects the position of the device at bootup.

For example, consider an arm which can travel from -0.2 to 0.6 rotations with a little leeway, where 0 is horizontally forward. Since -0.2 rotations has the same absolute position as 0.8 rotations, we can say that the arm typically does not travel in the range (0.6, 0.8) rotations. As a result, the discontinuity point would be the center of that range, which is 0.7 rotations. This results in an absolute sensor range of [-0.3, 0.7) rotations.

Given a total range of motion less than 1 rotation, users can calculate the discontinuity point using mean(lowerLimit, upperLimit) + 0.5. If that results in a value outside the range [0, 1], either cap the value to [0, 1], or add/subtract 1.0 rotation from your lower and upper limits of motion.

On a Talon motor controller, this is only supported when using the PulseWidth sensor source.
  • Minimum Value0.0
  • Maximum Value1.0
  • Default Value0.5
  • Unitsrotations
public double AbsoluteSensorDiscontinuityPoint

Field Value

double

AbsoluteSensorOffset

The offset applied to the PWM sensor. This offset is added to the reported sensor position.

This can be used to zero the sensor position in applications where the sensor is 1:1 with the mechanism.
  • Minimum Value-1
  • Maximum Value1
  • Default Value0.0
  • Unitsrotations
public double AbsoluteSensorOffset

Field Value

double

SensorDirection

Direction of the PWM sensor to determine positive rotation. Invert this so that forward motion on the mechanism results in an increase in PWM position.

  • Default ValueFalse
public bool SensorDirection

Field Value

bool

Methods

Clone()

Creates a copy of this config group.

public PWM1Configs Clone()

Returns

PWM1Configs

Deserialize(string)

Deserialize string and put values into this object

public StatusCode Deserialize(string to_deserialize)

Parameters

to_deserialize string

String to deserialize

Returns

StatusCode

OK if deserialization is OK

Serialize()

Serialize this object into a string

public string Serialize()

Returns

string

This object's data serialized into a string

ToString()

Provides the string representation of this object

public override string ToString()

Returns

string

WithAbsoluteSensorDiscontinuityPoint(double)

Modifies this configuration's AbsoluteSensorDiscontinuityPoint parameter and returns itself for method-chaining and easier to use config API.

The positive discontinuity point of the absolute sensor in rotations. This determines the point at which the absolute sensor wraps around, keeping the absolute position (after offset) in the range [x-1, x).
  • Setting this to 1 makes the absolute position unsigned [0, 1)
  • Setting this to 0.5 makes the absolute position signed [-0.5, 0.5)
  • Setting this to 0 makes the absolute position always negative [-1, 0)

Many rotational mechanisms such as arms have a region of motion that is unreachable. This should be set to the center of that region of motion, in non-negative rotations. This affects the position of the device at bootup.

For example, consider an arm which can travel from -0.2 to 0.6 rotations with a little leeway, where 0 is horizontally forward. Since -0.2 rotations has the same absolute position as 0.8 rotations, we can say that the arm typically does not travel in the range (0.6, 0.8) rotations. As a result, the discontinuity point would be the center of that range, which is 0.7 rotations. This results in an absolute sensor range of [-0.3, 0.7) rotations.

Given a total range of motion less than 1 rotation, users can calculate the discontinuity point using mean(lowerLimit, upperLimit) + 0.5. If that results in a value outside the range [0, 1], either cap the value to [0, 1], or add/subtract 1.0 rotation from your lower and upper limits of motion.

On a Talon motor controller, this is only supported when using the PulseWidth sensor source.
  • Minimum Value0.0
  • Maximum Value1.0
  • Default Value0.5
  • Unitsrotations
public PWM1Configs WithAbsoluteSensorDiscontinuityPoint(double newAbsoluteSensorDiscontinuityPoint)

Parameters

newAbsoluteSensorDiscontinuityPoint double

Parameter to modify

Returns

PWM1Configs

Itself

WithAbsoluteSensorOffset(double)

Modifies this configuration's AbsoluteSensorOffset parameter and returns itself for method-chaining and easier to use config API.

The offset applied to the PWM sensor. This offset is added to the reported sensor position.

This can be used to zero the sensor position in applications where the sensor is 1:1 with the mechanism.
  • Minimum Value-1
  • Maximum Value1
  • Default Value0.0
  • Unitsrotations
public PWM1Configs WithAbsoluteSensorOffset(double newAbsoluteSensorOffset)

Parameters

newAbsoluteSensorOffset double

Parameter to modify

Returns

PWM1Configs

Itself

WithSensorDirection(bool)

Modifies this configuration's SensorDirection parameter and returns itself for method-chaining and easier to use config API.

Direction of the PWM sensor to determine positive rotation. Invert this so that forward motion on the mechanism results in an increase in PWM position.
  • Default ValueFalse
public PWM1Configs WithSensorDirection(bool newSensorDirection)

Parameters

newSensorDirection bool

Parameter to modify

Returns

PWM1Configs

Itself