Skip to content
This repository was archived by the owner on Dec 7, 2024. It is now read-only.

Commit 36276f1

Browse files
committed
adds README descriptions for all examples
fixes typos and imports
1 parent 038129f commit 36276f1

File tree

29 files changed

+341
-3
lines changed

29 files changed

+341
-3
lines changed

C++/Alternate Encoder/README.md

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Alternate Encoder
2+
3+
### Description
4+
This example shows how to use an alternate encoder as the feedback device for the PID controller of a REV NEO Brushless Motor instead of the NEO's built-in hall sensor. For demonstration, the PID controller will be used to set the motor position.
5+
6+
### Usage
7+
Set the variables at the beginning of the example to match your setup.
8+
- `kCanID` - CAN device ID
9+
- `kMotorType` - Motor type
10+
- `kAltEncType` - Alternate encoder type
11+
- `kCPR` - Alternate encoder counts per revolution
12+
13+
PID Coefficients can be adjusted on SmartDashboard as well as the set rotations (position setpoint).
14+
15+
The setpoint and process variable will be displayed on SmartDashboard.
16+
17+
[More info about Alternate Encoder Mode](https://docs.revrobotics.com/sparkmax/operating-modes-1/alternate-encoder-mode)

C++/Analog Feedback Device/README.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Analog Feedback Device
2+
3+
### Description
4+
This example shows how to use an analog sensor as the feedback device for the PID controller of a REV NEO Brushless Motor instead of the NEO's built-in hall sensor. For demonstration, the PID controller will be used to set the motor position.
5+
6+
### Usage
7+
Set the variables at the beginning of the example to match your setup.
8+
- `deviceID` - CAN device ID
9+
10+
PID Coefficients can be adjusted on SmartDashboard as well as the set rotations (position setpoint).
11+
12+
The setpoint and process variable will be displayed on SmartDashboard.

C++/Arcade Drive With CAN/README.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Arcade Drive with CAN
2+
3+
### Description
4+
This example shows how to set up arcade drive with SPARK MAX controllers connected via the CAN interface.
5+
6+
### Usage
7+
Set the variables at the beginning of the example to match your setup.
8+
- `leftLeadDeviceID` - Left lead CAN device ID
9+
- `leftFollowDeviceID` - Left follower CAN device ID
10+
- `rightLeadDeviceID` - Right lead CAN device ID
11+
- `rightFollowDeviceID` - Righ follower CAN device ID
12+
13+
Control the robot's forward and reverse movement by moving the left joystick up or down.
14+
15+
Control the robot's heading by moving the right joystick left or right.

C++/Arcade Drive With PWM/README.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Arcade Drive with PWM
2+
3+
### Description
4+
This example shows how to set up arcade drive with SPARK MAX controllers connected via the PWM interface.
5+
6+
### Usage
7+
Set the variables at the beginning of the example to match your setup.
8+
- `leftPwmChannel` - Left motor PWM channel
9+
- `rightPwmChannel` - Right motor PWM channel
10+
11+
Control the robot's forward and reverse movement by moving the left joystick up or down.
12+
13+
Control the robot's heading by moving the right joystick left or right.

C++/Bus Measurements/README.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Bus measuremants
2+
3+
### Description
4+
This example shows how to read basic bus measurements from the SPARK MAX like bus voltage, current, applied output, and motor temperature.
5+
6+
### Usage
7+
Set the variables at the beginning of the example to match your setup.
8+
- `deviceID` - CAN device ID
9+
- `motorType` - Motor type
10+
11+
Control the motor's velocity by moving the joystick up or down.
12+
13+
Bus measurements will be displayed on SmartDashboard.

C++/Encoder Feedback Device/README.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Encoder Feedback Device
2+
3+
### Description
4+
This example shows how to use an encoder as the feedback device for the PID controller of a brushed motor. For demonstration, the PID controller will be used to set the motor position.
5+
6+
### Usage
7+
Set the variables at the beginning of the example to match your setup.
8+
- `deviceID` - CAN device ID
9+
10+
PID Coefficients can be adjusted on SmartDashboard as well as the set rotations (position setpoint).
11+
12+
The setpoint and process variable will be displayed on SmartDashboard.

C++/Get and Set Parameters/README.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Get and Set Parameters
2+
3+
### Description
4+
This example shows how to use the CANSparkMax class, specifically how to set and get the parameters necessary to operate a robot with tank drive.
5+
6+
### Usage
7+
Set the variables at the beginning of the example to match your setup.
8+
- `deviceID` - CAN device ID
9+
10+
Control the motor's velocity by moving the joystick up or down.
11+
12+
Values returned by the parameter's corresponding get method will be displayed on SmartDashboard.

C++/Limit Switch/README.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Limit Switch
2+
3+
### Description
4+
This example shows how to use limit switches with the SPARK MAX, specifically how to limit the forward and reverse direction of the motor.
5+
6+
### Usage
7+
Set the variables at the beginning of the example to match your setup.
8+
- `deviceID` - CAN device ID
9+
10+
Control the motor's velocity by moving the joystick up or down.
11+
12+
Forward/reverse limit switches can be toggled on/off on SmartDashboard.
13+
14+
The state of the limit switches will be displayed on SmartDashboard.

C++/Position PID Control/README.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Position PID Control
2+
3+
### Description
4+
This example shows how to use a PID closed loop controller to set the position of a motor to a specified number of rotations.
5+
6+
### Usage
7+
Set the variables at the beginning of the example to match your setup.
8+
- `deviceID` - CAN device ID
9+
10+
PID Coefficients can be adjusted on SmartDashboard as well as the set rotations (position setpoint).
11+
12+
The setpoint and process variable will be displayed on SmartDashboard.

C++/Read Encoder Values/README.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Read Encoder Values
2+
3+
### Description
4+
This example shows how to read the values from an encoder connected to the SPARK MAX, specifically how to read their position and velocity values.
5+
6+
### Usage
7+
Set the variables at the beginning of the example to match your setup.
8+
- `deviceID` - CAN device ID
9+
10+
Control the motor's velocity by moving the joystick up or down.
11+
12+
The position and velocity of the encoder will be displayed on SmartDashboard.

C++/Smart Motion Example/README.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Smart Motion Example
2+
3+
### Description
4+
This example shows how to use REV Smart Motion to control the position of the motor in a smooth and predictable manner by generating a motion profile on the fly in the SPARK MAX and controlling the velocity of the motor to follow that profile.
5+
6+
The example will use ShuffleBoard to graph the inputs and outputs such as process variable, setpoint, and applied output to easily visualize what is happening.
7+
8+
### Usage
9+
Set the variables at the beginning of the example to match your setup.
10+
- `deviceID` - CAN device ID
11+
12+
Use the "Mode" button on SmartDashboard to toggle between velocity and Smart Motion modes.
13+
14+
PID coefficients and Smart Motion coefficients can be adjusted on SmartDashboard as well as the velocity and position setpoints.
15+
16+
The setpoint, process variable, and the motor's applied output will be displayed on SmartDashboard.

C++/Soft Limits/README.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Soft Limits
2+
3+
### Description
4+
This example shows how to use soft limits with the SPARK MAX, specifically how to limit the forward and reverse direction of the motor at a particular point.
5+
6+
### Usage
7+
Set the variables at the beginning of the example to match your setup.
8+
- `deviceID` - CAN device ID
9+
10+
Soft Limits for the forward and reverse directions can be set and enabled/disabled on SmartDashboard.

C++/Velocity PID Control/README.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Velocity PID Control
2+
3+
### Description
4+
This example shows how to use a PID closed loop controller to set the velocity of a motor to a specified number of revolutions per minute. For demonstration, the velocity setpoint will be dependent on the joystick's y-axis value.
5+
6+
### Usage
7+
Set the variables at the beginning of the example to match your setup.
8+
- `deviceID` - CAN device ID
9+
10+
Control the motor's velocity by moving the joystick up or down.
11+
12+
The setpoint and process variable will be displayed on SmartDashboard.

Java/Alternate Encoder/README.md

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Alternate Encoder
2+
3+
### Description
4+
This example shows how to use an alternate encoder as the feedback device for the PID controller of a REV NEO Brushless Motor instead of the NEO's built-in hall sensor. For demonstration, the PID controller will be used to set the motor position.
5+
6+
### Usage
7+
Set the variables at the beginning of the example to match your setup.
8+
- `kCanID` - CAN device ID
9+
- `kMotorType` - Motor type
10+
- `kAltEncType` - Alternate encoder type
11+
- `kCPR` - Alternate encoder counts per revolution
12+
13+
PID Coefficients can be adjusted on SmartDashboard as well as the set rotations (position setpoint).
14+
15+
The setpoint and process variable will be displayed on SmartDashboard.
16+
17+
[More info about Alternate Encoder Mode](https://docs.revrobotics.com/sparkmax/operating-modes-1/alternate-encoder-mode)

Java/Alternate Encoder/src/main/java/frc/robot/Robot.java

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
package frc.robot;
99

10-
import edu.wpi.first.wpilibj.Joystick;
1110
import edu.wpi.first.wpilibj.TimedRobot;
1211
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
1312

Java/Analog Feedback Device/README.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Analog Feedback Device
2+
3+
### Description
4+
This example shows how to use an analog sensor as the feedback device for the PID controller of a REV NEO Brushless Motor instead of the NEO's built-in hall sensor. For demonstration, the PID controller will be used to set the motor position.
5+
6+
### Usage
7+
Set the variables at the beginning of the example to match your setup.
8+
- `deviceID` - CAN device ID
9+
10+
PID Coefficients can be adjusted on SmartDashboard as well as the set rotations (position setpoint).
11+
12+
The setpoint and process variable will be displayed on SmartDashboard.

Java/Bus Measurements/README.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Bus measuremants
2+
3+
### Description
4+
This example shows how to read basic bus measurements from the SPARK MAX like bus voltage, current, applied output, and motor temperature.
5+
6+
### Usage
7+
Set the variables at the beginning of the example to match your setup.
8+
- `deviceID` - CAN device ID
9+
- `motorType` - Motor type
10+
11+
Control the motor's velocity by moving the joystick up or down.
12+
13+
Bus measurements will be displayed on SmartDashboard.
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Encoder Feedback Device
2+
3+
### Description
4+
This example shows how to use an encoder as the feedback device for the PID controller of a brushed motor. For demonstration, the PID controller will be used to set the motor position.
5+
6+
### Usage
7+
Set the variables at the beginning of the example to match your setup.
8+
- `deviceID` - CAN device ID
9+
10+
PID Coefficients can be adjusted on SmartDashboard as well as the set rotations (position setpoint).
11+
12+
The setpoint and process variable will be displayed on SmartDashboard.

Java/Get and Set Parameters/README.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Get and Set Parameters
2+
3+
### Description
4+
This example shows how to use the CANSparkMax class, specifically how to set and get the parameters necessary to operate a robot with tank drive.
5+
6+
### Usage
7+
Set the variables at the beginning of the example to match your setup.
8+
- `deviceID` - CAN device ID
9+
10+
Control the motor's velocity by moving the joystick up or down.
11+
12+
Values returned by the parameter's corresponding get method will be displayed on SmartDashboard.

Java/Get and Set Parameters/src/main/java/frc/robot/Robot.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import com.revrobotics.CANSparkMaxLowLevel.MotorType;
1818

1919
/**
20-
* This is a demo program showing the use of the RobotDrive class, specifically
20+
* This is a demo program showing the use of the CANSparkMax class, specifically
2121
* it contains the code necessary to operate a robot with tank drive.
2222
*/
2323
public class Robot extends TimedRobot {

Java/Limit Switch/README.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Limit Switch
2+
3+
### Description
4+
This example shows how to use limit switches with the SPARK MAX, specifically how to limit the forward and reverse direction of the motor.
5+
6+
### Usage
7+
Set the variables at the beginning of the example to match your setup.
8+
- `deviceID` - CAN device ID
9+
10+
Control the motor's velocity by moving the joystick up or down.
11+
12+
Forward/reverse limit switches can be toggled on/off on SmartDashboard.
13+
14+
The state of the limit switches will be displayed on SmartDashboard.

Java/Limit Switch/src/main/java/frc/robot/Robot.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public void robotInit() {
5353
m_stick = new Joystick(0);
5454

5555
/**
56-
* Limit switches are enabled by default when the are intialized. They can be disabled
56+
* Limit switches are enabled by default when they are intialized. They can be disabled
5757
* by calling enableLimitSwitch(false) on a CANDigitalInput object
5858
*
5959
* Limit switches can be reenabled by calling enableLimitSwitch(true)

Java/Motor Follower/README.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Motor Follower
2+
3+
### Description
4+
This example shows how to control multiple motors simultaneously, specifically how to set motors to follow another motor and mirror the lead motor's actions.
5+
6+
### Usage
7+
Set the variables at the beginning of the example to match your setup.
8+
- `leadDeviceID` - CAN device ID for lead motor
9+
- `followDeviceID` - CAN device ID for follower motor
10+
- `kJoystickPort` - Joystick device port number
11+
12+
Control the motors' velocities by moving the joystick up or down.
13+
14+
Both motors will run accordingly.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Position Closed Loop Control
2+
3+
### Description
4+
This example shows how to use a PID closed loop controller to set the position of a motor to a specified number of rotations.
5+
6+
### Usage
7+
Set the variables at the beginning of the example to match your setup.
8+
- `deviceID` - CAN device ID
9+
10+
PID Coefficients can be adjusted on SmartDashboard as well as the set rotations (position setpoint).
11+
12+
The setpoint and process variable will be displayed on SmartDashboard.

Java/Read Encoder Values/README.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Read Encoder Values
2+
3+
### Description
4+
This example shows how to read the values from an encoder connected to the SPARK MAX, specifically how to read their position and velocity values.
5+
6+
### Usage
7+
Set the variables at the beginning of the example to match your setup.
8+
- `deviceID` - CAN device ID
9+
10+
Control the motor's velocity by moving the joystick up or down.
11+
12+
The position and velocity of the encoder will be displayed on SmartDashboard.

Java/Smart Motion Example/README.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Smart Motion Example
2+
3+
### Description
4+
This example shows how to use REV Smart Motion to control the position of the motor in a smooth and predictable manner by generating a motion profile on the fly in the SPARK MAX and controlling the velocity of the motor to follow that profile.
5+
6+
The example will use ShuffleBoard to graph the inputs and outputs such as process variable, setpoint, and applied output to easily visualize what is happening.
7+
8+
### Usage
9+
Set the variables at the beginning of the example to match your setup.
10+
- `deviceID` - CAN device ID
11+
12+
Use the "Mode" button on SmartDashboard to toggle between velocity and Smart Motion modes.
13+
14+
PID coefficients and Smart Motion coefficients can be adjusted on SmartDashboard as well as the velocity and position setpoints.
15+
16+
The setpoint, process variable, and the motor's applied output will be displayed on SmartDashboard.

Java/Soft Limits/README.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Soft Limits
2+
3+
### Description
4+
This example shows how to use soft limits with the SPARK MAX, specifically how to limit the forward and reverse direction of the motor at a particular point.
5+
6+
### Usage
7+
Set the variables at the beginning of the example to match your setup.
8+
- `deviceID` - CAN device ID
9+
10+
Soft Limits for the forward and reverse directions can be set and enabled/disabled on SmartDashboard.

Java/Tank Drive With CAN/README.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Tank Drive with CAN
2+
3+
### Description
4+
This example shows how to set up tank drive with SPARK MAX.
5+
6+
### Usage
7+
Set the variables at the beginning of the example to match your setup.
8+
- `leftDeviceID` - Right motor CAN device ID
9+
- `rightDeviceID` - Left motor CAN device ID
10+
11+
Control the left motor by moving the left joystick up or down.
12+
13+
Control the right motor by moving the right joystick up or down.

0 commit comments

Comments
 (0)