Compare commits
2 Commits
6a1dd305ce
...
eb3c920d2d
Author | SHA1 | Date |
---|---|---|
Matt McWilliams | eb3c920d2d | |
Matt McWilliams | 03e8df9617 |
|
@ -1 +1,2 @@
|
|||
*.DS_Store
|
||||
bin/
|
|
@ -13,6 +13,15 @@ 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);
|
||||
|
@ -20,7 +29,7 @@ void ContactPrinter::Setup () {
|
|||
}
|
||||
|
||||
void ContactPrinter::Start () {
|
||||
RampTakeup(0, takeup_pwm, takeup_ramp_time);
|
||||
RampTakeup(0, takeup_pwm_duty_cycle, takeup_ramp_time);
|
||||
delay(100);
|
||||
//drive_motor.Start();
|
||||
}
|
||||
|
@ -28,13 +37,13 @@ void ContactPrinter::Start () {
|
|||
void ContactPrinter::Stop () {
|
||||
//drive_motor.Start();
|
||||
delay(100);
|
||||
RampTakeup(takeup_pwm, 0, takeup_ramp_time);
|
||||
RampTakeup( takeup_pwm_duty_cycle, 0, takeup_ramp_time);
|
||||
|
||||
}
|
||||
|
||||
void ContactPrinter::SetSpeedTakeup(float speed) {
|
||||
takeup_speed = speed;
|
||||
takeup_pwm = round(speed * 255);
|
||||
takeup_pwm_duty_cycle = floor(speed * 255);
|
||||
}
|
||||
|
||||
void ContactPrinter::SetSpeedDrive(float speed) {
|
||||
|
@ -60,25 +69,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++;
|
||||
|
|
|
@ -11,18 +11,25 @@ class ContactPrinter {
|
|||
EncoderMotor drive_motor;
|
||||
|
||||
const uint16_t serial_delay = 5;
|
||||
const uint16_t baud = 57600;
|
||||
const uint16_t baud = 115200;
|
||||
|
||||
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 drive_pwm;
|
||||
volatile uint16_t takeup_pwm;
|
||||
volatile uint16_t takeup_pwm_duty_cycle = 255;
|
||||
|
||||
volatile bool takeup_picture_cw = false;
|
||||
volatile bool takeup_picture_ccw = true;
|
||||
|
|
|
@ -20,4 +20,7 @@ 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);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
#!/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
|
Loading…
Reference in New Issue