- Hello everyone in this project we thought one of the problem we had in the lab. Getting exact amount of powder is some time can be difficult but with this project not anymore.
- We used a loadcell for the scale the weight a display to show the weight and the input. For putting input we used simple button and potentiometer. Lastly servo motor used for dispense function.
- After loadcell is fixated to his platform we used code from Hrisko, J for calibrating the loadcell.
#include <Q2HX711.h>
const byte hx711_data_pin = 3;
const byte hx711_clock_pin = 4;
float y1 = 20.0; // calibrated mass to be added
long x1 = 0L;
long x0 = 0L;
float avg_size = 10.0; // amount of averages for each mass measurement
Q2HX711 hx711(hx711_data_pin, hx711_clock_pin); // prep hx711
void setup() {
Serial.begin(9600); // prepare serial port
delay(1000); // allow load cell and hx711 to settle
// tare procedure
for (int ii=0;ii<int(avg_size);ii++){
delay(10);
x0+=hx711.read();
}
x0/=long(avg_size);
Serial.println("Add Calibrated Mass");
// calibration procedure (mass should be added equal to y1)
int ii = 1;
while(true){
if (hx711.read()<x0+10000){
} else {
ii++;
delay(2000);
for (int jj=0;jj<int(avg_size);jj++){
x1+=hx711.read();
}
x1/=long(avg_size);
break;
}
}
Serial.println("Calibration Complete");
}
void loop() {
// averaging reading
long reading = 0;
for (int jj=0;jj<int(avg_size);jj++){
reading+=hx711.read();
}
reading/=long(avg_size);
// calculating mass based on calibration and linear fit
float ratio_1 = (float) (reading-x0);
float ratio_2 = (float) (x1-x0);
float ratio = ratio_1/ratio_2;
float mass = y1*ratio;
Serial.print("Raw: ");
Serial.print(reading);
Serial.print(", ");
Serial.println(mass);
}
- After calibrating the loadcell we started to build part for input function. We wanted this project to work without a computer. Installed a button a potentiometer and a display.
- Used potentiometer take input and with map function we converted potentiometer input to single digit number then button was used for confirmation with while loop
- After input received a while loop constantly checks if the weight reeded from loadcell is matched or not and when the desired weight reached it stops.
- In the process weight constantly showed in the display. We used a round function and basic math to show the weight in display
- We also did built 3 different speed so it is going slower when the desired weight is close.
- For dispense a servo motor was used. We used a basic servo.write function with different degrees for different speeds
- Lastly we added a tare function which measure weight when button pressed in the beginning so it can ignore containers weight.
After the coding part is over we started to assembly our powder dispenser, we used duplo blocks but you can use different materials of course.
Quinten Speleers, Mazlum Akif Altun
Posted by proprietor
Comments