UPM

The UPM API is a high level sensor library for IoT devices using MRAA. See examples here. Back to index page.
SparkFun sensor images provided under CC BY-NC-SA-3.0.

WheelEncoder Class

Module: wheelencoder

This sensor was developed for the DFRobot Wheel Encoder, though it could be used for any counting time-based task.
When you instantiate a class of this type, the gpio pin specified is connected to an interrupt. Whenever a low to high transition occurs on the gpio pin, the internal counter is incremented by one.
This class also includes a millisecond counter, so that you can correlate the number of counts to a time period for calculating an RPM or other value as needed.
wheelencoder.jpg

Methods

WheelEncoder

(
  • pin
)
Number

DFRobot Wheel Encoder sensor constructor

Parameters:

  • pin Number

    Digital pin to use

Returns:

Number:

getMillis

() Number

Returns the number of milliseconds elapsed since initClock() was last called.

Returns:

Number:

Elapsed milliseconds

initClock

()

Resets the clock

clearCounter

()

Resets the counter to 0. The counter should be stopped via stopCounter() prior to calling this function.

startCounter

()

Starts the counter. This function will also clear the current count and reset the clock.

stopCounter

()

Stops the counter

counter

() Number

Gets the current counter value

Returns:

Number:

counter value