Hey,
i am trying to make a program that ramps up the speed of the motor ( through the vectorSP or any Electric Speed controller ) the idea is i will just keep adding 0.01 until i reach the set speed i cant do it by making a loop ( because it will stop any other thing running on the roborio ) so i will need to know the amount of the MIPS ( million instructions per second ) of the roborio
Does anyone know the MIPS of the Roborio or different way of doing this.
What programming language are you using to program the RoboRIO? In Java, commands created for the command-based robot class will always run at 20 Hz (one execution every 0.05s) 50 Hz (one execution every 0.02s), so you can use that to create your ramping code.
Will you have an encoder or other sensor available?
If not, you can use edu.wpi.first.wpilibj.Timer.getFPGATimestamp() to get the current loop’s time. This allows you to ramp the motor up using an equation based upon actual time rather than MIPS (which is actually somewhat inaccurate each cycle).
Keep in mind that even in the ‘command’ structure, your code is still a single iteration of a gigantic loop.
Be careful always making this assumption. The loop timing can be variable. It’s far safer to calculate the actual elapsed time and use that to determine how much step function should increment. Especially in situations where things are looping quickly, small changes in loop timing can have large effects on the outcome.
It’s valid (and indeed must be valid) if everything between your software and the silicon is guaranteed real-time - this is how you are able to implement safety-critical software.
If you’re coming from Arduino or MSP430 type chip programming, you are used to this assumption being true.
The key difference is that Java in the RoboRIO cannot run real time due to the JVM.
One very minor caution on using delta-times read from getFPGATimestamp() - if you are single-step debugging and stop at some breakpoint, it does not stop the FPGA timer. This may cause abnormally long delta-t’s between loops and possibly unexpected behavior in your code.