View unanswered posts | View active topics It is currently Wed Sep 23, 2020 2:09 pm

Reply to topic  [ 2 posts ] 
Tetrix motor PID controls? 
Author Message

Joined: Thu Jan 21, 2010 3:08 pm
Posts: 2
Post Tetrix motor PID controls?
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;

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()

while (true)
move (20,-100);

Thu Jan 21, 2010 5:40 pm
User avatar

Joined: Mon Feb 23, 2009 12:40 pm
Posts: 27
Post Re: Tetrix motor PID controls?
One problem I see is that you have 360 as the number of counts per revolution. Actually the encoders have 1440 counts per revolution. I am not sure about using nMoterEncoderTarget with the 12VDC motors (our programmer just calculated the count value and waited until they were reached and stopped the motors.

Also, the way your code is written, your move routine is called every time through the main loop. You may want to wait in your routing until the robot has finished moving and you probably don't want to call you routine every time through the main while loop.

Mon Jan 25, 2010 2:09 pm
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.