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

tetrix PID motor controller question
http://robotc.net/forums/viewtopic.php?f=52&t=2124
Page 1 of 1

Author:  cdasher [ Fri Jan 22, 2010 10:09 am ]
Post subject:  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);
}
}

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