12. Mechanical Design, Machine Design¶
This week, we made Onigiri machine as a group work. This work was also tough assignment, we could made it anyway.
Mechanical Design (part 1 of 2)¶
Group assignment:¶
- Design a machine that includes mechanism + actuation + automation + application
- Build the mechanical parts and operate it manually
- Document the group project
Individual assignment:¶
- Document your individual contribution
Machine Design (part 2 of 2)¶
Group assignment:¶
- Actuate and automate your machine
- Document the group project
Individual assignment:¶
- Document your individual contribution
Learning outcomes¶
- Work and communicate effectively as a team
- Design, plan and build a machine
- Analyse and solve technical problems
- Recognise opportunities for improvements in the design
Group Work¶
This week’s group work page is
This is week, we decided to make “Onigiri machine(riceball making machine)”.
At first, we had brain-storming what type of machine we would make, such as great forming machine or automation onigiri machine. Then, we decided to make a onigiri forming machine.
Next, we discussed what type of moulding method will be used.
We had several pattern, and Midori-san got the idea of “Iris mechanism” for shaping.
So we had set out each one’s role as follows;
task | |
---|---|
Midori-san | Design, mechanism and fabrication in Iris mechanism |
Shoko-san | Design, mechanism and fabrication in Pressing part and PlanB |
Maki | Electric programming and planB |
Individual Task¶
I worked electric and programming part and planB moulding and basement design.
Plan B system¶
Materials¶
Name | Size | Required Number | vender |
---|---|---|---|
Timing Belt | width:6mm, length: 1m | 1 | from Korat Delta |
Timing Belt Pully | inside hole radius: 5mm, outer radius: 16mm | 1 | |
Bearing Wheel | 12 | from Korat Delta | |
Carriage Base | 55mm x 60mm | 3 | from Korat Delta |
Korat Delta was produced by Mio Kato san
Electrical Parts¶
Name | Required Number |
---|---|
Arduino UNO | 1 |
CNC Shield v3 | 1 |
NEMA Stepper Motor (bipola) (17 stepping) | 2 |
Stepper Motor Driver (DRV8825) | 2 |
Regulated Power Supply | 1 |
Design & Fablication¶
First Try¶
I made 1 big moving part which is attached to the roller and put a mold part inside.
Both mold and moving part has has tabs to fit them each other.
System seemed working, but basement part seemed too big for 3D printing and it was not useful to be modified.
(1) Making in Fusion360
First, the outer frame section was drawn. I drew this as a reference because we were planning to make an onigiri machine using an already existing frame (Delta 3D printer).
Then I draw a basement part and molding part.
We found the size of basement part was too fit at 3D printer maximum, so it was better to separate it into several parts. Separate parts are also easy to change.
(2) 3D Printing
Then these were printed by Bambu lab P1s.
Second try¶
As 2nd try, circle part and sleeve parts are separated and assembled one.
Therefore we could change and modify each part easily.
The mold part and the base part make contact all through their thickness, so the edge of the base side was slightly larger at half height to reduce the resistance there.
The longer tabs are put in mould part too.
They were assembled and put into the machine and it seemed working well.
Next, we checked up and down motion with roller.
Actuation¶
We checked if it was worked smoothly with the roller with hand at first.
Then I tried to move it with a stepper motor.
As I didn’t know if 1 stepper motor can lift whole parts,
I tested lifting with 1 stepper motor.
I put the bearing wheels at the piller.
Pulley is put on the bottom part too for moving basement part by timing belt.
Then, I tested basement pulling by 1 stepper motor.
It worked but it was not smooth as I expected, I tried to move it by 2 stepper motors.
A stepper motor and pulley system are put at each corners of 2 pillars.
I sent same command(DigitalWrite()) as almost same timing, but they didn’t move at same time.
As they were not from same manufacture, I changed one of the stepper motor.
They still didn’t move at same speed and timing.
Then, Tsuchiya-san told me CNC shield has mirror system and it sent signals 2 motors at the same time.
I changed the CNC shield for mirror system.
It was moved well with mirror.
Next step was moving smoothly.
Rico-san(another instructor) advised me there was a library for acceleration and deceleration called
AccelStepper.h.
Using this library and changed the code, one of the motors didn’t move well and it got hard to lift the basement.
I changed to use 1 stepper to move basement part again, and it worked well.
So back to 1 motor function and done!
Elecric Programming¶
Work flow¶
This machine needs 2 functions, “Pressing onigiri” and “Pulling molding and basement”. So I made this flow;
stateDiagram-v2
[*] --> Ask
Ask --> Pressing
Ask --> Pulling
Pressing --> Onigiri_Press
Pulling --> Basement_Up
Onigiri_Press --> Pick_and_Eat
Basement_Up --> Pick_and_Eat
Coding¶
As this week’s main control is done by stepper motor,
I made a first code using Tsuchiya-san(One of our instructors)’s basic stepper CNC shield code as a reference.
((1)code at Code part)
This code was using DigitalWrite() to control 3 stepper motors.
(1 for pressing part and 2 for moving the basement and a mold)
Then, next I tried making the code using AccelStepper.h. This library supplies smooth acceleration and deceleration of the movement. Unfortunately 2 steppers for moving basement part didn’t work well and it didn’t have time to solve it, I changed the 1 stepper motor control for moving them and it worked well.((2)code)
Research¶
First step was to check the operation of the control and organise the procedure.
Then I learnt the coding from Tsuchiya-san(One of our instructors)’s basic stepper CNC shield code as a reference and wrote the first one.
As a accelstepper, I searched several page at internet(links are below) and wrote a code.
Code¶
(1) First code using DigitalWrite()
/*
Onigiri Make Controller Version.1
*/
int x;
const int cncc_en = 8; // Pin for enable control CNCC
const int a_step = 2; // Pressing Part (X axis)
const int a_dir = 5; // Direction for A
const int b_step = 3; // Basement part 1 (Y axis)
const int b_dir = 6; //
//const int c_step = 4; // Basement part 1 (Z axis)
//const int c_dir = 7; //
const char sel_a ='a'; // Pressing
const char sel_b ='b'; // Basement
//const char sel_c ='c'; // 1 stepper moter in Basement
const char sel_all ='z'; // All
// Setting values for
int step_num = 200; // step number
int delay_time = 500; // Delay time
int step_num_a = 1600; // step number for Pressing (1600)
int delay_time_a = 750; // Delay time for Pressing
int step_num_b = 300; // step number for Basement
int delay_time_b = 1600; // Delay time for Basement
//Small step number
int step_num_L = 100; // step number
int delay_time_L = 1000; // Delay time
void setup() {
// Arduino pin setting
pinMode(cncc_en,OUTPUT); // Enable
pinMode(a_step,OUTPUT); // step setting for Pressing part
pinMode(a_dir,OUTPUT); // Direction for A
pinMode(b_step,OUTPUT); // Step setting for Basement1 part
pinMode(b_dir,OUTPUT); // Direction for B
// pinMode(c_step,OUTPUT); // Step setting for Basement2 part
// pinMode(c_dir,OUTPUT); // Direction for B
digitalWrite(cncc_en,LOW); // Set Enable lowでドライバーが動く
Serial.begin(9600);
}
void loop() {
Serial.println("Which tool do you want to use?(a:Pressing b:Basement z:All(Not yet)):");
while (Serial.available() == 0) {
delay(100);
}
char key = Serial.read();
Serial.println(key);
if(key == 'a'){ // Pressing
step_num = step_num_a;
delay_time = delay_time_a;
move_control(a_step, a_dir);
}
else if(key == 'b'){ // Basement (2 stepper motors move)
step_num = step_num_b;
delay_time = delay_time_b;
move_control(b_step, b_dir);
}else if(key == 'z'){ // All
move_control(a_step, a_dir);
delay(1000);
move_control(b_step, b_dir);
}
}
/*
parameter: pin no, direction pin no, High/low
*/
void step_move(int move_pin, int dir_pin, float dir){
digitalWrite(dir_pin ,dir); // Set Dir High 正転/逆転
for(x = 0; x < step_num ; x++) // step_numステップ分繰り返す
{
digitalWrite(move_pin, HIGH);
delayMicroseconds(delay_time);
digitalWrite(move_pin, LOW);
delayMicroseconds(delay_time);
}
delay(1000);
}
/*
Control up/down or clockwise/counter clockwise
parameter (Port No, Direction No)
*/
void move_control(int port_no, int port_dir){
int UP_mode;
int DOWN_mode;
int st_n;
int dl_t;
char go = ' ';
// Set direction (As Pressing and shaping rotation are opposite )
if(port_no == a_step){
UP_mode = HIGH;
DOWN_mode = LOW;
}else if(port_no == b_step){
UP_mode = LOW;
DOWN_mode = HIGH;
}
Serial.println("What do you want?(u:up d:Down l:Low steps x:exit):");
while(go != 'x'){
if (Serial.available()){
go= Serial.read();
// 改行や不要な文字を無視
if (go == '\n' || go == '\r') {
continue;
}
Serial.println(go);
}
if(go == 'u'){
step_move(port_no, port_dir, UP_mode);
}else if(go == 'd'){
step_move(port_no, port_dir, DOWN_mode);
}else if(go == 'l'){
step_num = step_num_L;
}else if(go == 'x'){
return;
}
go = ' ';
delay(1000);
}
}
(2) Code using AccelStepper()
/*
Onigiri Make Controller Version 2
*/
#include <AccelStepper.h>
int x;
const int cncc_en = 8; // Pin for enable control CNCC
const int a_step = 2; // Pressing Part (X axis)
const int a_dir = 5; // Direction for A
const int b_step = 3; // Basement part 1 (Y axis)
const int b_dir = 6; //
//const int c_step = 4; // Basement part 1 (Z axis)
//const int c_dir = 7; //
const char sel_a ='a'; // Pressing
const char sel_b ='b'; // Basement
//const char sel_c ='c'; // 1 stepper moter in Basement
const char sel_all ='z'; // All
// Setting values for
int step_num = 200; // step number
int delay_time = 500; // Delay time
int step_num_a = 1600; // step number for Pressing (Ideal : 1600)
int delay_time_a = 750; // Delay time for Pressing
int maxspeed_a = 1000; // Max speed setting
int accel_a = 500; // Accelaration setting
int step_num_b = 300; // step number for Basement <- Basement setting
int delay_time_b = 1600; // Delay time for Basement
int maxspeed_b = 200; // Max speed setting
int accel_b = 200; // Accelaration setting
//Small step number
int step_num_L = 100; // step number
int delay_time_L = 1000; // Delay time
// AccelStepper
AccelStepper stepperA(1,a_step , a_dir);
AccelStepper stepperB(1,b_step , b_dir);
void setup() {
// Arduino pin setting
pinMode(cncc_en,OUTPUT); // Enable
pinMode(a_step,OUTPUT); // step setting for Pressing part
pinMode(a_dir,OUTPUT); // Direction for A
pinMode(b_step,OUTPUT); // Step setting for Basement1 part
pinMode(b_dir,OUTPUT); // Direction for B
// pinMode(c_step,OUTPUT); // Step setting for Basement2 part
// pinMode(c_dir,OUTPUT); // Direction for B
digitalWrite(cncc_en,LOW); // Set Enable Driver move by low
// AccelStepper
stepperA.setMaxSpeed(maxspeed_a); // For A(Steps/sec)
stepperA.setAcceleration(accel_a); // (Steps/sec²)
stepperB.setMaxSpeed(maxspeed_b); // For B(Steps/sec)
stepperB.setAcceleration(accel_b); // (Steps/sec²)
Serial.begin(9600);
// Serial.println("Which tool do you want to use?(1:Pressing 2:Basement):");
}
void loop() {
Serial.println("Which tool do you want to use?(a:Pressing b:Basement z:All(Not yet)):");
int step_val;
while (Serial.available() == 0) {
delay(100);
}
char key = Serial.read();
Serial.println(key);
if (key == 'a') {
up_down_loop(stepperA, step_num_a);
} else if (key == 'b') {
up_down_loop(stepperB, step_num_b);
} else if (key == 'z') {
move_control(a_step, a_dir);
delay(1000);
move_control(b_step, b_dir);
} else {
Serial.println("Invalid tool selection.");
}
}
void up_down_loop(AccelStepper& stepper, int smotor) {
char go = ' ';
int step_val = 0;
while (true) {
Serial.println("What do you want? (u:up d:down x:exit):");
while (Serial.available() == 0) {
delay(100);
}
go = Serial.read();
if (go == '\n' || go == '\r') continue;
Serial.println(go);
if (go == 'u') {
step_val = smotor;
} else if (go == 'd') {
step_val = -smotor;
} else if (go == 'x') {
Serial.println("Exiting operation.");
break; // 終了
} else {
Serial.println("Invalid input.");
continue;
}
// move motor
stepper.moveTo(stepper.currentPosition() + step_val);
while (stepper.distanceToGo() != 0) {
stepper.run();
}
}
}
/*
parameter: pin no, direction pin no, High/low
*/
void step_move(int move_pin, int dir_pin, float dir){
digitalWrite(dir_pin ,dir); // Set Dir High 正転/逆転
for(x = 0; x < step_num ; x++) // step_numステップ分繰り返す
{
digitalWrite(move_pin, HIGH);
delayMicroseconds(delay_time);
digitalWrite(move_pin, LOW);
delayMicroseconds(delay_time);
}
delay(1000);
}
/*
Control up/down or clockwise/counter clockwise
parameter (Port No, Direction No)
*/
void move_control(int port_no, int port_dir){
int UP_mode;
int DOWN_mode;
int st_n;
int dl_t;
char go = ' ';
// Set direction (As Pressing and shaping rotation are opposite )
if(port_no == a_step){
UP_mode = HIGH;
DOWN_mode = LOW;
}else if(port_no == b_step){
UP_mode = LOW;
DOWN_mode = HIGH;
}
Serial.println("What do you want?(u:up d:Down l:Low steps x:exit):");
while(go != 'x'){
if (Serial.available()){
go= Serial.read();
// Ignore line break and unnecessary characters
if (go == '\n' || go == '\r') {
continue;
}
Serial.println(go);
}
if(go == 'u'){
step_move(port_no, port_dir, UP_mode);
}else if(go == 'd'){
step_move(port_no, port_dir, DOWN_mode);
}else if(go == 'l'){
step_num = step_num_L;
}else if(go == 'x'){
return;
}
go = ' ';
delay(1000);
}
}
What I’ve learnt this week(2 weeks)¶
I’ve learnt a lot of things in this assignment. I felt this week’s assignment work seemed small scale of “Final project”, I could feel how it worked with final project.
I also learnt a lot how to work with stepper motors. There were 2 ways of moving(screw and timing belt) by stepper motor in one coding.
I’m so happy this machine can work properly!