FRC  v1.5
mindsensors.com FRC library
mindsensors::CANSD540 Class Reference
Inheritance diagram for mindsensors::CANSD540:

Public Types

enum  StopMode : uint8_t { Coast = 0, Brake = 1 }
 
enum  LimitSwitchBehavior : uint8_t { NormallyOpen = 0, NormallyClosed = 1 }
 

Public Member Functions

 CANSD540 (uint8_t deviceNumber)
 
uint8_t GetDeviceID () const
 
std::string GetDeviceName () const
 
std::string GetFirmwareVersion () const
 
std::string GetHardwareVersion () const
 
std::string GetBootloaderVersion () const
 
std::string GetSerialNumber () const
 
void BlinkLED (uint8_t seconds)
 
void Set (double speed)
 
double Get () const
 
void SetInverted (bool isInverted)
 
bool GetInverted () const
 
void SetStopMode (CANSD540::StopMode stopMode)
 
CANSD540::StopMode GetStopMode () const
 
void EnableLimitSwitches (bool limitSwitchesEnabled)
 
bool GetLimitSwitchesEnabled () const
 
void SetForwardLimitSwitch (CANSD540::LimitSwitchBehavior behavior)
 
CANSD540::LimitSwitchBehavior GetForwardLimitSwitch () const
 
void SetReverseLimitSwitch (CANSD540::LimitSwitchBehavior behavior)
 
CANSD540::LimitSwitchBehavior GetReverseLimitSwitch () const
 
void SetVoltageRamp (uint8_t voltageRamp)
 
double GetBatteryVoltage () const
 
bool GetForwardLimitSwitchState () const
 
bool GetReverseLimitSwitchState () const
 

Static Public Member Functions

static std::string GetLibraryVersion ()
 

Member Enumeration Documentation

§ LimitSwitchBehavior

An enumeration representing the default state of a limit switch.

See also
EnableLimitSwitches()
SetForwardLimitSwitch()
SetReverseLimitSwitch()
Enumerator
NormallyOpen 

This limit switch is expected to be normally open and will only activate when it becomes closed.

NormallyClosed 

This limit switch is expected to be normally closed and will only activate when it becomes open.

§ StopMode

An enumeration representing how the SD540C should stop.

Enumerator
Coast 

Allow the motor to freely turn once stopped.

Brake 

Motor resist motion when it is stopped.

Constructor & Destructor Documentation

§ CANSD540()

CANSD540::CANSD540 ( uint8_t  deviceNumber)
explicit

An instance of this object represents a single SD540C device. Only a single instance can be created for each device ID. Please construct this object only once when initializing your robot and pass the reference around. If you do with to call this constructor with the same ID later, call the destructor first.

Parameters
deviceNumberAn integer between 1 and 60 (inclusive) for the ID of this SD540C. CAN IDs can be modified through the mindsensors configuration tool, avaliable at mindsensors.com/pages/311. Devices will ship with a factory default CAN ID of 3. Please use a unique ID for each device.

Member Function Documentation

§ BlinkLED()

void CANSD540::BlinkLED ( uint8_t  seconds)

Each SD540C has a build-in LED embedded next to the CAN pins. This command will cause it to blink between red and green for a specified duration. This can be useful in debugging. Please do not confuse thiswith both colors flashing quickly, which signifies that the SD540C can not find a connection to the FRC driver station.

Parameters
secondsThe number of seconds to blink.

§ EnableLimitSwitches()

void CANSD540::EnableLimitSwitches ( bool  limitSwitchesEnabled)
Parameters
limitSwitchesEnabledFalse will disable any limit switch functionality. True will enable it, causing a triggered limit switch to stop the motor and not move further in that direction. This value will be remembered through power cycles.
See also
LimitSwitchBehavior
SetForwardLimitSwitch(LimitSwitchBehavior)
SetReverseLimitSwitch(LimitSwitchBehavior)

§ Get()

double CANSD540::Get ( ) const
Returns
The current speed this SD540C is set to.

§ GetBatteryVoltage()

double CANSD540::GetBatteryVoltage ( ) const
Returns
The voltage this SD540C device is currently receiving. A value of 0.0 likely indicates this SD540C is not connected properly. Please check the CAN and power connections, or look to the SD540C user guide on mindsensors.com.

§ GetBootloaderVersion()

string CANSD540::GetBootloaderVersion ( ) const
Returns
The bootloader version of this SD540C. The bootloader is used to update firmware on the SD540C.

§ GetDeviceID()

uint8_t CANSD540::GetDeviceID ( ) const
Returns
The device ID provided when constructing this CANSD540 instance.

§ GetDeviceName()

string CANSD540::GetDeviceName ( ) const
Returns
The name associated with this SD540C. The factory default will be "SD540C", but this value can be changed through the mindsensors configuration tool.

§ GetFirmwareVersion()

string CANSD540::GetFirmwareVersion ( ) const
Returns
The firmware version of this SD540C. Firmware can be updated through the mindsensors configuration tool. This may be considered during inspection at competitions. Firmware updates can provide new features. The firmware version of the SD540C device must be compatible with this library.

§ GetForwardLimitSwitch()

CANSD540::LimitSwitchBehavior CANSD540::GetForwardLimitSwitch ( ) const
Returns
The default expected state of this limit switch.
See also
LimitSwitchBehavior

§ GetForwardLimitSwitchState()

bool CANSD540::GetForwardLimitSwitchState ( ) const
Returns
True if the forward limit switch is currently activated. Note this does take in to account the limit switch settings on this SD540C.

§ GetHardwareVersion()

string CANSD540::GetHardwareVersion ( ) const
Returns
The hardware version of this SD540C. Any hardware revisions will have a different hardware version number.

§ GetInverted()

bool CANSD540::GetInverted ( ) const
Returns
Whether or not this SD540C is set inverted.

§ GetLibraryVersion()

string CANSD540::GetLibraryVersion ( )
static
Returns
The version of this library in the format major.minor, for example: "1.1"

§ GetLimitSwitchesEnabled()

bool CANSD540::GetLimitSwitchesEnabled ( ) const
Returns
Whether limit switch functionality is currently enabled or not.

§ GetReverseLimitSwitch()

CANSD540::LimitSwitchBehavior CANSD540::GetReverseLimitSwitch ( ) const
Returns
The default expected state of this limit switch.
See also
LimitSwitchBehavior

§ GetReverseLimitSwitchState()

bool CANSD540::GetReverseLimitSwitchState ( ) const
Returns
True if the reverse limit switch is currently activated. Note this does take in to account the limit switch settings on this SD540C.

§ GetSerialNumber()

string CANSD540::GetSerialNumber ( ) const
Returns
The serial number of this device. Each serial number is unique and may be requested for customer support.

§ GetStopMode()

CANSD540::StopMode CANSD540::GetStopMode ( ) const
Returns
What action this SD540C will take when stopping.
See also
StopMode

§ Set()

void CANSD540::Set ( double  speed)
Parameters
speedThe speed to set this SD540C to. Speed must be in the range -1.0 to 1.0 (inclusive).

§ SetForwardLimitSwitch()

void CANSD540::SetForwardLimitSwitch ( CANSD540::LimitSwitchBehavior  behavior)
Parameters
behaviorThe default expected state of this limit switch. This value can also be set in the mindsensors configuration tool.
See also
LimitSwitchBehavior
EnableLimitSwitches(bool)

§ SetInverted()

void CANSD540::SetInverted ( bool  isInverted)
Parameters
isInvertedWhether or not to invert this motor. This can be useful if SD540C's are mounted in opposite directions. The SD540C will retain this value even if it loses power.

§ SetReverseLimitSwitch()

void CANSD540::SetReverseLimitSwitch ( CANSD540::LimitSwitchBehavior  behavior)
Parameters
behaviorThe default expected state of this limit switch. This value can also be set in the mindsensors configuration tool.
See also
LimitSwitchBehavior
EnableLimitSwitches(bool)

§ SetStopMode()

void CANSD540::SetStopMode ( CANSD540::StopMode  stopMode)
Parameters
stopModeWhat action this SD540C will take when stopping.
See also
StopMode

§ SetVoltageRamp()

void CANSD540::SetVoltageRamp ( uint8_t  voltageRamp)

Set at what rate output voltage will increase or decrease. The default value of 0 will disable voltage ramp (instantly setting the speed to the requested value). A positive integer less than 256 (1-255) will make the SD540C gradually increase or decrease to the new set value. Lower numbers close to zero will reach the new value more quickly, while high numbers will take some time resulting in a smoother motion. A higher voltage ramp will limit the maximum acceleration of the motor.

Parameters
voltageRampA non-negative integer between 0 and 255 (inclusive) to use for the voltage ramp

The documentation for this class was generated from the following files: