Some more info port updates
This commit is contained in:
parent
c851073336
commit
8feb8e41a8
3 changed files with 86 additions and 1128 deletions
File diff suppressed because it is too large
Load diff
|
@ -1,30 +1,73 @@
|
|||
/* Example sketch to control a 28BYJ-48 stepper motor with ULN2003 driver board and Arduino UNO. More info: https://www.makerguides.com */
|
||||
// Include the Arduino Stepper.h library:
|
||||
#include <Stepper.h>
|
||||
// Define number of steps per rotation:
|
||||
const int stepsPerRevolution = 2048;
|
||||
// Wiring:
|
||||
// Pin 8 to IN1 on the ULN2003 driver
|
||||
// Pin 9 to IN2 on the ULN2003 driver
|
||||
// Pin 10 to IN3 on the ULN2003 driver
|
||||
// Pin 11 to IN4 on the ULN2003 driver
|
||||
// Create stepper object called 'myStepper', note the pin order:
|
||||
Stepper myStepper = Stepper(stepsPerRevolution, 8, 10, 9, 11);
|
||||
void setup() {
|
||||
// Set the speed to 5 rpm:
|
||||
myStepper.setSpeed(5);
|
||||
|
||||
// Begin Serial communication at a baud rate of 9600:
|
||||
Serial.begin(9600);
|
||||
#include <obus_module.h>
|
||||
|
||||
const int stepsPerRevolution = 2038;
|
||||
|
||||
#define IN_ONE 2
|
||||
#define IN_TWO 3
|
||||
#define IN_THREE 5
|
||||
#define IN_FOUR 6
|
||||
|
||||
Stepper stepper = Stepper(stepsPerRevolution, IN_ONE, IN_THREE, IN_TWO, IN_FOUR);
|
||||
|
||||
#define LIMIT_SWITCH_PIN 9
|
||||
|
||||
bool needs_calibration = false;
|
||||
int calib_steps_to_do = 0;
|
||||
int steps_to_do = 0;
|
||||
|
||||
void updatemotor() {
|
||||
if (calib_steps_to_do > 0) {
|
||||
stepper.step(1);
|
||||
calib_steps_to_do--;
|
||||
}
|
||||
else if (needs_calibration) {
|
||||
if (digitalRead(LIMIT_SWITCH_PIN)) {
|
||||
// Button not pushed down
|
||||
stepper.step(1);
|
||||
} else {
|
||||
// Button pushed down for first time, will be at 0 within stepsPerRevolution/64
|
||||
needs_calibration = false;
|
||||
}
|
||||
} else {
|
||||
if (steps_to_do > 0) {
|
||||
stepper.step(1);
|
||||
steps_to_do--;
|
||||
} else {
|
||||
digitalWrite(IN_ONE, LOW);
|
||||
digitalWrite(IN_TWO, LOW);
|
||||
digitalWrite(IN_THREE, LOW);
|
||||
digitalWrite(IN_FOUR, LOW);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setPosition(uint8_t index) {
|
||||
needs_calibration = true;
|
||||
int slotsToTurn = (16 - index) % 16;
|
||||
steps_to_do = stepsPerRevolution/64 + (slotsToTurn*(stepsPerRevolution/16));
|
||||
if (!digitalRead(LIMIT_SWITCH_PIN)) {
|
||||
calib_steps_to_do = stepsPerRevolution / 16;
|
||||
}
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
stepper.setSpeed(5);
|
||||
pinMode(LIMIT_SWITCH_PIN, INPUT_PULLUP);
|
||||
obus_module::setup(OBUS_TYPE_INFO, 3);
|
||||
}
|
||||
|
||||
uint8_t port_position = 0;
|
||||
obus_can::message message;
|
||||
void loop() {
|
||||
// Step one revolution in one direction:
|
||||
Serial.println("clockwise");
|
||||
myStepper.step(stepsPerRevolution);
|
||||
delay(500);
|
||||
|
||||
// Step one revolution in the other direction:
|
||||
Serial.println("counterclockwise");
|
||||
myStepper.step(-stepsPerRevolution);
|
||||
delay(500);
|
||||
obus_module::loopInfo(&message, info_generator);
|
||||
updatemotor();
|
||||
}
|
||||
|
||||
int info_generator(uint8_t* buffer) {
|
||||
uint8_t location = random(16);
|
||||
buffer[0] = location;
|
||||
setPosition(location);
|
||||
return 1;
|
||||
}
|
|
@ -17,7 +17,6 @@ eps=0.0001;
|
|||
|
||||
outer_radius=40; // outer radius of inner cylinder (the one with holes)
|
||||
wall_thickness=2;
|
||||
use <gears.scad>;
|
||||
gear_height=13;
|
||||
|
||||
big_gear=30;
|
||||
|
@ -74,6 +73,8 @@ module rotating_cylinder() {
|
|||
|
||||
// http://sammy76.free.fr/conseils/electronique/arduino/SG90.php
|
||||
clearance=0.5;
|
||||
size_outer = 2*(outer_radius+wall_thickness+clearance);
|
||||
|
||||
|
||||
// Print upside-down
|
||||
module small_gear_cylinder() {
|
||||
|
@ -97,7 +98,6 @@ distance_to_mount=22.7 - 15.9 - 2.5;
|
|||
|
||||
module container() {
|
||||
translation_outer = -outer_radius - wall_thickness - clearance;
|
||||
size_outer = 2*(outer_radius+wall_thickness+clearance);
|
||||
module clip_hole() {
|
||||
cube([clip_thickness+clearance, 100, 10+1]);
|
||||
translate([0, -clip_depth-clearance, 10]) cube([clip_thickness+clearance, 100, 10+clearance]);
|
||||
|
@ -174,8 +174,6 @@ module clip(thickness=5, clip_depth=1) {
|
|||
}
|
||||
|
||||
module container_bottom() {
|
||||
|
||||
size_outer = 2*(outer_radius+wall_thickness+clearance);
|
||||
translate([0, -size_outer/2, 0]) {
|
||||
cube([size_outer, size_outer, wall_thickness]);
|
||||
}
|
||||
|
@ -237,12 +235,13 @@ module ccube(size = [1,1,1], center = false)
|
|||
|
||||
|
||||
module keycap() {
|
||||
difference() {
|
||||
translate([0, 0, -1]) difference() {
|
||||
scale([12, 7, 15]) sphere(d=1);
|
||||
union() {
|
||||
ccube([cut, cut, cut], center=[true, true, false]);
|
||||
}
|
||||
}
|
||||
rotate([0, 180, 0]) ccube([12, 7, 1], center=[1, 1, 0]);
|
||||
translate([-5.8/2, 0, 0]) ccube([1, 2.5, 3], center=[1, 1, 0]);
|
||||
translate([5.8/2, 0, 0]) ccube([1, 2.5, 3], center=[1, 1, 0]);
|
||||
}
|
||||
|
@ -251,14 +250,25 @@ module keycap() {
|
|||
translation_outer = -outer_radius - wall_thickness - clearance;
|
||||
|
||||
|
||||
module extracase() {
|
||||
difference() {
|
||||
ccube([size_outer, size_outer, 61.5], center=[1, 1, 0]);
|
||||
translate([0, 0, 1.5]) ccube([size_outer-3, size_outer-3, cut], center=[1, 1, 0]);
|
||||
translate([0, 0, -1]) cylinder(d=15, h=cut);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* rotating_cylinder(); */
|
||||
|
||||
/* translate([125, 0, 0]) container(); */
|
||||
|
||||
small_gear_cylinder();
|
||||
// small_gear_cylinder();
|
||||
|
||||
|
||||
/* translate([125 + translation_outer, 125, -wall_thickness]) container_bottom(); */
|
||||
|
||||
// keycap();
|
||||
// keycap();
|
||||
|
||||
extracase();
|
Loading…
Reference in a new issue