Does anyone have any experience with ramping motors in a command based system? I tried adding a for loop to a subsystem method but then I couldn’t drive the robot asynchronously. So I tried adding a command to make the subsystem drive at a variable speed and then creating a command group that uses a for-loop to add a series of that command, each with an increasing parameter. This worked asynchronously, but I needed to be able to change the variables continually throughout the program, not have them be statically set like commands do (if you use them correctly, of course). I could. I know these are both terrible ways to accomplish this besides the caveats I mentioned (the second one particularly bad), but I was desperate.
**In short, is there a better way to do this by making the variables both adjustable via the dashboard (instead of being initially set when the robot turns on) *AND *make this loop operate asynchronously? **
if (currentVoltage < targetVoltage)
currentVoltage += 0.01
else if (currentVoltage > targetVoltage)
currentVoltage -= 0.01
This will bump your voltage closer to your target voltage each iterative loop.
Of course you’ll want to clean it up, but this should give you a general idea.
Do not use loops inside your command executes. They are already looped for you each during iteration. Unlike the SimpleRobot template, you cannot loop inside your command executes for a long period of time. Your execute methods need to run as quickly as possible, so any other parallel commands can be run immediately after. If you loop, you will stall the rest of your code, thus losing the ability to run things asynchronously.
Instead of trying to do what you want programatically, you might want to use built-in options for your motor controller.
If you are using jaguars, they have ramping modes built in(but disabled by default). To enable voltage ramping, you need to change some jumpers.(see in the attached manual p.12) You can even change the rate of ramping using the serial interface and some NI software.
Checkout page 11 of the attached manual to see if this is what you want. Look at coast/break jumper and the automatic ramp mode.
Q8 & Q9 in the FAQ seem to be saying that the factory “preset value” cannot be changed, and will be used every time the Jag is power cycled. Could someone who has actually done it please confirm?
Q8 & Q9 in the FAQ seem to be saying that the factory “preset value” cannot be changed, and will be used every time the Jag is power cycled. Could someone who has actually done it please confirm?
It also mentions that it only resets the ramp rate if the automatic mode is enabled. You can disable the mode, it says in your second thumbnail.
If you disable it, it doesn’t function in PWM mode. So it’s not clear what point you are making. e.g. I have a car with a dead battery. It works fine unless I try to start it.
No, you can’t save a ramp rate and have it stick after a power cycle. The only configuration parameter that is saved in flash (immune to a power cycle) is the Jaguar ID.
The idea behind the Automatic Ramp Mode was to give teams a quick way to prevent high current spikes without having to write code or hook up the CAN/Serial interface.
If you need the ability to tweak your ramp rate, you either need to use CAN/Serial the whole time or write a ramp into your PWM code.
PWM is stupid, I’m switching to CAN. Unfortunately, I didn’t request CAN when I ordered, so now I have to buy the RS232-RJ11 and RJ11-RJ11 cables. Oh well…
If you don’t want to use CAN and you still want ramping, you can modify the source file for the Jaguar class to just average out speeds over the last 20 ms or so before setting the output speed.