Decreasing sensitivity of my PS2 controlled bot
hi there!
so using code control robot wireless ps2 gaming controller.
problem controls sensitive difficult control robot. minor movement on analog stick causes shoot across room! need create similar "expo" on rc transmitters. quick explanation:
""expo" short "exponential" , gives slop in movement of controller sticks. expo disabled (the default value), if move stick 50% of distance between center , edge, servo move 50%. move 75% servo moves 75%. easy, right?
now, give expo value , softening factor comes in. let's move stick 30%. instead of servo moving 30% of range, move degree less. higher expo setting, less servo move near center-stick area."
i've been looking @ softpwm library (https://code.google.com/p/rogue-code/wiki/softpwmlibrarydocumentation). perhaps come play. suggestions on how bot under control?
thanks!!!!
walter
so using code control robot wireless ps2 gaming controller.
code: [select]
// 4/24/14
//sketch uses input left analog stick of ps2 gaming controller
// control motor driver requiring inputs 1000-2000us
#include <servo.h>
#include <ps2x_lib.h> //for v1.6
ps2x ps2x; // create ps2 controller class
int error = 0;
byte type = 0;
byte vibrate = 0;
servo signal1;
servo signal2;
int input1 = 1500;// creates servo object
int input2 = 1500;
void setup()
{
serial.begin(57600);
signal1.attach(4); //the pins servo control
signal2.attach(5);
error = ps2x.config_gamepad(13,11,10,12, true, true); //setup pins , settings: gamepad(clock, command, attention, data, pressures?, rumble?) check error
if(error == 0)
serial.println("controller found! may send commands");
else if(error == 1)
serial.println("no controller found, check wiring, see readme.txt enable debug. visit www.billporter.info troubleshooting tips");
else if(error == 2)
serial.println("controller found not accepting commands. see readme.txt enable debug. visit www.billporter.info troubleshooting tips");
else if(error == 3)
serial.println("controller refusing enter pressures mode, may not support it. ");
type = ps2x.readtype();
switch(type)
{
case 0:
serial.println("unknown controller type");
break;
case 1:
serial.println("dualshock controller found");
break;
}
}
//my sabortooth motordriver can use 2 signals 1000us-2000us control 2 motors
void loop()
{
if(error == 1) //skip loop if no controller found
{
return;
}
else
{
ps2x.read_gamepad(false, 0);
input1 = map(ps2x.analog(pss_ly), 0, 255, 2000, 1000);
signal1.writemicroseconds(input1);
//serial.print ("input1: ");
// serial.println (input1);
input2 = map(ps2x.analog(pss_lx), 0, 255, 2000, 1000);
signal2.writemicroseconds(input2);
//serial.print ("input2: ");
// serial.println (input2);
delay(8);
}
}
problem controls sensitive difficult control robot. minor movement on analog stick causes shoot across room! need create similar "expo" on rc transmitters. quick explanation:
""expo" short "exponential" , gives slop in movement of controller sticks. expo disabled (the default value), if move stick 50% of distance between center , edge, servo move 50%. move 75% servo moves 75%. easy, right?
now, give expo value , softening factor comes in. let's move stick 30%. instead of servo moving 30% of range, move degree less. higher expo setting, less servo move near center-stick area."
i've been looking @ softpwm library (https://code.google.com/p/rogue-code/wiki/softpwmlibrarydocumentation). perhaps come play. suggestions on how bot under control?
thanks!!!!
walter
code: [select]
input1 = map(ps2x.analog(pss_ly), 0, 255, 2000, 1000);
what proof can offer analog() method returns value in range 0 255?
the other values speed set (continuous rotation, not a) servo to. if want robot go slower, use 2 values equally closer 1500 range.
Arduino Forum > Using Arduino > Programming Questions > Decreasing sensitivity of my PS2 controlled bot
arduino
Comments
Post a Comment