CALPOLY MECHATRONICS
Documentation for all Mechatronics Labs
ME405_FP_Encoder.ME405_FP_Encoder Class Reference

Runs operations and returns values specific to the encoder count. More...

Public Member Functions

def __init__ (self, tim, pin1, pin2)
 Initiates encoder operations using approprate timers and pins. More...
 
def update (self)
 Updates the encoder count and corrects for overflow. More...
 
def getPosition (self)
 Gives the last stored position of the encoder arm. More...
 
def setPosition (self, reset_value)
 Sets the encoder count to a desired value. More...
 
def getDelta (self)
 Returns the change between the last two counts in update. More...
 

Public Attributes

 AngList
 
 DatumCnt
 Initial value that will be used to measure a change in count.
 
 DeltaCnt
 Establishes the change in count. More...
 
 theta
 
 tim
 The timer from which the encoder counts.
 
 pin1
 One of two pins needed for collecting data on motor ops.
 
 timCh1
 One of two channels needed for the encoder operation.
 
 pin2
 One of two pins needed for collecting data on motor ops.
 
 timCh2
 One of two channels needed for the encoder operation.
 
 newCnt
 A count value that will be updated each time update is called. More...
 

Detailed Description

Runs operations and returns values specific to the encoder count.

Class for updating, getting, setting, and computing the change in the encoder count.

Constructor & Destructor Documentation

◆ __init__()

def ME405_FP_Encoder.ME405_FP_Encoder.__init__ (   self,
  tim,
  pin1,
  pin2 
)

Initiates encoder operations using approprate timers and pins.

The encoder architecture requires two channels from which the timer reads in order to determine directional differences

Member Function Documentation

◆ getDelta()

def ME405_FP_Encoder.ME405_FP_Encoder.getDelta (   self)

Returns the change between the last two counts in update.

Returns
DeltaCnt; The change in the count

◆ getPosition()

def ME405_FP_Encoder.ME405_FP_Encoder.getPosition (   self)

Gives the last stored position of the encoder arm.

Returns
theta; The position of the encoder arm in ticks

◆ setPosition()

def ME405_FP_Encoder.ME405_FP_Encoder.setPosition (   self,
  reset_value 
)

Sets the encoder count to a desired value.

Parameters
reset_value;The position one wishes to set the encoder to

◆ update()

def ME405_FP_Encoder.ME405_FP_Encoder.update (   self)

Updates the encoder count and corrects for overflow.

Returns
theta The position of the encoder arm in ticks

Member Data Documentation

◆ DeltaCnt

ME405_FP_Encoder.ME405_FP_Encoder.DeltaCnt

Establishes the change in count.

The change in count represents the change in the location of the motor arm between sample periods. This change in count conveys direction and velocity data. The count can only go so high before an overflow condtion occurs, meaning we have to correct the overflow in order to get a continuous representation of the motor;s motion.

◆ newCnt

ME405_FP_Encoder.ME405_FP_Encoder.newCnt

A count value that will be updated each time update is called.

A change in value for newCnt, or for that matter any value based on timer counts, will only occur if the arm of the motor is rotated, because the rotation of the motor arm is what brings about the change in pulses of the encoder, which is interpreted by the timer attached to the encoder channel and returns a change in count to reflect the change in the motor arm position


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