xdd44, Dec. 11, 2024
I realized we have an option of metal lasercutting for this week. It is exactly what I need to build a stronger physical structure of my toy (pls check previous two weeks for context).
I still used acrylic for the enclosed frame and added an additional layer, since acrylic's thickness brings easy joints and prevents buckling. For the supporting part, I designed a aluminum sheet version.
I also added 1:4 gear pairs to increase the torque applied to the platform, and shifted the axis a bit to balance the weight of the motor.
Design
Cut Path
Cutting
My aluminum sheet is quite dirty since it comes from two years ago lol. Luckily, Jacob showed me an easy sand blowing technique (it is actually for my final project) that made my parts look much better.
Result Parts with Sand Finish
Since I have potentiometers for angle feedback, I was wondering if I need a PID algorithm to control the motor, but it turned out rotating one step each time worked fine.
void loop() {
int rawValue1 = analogRead(pot1Pin);
int rawValue2 = analogRead(pot2Pin);
float angle1 = (rawValue1 / 4095.0) * 300 - 160;
angle1 = constrain(angle1, -30, 30);
float angle2 = (rawValue2/ 4095.0) * 300 - 160;
angle2 = constrain(angle2, -30, 30);
float targetAngle1 = atan(vector[1] / vector[2]) * 180 / 3.14159;
targetAngle1 = constrain(targetAngle1, -30, 30);
float targetAngle2 = atan(vector[0] / vector[2]) * 180 / 3.14159;
targetAngle2 = constrain(targetAngle2, -30, 30);
controlMotor1Continuous(angle1, targetAngle1);
controlMotor2Continuous(angle2, targetAngle2);
}
void controlMotor1[2]Continuous(float currentAngle, float targetAngle) {
float error = targetAngle - currentAngle;
if (abs(error) < 1.0) return;
digitalWrite(dir1[2]Pin, error > 0 ? HIGH : LOW);
digitalWrite(step1[2]Pin, HIGH);
delayMicroseconds(stepDelay); // Adjust speed here
digitalWrite(step1[2]Pin, LOW);
delayMicroseconds(stepDelay);
}
Machine working
But as Neil mentioned in class, my motors were not working properly as they shaked a lot, potentially because of incorrect current or lack of microstep. I have to do more testing since I also need these motors for my final project.