Glossary Item Box
The Generic Encoder service contract enables you to access state information from encoders. The most typical use of encoders is to measure rotation of a rotational device, such as a motor, to keep track of its distance traveled and thereby the robot's relative position. It may also be used to control speed. While distance and position can also be estimated based on the elapsed time and motor power, such alternatives are not as accurate since the distance traveled may be affected by factors such the surface the wheel connected to the motor is traveling on. However, even encoders might not always be entirely accurate as a wheel may slip or the robot might be relocated by some other means.
The Generic Encoder service provides the following operations. All except the Get operation also are available as notifications.
|Get||Returns the entire state of the encoder service.|
|EncoderReplace||Changes or indicates a change to the state of the encoder service.|
|ResetTickCounter||Resets the encoder's tick count or indicates a change to the encoder's tick count.|
|UpdateTickCount||Updates or indicates an update to the encoder's tick count.|
The encoder's state is represented by the following properties:
|CurrentAngle||double||Indicates the current angle reading in radians.|
|CurrentReading||int||Indicates the current encoder reading in ticks.|
|HardwareIdentifier||int||Identifies the hardware port the encoder uses.|
|TicksPerRevolution||int||Indicates the number of ticks per axle revolution.|
|TicksSinceReset||int||Indicates the number of ticks since the encoder was reset.|
|TimeStamp||DateTime||Indicates the timestamp of the encoder reading.|
The generic encoder service reports its rotation readings in terms of ticks. A tick represents a small portion of the rotation of the axle (of a motor or wheel). Because encoders may vary in the number of ticks per revolution, this is a configurable option. You can use the EncoderReplace to set the TicksPerRevolution setting.
The UpdateTickCount notification provides updates as the tick count changes. You can also access the current tick count (CurrentReading) at any time by using the Get request. This will also provide the current reading as an angle in radians (if TicksPerResolution is set) and the TimeStamp for the reading. It also returns tick count since the last reset of the counter (which you can reset using ResetTickCounter).
Updated information might be available online in the MSDN Library page:
Robotics Common: Robotics Common Overview
© 2012 Microsoft Corporation. All Rights Reserved.