Some more info port updates

This commit is contained in:
redfast00 2022-03-10 22:09:37 +01:00
parent c851073336
commit 8feb8e41a8
No known key found for this signature in database
GPG key ID: 5946E0E34FD0553C
3 changed files with 86 additions and 1128 deletions

File diff suppressed because it is too large Load diff

View file

@ -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> #include <Stepper.h>
// Define number of steps per rotation: #include <obus_module.h>
const int stepsPerRevolution = 2048;
// Wiring: const int stepsPerRevolution = 2038;
// Pin 8 to IN1 on the ULN2003 driver
// Pin 9 to IN2 on the ULN2003 driver #define IN_ONE 2
// Pin 10 to IN3 on the ULN2003 driver #define IN_TWO 3
// Pin 11 to IN4 on the ULN2003 driver #define IN_THREE 5
// Create stepper object called 'myStepper', note the pin order: #define IN_FOUR 6
Stepper myStepper = Stepper(stepsPerRevolution, 8, 10, 9, 11);
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() { void setup() {
// Set the speed to 5 rpm: Serial.begin(115200);
myStepper.setSpeed(5); stepper.setSpeed(5);
pinMode(LIMIT_SWITCH_PIN, INPUT_PULLUP);
// Begin Serial communication at a baud rate of 9600: obus_module::setup(OBUS_TYPE_INFO, 3);
Serial.begin(9600);
} }
uint8_t port_position = 0;
obus_can::message message;
void loop() { void loop() {
// Step one revolution in one direction: obus_module::loopInfo(&message, info_generator);
Serial.println("clockwise"); updatemotor();
myStepper.step(stepsPerRevolution); }
delay(500);
int info_generator(uint8_t* buffer) {
// Step one revolution in the other direction: uint8_t location = random(16);
Serial.println("counterclockwise"); buffer[0] = location;
myStepper.step(-stepsPerRevolution); setPosition(location);
delay(500); return 1;
} }

View file

@ -17,7 +17,6 @@ eps=0.0001;
outer_radius=40; // outer radius of inner cylinder (the one with holes) outer_radius=40; // outer radius of inner cylinder (the one with holes)
wall_thickness=2; wall_thickness=2;
use <gears.scad>;
gear_height=13; gear_height=13;
big_gear=30; big_gear=30;
@ -74,6 +73,8 @@ module rotating_cylinder() {
// http://sammy76.free.fr/conseils/electronique/arduino/SG90.php // http://sammy76.free.fr/conseils/electronique/arduino/SG90.php
clearance=0.5; clearance=0.5;
size_outer = 2*(outer_radius+wall_thickness+clearance);
// Print upside-down // Print upside-down
module small_gear_cylinder() { module small_gear_cylinder() {
@ -97,7 +98,6 @@ distance_to_mount=22.7 - 15.9 - 2.5;
module container() { module container() {
translation_outer = -outer_radius - wall_thickness - clearance; translation_outer = -outer_radius - wall_thickness - clearance;
size_outer = 2*(outer_radius+wall_thickness+clearance);
module clip_hole() { module clip_hole() {
cube([clip_thickness+clearance, 100, 10+1]); cube([clip_thickness+clearance, 100, 10+1]);
translate([0, -clip_depth-clearance, 10]) cube([clip_thickness+clearance, 100, 10+clearance]); 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() { module container_bottom() {
size_outer = 2*(outer_radius+wall_thickness+clearance);
translate([0, -size_outer/2, 0]) { translate([0, -size_outer/2, 0]) {
cube([size_outer, size_outer, wall_thickness]); cube([size_outer, size_outer, wall_thickness]);
} }
@ -237,12 +235,13 @@ module ccube(size = [1,1,1], center = false)
module keycap() { module keycap() {
difference() { translate([0, 0, -1]) difference() {
scale([12, 7, 15]) sphere(d=1); scale([12, 7, 15]) sphere(d=1);
union() { union() {
ccube([cut, cut, cut], center=[true, true, false]); 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]);
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; 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(); */ /* rotating_cylinder(); */
/* translate([125, 0, 0]) container(); */ /* translate([125, 0, 0]) container(); */
small_gear_cylinder(); // small_gear_cylinder();
/* translate([125 + translation_outer, 125, -wall_thickness]) container_bottom(); */ /* translate([125 + translation_outer, 125, -wall_thickness]) container_bottom(); */
// keycap(); // keycap();
extracase();