Takeup WIP
This commit is contained in:
parent
a5907409ca
commit
6060381e95
|
@ -9,6 +9,15 @@ ARM_CUTOFF = 101.25;
|
|||
|
||||
ARMS_ANGLE = 40;
|
||||
|
||||
module original_takeup () {
|
||||
module block () {
|
||||
cube([105, 26.8, 5.9], center = true);
|
||||
cube([105, 36.6, 5.9], center = true);
|
||||
}
|
||||
|
||||
block();
|
||||
}
|
||||
|
||||
module projector_mount () {
|
||||
//intersection () {}
|
||||
$fn = 60;
|
||||
|
@ -39,4 +48,6 @@ rotate([0, 0, ARMS_ANGLE]) {
|
|||
rotate([0, 0, -ARMS_ANGLE]) {
|
||||
translate([ARM_LENGTH/2, 0, 2.75]) projector_arm();
|
||||
translate([ARM_LENGTH, 0, 5.5]) projector_mount();
|
||||
}
|
||||
}
|
||||
|
||||
color("red") original_takeup();
|
|
@ -1,58 +1,144 @@
|
|||
|
||||
/**
|
||||
* Prototype
|
||||
* Arduino Duemilanove
|
||||
* L298N shield V03
|
||||
* https://traction-design.be/home/arduino-l298n-shield-v03-from-flamingoeda-com/
|
||||
*
|
||||
* Pin 13 = motor A or coil A +
|
||||
* Pin 12 = motor A or coil A –
|
||||
* Pin 11 = motor B or coil B +
|
||||
* Pin 10 = motor A or coil A enable
|
||||
* Pin 9 = motor B or coil B enable
|
||||
* Pin 8 = motor B or coil B –
|
||||
* Arduino Uno
|
||||
* L298N
|
||||
**/
|
||||
|
||||
#define Apos 9
|
||||
#define Aneg 10
|
||||
#define Aenable 10
|
||||
|
||||
#define Bpos 5
|
||||
#define Bneg 6
|
||||
|
||||
volatile int Aspeed = 255;
|
||||
volatile int Bspeed = 255;
|
||||
|
||||
volatile boolean Arunning = false;
|
||||
volatile boolean Brunning = false;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(57600);
|
||||
Serial.println("Started takeup demo");
|
||||
pinMode(Apos, OUTPUT);
|
||||
pinMode(Aneg, OUTPUT);
|
||||
pinMode(Aenable, OUTPUT);
|
||||
pinMode(Bpos, OUTPUT);
|
||||
pinMode(Bneg, OUTPUT);
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
clockwise();
|
||||
set_speed(250);
|
||||
clockwise(0);
|
||||
counter_clockwise(1);
|
||||
set_speed(0, 255);
|
||||
set_speed(1, 255);
|
||||
delay(5000);
|
||||
brake();
|
||||
delay(2000);
|
||||
counter_clockwise();
|
||||
set_speed(250);
|
||||
counter_clockwise(0);
|
||||
clockwise(1);
|
||||
set_speed(0, 150);
|
||||
set_speed(1, 150);
|
||||
delay(5000);
|
||||
brake();
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
//input value from 0 to 255
|
||||
void set_speed (int val){
|
||||
analogWrite(Aenable, val);
|
||||
void set_speed (int motor, int val){
|
||||
if (motor == 0) {
|
||||
Aspeed = val;
|
||||
} else if (motor == 1) {
|
||||
Bspeed = val;
|
||||
}
|
||||
}
|
||||
|
||||
void clockwise(){
|
||||
digitalWrite(Apos, HIGH);
|
||||
digitalWrite(Aneg, LOW);
|
||||
void clockwise_fade (int motor, int startSpeed, int stopSpeed, int ms) {
|
||||
int steps = ceil((float) ms / (float) abs(stopSpeed - startSpeed));
|
||||
int stepMs = round((float) ms / (float) steps);
|
||||
int motorSpeed = startSpeed;
|
||||
for (int i = 0; i < steps; i++) {
|
||||
if (motor == 0) {
|
||||
analogWrite(Apos, motorSpeed);
|
||||
analogWrite(Aneg, 0);
|
||||
Arunning = true;
|
||||
} else if (motor == 1) {
|
||||
analogWrite(Bpos, motorSpeed);
|
||||
analogWrite(Bneg, 0);
|
||||
Brunning = true;
|
||||
}
|
||||
delay(stepMs);
|
||||
motorSpeed += stopSpeed > startSpeed ? 1 : -1;
|
||||
}
|
||||
if (motor == 0) {
|
||||
Aspeed = stopSpeed;
|
||||
} else if (motor == 1) {
|
||||
Bspeed = stopSpeed;
|
||||
}
|
||||
}
|
||||
|
||||
void counter_clockwise(){
|
||||
digitalWrite(Apos, LOW);
|
||||
digitalWrite(Aneg, HIGH);
|
||||
void counter_clockwise_fade (int motor, int startSpeed, int stopSpeed, int ms) {
|
||||
int steps = ceil((float) ms / (float) abs(stopSpeed - startSpeed));
|
||||
int stepMs = round((float) ms / (float) steps);
|
||||
int motorSpeed = startSpeed;
|
||||
if (motor == 0) {
|
||||
analogWrite(Apos, 0);
|
||||
} else if (motor == 1) {
|
||||
analogWrite(Bpos, 0);
|
||||
}
|
||||
for (int i = 0; i < steps; i++) {
|
||||
if (motor == 0) {
|
||||
analogWrite(Aneg, motorSpeed);
|
||||
Arunning = true;
|
||||
} else if (motor == 1) {
|
||||
analogWrite(Bneg, motorSpeed);
|
||||
Brunning = true;
|
||||
}
|
||||
delay(stepMs);
|
||||
motorSpeed += stopSpeed > startSpeed ? 1 : -1;
|
||||
}
|
||||
if (motor == 0) {
|
||||
Aspeed = stopSpeed;
|
||||
} else if (motor == 1) {
|
||||
Bspeed = stopSpeed;
|
||||
}
|
||||
}
|
||||
|
||||
void clockwise (int motor){
|
||||
if (motor == 0) {
|
||||
analogWrite(Apos, Aspeed);
|
||||
analogWrite(Aneg, 0);
|
||||
Arunning = true;
|
||||
} else if (motor == 1) {
|
||||
analogWrite(Bpos, Bspeed);
|
||||
analogWrite(Bneg, 0);
|
||||
Brunning = true;
|
||||
}
|
||||
}
|
||||
|
||||
void counter_clockwise (int motor){
|
||||
if (motor == 0) {
|
||||
analogWrite(Apos, 0);
|
||||
analogWrite(Aneg, Aspeed);
|
||||
Arunning = true;
|
||||
} else if (motor == 1) {
|
||||
analogWrite(Bpos, 0);
|
||||
analogWrite(Bneg, Bspeed);
|
||||
Brunning = true;
|
||||
}
|
||||
}
|
||||
|
||||
void brake (){
|
||||
digitalWrite(Aenable, LOW);
|
||||
if (Arunning) {
|
||||
digitalWrite(Apos, LOW);
|
||||
digitalWrite(Aneg, LOW);
|
||||
Arunning = false;
|
||||
}
|
||||
if (Brunning) {
|
||||
digitalWrite(Bpos, LOW);
|
||||
digitalWrite(Bneg, LOW);
|
||||
Brunning = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue