ROBOTC.net forums
http://www.robotc.net/forums/

Tetrix Ranger Bot Arm and Gripper
http://www.robotc.net/forums/viewtopic.php?f=1&t=8871
Page 1 of 1

Author:  bjoe777 [ Sat May 24, 2014 8:56 pm ]
Post subject:  Tetrix Ranger Bot Arm and Gripper

I am brand new to Tetrix. I have been trying for a week to get my Tetrix Ranger Bot to work. I was able to program the Ranger Bot to move. However, I cannot get the arm and gripper to move with my joystick. I am referring to this arm and gripper: http://www.tetrixrobotics.com/gettingst ... ion2_3.htm. The sample program on this page is the automated version. I want to use my joystick. Any help with be greatly appreciated! :?

Author:  BurningLights [ Mon May 26, 2014 11:56 am ]
Post subject:  Re: Tetrix Ranger Bot Arm and Gripper

What are you trying to use to make the arm and gripper move? Buttons? Thumbsticks? The D-pad? If you post the code you have so far, we'll be able to help you out a lot more easily.

Author:  bjoe777 [ Mon May 26, 2014 5:32 pm ]
Post subject:  Re: Tetrix Ranger Bot Arm and Gripper

#pragma config(Hubs, S1, HTMotor, HTServo, none, none)
#pragma config(Sensor, S1, , sensorI2CMuxController)
#pragma config(Motor, mtr_S1_C1_1, motorD, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C1_2, motorE, tmotorTetrix, openLoop, reversed)
#pragma config(Servo, srvo_S1_C2_1, servo1, tServoNone)
#pragma config(Servo, srvo_S1_C2_2, servo2, tServoNone)
#pragma config(Servo, srvo_S1_C2_3, servo3, tServoNone)
#pragma config(Servo, srvo_S1_C2_4, servo4, tServoNone)
#pragma config(Servo, srvo_S1_C2_5, servo5, tServoNone)
#pragma config(Servo, srvo_S1_C2_6, servo6, tServoNone)

#include "JoystickDriver.c"

task main()
{
int threshold = 20; /* Int 'threshold' will allow us to ignore low */

while(true) // Infinite loop:

{
getJoystickSettings(joystick);

if(abs(joystick.joy1_y2) > threshold) // If the right analog stick's Y-axis readings are either above or below the threshold:
{
motor[motorD] = joystick.joy1_y2; // Motor D is assigned a power level equal to the right analog stick's Y-axis reading.
}
else // Else if the readings are within the threshold:
{
motor[motorD] = 0; // Motor D is stopped with a power level of 0.
}

if(abs(joystick.joy1_y1) > threshold) // If the left analog stick's Y-axis readings are either above or below the threshold:
{
motor[motorE] = joystick.joy1_y1; // Motor E is assigned a power level equal to the left analog stick's Y-axis reading.
}
else // Else if the readings are within the threshold:
{
motor[motorE] = 0; // Motor E is stopped with a power level of 0.
}

// BUTTONS TO CONTROL SERVO ARM
// Control arm via shoulder buttons, 1 and 4... 1=up, 4=down

int a = ServoValue[servo1];

if(joy1Btn(1) && a <= 245) // If Button 1 is pressed:
{
a = a + 5;
servo[servo1] = a; // Raise Servo 5 to position to 245.
}

if(joy1Btn(4) && a >=10) // If Button 4 is pressed:
{
a = a - 5; // Lower Servo 5 positions.
}
servo[servo1] = a;

wait1Msec (50);
}

//Buttons to control gripper
//This is the code that will not work

if(joy1Btn(2) && b <= 245) // If Button 2 is pressed:
{
b = b + 5;
servo[servo2] = a; // Open Servo 5 to position to 245.
}

if(joy1Btn(3) && a >=10) // If Button 3 is pressed:
{
b = b - 5; // Lower Servo 5 positions.
}
servo[servo2] = b;

wait1Msec (50);
}
}

//I would like to control servo2 (gripper) with buttons 2 and three, but I cannot get the gripper to work???

Author:  BurningLights [ Mon May 26, 2014 8:48 pm ]
Post subject:  Re: Tetrix Ranger Bot Arm and Gripper

You have the arm and gripper code outside of your infinite loop. Move the closing brace for that loop down below your arm and gripper code to fix this.

Author:  bjoe777 [ Mon May 26, 2014 9:39 pm ]
Post subject:  Re: Tetrix Ranger Bot Arm and Gripper

Thanks a bunch! Just corrected the code and compiled the program! It works great! I knew it was something small like that!!!!!

Author:  bjoe777 [ Wed May 28, 2014 11:16 am ]
Post subject:  Re: Tetrix Ranger Bot Arm and Gripper

How can I set the power level on motors d and e?

Author:  BurningLights [ Wed May 28, 2014 2:05 pm ]
Post subject:  Re: Tetrix Ranger Bot Arm and Gripper

bjoe777 wrote:
How can I set the power level on motors d and e?


It looks like you are in the code. Do the motors not work? If they don't, then it might be some kind of hardware problem.

Author:  bjoe777 [ Wed May 28, 2014 3:42 pm ]
Post subject:  Re: Tetrix Ranger Bot Arm and Gripper

Both motors work correctly. However, they are operating at 100%. I want to power both mothers (D,E) at 50%.

Author:  BurningLights [ Thu May 29, 2014 12:57 pm ]
Post subject:  Re: Tetrix Ranger Bot Arm and Gripper

bjoe777 wrote:
Both motors work correctly. However, they are operating at 100%. I want to power both mothers (D,E) at 50%.


Ah, OK. The values for the joystick axes go from -128 to +127. If you multiply the values by 0.5 before assigning them to the motor powers, this will give you a range of -64 to +63, which is about what you want. Or, to be a little more precise, you can multiply it by 0.39, which will give you a range of -50 to +49.

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/