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

HiTechnic DC Motor Shaft Encoder Problem with RobotC
http://robotc.net/forums/viewtopic.php?f=52&t=878
Page 1 of 1

Author:  cdvenkat [ Sun Nov 02, 2008 3:44 pm ]
Post subject:  HiTechnic DC Motor Shaft Encoder Problem with RobotC

We are trying to make Shaft encoders to work on RobotC 1.44. The listing below. Trying to run the motor until shaft encode reaches 1000. Motor is keeps running not stopping. Motors are working fine though. We mounted the the Shaft encoders as per instructions on the Shaft Encoders.

Connection: MotorE --> DC Motor Controller Motor2 and Enc2


Here is program, we are running.
#pragma config(Hubs, S1, HTMotor, HTServo, none, none)
#pragma config(Motor, mtr_S1_C1_1, motorD, tmotorNormal, openLoop, reversed)
#pragma config(Motor, mtr_S1_C1_2, motorE, tmotorNormal, PIDControl)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

task main()
{
nMotorEncoder[motorE] = 0;
nMotorEncoderTarget[motorE] = 1000;
motor[motorE]=75;
while(nMotorEncoder[motorE] < 1000)
{
nxtDisplayTextLine(1, "EV=%d", nMotorEncoderTarget[motorE] );
}
wait10Msec(100);
}

-C D Venkatesh

Author:  Jeff McBride [ Sun Nov 02, 2008 4:22 pm ]
Post subject:  Re: HiTechnic DC Motor Shaft Encoder Problem with RobotC

Your code never stops motorE.

Code:
...

while(nMotorEncoder[motorE] < 1000)
{
    nxtDisplayTextLine(1, "EV=%d", nMotorEncoderTarget[motorE] );
    wait10Msec(1);  // No reason to loop any faster than this.
}

motor[motorE] = 0;  // Reached the target
wait10Msec(100);

}

Author:  cdvenkat [ Sun Nov 02, 2008 8:53 pm ]
Post subject:  Re: HiTechnic DC Motor Shaft Encoder Problem with RobotC

Thanks Jeff. I have tried that.., but still no use. Forgot to mention.., though, the Encoder Value I am printing is always zero. It appears, it is not reading the value at all. In "NXT Device Control Display", "Tach Limit" is saying 1000. But in the "NXT Device Control Display" window is showing as 1000. Other Tach numbers are zero.
Appreciate your help.

I wonder what I am doing wrong..

Here is the new program.
#pragma config(Hubs, S1, HTMotor, HTServo, none, none)
#pragma config(Motor, mtr_S1_C1_1, motorD, tmotorNormal, openLoop, reversed)
#pragma config(Motor, mtr_S1_C1_2, motorE, tmotorNormal, PIDControl)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

task main()
{
//nMotorEncoder[motorE] = 0;
nMotorEncoderTarget[motorE] = 1000;
motor[motorE]=75;
while(nMotorEncoder[motorE] < 1000 )
{
nxtDisplayTextLine(1, "EV=%d", nMotorEncoderTarget[motorE] );
wait10Msec(1);
}

motor[motorE]=0;
wait10Msec(100);
}

Author:  Jeff McBride [ Mon Nov 03, 2008 12:12 am ]
Post subject:  Re: HiTechnic DC Motor Shaft Encoder Problem with RobotC

If the MotorEncoder[] value is always zero then either there is something wrong with your shaft encoder or it isn't wired properly. Those encoders are very fragile. Are you positive that you assebled it correctly?

Author:  cdvenkat [ Mon Nov 03, 2008 12:14 pm ]
Post subject:  Re: HiTechnic DC Motor Shaft Encoder Problem with RobotC

Thx. Jeff. we rechecked --> I think, we may have dis-assemble the Shaft encoder and try again. At least we know there nothing wrong with Robotc Program.
-CD

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