Compare commits

..

No commits in common. "0dc3269b31dfe6f894f5f111f19421f5c379591d" and "93a4418545ec3aaf7ae8f3d03b70c2de20dff4e1" have entirely different histories.

6 changed files with 21 additions and 38 deletions

View File

@ -6,12 +6,10 @@ 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();
@ -31,19 +29,19 @@ void ContactPrinter::Setup () {
digitalWrite(takeup_stock_pin_ccw, LOW);
SetSpeedTakeup(0.4);
SetSpeedDrive(1.0);
//SetSpeedDrive(1.0);
}
void ContactPrinter::Start () {
Serial.println("Start()");
RampTakeup(0, takeup_pwm_duty_cycle, takeup_ramp_time);
delay(100);
drive_motor.Start();
//RampTakeup(0, takeup_pwm_duty_cycle, takeup_ramp_time);
running = true;
}
void ContactPrinter::Stop () {
drive_motor.Stop();
drive_motor.Start();
delay(100);
RampTakeup(takeup_pwm_duty_cycle, 0, takeup_ramp_time);
digitalWrite(takeup_picture_pin_cw, LOW);
digitalWrite(takeup_picture_pin_ccw, LOW);
@ -57,7 +55,7 @@ void ContactPrinter::SetSpeedTakeup(float speed) {
}
void ContactPrinter::SetSpeedDrive(float speed) {
drive_motor.SetSpeed(speed);
//drive_motor.SetSpeed();
}
void ContactPrinter::SetDirectionStock(bool clockwise) {
@ -125,11 +123,8 @@ bool ContactPrinter::IsRunning () {
void ContactPrinter::Loop () {
timer = millis();
ButtonLoop();
if (running) {
drive_motor.Loop();
if (takeup_ramping) {
RampTakeupLoop();
}
}
}

View File

@ -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 = 15;
const uint8_t start_button_pin = 17;
/* MOTOR PWM */
const uint32_t pwm_frequency = 30000;

View File

@ -17,9 +17,6 @@ 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);
@ -33,18 +30,14 @@ 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(float speed) {
pwm_duty_cycle = floor(255 * speed);
Serial.print("Set drive motor PWM = ");
Serial.println(pwm_duty_cycle);
void DriveMotor::SetSpeed() {
pwm_duty_cycle = 255;
}
void DriveMotor::Loop () {

View File

@ -8,11 +8,11 @@ class DriveMotor {
private:
//defaults are for EPS32 dev board
volatile uint8_t enable_pin = 26;
volatile uint8_t forward_pin = 27; //Clockwise
volatile uint8_t enable_pin = 13;
volatile uint8_t forward_pin = 12; //Clockwise
volatile uint8_t backward_pin = 14; //Counter-clockwise
volatile uint8_t encoder_a_pin = 33;
volatile uint8_t encoder_b_pin = 25;
volatile uint8_t encoder_a_pin = 27;
volatile uint8_t encoder_b_pin = 26;
volatile uint8_t pwm_duty_cycle = 0;
@ -36,9 +36,7 @@ class DriveMotor {
void Loop();
void Start();
void Stop();
void SetSpeed(float speed);
static void ReadEncoder();
void SetSpeed();
};

View File

@ -23,7 +23,7 @@
* 27 Drive Encoder A
* 26 Drive Encoder B
*
* 15 Start Button
* 17 Start Button
*
* 33 Lamp
*
@ -32,10 +32,7 @@
ContactPrinter contact_printer;
void setup () {
Serial.begin(115200);
contact_printer.Setup();
Serial.print("contact_printer v");
Serial.println(VERSION);
}
void loop () {
contact_printer.Loop();

View File

@ -6,9 +6,9 @@
*********/
// Motor A
int motor1Pin1 = 14;
int motor1Pin2 = 27;
int enable1Pin = 26;
int motor1Pin1 = 27;
int motor1Pin2 = 26;
int enable1Pin = 14;
// Setting PWM properties
const int freq = 30000;