encoder_task

class encoder_task.EncoderTask(pins)

Bases: object

A class to handle reading the encoder and updating shared variables.

right_enc_A

The pin for channel A for the right wheel encoder.

Type:

int

right_enc_B

The pin for channel B for the right wheel encoder.

Type:

int

right_enc_timer

The channel timer number for the right wheel encoder.

Type:

int

left_enc_A

The pin for channel A for the left wheel encoder.

Type:

int

left_enc_B

The pin for channel B for the left wheel encoder.

Type:

int

left_enc_timer

The channel timer number for the left wheel encoder.

Type:

int

S0_init

Initialization state value.

Type:

int

S1_init

Read state value.

Type:

int

state

Current state value.

Type:

int

right_encoder

Encoder class object for the right wheel encoder.

Type:

Encoder

left_encoder

Encoder class object for the left wheel encoder.

Type:

Encoder

encoder_gen(shares)

The generator that implements the finite state machine for the Encoder task.

State 0 zeros the encoder and moves to state 1. State 1 updates the shares for the motor position and velocity for each motor from the Encoder class that handles the Encoder.

Parameters:

shares (list[right_pos, right_vel, left_pos, left_vel]) – Shared values for position and velocity for each wheel.

Yields:

state (int) – The value of the current state within the machine