|
cdasher
Rookie
Joined: Thu Jan 21, 2010 3:08 pm Posts: 2
|
 tetrix PID motor controller question
I want to be able to determine how far my robot goes based on the PID control in the tetrix motors. Is this like the NXT motor, where it polls how many degrees of rotation the motor has gone? Is this possible, and if so, what is wrong with my code?
#pragma config(Hubs, S1, HTMotor, HTServo, HTMotor, none) #pragma config(Sensor, S2, ultra, sensorSONAR) #pragma config(Motor, mtr_S1_C1_1, motorD, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C1_2, motorE, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C3_1, motorF, tmotorNormal, PIDControl, encoder) #pragma config(Motor, mtr_S1_C3_2, motorG, tmotorNormal, PIDControl, encoder) #pragma config(Servo, srvo_S1_C2_1, , tServoNormal) #include "JoystickDriver.c"
void initializeRobot() { servo[servo1] = 80; return; }
void move (int x, int y); void move (int x, int y) { int target1; target1 = x * 360 / 12.56; nMotorEncoder[motorF] = 0; nMotorEncoderTarget[motorF] = target1; motor[motorF] = -y; int target2; target2 = x * 360 / 12.56; nMotorEncoder[motorG] = 0; nMotorEncoderTarget[motorG] = -target2; motor[motorG] = y; }
task main() { initializeRobot();
while (true) { move (20,-100); } }
|