Programming Overview

The central point of the Helium Canandcoder in ReduxLib is the Canandcoder object. The Canandcoder object lets you read the device’s position, velocity, set and read settings, read faults, and more.

Constructor

Creating a Canandcoder object is simple. The one parameter you need is the CAN ID assigned to the encoder, generally set in Alchemist.

//Creates a Canandcoder object referencing a Canandcoder with CAN ID 0
Canandcoder canandcoder = new Canandcoder(0);

//Creates a Canandcoder object referencing a Canandcoder with CAN ID 3
Canandcoder canandcoder3 = new Canandcoder(3);
using namespace redux::sensors::canandcoder;
//Creates a Canandcoder object referencing a Canandcoder with CAN ID 0
Canandcoder canandcoder{0};

//Creates a Canandcoder object referencing a Canandcoder with CAN ID 3
Canandcoder canandcoder3{3};

Magnet Check

The Magnet In Range function can be used to check if the magnet is correctly set up and in range of the sensor. This maintains parity with the onboard LED, when the magnet is not in range the LED will turn red, and when it is in range the LED will turn green.

canandcoder.magnetInRange();
canandcoder.MagnetInRange();

Party Mode

Party Mode is an identification tool that blinks the onboard LED different colors at a user specified integer speed level. The period of the LED change will be equal to (50 milliseconds * level). Setting this to 0 will turn off party mode.

canandcoder.setPartyMode(level);
canandcoder.SetPartyMode(level);

Presence Detection

Presence Detection checks if the encoder has sent a message in the last 2 seconds. This is a useful tool to ensure that the encoder has not disconnected from the CAN bus.

canandcoder.isPresent();
canandcoder.IsPresent();

Temperature

The temperature function reports the onboard temperature reading of the device. This should be kept within 0 and 70 degrees Celsius for normal operation.

canandcoder.getTemperature();
canandcoder.GetTemperature();

Reset To Factory Default

Danger

Resetting the encoder to factory default will wipe all settings. There is no way to undo this other then manually re-inputting all of your settings.

Resets the encoder to factory zero. The clearZero boolean passed controls whether the absolute position offset should be cleared too; if set to true then this value will be reset to 0.

canandcoder.resetFactoryDefaults(clearZero);
canandcoder.ResetFactoryDefaults(clearZero);