Prototype¶
This Prototype was crated to test one of the dispensing mechanisms we were considering. Here are tasks that we conducted:
-
create 3D design
-
Cut the design using cardboard and assemble it.
-
Connect the electronic together.
-
Write the code.
-
Test the Prototype.
Create the 3D design:¶
Here is the 3D design of the prototype. The design was made using SolidWorks.
You can download the model from here
Here is the design of the gear:
The slot in the middle of the gear (where the motor enter), it dimensions were designed based on the this stepper model design that has been downloaded online.
You can download the model from here
Here you can notice that 0.8 mm where the tolerance that has been considered, this is accounted for since the laser cutting is a subtractive manufacturing process.
Cut the design using cardboard and assemble it.¶
After finishing the design, as a team we acquired a piece of 2 mm cardboard and started cutting our parts using cutters and scissors.
After cutting the pieces, we assembled them together using tape and toothpicks.
and here what we ended up with:
All the parts were cut manually, expect for the gear. The gear where cut in the laser cutting machine since the teeth of the hear are very small and detailed that it would be very difficult to cut them manually. The gear part was also cut on 2 mm thick cardboard. However, we cut 4 pieces of the gear and glued them together to have one 8 mm thick gear.
Connect the electronic components together¶
Here is the connection diagram that we will follow to create the prototype.
below is a simple demonstration of the use of the rotary encoder and the LCD screen.
Write the code¶
Click to expand
#include <Stepper.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#define outputA 2
#define outputB 3
const int stepsPerRevolution = 1800; // change this to fit the number of steps per revolution
const int rolePerMinute = 15; // Adjustable range of 28BYJ-48 stepper is 0~17 rpm
// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 10, 9, 11);
int counter = 0;
int aState, bState;
int aLastState;
String Medicine1 = "Vitamin D";
String Medicine2 = "Iron";
String Medicine3 = "Thyroxin";
String Medicine4 = "Tryptizol";
String Medicine5 = "Ferritin";
uint32_t interval = 5000;
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
myStepper.setSpeed(rolePerMinute);
pinMode (outputA,INPUT_PULLUP);
pinMode (outputB,INPUT_PULLUP);
Serial.begin (9600);
// Reads the initial state of the outputA
aLastState = digitalRead(outputA);
//initialize lcd screen. screen messes up without this
lcd.init();
// turn on the backlight
lcd.backlight();
}
void loop() {
aState = digitalRead(outputA); // Reads the "current" state of the outputA
// If the previous and the current state of the outputA are different, that means a Pulse has occured
if (aState != aLastState){
// If the outputB state is different to the outputA state, that means the encoder is rotating clockwise
if (digitalRead(outputB) != aState) {
counter ++;
if ( counter > 30) counter = 0;
} else {
counter --;
if ( counter < 0) counter = 30;
}
lcd.setCursor(0, 0);
lcd.print("Med: ");
if (counter >= 0 && counter < 7){
lcd.clear();
lcd.print("Medicine #1");
lcd.setCursor(0,1);
lcd.print(Medicine1);
}
if (counter > 6 && counter < 13){
lcd.clear();
lcd.print("Medicine #2");
lcd.setCursor(0,1);
lcd.print(Medicine2);
}
if (counter > 12 && counter < 19){
lcd.clear();
lcd.print("Medicine #3");
lcd.setCursor(0,1);
lcd.print(Medicine3);
}
if (counter > 18 && counter < 25){
lcd.clear();
lcd.print("Medicine #4");
lcd.setCursor(0,1);
lcd.print(Medicine4);
}
if (counter > 24 && counter < 31){
lcd.clear();
lcd.print("Medicine #5");
lcd.setCursor(0,1);
lcd.print(Medicine5);
}
}
aLastState = aState; // Updates the previous state of the outputA with the current state
static uint32_t nextTime;
if (millis() - nextTime >= interval) {
nextTime += interval;
Serial.println("Medicine Time!");
myStepper.step(100);
}
}
Test the prototype:¶
Here is a demonstration of how the gear mechanism would work. However, this method were discarded due to several issues:
-
The pills often get stuck in the funnel.
-
If the pill fell from the funnel, it must fell vertically between the teeth. This was not the case every time since the pills sometimes dose not fall perfectly between the Two teeth.
- As demonstrated in the video, for the first pill, the gear must take 180 degrees to be dispensed. If a pill missed its place between the two teeth it will ruin the schedule.
Due to these problems we concluded that there are to many factors that depends on the chance in this mechanism and it would not preform perfectly every time.