for some reason, it works fine but not in the correct direction. When I make the value positive instead of negative, the motor will step, it is not continuous.
here is what I am trying to do:
frc::Spark spark{2}; // 0 is the RIO PWM port this is connected to
spark.Set(0.75); // the % output of the motor, between -1 and 1 THIS IS THE VALUE I CHANGED
frc::VictorSP victor{2}; // 0 is the RIO PWM port this is connected to
victor.Set(.6); // the % output of the motor, between -1 and 1 I DONT KNOW WHAT THIS MEANS
First of all, this is the old version of the docs. Try this instead:
Next, if your motor is “jittering” in one direction or the other, the most likely cause is that you have two different controller.Set() calls in each loop, one of which is always negative if it works negative but not positive.
And finally, it’s much easier to troubleshoot your problem if we can see all of your code. The usual way to do this is to post it to github or similar and provide a link.
So, when we say the percent output is between -1 and 1, we mean that -1 is 100% the voltage of the battery input, hooked up completely backwards, which for brushed DC Motors (that you use with a Spark) forces them backwards. 0 would be “no output” or neutral, and 1 would be “full speed forward”.
Setting .75 means 75% battery voltage applied “positively”, and .6 is 60% of battery voltage applied positively. Doing both of these in the same robot periodic function will result in a slight jitter.
Your example snippet has two motor controller objects on the same physical port, which I can’t recall offhandedly if it’ll work at all but it’s certainly not a good idea. I suspect the jittering you report is related to that, or there’s a motor controller wiring issue.
And the documentation you’re looking at is correct.
I’m not seeing anything terribly wrong at first glace. Have you tried running your code in simulation? This will let you double-check what values you’re driving in your code to the PWM outputs. If simulation looks good it could be a cal issue on the motor controllers.