Class CANSparkMaxLowLevel

  • All Implemented Interfaces:
    edu.wpi.first.wpilibj.PIDOutput, edu.wpi.first.wpilibj.SpeedController
    Direct Known Subclasses:
    CANSparkMax

    public abstract class CANSparkMaxLowLevel
    extends java.lang.Object
    implements edu.wpi.first.wpilibj.SpeedController
    • Field Detail

      • kDefaultControlFramePeriodMs

        public static final int kDefaultControlFramePeriodMs
        See Also:
        Constant Field Values
      • kDefaultStatus0PeriodMs

        public static final int kDefaultStatus0PeriodMs
        See Also:
        Constant Field Values
      • kDefaultStatus1PeriodMs

        public static final int kDefaultStatus1PeriodMs
        See Also:
        Constant Field Values
      • kDefaultStatus2PeriodMs

        public static final int kDefaultStatus2PeriodMs
        See Also:
        Constant Field Values
      • m_can

        protected edu.wpi.first.wpilibj.CAN m_can
      • m_controlPeriodMs

        protected int m_controlPeriodMs
      • m_canTimeoutMs

        protected int m_canTimeoutMs
      • m_inverted

        protected boolean m_inverted
    • Constructor Detail

      • CANSparkMaxLowLevel

        public CANSparkMaxLowLevel​(int deviceID,
                                   CANSparkMaxLowLevel.MotorType type)
        Create a new SPARK MAX Controller
        Parameters:
        deviceID - The device ID.
        type - The motor type connected to the controller. Brushless motors must be connected to their matching color and the hall sensor plugged in. Brushed motors must be connected to the Red and Black terminals only.
    • Method Detail

      • getFirmwareVersion

        public int getFirmwareVersion()
        Get the firmware version of the SPARK MAX.
        Returns:
        uint32_t Firmware version integer. Value is represented as 4 bytes, Major.Minor.Build H.Build L
      • getFirmwareString

        public java.lang.String getFirmwareString()
        Get the firmware version of the SPARK MAX as a string.
        Returns:
        std::string Human readable firmware version string
      • getSerialNumber

        public byte[] getSerialNumber()
        Get the unique serial number of the SPARK MAX.
        Returns:
        byte[] Vector of bytes representig the unique serial number
      • getDeviceId

        public int getDeviceId()
        Get the configured Device ID of the SPARK MAX.
        Returns:
        int device ID
      • setMotorType

        public CANError setMotorType​(CANSparkMaxLowLevel.MotorType type)
        Set the motor type connected to the SPARK MAX. This uses the Set Parameter API and should be used infrequently. The parameter does not presist unless burnFlash() is called. The recommended method to configure this parameter is to use the SPARK MAX GUI to tune and save parameters.
        Parameters:
        type - The type of motor connected to the controller. Brushless motors must be connected to their matching color and the hall sensor plugged in. Brushed motors must be connected to the Red and Black terminals only.
        Returns:
        CANError Set to CANError::kOk if successful
      • getMotorType

        public CANSparkMaxLowLevel.MotorType getMotorType()
        Get the motor type setting for the SPARK MAX. This uses the Get Parameter API and should be used infrequently. This function uses a non-blocking call and will return a cached value if the parameter is not returned by the timeout. The timeout can be changed by calling SetCANTimeout(int milliseconds)
        Returns:
        MotorType Motor type setting
      • setPeriodicFramePeriod

        public CANError setPeriodicFramePeriod​(CANSparkMaxLowLevel.PeriodicFrame frameID,
                                               int periodMs)
        Set the rate of transmission for periodic frames from the SPARK MAX Refer to the SPARK MAX reference manual on details for how and when to configure this parameter.
        Returns:
        CANError Set to CANError::kOk if successful
      • setControlFramePeriod

        public void setControlFramePeriod​(int periodMs)
        Set the rate of transmission for setpoint frame. This will not take effect until the next call of a method that sets a new setpoint. Refer to the SPARK MAX reference manual on details for how and when to configure this parameter.
        Parameters:
        periodMs - The rate to send control frames
      • getControlFramePeriod

        public int getControlFramePeriod()
        Return the rate of transmission for setpoint frame
        Returns:
        Control frame perioid in milliseconds