R2R
Functions
Encoder.h File Reference

Encoder header. More...

Go to the source code of this file.

Functions

void encoderSPIInit (void)
 Initializes the SPI channels for the motor drivers, encoders, and RAM. More...
 
void encoderRead (void)
 Updates value in sensor array. More...
 
void resetMotor1RawRelative (void)
 Resets the relative counts on encoder 1. More...
 
void resetMotor2RawRelative (void)
 Resets the relative counts on encoder 2. More...
 
void zeroMotor1RawRelative (void)
 Reads value of motor 1 encoders and sets the relative angle to zero. More...
 
void zeroMotor2RawRelative (void)
 Reads value of motor 2 encoders and sets the relative angle to zero. More...
 
float readMotor1Angle (void)
 Reads value in encoderVal array for motor 1 and converts it to an angle. More...
 
float readMotor2Angle (void)
 Reads value in encoderVal array for motor 2 and converts it to an angle. More...
 
int readMotor1Raw (void)
 Reads value in encoderVal array for motor 1. More...
 
int readMotor2Raw (void)
 Reads value in encoderVal array for motor 2. More...
 
int readMotor1RawRelative (void)
 Reads value in encoderVal array for motor 1 and keeps track of multiturn counts. More...
 
int readMotor2RawRelative (void)
 Reads value in encoderVal array for motor 2 and keeps track of multiturn counts. More...
 
float readMotor1AngleRelative (void)
 Reads value in encoderVal array for motor 1 and keeps track of multiturn angles. More...
 
float readMotor2AngleRelative (void)
 Reads value in encoderVal array for motor 2 and keeps track of multiturn angles. More...
 

Detailed Description

Encoder header.

TThis file contains functions for initializing and reading from encoders.

Author
Benjamen Lim
Huan Weng
Blake Strebel

Function Documentation

◆ encoderRead()

void encoderRead ( void  )

Updates value in sensor array.

This function sends a 't' and 40 pulses via SPI to the encoder and reads out the encoder's reply to the encoderVal array

Parameters
Void
Returns
Void

This function reads both encoder counts and stores them in an array

Comes after: spiInit();

Writes to: encoderVal array

◆ encoderSPIInit()

void encoderSPIInit ( void  )

Initializes the SPI channels for the motor drivers, encoders, and RAM.

Initializes SSI1 ~ 4 and their corresponding GPIO pins

Parameters
Void
Returns
Void

◆ readMotor1Angle()

float readMotor1Angle ( void  )

Reads value in encoderVal array for motor 1 and converts it to an angle.

Parameters
Void
Returns
The angle as a float

◆ readMotor1AngleRelative()

float readMotor1AngleRelative ( void  )

Reads value in encoderVal array for motor 1 and keeps track of multiturn angles.

This function reads out the angle and keeps track of it for multiple turns.

Parameters
Void
Returns
The angle as an int

◆ readMotor1Raw()

int readMotor1Raw ( void  )

Reads value in encoderVal array for motor 1.

The range for the read angle is 0 to 16383

Parameters
Void
Returns
The angle as an int

◆ readMotor1RawRelative()

int readMotor1RawRelative ( void  )

Reads value in encoderVal array for motor 1 and keeps track of multiturn counts.

This function reads out the angle and keeps track of it for multiple turns. The value ranges from -2,147,483,648 to 2,147,483,648. Each turn is 16383 counts

Parameters
Void
Returns
The counts as an int

◆ readMotor2Angle()

float readMotor2Angle ( void  )

Reads value in encoderVal array for motor 2 and converts it to an angle.

Parameters
Void
Returns
The angle as a float

◆ readMotor2AngleRelative()

float readMotor2AngleRelative ( void  )

Reads value in encoderVal array for motor 2 and keeps track of multiturn angles.

This function reads out the angle and keeps track of it for multiple turns.

Parameters
Void
Returns
The angle as an int

◆ readMotor2Raw()

int readMotor2Raw ( void  )

Reads value in encoderVal array for motor 2.

The range for the read angle is 0 to 16383

Parameters
Void
Returns
The angle as an int

◆ readMotor2RawRelative()

int readMotor2RawRelative ( void  )

Reads value in encoderVal array for motor 2 and keeps track of multiturn counts.

This function reads out the angle and keeps track of it for multiple turns. The value ranges from -2,147,483,648 to 2,147,483,648

Parameters
Void
Returns
The counts as an int

◆ resetMotor1RawRelative()

void resetMotor1RawRelative ( void  )

Resets the relative counts on encoder 1.

Parameters
Void
Returns
Void

◆ resetMotor2RawRelative()

void resetMotor2RawRelative ( void  )

Resets the relative counts on encoder 2.

Parameters
Void
Returns
Void

◆ zeroMotor1RawRelative()

void zeroMotor1RawRelative ( void  )

Reads value of motor 1 encoders and sets the relative angle to zero.

Parameters
Void
Returns
Void

◆ zeroMotor2RawRelative()

void zeroMotor2RawRelative ( void  )

Reads value of motor 2 encoders and sets the relative angle to zero.

Parameters
Void
Returns
The angle as a float