Using a Neo and Sparkmax with Arduino

Hey CD!

Is it at all possible to run a neo or neo550 paired with a sparkmax with an arduino? I’ve read about the PWM ports on the sparkmax but am unsure about how they would be wired to the arduino. So far I understand that I would have to power the sparkmax externally with 12V and enough current. I am just unsure about how to actually tell the motor controller to spin the motor and how it would be wired.

You’d need to generate a PWM signal from the arduino to the Spark Max controller.

Here is the connector for PWM included with the controller and pinout:

CAN/PWM Port Connector Information

Connector Pin CAN Function PWM Function
1 CAN High Signal
2 CAN Low Ground
3 CAN High Signal
4 CAN Low Ground

Here is a video that goes into generating a PWM from an arduino to drive a different controller, but probably covers enough to figure it out with your devices: https://www.youtube.com/watch?app=desktop&v=Rc892r--njw&t=0s

edit: For power, we use a little 12v automotive circuit panel with circuit breakers to connect to 1-2 controllers for testing. We use a airplane servo controller to generate PWM to the spark maxes.

3 Likes

The examples for the Servo library will help here. It’s the same protocol, but the signal just corresponds to speed rather than a specific angle.

I see, could you elaborate a bit more on what you mean by “angle” vs “speed”? Would just running an analogWrite({PWM_PIN}, {0-255}) in a loop not work to spin the motor? Would it just send the motor to a certain angle like a servo?

What you’re looking for is the Servo.write() function. The note on continuous-rotation servos also applies to PWM motor controllers:

On a continuous rotation servo, this will set the speed of the servo (with 0 being full-speed in one direction, 180 being full speed in the other, and a value near 90 being no movement).

I’ve found that the Knob example is a good place to start with when working with motor controllers and Arduino.

Ive actually been doing work with this recently. I havent done it with sparkmaxes, but rather the original sparks with CIM motors, it should be a similar process. In terms of wiring, I’m using PWM control. I’m getting the signal, 5v power, and ground from the arduino. The Arduino must have a shared ground connection to the main FRC circuit for this to work. From there I am just using the arduino servo library, 180 is motor full speed forward, 90 is stopped, and 0 is full speed reverse. Let me know if you have any questions.

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