Sensors, encoders,….

Here is some info about sensors/encoders we are using and how one programs for them.


For moving straight: we are using encoders on the right motor. Encoder provides an integer valued counter for the corresponding motor:
1 degree =4 encoder ‘ticks’
1 revolution = 360 deg = 1440 ticks

For more info, see RobotC online help.

Note that we are not currently using PID control with TETRIX motors; it is possible but would require two encoders (on both left and right motors) and would slightly slow down the motors as discussed here

Turns and Gyro sensor

For precise turns, we are using the gyro sensor, with hitechnic-gyro.h driver from 3rd party driver suite (see this page). This sensors measures angular velocity for turns; by integrating it, we get total turns. We have a separate task gyro which does that (code mostly borrowed from the sample program). This task constantly updates the values of the global variable GYRO_ORIENTATION. This variable shows current orientation of the robot relative to the starting position. Unit of measurement is degrees, and positive direction is counterclockwise.

Infrared sensor

This sensor (IRseeker v2) is used to find the IR beacon. Its operation is described in this document: IRSeekerV2characteristicsR2-rev3.

We are using the hitechnic-irseeker-v2.h driver from 3rd party driver suite. Note that we are using modulated (AC) readings, for 1200 hz square wave, so the mode needs to be set to DSP_1200. We are not using the direction returned by the sensor, but separately reading the signal strength for each of 5 sensors:

int IRvalues[5];
HTIRS2readAllACStrength(IRsensor, IRvalues[0], IRvalues[1], IRvalues[2], IRvalues[3], IRvalues[4])