3.final project box
box¶
Overview¶
This is the final version of the box within the FabAcademy period👍
Created a circuit design and programming part in week12
Design with Fusion360¶
The final box design looked like this
The following video was used as a reference in creating the Iris mechanism
Solidworks tutorial: iris Mechanism/Diaphragm Camera Shutter Design Assembly and Animation
Autodesk Fusion 360 - Designing an Iris mechanism
I did not use it this time, but there is a tool that can easily create iris mechanism
Creation of gears¶
First, created two gears to transmit power to the iris mechanism by servo motor.
Select “UTILITIES” => “Add-INS” => “Scripts and Add-Ins…” => “SpurGear” (Python version) and click “Run” button.
Parameters are set as follows
Pitch diameter value cannot be entered, but can be calculated using the following formula.
Pitch Diameter = Module x Number of teeth
Since 5.5mm MDF is used, Gear thickness is set to 5.5mm.
Backlash is set to 0.00mm to account for the kerf gap since the laser cutter is used to create the gears.
Click “OK”, the gear is automatically generated as shown below.
Next, created the gears to attach the servo motor. In order for the gears to mesh, the module values must match.
Click “OK”, the gear is automatically generated as shown below.
To rotate a gear, the pitch circles of the two gears must be aligned.
360° / 10 (Number of teeth) / 2
by rotating the gear along the Z-axis to mesh the position of the gears
Click “OK”
This flow made it easy to create gears!
Select Appearance => MDF
Appearance can be changed to MDF
The gear blades are left only as much as is needed to engage the servomotor gears as they rotate 180 degrees
Eight rectangular grooves are placed every 45 degrees using a circular pattern.
The base of the Iris mechanism is as follows
Eight rectangular grooves are placed every 45 degrees using a circular pattern.
Iris blades were created as follows
Cut off the useless parts from the fan shape so that the sides of the blade do not come out when the iris is opened
Front Side
Back Side
I have placed the ultrasonic sensor and servo motor in the following positions
Embed 5 mm diameter magnets in the four holes.
Since this part is a lid part, a magnet is embedded in the body as well, making it easy to remove with the magnet.
Fix the base of the iris mechanism to the base with wood glue during assembly.
Place the iris blade as follows
This part was created with a 3D printer.
Place the gears so that they engage.
Front Side
Back Side
Next, I created the bottom of the box body.
Create a 5 mm groove.
The side are attached with MDF using the kerf bending
Attach magnets to the top in four places so that they stick to the magnets on the lid.
Create a 5mm groove for attaching the case to the part where the ultrasonic sensor is mounted as well.
I have created the following case
Attach the case to the groove.
kerf bending on side of box¶
The side of the box was created using a technique called kerf bending, in which a cut is made and the sides are bent as shown below.
Sketch the following
Use the Rectangular Pattern tool to duplicate
Save the file in DXF format.
Laser cutting¶
MDF 5.5mm was used as material. Only the kerf bending parts on the side was made of MDF 4mm.
3D Printing¶
3d printed blade with Prusa
The design is as follows
Design electric circuit with Kicad¶
Designed the board in Kicad.
I used ATTiny3216 for the microcontroller board
ATTiny3216, ATTiny1614 have servo.h library, so I used ATTiny3216, which the lab had plenty of in stock.
For ATtiny3216 to control the ultrasonic sensor and servo motor, connected the trigger pin of the ultrasonic sensor to PA4 (pin 0) and the echo pin to PA5 (pin 1).
Also connected the servo signal pin to PB0 (pin 9).
The following circuit design was done in kicad
HC-SR04 (ultrasonic distance sensor)¶
First, I read the HCSR04 datasheet
Wire connecting direct as following:¶
- 5V Supply
- Trigger Pulse Input
- Echo Pulse Output
- 0V Ground
Electric Parameter¶
Electric Parameter | parameter |
---|---|
Working Voltage | DC 5 V |
Working Current | 15mA |
Working Frequency | 40Hz |
Max Range | 4m |
Min Range | 2cm |
MeasuringAngle | 15 degree |
Trigger Input Signal | 10uS TTL pulse |
Echo Output Signal | Input TTL lever signal and the range in proportion |
Dimension | 45 x 20 x 15mm |
Create board¶
The electronic parts are as follows
This time I created 3 boxes and therefore 3 boards!
After soldering, the board is completed.
Programming¶
Referred to the following article
First, show the flow of the ultrasonic sensor in the program
By sending a 10ms pulse from the ATTiny3216 to the Triger pin, ultrasonic waves can be emitted from the ultrasonic sensor.
The ultrasonic waves hit the object, bounce back, and are received by the Echo pin.
Definition of variables to be used this time
The travel time of the ultrasonic wave (ms):
travel_time = pulse_duration
The speed of the ultrasonic wave:
speed = SPEED_OF_SOUND = 340 [m/s] = 0.034 [cm/ms]
The travel distance of the ultrasonic wave (cm):
travel_distance = speed x travel_time = 0.034 x pulse_duration
The distance between sensor and obstacle (cm):
distance = travel_distance / 2 = 0.034 x pulse_duration / 2 = 0.017 x pulse_duration
// Referenced by https://arduinogetstarted.com/tutorials/arduino-ultrasonic-sensor
#include <Servo.h>
const int TRIG_PIN = 0;
const int ECHO_PIN = 1;
const int SERVO_PIN = 4;
const int DISTANCE_THRESHOLD = 20;
Servo servo;
float duration_us, distance_cm;
void setup() {
Serial.begin (9600);
pinMode(TRIG_PIN, OUTPUT);
pinMode(ECHO_PIN, INPUT);
servo.attach(SERVO_PIN);
servo.write(0);
}
void loop() {
digitalWrite(TRIG_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG_PIN, LOW);
duration_us = pulseIn(ECHO_PIN, HIGH);
distance_cm = 0.017 * duration_us;
if (distance_cm < DISTANCE_THRESHOLD){
servo.write(180);
} else {
servo.write(0);
}
Serial.print("distance: ");
Serial.print(distance_cm);
Serial.println(" cm");
delay(500);
}
Explanation of Codes¶
Define the numbers of the trigger pin and echo pin of the ultrasonic sensor and the signal pin of the servo motor
const int TRIG_PIN = 0;
const int ECHO_PIN = 1;
const int SERVO_PIN = 4;
Define distance thresholds
const int DISTANCE_THRESHOLD = 20;
Declares a Servo object
Servo servo;
Define variables with the float type.
float duration_us, distance_cm;
Codes of void setup()
void setup() {
Serial.begin (9600);
pinMode(TRIG_PIN, OUTPUT);
pinMode(ECHO_PIN, INPUT);
servo.attach(SERVO_PIN);
servo.write(0);
}
Prepare serial communication (9600 bps)
Serial.begin (9600);
Set the trigger pin as output and the echo pin as input
pinMode(TRIG_PIN, OUTPUT);
pinMode(ECHO_PIN, INPUT);
Assign servo variables to pin.
servo.attach(SERVO_PIN);
Set the angle of the servo motor to 0 degrees
servo.write(0);
Codes of void loop()
void loop() {
digitalWrite(TRIG_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG_PIN, LOW);
duration_us = pulseIn(ECHO_PIN, HIGH);
distance_cm = 0.017 * duration_us;
if (distance_cm < DISTANCE_THRESHOLD){
servo.write(180);
} else {
servo.write(0);
}
Serial.print("distance: ");
Serial.print(distance_cm);
Serial.println(" cm");
delay(500);
}
Switches from HIGH to LOW at intervals of 10μs on the trigger pin
digitalWrite(TRIG_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG_PIN, LOW);
Reads a pulse (either HIGH or LOW) on a pin.
pulseIn(pin, value, timeout)
pin: the number of the pin on which you want to read the pulse. (int)
value: type of pulse to read: either HIGH or LOW. (int)
timeout (optional): the number of microseconds to wait for the pulse to be completed: the function returns 0 if no complete pulse was received within the timeout. Default is one second (unsigned long).
duration_us = pulseIn(ECHO_PIN, HIGH);
Calculate the distance
distance_cm = 0.017 * duration_us;
If distance_cm is shorter than the threshold value (20cm), it rotate 180 degrees.
if (distance_cm < DISTANCE_THRESHOLD){
servo.write(180);
} else {
servo.write(0);
}
Display distance_cm on the serial monitor every 0.5 seconds
Serial.print("distance: ");
Serial.print(distance_cm);
Serial.println(" cm");
delay(500);
Write the program and check serial communication
Packaging¶
Apply wood glue.
Attach the frame to the base part in order to install the side kerf bends.
Attach the side Kerf bending with wood glue.
Insert the magnet.
A 3mm magnet and 2.5mm MDF are placed in a 5.5mm thick MDF hole.
I painted the MDF created parts black with black oil-based spray
The orange and black design of Prusa, a 3D printer, was so cool that I decided to integrate the colors as much as possible in orange and black!
The electric board was installed as follows
The electrical board and batteries were fixed with double-sided tape.
Covered with a case.
The following box was finally completed