Example code for SPARK MAX
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
C++ Updated smart motion parameters and comments Feb 15, 2019
Java Update smart motion parameters and comments Feb 15, 2019
LabVIEW Bug Fixes Jan 14, 2019
images Add images for LabVIEW Jan 14, 2019
README.md Update README.md Jan 14, 2019

README.md

SPARK-MAX-Examples

Table of Contents

Installing libraries for Java/C++

Download the SPARK-MAX-roboRIO-SDK from RevRobotics.

Extract the zipped archive to a location where you can find it. Within the extracted folder, there will be two folders title "maven" and "vendordeps".

alt text

Copy and paste these folders into the location C:\Users\Public\frc2019. Go ahead and replace the files in the destination if you are prompted.

alt text

Installing in Visual Studio

Once the archive containing the SPARK-MAX-roboRIO-SDK has been extracted to the correct location, it can be installed in Visual Studio.

Begin by creating a new project in the language of your choice or by opening an existing project. Press ctrl + shift + p to bring up the command pallette and select WPILib: Manage Vendor Libraries

alt text

Then select Install new libraries (offline), check the box next to RevRobotics and select OK.

alt text

After a few moments SPARK MAX libraries will be available for you to use in your current project. This process will need to be repeated for each subsequent project that requires SPARK MAX libraries.

For Java all functions can be imported using import com.revrobotics.*;. Similarly, for C++ use #include "rev/CANSparkMax.h.

Building and Running Examples in Visual Studio

After cloning this GitHub repository, Java and C++ examples can be opened in Visual Studio by going to File->Open Folder... and selecting the parent folder of the example you want to run.

By default, the Team Number is set to 0 in the .wpilib/wpilib_preferences.json file. Make sure to change this to the Team Number configured on your roboRIO by either editing this file directly or by pressing ctrl + shift + p and selecting WPILib: Set Team Number.

Installing libraries for LabVIEW

Download the SPARK MAX LabVIEW API from RevRobotics here.

Simply run the installer and follow the instructions on screen.

Running Examples in LabVIEW

Open LabVIEW and select File->Open Project.... Open the .lvproj file in the top directory of the example you wish to run.

By default the IP address of the roboRIO is set to 172.22.11.2. This IP address will work if you are connecting to the roboRIO over USB, but if you are connected over ethernet or WIFI you will need to right click Target, select Properties, and configure the IP set for your roboRIO.

alt text

Run the program by opening Robot Main.vi a pressing the white arrow at the top of the window.

alt text