View Single Post
  #3   Spotlight this post!  
Unread 15-10-2011, 16:05
kz2zx kz2zx is offline
Ruthlessly Insufficient
FTC #5246
Team Role: Coach
 
Join Date: Sep 2011
Rookie Year: 2011
Location: AZ
Posts: 14
kz2zx will become famous soon enough
Re: [FTC]: Motor Encoders

Alyssa,

I can't help with LabView, but in general, I'd say look for a variable/attribute in the motor block with 'Encoder' or 'Count' in the name.

Jason,

How are you trying to use them? Through the standard HiTechnic interface, you can access a variable in RobotC named 'nMotorEncoder[]'...

Find a file in your (this was RobotC 2.xx) distribution of sample programs:

C:\Program Files (x86)\Robotics Academy\ROBOTC for MINDSTORMS\Sample Programs\NXT\TETRIX Motors\TETRIX nMotorEncoders Example.c

and see this code:
Code:
task main()
{

  nMotorEncoder[motorE] = 0;  //clear the TETRIX encoders in motors D and E
  nMotorEncoder[motorD] = 0;

  while (nMotorEncoder[motorE] < 1440) //while the encoder wheel turns one revolution
  {
    motor[motorE] = 30; //turn both motors on at 30 percent power
    motor[motorD] = 30;
  }

  motor[motorE] = 0; //turn both motors off
  motor[motorD] = 0;

  wait1Msec(3000); // wait 3 seconds to see feedback from the debugger screens
                    // open the "NXT Devices" window to see the distance the encoder
                    //spins. The robot will coast a little bit.
}

Last edited by kz2zx : 15-10-2011 at 16:08.
Reply With Quote