FRC VsCode Java Software that just runs one spark max controller and motor

Hello everyone. I am a software student that is fairly new to software and I need some help to get started. Could someone send me a link to download bare bones project that just runs one spark max motor controller and one spark max motor with a joystick? Thanks in advance, please ask a question if this doesn’t make any sense

One thing someone is going to need to know, is the CAN ID of the motor controller and whether a brushless or brushed motor is attached to it.

I would advise you to be cautious just downloading and running programs without understanding them first as the brushless setting being wrong could damage a NEO motor.

That combined with it being super simple to do this yourself.

On that note, you can create a Spark MAX motor controller in your code by calling something like (in a constructor)

CANSparkMax sparkMax = new CANSparkMax(int can_id, MotorType brushless/brushed); 

And create a joystick with (in a constructor)

Joystick joystick = new Joystick(int joysitck_port);

You can then run the motor in a periodic loop with something like

sparkMax.set(joystick.getY());

If you still want, I can create a simple project which does this. Otherwise there are plenty of example projects already out in the wild.

1 Like

Could you do that for me? That would be amazing!

If you are in the learning stage (I’m hoping) and not having to write production code for this year’s robot right now (it’s almost end of week 4). I would suggested that you start with just learning the basis of the RoboRio and the Control System (as in reading all those doumentations). Then start with just reading from/to a dashboard (using Network Tables). Might even wanted to start with using Robot Builder so that you don’t have to worry about the underlying stuff. Once you get more knowledge, then you can bypass the Robot Builder.

2 Likes

Yes, I am in the learning stage, thank you! P.S., why do you hope I am?

I would also checkout the examples that REV has which covers both brushed and brushless control.

Those examples can be found here: SPARK-MAX-Examples

I would also look at their Quick Start Guide for getting started using Spark Maxes in general.

WPILib Documentation can also be found here, which covers the FRC Control System basics.

3 Likes

Thank you!!

Have you looked at the Rev Robotics Spark Max example code? I think the read encoder values example does what you want.

2 Likes

Yes, but I was not sure how to implement it into my code.

Looking at the example projects and reading the documentation, should give you a good enough understanding of how to use the motor controllers in your own code. The example projects pretty much are already barebones projects as they stand.

If you’re looking for help integrating them into your own code, firstly, read over the documentation, guides, and examples provided by REV and WPI, then if you still need help, share the project you already have and we can give you some pointers.

1 Like

Be sure to install vendor libraries before writing any sort of code to test, or at least download a example from github with the correct vendor libraries Installed. often overlooked when making a new robot project. once you have downloaded the correct vendor libraries you should see them pop up under this directory in VS code. rev robotics

2 Likes

If you want to get started with java, take a look at the WPIlib docs here.

1 Like

because otherwise, you’ll be under extreme amount of stress to get to production ready code.

my advise for anyone starting programming, learn how to read housekeeping data and using network tables for passing variables back and forth between the drive station’s dashboard and roborio 1st (yes, without any motor/joystick/etc). then move on to just controlling a single motor (motor controller - start off easy with a PWM mc. going up to CAN bus isn’t much different other than a lot of options open up like piggybacked sensors, etc). while in learning mode, take your time, play with code and try to understands the why and how as before just jumping in.

good luck!

2 Likes

Thank you!

Thank you very much!

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.