nerf-turret 1
Infrared targeting nerf turret
Loading...
Searching...
No Matches
encoder_reader.EncoderReader Class Reference

This class implements an encoder reader for an ME 405 kit. More...

Public Member Functions

def __init__ (self, str pin1, str pin2, int timer, int ch1, int ch2)
 Creates an encoder reader and configures the appropriate pins, timers, and timer channels.
 
def zero (self)
 Sets the current position of the encoder to zero (does not modify the timer count).
 
def read (self)
 Reads the current position of the encoder.
 

Public Attributes

 pin1
 Pin object for pin 1.
 
 pin2
 Pin object for pin 2.
 
 timer
 Timer object for the encoder.
 
 ch1
 Channel object for channel 1.
 
 ch2
 Channel object for channel 2.
 
 position
 Current position of the motor.
 
 prev_cnt
 Reference count value for measuring difference between readings.
 

Detailed Description

This class implements an encoder reader for an ME 405 kit.

Constructor & Destructor Documentation

◆ __init__()

def encoder_reader.EncoderReader.__init__ (   self,
str  pin1,
str  pin2,
int  timer,
int  ch1,
int  ch2 
)

Creates an encoder reader and configures the appropriate pins, timers, and timer channels.

Parameters
pin1String containing the pin label for the first encoder channel (e.g. 'A10' for pin A10)
pin2String containing the pin label for the second encoder channel
timerNumber of the timer to configure, given as integer (e.g. 5 for TIM5)
ch1The channel number of the first encoder channel, given as integer (e.g. 1 for TIMx CH1)
ch2The channel number of the second encoder channel, given as integer

Member Function Documentation

◆ read()

def encoder_reader.EncoderReader.read (   self)

Reads the current position of the encoder.

Returns
self.position Current position of the encoder

The documentation for this class was generated from the following file: