Having issue with our remote having a deadzone. And do not know how to program a fix for it. We are using arcade mode drive and can’t find a sample or a code already developed that we can use. Any help would be great. C++ format
First set a variable to the joystick value. Then see if it’s less than the deadzone, if it is set the variable to 0. Set the motor to the variable.
int x = joystick value
if abs(joystick value) less than 10, set x to 0
Motor.spin(forward, x, percent);
I’m pretty new to coding and basically been learning and experimenting from the sample codes. This is all over my head. Some solid examples would be great.
int x = Controller1.Axis3.value();
if(fabs(x)<10){
x=0;
}
Motor.spin(forward,x,percent);
This basically gets the value from the joystick and checks if it’s less than 10.
If it’s less than 10, set the motor to 0.
If it’s greater than 10, run the motor at the joystick value.
Basically make an int for every joystick, check each joystick and incorporate the variables into the Motor.spin
Where does that particular code would go before or after on the drive code?
It would go before because u want to check if it’s less than 10 before giving power to the motor
Finally go around with programming still not working.
Any help would help. I wish vex would come up one a sample program to help all teams out.
sample program to do what ?
For a deadzone program. This ghost remote drifting is only affecting us not the other teams.
ok, here is an example valid for VEXcode.
VEXcode simple arcade control with deadband
/*----------------------------------------------------------------------------*/
/* */
/* Module: main.cpp */
/* Author: james */
/* Created: Wed Nov 20 2019 */
/* Description: V5 project */
/* */
/*----------------------------------------------------------------------------*/
#include "vex.h"
using namespace vex;
// A global instance of vex::brain used for printing to the V5 brain screen
vex::brain Brain;
// define your global instances of motors and other devices here
vex::controller Controller;
vex::motor motor_l( vex::PORT1 );
vex::motor motor_r( vex::PORT10 );
int main() {
int forward_pct;
int turn_pct;
double drive_l;
double drive_r;
while(1) {
forward_pct = Controller.Axis3.position();
turn_pct = Controller.Axis4.position();
// deadband, set to 0 if below the deadband value
const int deadband = 15;
if( abs( forward_pct ) < deadband ) forward_pct = 0;
if( abs( turn_pct ) < deadband ) turn_pct = 0;
// arcade drive
drive_l = forward_pct + turn_pct;
drive_r = forward_pct - turn_pct;
// send to motors
motor_l.spin( forward, drive_l, percentUnits::pct );
motor_r.spin( forward, drive_r, percentUnits::pct );
// Allow other tasks to run
this_thread::sleep_for(10);
}
}
For the last parameters in the .spin commands you need to put velocityUnits::pct and not % or velocityUnits::.
Wait a minute he is using VCS shouldn’t he be using vex code instead as VCS is no longer supported.
We haven’t switched over yet because school haven’t updated the software for us yet.
It’s ultimately their choice, there are no rules against using VCS, however VexCode is recommended.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.