|
悬赏1乐币未解决
写个简单的robotc 程序,BC两轮前进,每转动1度做一次记录.察看文件前面数据正常,后面一段就跳变,是什么原因呀.
程序很简单:
#pragma config(Motor, motorC, leftwheel, tmotorEV3_Large, PIDControl, encoder)
#pragma config(Motor, motorB, rightwheel, tmotorEV3_Large, PIDControl, encoder)
int old_encode, g_encode;
task main()
{
motor[motorC] = 20;
motor[motorB] = 20;
if (!datalogOpen(9, 2, false))
writeDebugStreamLine("Unable to open datalog");
resetMotorEncoder(motorC);
old_encode = getMotorEncoder(motorC);
time1[T1] = 0;
while(time1[T1] < 1500)
{
g_encode = getMotorEncoder(motorC);
if (g_encode > old_encode) '如果有变化就 记录
{
datalogAddLong(0, time1[T1]);
datalogAddLong(1, g_encode);
old_encode = g_encode;
}
}
datalogClose();
motor[motorC] = 0;
motor[motorB] = 0;
}
=========记录的结果摘取部分============
558,99
558,100
564,101
570,102
573,103
579,104
584,105
591,106
591,173 '-----这个地方跳变了
591,174
933,175
939,176
|
|