How do I set up 393 IMEs to ensure two motors are rotating at the same speed (on joystick control)?

I’m currently using some very basic code to run the robot, and would like to use the IMEs to fix some drag we are experiencing. I have set up the IMEs such that they are reading correct data.

Basic code:

#pragma config(I2C_Usage, I2C1, i2cSensors)
#pragma config(Sensor, I2C_1,  Left_IEM,       sensorQuadEncoderOnI2CPort,    , AutoAssign )
#pragma config(Sensor, I2C_2,  Right_IEM,      sensorQuadEncoderOnI2CPort,    , AutoAssign )
#pragma config(Motor,  port1,           right,         tmotorVex393_HBridge, openLoop, reversed, encoderPort, I2C_2)
#pragma config(Motor,  port6,           claw,          tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port7,           arm,           tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor,  port10,          left,          tmotorVex393_HBridge, openLoop, encoderPort, I2C_1)

//

task main()
{
	while(1 == 1)
	{
		motor[left] = vexRT[Ch2];
		motor[right] = vexRT[Ch3];
		motor[center] = (vexRT[Ch1]/2 + vexRT[Ch4]/2);
		motor[arm]= (vexRT[Btn5U]*-70 + vexRT[Btn5D]*70);
		motor[claw]= (vexRT[Btn6U]*-50 + vexRT[Btn6D]*50);
	}
}

To make sure that both are running at the same velocity, you will need some kind of PID controller for each motor. If these are on a drive, you will also need another controller to ensure that the robot drives straight.

2 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.