Classes | |
class | Encoder |
An encoder driver object. More... | |
Variables | |
int | Timer1 = 4 |
int | Timer2 = 8 |
int | prescaler = 0 |
int | period = 65535 |
EncoderA1 = pyb.Pin.cpu.B6 | |
EncoderB1 = pyb.Pin.cpu.B7 | |
EncoderA2 = pyb.Pin.cpu.C6 | |
EncoderB2 = pyb.Pin.cpu.C7 | |
enco1 = Encoder(Timer1, EncoderA1, EncoderB1, prescaler, period) | |
enco2 = Encoder(Timer2, EncoderA2, EncoderB2, prescaler, period) | |
This is the encoder that is build into the motors provided in our ME 405 kits. When installed correct, the encoder allows the microcontroller to count encoder ticks since the controller cannot understand distances, angles, nor direction. This code chen called will help the user designate distances and angles by giving encoder ticks. It is up to the user to find the approximation of those distances and angles.
This class was built to function with the NUCLEO and motor driver. The user will be required to designate the ports being used for the encoder. The user will also input the timer number, Encoder ports from the motors, the prescaler, and the period (number of counts), respectively. The lines of code given in the main part of this code is an example of what the user needs to input when implementing two different motors.