Our team is new to vex EDR because previously we were in IQ and our robot keeps driving in a curved line so we bought motor encoders (the integrated encoder ones) and I’m supposed to program them but no one knows how to so I watched this video :
which i must admit is very helpful but i basically just copied it exactly and i understand how it works but I don’t get how to plug it in to the robot. What is daisy chaining? Also what kind of sensor is it in robot c because there isn’t an option for integrated encoders in ‘motors and sensors set up’ and I’m really confused. Additionally where does the programming for the motor encoders go in the competition template: before the pre auton, in the pre auton or in the autonomous part or at the end or what?
*(Also I originally put this in the ROBOTC Tech Support channel because i didn’t get how the channels work but now it’s on this channel because I was corrected.) *
The IEM’s are connected to the I2C port in a daisy chain… you connect one of the IEM’s to that port, then a second IEM to the first one and so on. In motor setup, there is a column named “encoder port” . For each motor with an IEM, assign it an I2C-# based on its order in the chain. When coding for the sensor value, refer to the motor name.
The I2C sensors communicate in data packets back to the Cortex telling it what happened since the last time it communicated. RobotC takes care of the heavy lifting for you so all you have to do is use nMotorEncoder[your_motor_name] to get the value of ticks it has seen. The sensors post back their data set every few milliseconds one sensor at a time. The longer your daisy chain the longer in between messages. (but it should be within a few milliseconds)
Hi
I was wondering if it is possible to programme our claw to stop it from rotating inwards past a ‘closed’ position using IEMs?
Does anyone know how to do this or if there are any links online such as the very helpful Carnegie Mellon ones?
The IME reads how many ticks your motor has moved since the starting position.
So you can start in the open or closed position. You will have to know how far the motor can close if you start in the open position. That is much harder.
If you start in the closed position, you are at 0. So you just need to be close to 0 when you stop. You may want to have a timer kick you out if the IME does not move in a few hundred milliseconds. That would mean you are blocked.
I think we will start in the open position because our claw starts all the way open (past 180 degrees) around our robot to be within the size restrictions at the start of a match. We don’t mind having to test how many ‘ticks’ the motor moves to bring it to a closed position.
I’m just not sure what functions and commands to use on Robot c to prevent the claw from over-rotating inwards in Driver Control mode.
close. The nMotorEncoder only accepts one argument so you will have to measure one claw motor. The while loop also will stay in control there until the IME is under 220. So an if statement will work there and you catch it each loop around.
Also, once you leave the while loop, you should shut the claw motors off. The motors won’t shut off until the buttons are not pressed any longer. You never tell the motors something else to do.
This will work but one problem that can arise with this is that if the motor has something preventing closing further, it will still run the motors full force to close.
So making a function to put all this special logic is a good way to treat the open and close claw activities. In there, you can check to see if too much time has passed, compute a IME ticks velocity to see if it is stuck, and other cool tricks to save your motors from overheating. Independently controlling left or right claw, etc.
But the structure you have now with some tweaks should work for what you want to do.
If left and right are independent, make them into their own if blocks.
if(vexRT[Btn6U]==1)
{
if(nmotorencoder[clawLeft] < 220) //assuming that it takes 220 ticks to close the claw
{
motor[clawLeft] = 127;
motor[clawRight] = 127;
}
else
{
motor[clawLeft] = 0;
motor[clawRight] = 0;
}
}
else if (vexRT[Btn6D]==1)
{
motor[clawLeft] = -127;
motor[clawRight] = -127;
}
else
{
motor[clawLeft] = 0;
motor[clawRight] =0;
}
hi guys, I’ve managed to zero the motor controllers in the closed position, can anyone help with the code to stop the claw opening past 90 degrees?
Our problem is that when we set the parameters to any positive number, the claw is able to open and close fully, as if there were no parameters and if the parameters are any negative number then the button to open the law doesn’t wok at all.
if(vexRT[Btn6U]==1)
{
motor[leftClaw] = 127;
motor[rightClaw] = 127;
}
else if (vexRT[Btn6D]==1)
{
if(nMotorEncoder[leftClaw] < 1) // -100 is the amount of ticks when claw open at horizontal
{
motor[leftClaw] = -127;
motor[rightClaw] = -127;
}
else
{
motor[leftClaw] = 0;
motor[rightClaw] = 0;
}
}
else
{
motor[leftClaw] = 0;
motor[rightClaw] = 0;
}
You will need to do the math on ticks per 90 degrees based on your gearing. Torque geared motors have 627 ticks per revolution. Your external gearing will affect how that becomes 90 degrees of claw motion. To resolve the negative sensor value, you can test for the absolute value.
if ( abs(nMotorEncoder[leftClaw]) < 627 ) // tests for one torque rotation in either direction
{
// claw code
}