Compare commits

..

No commits in common. "eb3c920d2d6b916ef91d30892861e1c2450a368e" and "6a1dd305ce8bba9916135bc9970046b7faa58db6" have entirely different histories.

5 changed files with 12 additions and 46 deletions

1
.gitignore vendored
View File

@ -1,2 +1 @@
*.DS_Store
bin/

View File

@ -13,15 +13,6 @@ void ContactPrinter::Setup () {
drive_motor.Setup();
ledcSetup(takeup_picture_pwm_channel, pwm_frequency, pwm_resolution);
ledcSetup(takeup_stock_pwm_channel, pwm_frequency, pwm_resolution);
ledcAttachPin(takeup_picture_pin_enable, takeup_picture_pwm_channel);
ledcAttachPin(takeup_stock_pin_enable, takeup_stock_pwm_channel);
ledcWrite(takeup_picture_pwm_channel, takeup_pwm_duty_cycle);
ledcWrite(takeup_stock_pwm_channel, takeup_pwm_duty_cycle);
digitalWrite(takeup_picture_pin_cw, LOW);
digitalWrite(takeup_picture_pin_ccw, LOW);
digitalWrite(takeup_stock_pin_cw, LOW);
@ -29,7 +20,7 @@ void ContactPrinter::Setup () {
}
void ContactPrinter::Start () {
RampTakeup(0, takeup_pwm_duty_cycle, takeup_ramp_time);
RampTakeup(0, takeup_pwm, takeup_ramp_time);
delay(100);
//drive_motor.Start();
}
@ -37,13 +28,13 @@ void ContactPrinter::Start () {
void ContactPrinter::Stop () {
//drive_motor.Start();
delay(100);
RampTakeup( takeup_pwm_duty_cycle, 0, takeup_ramp_time);
RampTakeup(takeup_pwm, 0, takeup_ramp_time);
}
void ContactPrinter::SetSpeedTakeup(float speed) {
takeup_speed = speed;
takeup_pwm_duty_cycle = floor(speed * 255);
takeup_pwm = round(speed * 255);
}
void ContactPrinter::SetSpeedDrive(float speed) {
@ -69,25 +60,25 @@ void ContactPrinter::RampTakeup(uint16_t start, uint16_t end, uint16_t time) {
if (takeup_picture_cw) {
takeup_picture_pin = takeup_picture_pin_cw;
//analogWrite(takeup_picture_pin_ccw, 0);
analogWrite(takeup_picture_pin_ccw, 0);
} else {
takeup_picture_pin = takeup_picture_pin_ccw;
//analogWrite(takeup_picture_pin_cw, 0);
analogWrite(takeup_picture_pin_cw, 0);
}
if (takeup_stock_cw) {
takeup_stock_pin = takeup_stock_pin_cw;
//analogWrite(takeup_stock_pin_ccw, 0);
analogWrite(takeup_stock_pin_ccw, 0);
} else {
takeup_stock_pin = takeup_stock_pin_cw;
//analogWrite(takeup_stock_pin_cw, 0);
analogWrite(takeup_stock_pin_cw, 0);
}
for (uint16_t i = 0; i < steps; i++) {
if (pwm <= 0 || pwm >= 256) {
break;
}
//analogWrite(takeup_picture_pin, pwm);
//analogWrite(takeup_stock_pin, pwm);
analogWrite(takeup_picture_pin, pwm);
analogWrite(takeup_stock_pin, pwm);
delay(step);
if (dir) {
pwm++;

View File

@ -11,25 +11,18 @@ class ContactPrinter {
EncoderMotor drive_motor;
const uint16_t serial_delay = 5;
const uint16_t baud = 115200;
const uint16_t baud = 57600;
const uint8_t takeup_picture_pin_enable = 7;
const uint8_t takeup_picture_pin_cw = 8;
const uint8_t takeup_picture_pin_ccw = 9;
const uint8_t takeup_stock_pin_enable = 12;
const uint8_t takeup_stock_pin_cw = 10;
const uint8_t takeup_stock_pin_ccw = 11;
const uint32_t pwm_frequency = 30000;
const uint8_t takeup_picture_pwm_channel = 1;
const uint8_t takeup_stock_pwm_channel = 2;
const uint8_t pwm_resolution = 8;
volatile float drive_speed = 1.0; //calculated rpm
volatile float takeup_speed = 1.0; //estimated rpm
volatile uint16_t takeup_pwm_duty_cycle = 255;
volatile uint16_t drive_pwm;
volatile uint16_t takeup_pwm;
volatile bool takeup_picture_cw = false;
volatile bool takeup_picture_ccw = true;

View File

@ -20,7 +20,4 @@ void EncoderMotor::Setup () {
ledcSetup(pwm_channel, pwm_frequency, pwm_resolution);
ledcAttachPin(enable_pin, pwm_channel);
ledcWrite(pwm_channel, pwm_duty_cycle);
digitalWrite(forward_pin, LOW);
digitalWrite(backward_pin, LOW);
}

View File

@ -1,14 +0,0 @@
#!/bin/bash
set -e
FQBN=esp32:esp32:esp32 #ESP32
INO="./ino/contact_printer"
INOFILE="${INO}/contact_printer.ino"
OUTPUT="./bin"
mkdir -p "${OUTPUT}"
#esp32
arduino-cli compile --fqbn ${FQBN} --output-dir "${OUTPUT}" "${INO}" || echo 'Compile failed' && exit 1