Could you help me control rev spark max & motor 550 with torgue and power

could you tell me which function will be used for rev spark max & motor 550 to calculate or controll it’s torgue and power? its manual have said it can use like a FOC controller, but how i can make it

i’ve also tried use frame to control it but seems do not do a great work

AFAIK there is no torque or FOC with any of REVs products. There is current control, but that’s the limit.

If you had posted the reference we might have been able to explain. The only thing I find is RevRobotics Falcon 500 with the integrated CTRE TalonFX has FOC and I think that means that’s the only way it works in brushless mode and there is no need to request it.

I and others in another CD thread agree with you that some of the update periods are long and not changeable. I don’t remember the details, though.

humm, in this page shows a function called setReference() provide a interrupt to use ControlType::Current
SparkMaxPIDController (FRC-REVLib API) (

REVLibError setReference​(double value, CANSparkMax.ControlType ctrl) Set the controller reference value based on the selected control mode.

Right that’s what @Daltz3 wrote. The doc you reference says:

value - The value to set depending on the control mode. For basic duty cycle control this should be a value between -1 and 1 Otherwise: Voltage Control: Voltage (volts) Velocity Control: Velocity (RPM) Position Control: Position (Rotations) Current Control: Current (Amps). Native units can be changed using the setPositionConversionFactor() or setVelocityConversionFactor() methods of the CANEncoder class

So you can control voltage or current but not both at the same time which is what I think you are asking.

1 Like

emm, does this mean that when I control it in mode::current I can’t make sure it’s at 12V

That’s true.

  • Control one or the other.
  • Run your machine to see what the uncontrolled value that must necessarily follow the controlled parameter for the motor load or check your motor speed.
  • Pick gears to get you where you want to be on the motor operating curves.

This isn’t true (as of today).

The firmware update for FOC for Falcon 500 / Talon FX is still not available.


Well we have already tried, actually we ignore the point that the voltage will change, so we are just puzzled about why we couldn’t control it well, & we’d like to try again with voltage shows in shuffleboard

You probably want to check out the motor curves for NEO 550: VEX Robotics Motor Data - NEO 550 (REV-21-1651). See how there are different graphs for different voltages? And, how for each voltage, the current, torque, and power are graphed against RPM? Note that you really want to run motors (especially this one) on the right half of the power curve.

Another important graph is here: NEO Brushless Motor - Locked-rotor Testing. You really want to set a non-default current limit when using this motor. If you do this, you can kind of just try different things and not have to worry about frying the motor – provided you watch the temperature/time and understand what the “Data Summary” graph is telling you.

So, set an appropriate limit, and see where the motor runs at full power – set(1.0) – when running your mechanism, for just a short time. Check the voltage and current. You may need to change your gearing, if it is stalling or running in the left half of the power curve. You will lose some power through gearing, mechanism, rolling resistance, etc. You may be able to just use setVoltage(), which is probably the simplest way to control things for many mechanisms.

If you need/want to do some other type of control, the most common is either position or velocity. If you want to control torque, current control is a good proxy, since you have a built-in sensor for this (and, typically do not for torque). The API for this is setReference(current, rev::CANSparkMax::ControlType::kCurrent, …), but there’s a bit more to it (you need to set PID constants).

One way to look a this is to work out the mechanical load – where do you need to be with RPM / torque / power? Which of these is important for your mechanism? For a shooter, it’s probably RPM. For an arm, it may well be torque. Then, work out the power – can the motor produce this?
For how long and at what torque? These theoretical calculations can help you with selecting your gearing, but it’s common for people to just guess here. Getting the gearing right will make a big difference, so if you go this route, it’s very nice to be able easily change the gear ratio. You may want to design using the 10V motor curve, to allow for lower voltage during a match, and/or to give yourself some margin.

1 Like

yeh! I found in CANSparkMax.h but API says it is equivalent to SetReference(output,CANSparkMax::ControlType::kVoltage)
I’d like to understand it as a voltage PIDcontroller. So I’m curious about it if I can use one more PIDcontroller object to control current. Maybe use another PIDcontroller object for voltage instead function SetVoltage

void CANSparkMax::SetVoltage ( units::volt_t output ) override
Sets the voltage output of the SpeedController. This is equivalent to a call to SetReference(output, CANSparkMax::ControlType::kVoltage). The behavior of this call differs slightly from the WPILib documentation for this call since the device internally sets the desired voltage (not a compensation value). That means that this can be a ‘set-and-forget’ call.

And my mentor doesn’t allow me to infer it without I actually measure the voltage & current

Our offseason project seems like a robot arm, so a precise controller is necessary to us to against with gravity. We’ve tried use inference with motor data which is provided by VEX. But there are still problems in actually use with other noise, steady error or even more factors that is unpredictable. So, we are finding a way which can provide us an interface to control torque directly. I also tried some products, maybe ESC. We are also looking for some FOC controller from third but some of them is too expensive or maybe we will make the FOC controller ourselves.

1 Like

I doubt kVoltage and kCurrent are the same – they operate in a similar way, but are using a different measurement for feedback. Also, they may do similar things in practice. But, if you really want to control torque, use kCurrent. SetVoltage is normally different – it is not using closed-loop feedback, it is compensating by adjusting the output percentage by scaling the desired output voltage to reflect the input voltage (which isn’t fixed, as the load changes and the battery discharges). The REV documentation you linked suggests that the SPARK MAX implementation of SetVoltage instead works in a similar way as with kVoltage. This still isn’t the same as using kCurrent.

For an arm, there are threads here on CD which discuss using position control, with a feedforward term computed based on the angle of the arm. This is probably a better way to go than trying to use current control, since you ultimately care about the position of the arm.

No matter what, don’t forget to set current limits, especially for NEO 550.

cool maybe

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