Hello, I am very early beginner to coding in LabVeiw, and I’m trying to use SparkMax encoders to help me write accurate auto-code, but I can’t find anything anywhere!
If anyone knows how to:
A. Set an encoder up on a SparkMax (which is connected to a Neo)
B. Draw values from it that I can use in auto
Okay perfect, my encoder is now reading, but how can we use those values from the encoder in our auto code? I couldn’t really find any examples on that anywhere…
For example: I want to run my motors until we hit 15 revolutions.
Something like this in Autonomous Independent.vi
I’d usually translate revolutions into inches traveled as that’s easier to think about and measure,
e.g., either calculate it or push the robot a measured distance and see what value Left Motor Rotations ends with.
Watch the value of Left Motor Rotations when you try this.
The value may be negative depending on direction, so you may need to add a check for (< -15) as well, e.g., > 15 or < -15
Okay, the motors will run in our auto, but they won’t stop after 15 rotations. I’ve tried <-15 and >15 but neither seem to work. No errors appear in the driver station. I just copied the screenshot so I don’t exactly know what the problem could be, mind helping out again?
We have gotten it working now, however I am trying to write it myself but I don’t know how you got the DBL for the motor rotations. If you could explain how you got it that would help a lot!
That’s just a right-click and “Create indicator” on the output node.
It’ll first appear a little different and will work fine, but there is a show as icon selection that just makes it smaller.