Fixed the pinouts for the drive motor. Temporarily disabled takeup.
This commit is contained in:
parent
6869b6f403
commit
0dc3269b31
|
@ -6,10 +6,12 @@ ContactPrinter::ContactPrinter () {
|
|||
}
|
||||
|
||||
void ContactPrinter::Setup () {
|
||||
|
||||
pinMode(takeup_picture_pin_cw, OUTPUT);
|
||||
pinMode(takeup_picture_pin_ccw, OUTPUT);
|
||||
pinMode(takeup_stock_pin_cw, OUTPUT);
|
||||
pinMode(takeup_stock_pin_ccw, OUTPUT);
|
||||
|
||||
pinMode(start_button_pin, INPUT_PULLUP);
|
||||
|
||||
drive_motor.Setup();
|
||||
|
@ -29,19 +31,19 @@ void ContactPrinter::Setup () {
|
|||
digitalWrite(takeup_stock_pin_ccw, LOW);
|
||||
|
||||
SetSpeedTakeup(0.4);
|
||||
//SetSpeedDrive(1.0);
|
||||
SetSpeedDrive(1.0);
|
||||
}
|
||||
|
||||
void ContactPrinter::Start () {
|
||||
RampTakeup(0, takeup_pwm_duty_cycle, takeup_ramp_time);
|
||||
delay(100);
|
||||
Serial.println("Start()");
|
||||
drive_motor.Start();
|
||||
//RampTakeup(0, takeup_pwm_duty_cycle, takeup_ramp_time);
|
||||
|
||||
running = true;
|
||||
}
|
||||
|
||||
void ContactPrinter::Stop () {
|
||||
drive_motor.Start();
|
||||
delay(100);
|
||||
drive_motor.Stop();
|
||||
RampTakeup(takeup_pwm_duty_cycle, 0, takeup_ramp_time);
|
||||
digitalWrite(takeup_picture_pin_cw, LOW);
|
||||
digitalWrite(takeup_picture_pin_ccw, LOW);
|
||||
|
@ -55,7 +57,7 @@ void ContactPrinter::SetSpeedTakeup(float speed) {
|
|||
}
|
||||
|
||||
void ContactPrinter::SetSpeedDrive(float speed) {
|
||||
//drive_motor.SetSpeed();
|
||||
drive_motor.SetSpeed(speed);
|
||||
}
|
||||
|
||||
void ContactPrinter::SetDirectionStock(bool clockwise) {
|
||||
|
@ -123,8 +125,11 @@ bool ContactPrinter::IsRunning () {
|
|||
|
||||
void ContactPrinter::Loop () {
|
||||
timer = millis();
|
||||
ButtonLoop();
|
||||
if (running) {
|
||||
drive_motor.Loop();
|
||||
if (takeup_ramping) {
|
||||
RampTakeupLoop();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -25,7 +25,7 @@ class ContactPrinter {
|
|||
const uint8_t takeup_stock_pin_cw = 18;
|
||||
const uint8_t takeup_stock_pin_ccw = 5;
|
||||
|
||||
const uint8_t start_button_pin = 17;
|
||||
const uint8_t start_button_pin = 15;
|
||||
|
||||
/* MOTOR PWM */
|
||||
const uint32_t pwm_frequency = 30000;
|
||||
|
|
|
@ -17,6 +17,9 @@ void DriveMotor::Setup () {
|
|||
pinMode(forward_pin, OUTPUT);
|
||||
pinMode(backward_pin, OUTPUT);
|
||||
|
||||
pinMode(encoder_a_pin, INPUT);
|
||||
pinMode(encoder_b_pin, INPUT);
|
||||
|
||||
ledcSetup(pwm_channel, pwm_frequency, pwm_resolution);
|
||||
ledcAttachPin(enable_pin, pwm_channel);
|
||||
ledcWrite(pwm_channel, pwm_duty_cycle);
|
||||
|
@ -30,14 +33,18 @@ void DriveMotor::Start() {
|
|||
digitalWrite(forward_pin, HIGH);
|
||||
digitalWrite(backward_pin, LOW);
|
||||
}
|
||||
|
||||
void DriveMotor::Stop() {
|
||||
pwm_duty_cycle = 0;
|
||||
digitalWrite(forward_pin, LOW);
|
||||
digitalWrite(backward_pin, LOW);
|
||||
ledcWrite(pwm_channel, pwm_duty_cycle);
|
||||
}
|
||||
void DriveMotor::SetSpeed() {
|
||||
pwm_duty_cycle = 255;
|
||||
|
||||
void DriveMotor::SetSpeed(float speed) {
|
||||
pwm_duty_cycle = floor(255 * speed);
|
||||
Serial.print("Set drive motor PWM = ");
|
||||
Serial.println(pwm_duty_cycle);
|
||||
}
|
||||
|
||||
void DriveMotor::Loop () {
|
||||
|
|
|
@ -8,11 +8,11 @@ class DriveMotor {
|
|||
private:
|
||||
|
||||
//defaults are for EPS32 dev board
|
||||
volatile uint8_t enable_pin = 13;
|
||||
volatile uint8_t forward_pin = 12; //Clockwise
|
||||
volatile uint8_t enable_pin = 26;
|
||||
volatile uint8_t forward_pin = 27; //Clockwise
|
||||
volatile uint8_t backward_pin = 14; //Counter-clockwise
|
||||
volatile uint8_t encoder_a_pin = 27;
|
||||
volatile uint8_t encoder_b_pin = 26;
|
||||
volatile uint8_t encoder_a_pin = 33;
|
||||
volatile uint8_t encoder_b_pin = 25;
|
||||
|
||||
volatile uint8_t pwm_duty_cycle = 0;
|
||||
|
||||
|
@ -36,7 +36,9 @@ class DriveMotor {
|
|||
void Loop();
|
||||
void Start();
|
||||
void Stop();
|
||||
void SetSpeed();
|
||||
void SetSpeed(float speed);
|
||||
|
||||
static void ReadEncoder();
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
*********/
|
||||
|
||||
// Motor A
|
||||
int motor1Pin1 = 27;
|
||||
int motor1Pin2 = 26;
|
||||
int enable1Pin = 14;
|
||||
int motor1Pin1 = 14;
|
||||
int motor1Pin2 = 27;
|
||||
int enable1Pin = 26;
|
||||
|
||||
// Setting PWM properties
|
||||
const int freq = 30000;
|
||||
|
|
Loading…
Reference in New Issue