I set up a base with a pair of motors and a single controller on one of our V5 systems. I used the sample code provided on the “help” website and downloaded it to the “brain”. The issue seems that the value(s) associated with axis2 and axis3 of the controller are not being read in when the program runs. If I replace the values with constants (numbers) rather than the axis values, the motors run properly. I have the controller plugged into a port on the brain and it is recognized by the system and when the program runs, the controller display looks fine. I have written a program that displays the values of the axes on the brain but the values are always 0. Appears to be some sort of configuration problem. Any insight would be appreciated.
Is the controller properly setup in robot-config.h? It should say something like vex::controller Controller1 = vex::controller();
. If that looks good, double check to make sure the code that sets the motor speeds is correct. For split drive, something like this should work:
If not, can you post the code or the link to the code so I can look over it?
Heres the code; I think that it contains all your suggestions and I thank you for your help.
robot-config.h
using namespace vex;
vex:: motor LeftMotor (vex::PORT6, vex::gearSetting::ratio18_1, false);
vex:: motor RightMotor (vex::PORT10, vex::gearSetting::ratio18_1, true);
vex::controller Controller1 = vex::controller();
main.cpp
#include “robot-config.h”
int main() {
while(true) {
LeftMotor.spin(vex::directionType::fwd, Controller1.Axis3.value(),vex::velocityUnits::pct);
RightMotor.spin(vex::directionType::fwd, Controller1.Axis2.value(),vex::velocityUnits::pct);
vex::task::sleep(20);
}
}
Try changing your robot-config.h to:
vex::brain Brain;
vex::motor LeftMotor = vex::motor(vex::PORT6, vex::gearSetting::ratio18_1, true);
vex::motor RightMotor = vex::motor(vex::PORT10, vex::gearSetting::ratio18_1, false);
vex::controller Controller1 = vex::controller();
I’ll give it a shot when I get back to the lab, most likely tomorrow. I’m home with “zero” equipment. Thanks again for your help.