Our team is trying to code our robot to accelerate slowly, regardless of the joystick’s position(The driver slams the joystick full forward, but the robot takes off slowly). We are doing this to keep the robot from spinning the tires on the slick floor and hopefully to gain better traction at take-off. We are using the Get Motor subVI, Set Motor, and Get Joystick. We subtract the value of the motor from the value of the Joystick, divide the result by a set number(currently 10,000), add this quotient to the motor value, then set the motor to that value. We are quite sure that Get Joystick, Set Motor, and Get Motor all use decimal values from -1.0 to 1.0, but if someone knows otherwise, please tell us. The code works when the joystick is being pressed in one direction, but not when it is being pressed in the opposite direction. We have also noticed that the motor is in the deadband until it reaches the maximum value. If anyone has any information on creating a code like this, please speak up, as it has halted our coding from going any farther for the time being.
It would help immensely if you could post your code, or a snapshot of the relevant portion of your code. As it is, my questions are, which divide function are you using, floating point divide, or “Quotient and Remainder”? Also, your code as described, will accelerate faster at the beginning and slower towards the end. I don’t want to think of how long it’d take your robot to get up to the joystick’s command doing it that way. It’d be a very long time, however.
The usual way to do this is to pick a specific number to add to the motor command every loop, until you get to the joystick command. So you’d just add (or subtract), say, 0.001 to the motor command on every loop, and then make sure it’s not larger (or smaller) than the joystick value.
One thing that we’ve learned certainly aids in the debugging process is probes and the button I like to call “data flow”. I’m sure there is specific technical LabView documentation on this somewhere, but this is what I know. Click on any wire while the program/code is running, and you’ll get a look into what that wire is carrying at the moment (might be real time, but I can’t remember). Another nice thing is there is a button at the top of the screen that looks kinda like a light bulb (aka “data flow” as I call it). If you press it, you will see the data flow across the screen (no serious, like electrons do in wires in animated movies) along with numbers showing up for where actions occur. Be warned though that “data flow” SEVERELY slows down your code execution for the time is takes the data to flow through your entire VI, and may cause robot damage if you do any motor movement that isn’t changed until later in the VI.
Cheers
-Tanner
Here is something you can try. You don’t need a cRIO to run it and play with it. It uses a mouse (horizontal movement), but you get the idea, we may use something like this for our robot, we may also add feedback. You will need to change the upper limit to something greater than 100, like 1600, do this in the front panel before you run it.
jim
LeadLagEx.vi (36.4 KB)
LeadLagEx.vi (36.4 KB)