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

motor power reading
http://www.robotc.net/forums/viewtopic.php?f=1&t=4223
Page 1 of 1

Author:  Thibaud [ Wed Feb 08, 2012 3:15 pm ]
Post subject:  motor power reading

Hi,

Could you explain to me why the following code :
Code:
#pragma config(Motor,  motorA,          ,              tmotorNormal, openLoop)
#pragma config(Motor,  motorC,          ,              tmotorNormal, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

//#include "PID.h"
#include "Odo.h"



task main()
{
nMotorEncoder[motorA] = 0;
nMotorEncoder[motorC] = 0;

   motor[motorA] = (int)(1.0*0.047);
         motor[motorC] = (int)(1.0 * 0.047);
         wait1Msec(10);
         writeDebugStreamLine("%d;%d;", motor[motorC],motor[motorA]);//,(int)(1.0 * 0.047));

   motor[motorA] = floor(1.0*0.047);
         motor[motorC] = floor(1.0 * 0.047);
         wait1Msec(10);
         writeDebugStreamLine("%d;%d;%d", motor[motorC],motor[motorA],floor(1.0 * 0.047));

            motor[motorA] = 0;
         motor[motorC] = 0;
         wait1Msec(10);
         writeDebugStreamLine("%d;%d", motor[motorC],motor[motorA]);
         wait10Msec(100);
      writeDebugStreamLine("%d;%d", motor[motorC],motor[motorA]);

}


I have the following debug stream :

34;40;
34;40;0
34;40
34;40

My robot works better when the read of the motor[motorC] give 0 and not 34 or 40!

Thanks

Thibaud

Author:  MHTS [ Wed Feb 08, 2012 3:28 pm ]
Post subject:  Re: motor power reading

Hmm, that sounds like a bug in RobotC. The motor array takes integer type so the (int) cast of (1.0*0.047) should be 0. Please send a report to support@robotc.net.

Author:  Thibaud [ Wed Feb 08, 2012 4:53 pm ]
Post subject:  Re: motor power reading

Thanks for your answer i will send an email to the support.

If i restart the NXT(with usb connected) i obtain good results but sometimes the result are bad... it's very strange

Author:  Thibaud [ Sun Feb 12, 2012 3:06 pm ]
Post subject:  Re: motor power reading

I've done some tests today, after a run of my program, and download via usb the same program i've always the error. But if i use Bluetooth to download my program I don't have the error.

Author:  Thibaud [ Sun Feb 12, 2012 6:00 pm ]
Post subject:  Re: motor power reading

Hi Miki,

the error that I have is explained on my first post. When i download the program with usb and execute it the debug stream output is not good(i read some values in the motor array but not the 0 that i put in)

The motor execute my 0 as an other value!

Author:  Thibaud [ Mon Feb 13, 2012 4:59 am ]
Post subject:  Re: motor power reading

I will doing the test tonight.

But i want to add an information, the error is not only on the debugstream
if i do the following test

Code:
motor[motorA] = 0;
if(motor[motorA] == 0)
{
}
else
{
}


I enter in the else and not in the if. The thing persist in USB but not in BT... Sometimes if i'm not in debug i've the error to.

Thibaud.

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