Yes, using Motor.set(speed), it will accept a percent value between -1 (backwards at full speed) to 1 (forwards at full speed)
minor correction: -1 to 1 is a fractional value, not a percent value.
when we entering +0.3 accepts but it doesn’t accept -0.3, why and how we can solve it
Your code should work as intended, since every class that implements MotorController (which SparkMax does) can take negative (reversed) speeds as a parameter. Though VS Code may not display the parameter, the code looks like it should work, and the lack of parameter could just be a quirk of VS Code’s IntelliSense.
What is IntelliSense and can we turn it off
IntelliSense is extremely useful since it suggests the methods associated with classes, etc. You can turn it off in VSCode settings. If you want to turn off the parameter: value thing, you can search up inlay in VSCode and turn it off. Again, I suggest not turning off IntelliSense.
Do you have soft limits or maximum/minimum outputs set on the SparkMax? Check this in REV Hardware Client.
Is the NEO’s encoder cable connected to the correct SparkMax? I’ve seen issues where a motor controller won’t drive in one direction if the NEO has an encoder cable connected to the wrong motor controller.
i’ll check it tomorrow
btw thx
I think you are referring to the VSC setting Inlay Hints
. Some people on my team don’t like them but I do but only if less intrusive, I set the Font size 9 to make them a little smaller and more obviously not what is actual code.
I have noticed that occasionally the hint doesn’t appear and I haven’t figured out the pattern. The code that I guess you have shown works for me but unfortunately you didn’t show enough program to know for sure what your code is. Showing the minimal failing code is a good practice but one needs to show the COMPLETE minimal failing program and not just a small fractured piece of it.
Besides soft limits and hard digital switch limits set in the motor controller there are also voltage compensation/nominal voltage settings that can cause the motor to stop at certain points such as don’t run backwards. That can be useful for a motor such as on a shooter that is never to run backwards even if the PID controller wants to change the speed quickly by forcing a short stint going backwards.
Does the CIM motor run in both directions when you remove that motor from the gearbox you have it attached to? What can you tell us about that gearbox?
yea it works, we can turn it each sides when we use rev Hadrare client but when we use teleoperating it turns only forward but everyone says code is right
To clarify my question - does the CIM motor run in both directions (using that code or otherwise) when it’s not attached to that gearbox?
Maybe controller is bad, check it at driverstation.
If it’s a CIM, swap the red and black temporarily, then try to drive forward. If it drives in reverse, you have a software issue. If not, it’s a hardware problem
Did you do the calibration steps for forcing it to learn full pwm range of the motor controller? Most of the victor motor controllers need you to calibrate by holding down a teeny tiny button and providing a full forwards and backwards PWM value. Uncalibrated it might only be tuned for half of your PWM square waves length. Therefore it could only spin one direction.
how can we do it for SparkMax
Similar threads merged. Users, please don’t create duplicates.