WWU-Robotics-Club / Rover

1 stars 1 forks source link

Investigate motors and drivers #17

Open CalebJ2 opened 4 years ago

CalebJ2 commented 4 years ago

This kit https://www.amazon.com/gp/product/B07PRW11VR/ has a brushed motors with quadrature encoders. A driver like this could power them https://learn.adafruit.com/adafruit-motor-shield-v2-for-arduino although that is a little under powered. I don't see many motor controllers that are made for using quadrature encoder and a reasonable price. Could read the encoders with an arduino: https://www.pjrc.com/teensy/td_libs_Encoder.html

CalebJ2 commented 4 years ago

The motors have this pinout: image

CalebJ2 commented 4 years ago

I think 2 tb6612fng chips would work well for driving this: https://learn.sparkfun.com/tutorials/tb6612fng-hookup-guide/all

CalebJ2 commented 4 years ago

Encoder test script:

// https://www.pjrc.com/teensy/td_libs_Encoder.html
#include <Encoder.h>

Encoder encoder(11,12);
double previousPos = 0;
double previousTime = 0;
double currentPos = 0;

void setup() {
    Serial.begin(9600);
    Serial.println("Encoder Test:");
}

void loop() {
    // put your main code here, to run repeatedly:
    previousPos = currentPos;
    currentPos = encoder.read();
    double currentTime = millis();
    float speed = (float)(currentPos-previousPos)/(float)(currentTime-previousTime);
    previousTime = currentTime;
    Serial.println(speed);
    if (Serial.available()) {
        Serial.read();
        Serial.println("Reset to zero");
        encoder.write(0);
    }
    delay(100);
}