10. Mechanical Design, Machine design¶
This week we work as a group with Antonio, Theo and Elina on how to built a machine.
Assignment:
Mechanical design
group assignment
- design a machine that includes mechanism+actuation+automation
- build the mechanical parts and operate it manually
- document the group project and your individual contribution
Machine design
group assignment
- actuate and automate your machine
- document the group project and your individual contribution
Video shot¶
Here is group page where all the workflow and all we have done is documented
Day 1 - The idea¶
Thinking of an idea, looking for kind of equipment we have at Agrilab, start the design and test some electronics¶
On the first day, we made a brainstorming together on which kind of machine we want to build and how to build it.
We want to have a device that is working with 2 or 3 axes.
- First Theo has the idea to make a smart garbage sorting device, where we put some garbage in a box and with buttons, it will throw the garbage in the right trash can we would have built.
- The second idea was to make a device that print pancakes to a warming plate, to draw pancakes with different shpaes, such as pancakes in the shape of houses, or animals.
So we decided to make a pancake printer because it is a device that interested us, to make something with food. We started to think to a way to make this device, we drew on paper how the machine could work. We want to have an extruder, to pour the pancake dough on the plate, that will move on 2 axes, X and Y, with motors. We thought about 2 differents systems to pour the pancake dough. Because this paste is pretty fluid, we thought of a system with pump that will bring the dough to the extruder, or a system with a syringe, that can be activate with a motor to push the pancake dough.
We also took a look at the PancakeBot that were used to be sold before
Some shields for Arduino have been ordered in our lab for this week so we gonna use an Arduino Uno board with a shield GRBL to use gcode to pilot our device.
Antonio talked to us about peristaltic we can use for the device. In Agrilab we have a device that dispense hydroalcoholic gel (because of the pandemic) which is using this kind of pump. We went to check it for how it works and how we can use it in the device.
To move the extruder of pancake dough we have thought of two possibilites:
- One is the plate that can move, like creality 10
- Second is to have 2 axes for the extruder
We would like to use a hotplate that can be find in a kitchen, with a pan, that’s why we are choosing the second possibilities. To do this we drew a ramp system.
Now we have a pretty clear idea in our mind, we went over Agrilab to look of all the device we have and which system inspire us.
We have a 3D printer where we can see the mechanism, a Creality ender 5 plus.
It is working with wheels that roll along an aluminium V-profile rail that is drived with a belt thanks to a motor and a puley for X and Y axes.
One of the axes is drived with a motor with two sides.
For the Z axe, it is the plate that goes up and and down with a threaded rod and a motor.
We found in storage aluminium profiles that we will certainly use.
In Agrilab we have an other device made by Luc, that engrave cardboard plates.
Here is it moving accoding to a motor with puley, a belt and wheels that block everything.
There is this kind of system with motors on both sides of the aluminium V-profile that are coordinate to move together.
The other axis is working according to the same principle.
We took a look on a small CNC built in our lab.
This device is moving with bearings, metal sticks and the movement is make by and threaded rot with a screw, that turn with a motor and drive the cnc tool.
We found in the storage some metal sticks that fit perfectly with the bearing that we have at our disposal, and also threaded shafts with screw, but that is not the system we gonna use.
We were inspired by all these systems to make our pancake printer bot. We were given some wheels for the aluminium V-profiles to check what is it.
Now we have started to design our machine. Theo started the design on Fusion 360.
Antonio was looking into a power source for our motors.
And he also tried to flash the Arduino board with the shield for CNC.
Peristaltic pump¶
I personally worked on the system to make the pump bring the pancake paste to the warming plate. For the machine we built, I worked on the peristaltic pump. First I needed to make the pump turn in one way and an other way to have a retract of the paste of pancake inside the tube. The first step was to find how to plug the pump to an arduino board to flash it.
The pump is made of ball bearings and silicone pipe. It is working with 12V current and 2A. The motor is a DC motor. In AgriLab the instructors ordered for us some H-bridges for the motors. I looked on internet how to wire the motor of the pump with that and on Arduino and I found this website on how to use H-bridge with a L298N motor.
This schematic were very useful to know where to plug what.
This website helped me also to understand how to control the CNC shield with Arduino.
The pump is powered with an AC/DC electric power supply 12V.
Step by step, I wrote the code to make the pump turn. The program is taking a value written in the serial monitor and send it to the motor as the speed. The turning side of the motor depend on the sign of the number (positives numbers will turn in one directon, negatives numbers will turn in another one).
Here is the wiring of the pump I made:
The enA, the white-white wire is connected to pin 9 on Arduino board. The in1, the brown-grey wire is connected to pin 10 on Arduino board. The in2, the purple-blue wire is connected to pin 11 on the Arduino board. There is a power source 12V, and the yellow and blue wire is the motor’s wires.
Here is the code I wrote. I used the IDE Visual Studio Code I discovered during a previous week. First there is the constants, the pins where the wires are plugged. In the setup function, I set the pins as outputs. Then I wrote a function for the movement, with two variables, the speed and the direction. And in the loop I first collect the value of the speed that is set, then transform it a bit in order to make it nice for the motor.
Here 200 is the speed I set of the motor, -200 is the same speed but in the other side, and -1 stop the motor. To find those values, I made some tests. The top value is 255 because the motor receive a value at 8 bits (2 to the power of 8 is 256). If I put a too small value, as 100, the motor does not receive enough power to turn.
I got a problem on the value when I print it on the serial monitor. The value I wrote is read but after the delay it take again the 0 value, and stop the motor. To fix that the 0 was excluded for the program and I changed the stop for the value -1.
#include <Arduino.h>
//https://ardwinner.jimdofree.com/arduino/iv-les-moteurs-continus/3-faire-tourner-un-moteur-dc-bidirectionnel-avec-un-module-l298n/
//https://arduino.blaisepascal.fr/pont-en-h-l298n/
//declaration des variables et des constantes
int enA = 9; //les pins avec des tilds
int in1 = 10;
int in2 = 11;
int speedmotor = 0; //vitesse du moteur
void setup() {
// put your setup code here, to run once:
pinMode(enA, OUTPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
Serial.begin(9600); //la valeur de communication
}
void move(int speed, bool testforward) {// speed between 0 and 255 analog write, test d'un booléen pour aller dans un sens ou dans un autre
if (testforward){
digitalWrite(in1, HIGH); //envoie du courant dans un sens (set to +)
digitalWrite(in2, LOW); //en envoie pas, le récupère (set to -)
}
else{
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
}
analogWrite(enA, speed);
}
void loop() {
// put your main code here, to run repeatedly:
if(Serial.available() > 0){ //si la board arduino est branchée
speedmotor = Serial.parseInt(); // speedmotor recupere la valeur inscrite dans le serial
Serial.println(speedmotor);
if (speedmotor == 0){
return;
}
if(speedmotor > 0){ //si speedmoto a une valeur, plus grande que 0
if (speedmotor > 255){
speedmotor = 255; //speedmotor est forcé à 255 maxi
}
move(speedmotor, true); //alors marche avant
}
else if(speedmotor < -1){
speedmotor = -1*speedmotor; //pour que la vitesse ait une valeur de vitesse mais en marche arrière
if (speedmotor > 255){ //recopiage du test parce que speedmotor est de nouveau positif
speedmotor = 255; //speedmotor est forcé à 255 maxi
}
move(speedmotor,false); //marche arriere
}
else if(speedmotor == -1){ //c'est zero donc tout s'arrete
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
}
}
}
With this code, I was able to make the viscosity test of the pancake paste in the tubes.
Viscosity test¶
I cooked the first pancake paste according to this recipe.
- 150 g of flour T55
- 1 egg
- 1 tablespoon of sugar
- 1 tablespoon of oil
- 1 teaspoon of chemical yeast
- 200 mL of milk
I made a small test with this consistency of dough but it is too liquid, the flow continues to fall even with gravity when the pump is stopped.
So I made different paste with different viscosity, the first one is the control sample, with initial recipe.
The second one has 25% more flour, and the third one has 50% more flour. We can see the different viscosity of the paste on the video.
To make the extruder I assembled some tubes from the largest to the smallest we could find. The biggest one is 7.6 mm, the second is 5.4 mm, the third one is 3.5 mm,a nd the last one is that small iI wasn’t able to measure it with the calliper.
I also tested the different tube with the different viscosity of the paste.
With the pipe of 3.5 mm I draw by hand a line on the warm plate to see how the dough is reacting to warm. We can see that the less viscose paste make the thinner line. After we taste it, because of too much flour we pour inside it is not really tasty.
We finally decided to take the consitency of the second dough, with 25% more flour, and the third pipe.
Improving the control of the pump with a joystick¶
After making the pump turning according to some values, I wanted to add an input, a joystick to control the speed of the pump. I searched on internet how to use a potential meter and found this very useful website on how to control a potential meter with Arduino. There is a picture of the wiring and how to control a LED with a potential meter.
I apply this to my motor of the pump.
To understand how a potential meter is working I just copied the code and watch the values of the potential meter printed on the serial monitor.
To plug everything on the Arduino board I checked this website with H-bridge and Arduino and I followed this schematic with the potential meter and the motor.
I discover the function map to transform some value to some other which was very usefu because the motor handle values from 0 to 255 and the potential meter have value from 0 to 1023. I modify the code to make the pump go in a way or in an other according to the position of the potential meter.
Here is the code I wrote, and we use it for the device, the pancake bot.
#include <Arduino.h>
//https://ardwinner.jimdofree.com/arduino/iv-les-moteurs-continus/3-faire-tourner-un-moteur-dc-bidirectionnel-avec-un-module-l298n/
//https://arduino.blaisepascal.fr/pont-en-h-l298n/
//https://www.mataucarre.fr/index.php/2019/03/09/utiliser-un-potentiometre-avec-un-arduino/
//declaration des variables et des constantes
int enA = 9; //les pins avec des tilds
int in1 = 10;
int in2 = 11;
int pot; //valeur du potentiometre
int speedmotor = 0; //vitesse du moteur
void setup() {
// put your setup code here, to run once:
pinMode(enA, OUTPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
Serial.begin(9600); //la valeur de communication
}
void move(int speed, bool testforward) {// speed between 0 and 255 analog write, test d'un booléen pour aller dans un sens ou dans un autre
if (testforward){
digitalWrite(in1, HIGH); //end current in one side (set to +)
digitalWrite(in2, LOW); //receive the current (set to -)
}
else{
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
}
analogWrite(enA, speed); //send some speed to the motor
}
void loop() {
// put your main code here, to run repeatedly:
pot = analogRead(A0); // read the value of the potentialmeter
delay(200);
Serial.println(pot); //print the value, to have a check
if(pot < 470){ //separate the value of the potential meter, and have a gap of 40 to be sure to taje the value
speedmotor = map(pot, 470, 0, 0, 255); // the speedmotor variable take the value of pot that is transformed, the speed has to be from 0 to 255, map function transform the value, when the potential meter go farther the origin, it increae the peed of the motor
move(speedmotor, true); //alors marche avant
}
else if(pot > 550){ // other case, the potentialmeter is in the other side
speedmotor = map(pot, 550, 1023, 0, 255); //map the value, but in the other way
move(speedmotor,false); //marche arriere
}
else{ // if it is not on the values before it stops
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
}
}
To control the peristaltic pump for our pancake bot, we used this system so they are two Arduino boards to control the pancake bot. We decided to use the joystick because the time was short, and we wanted to have the device ready pretty quickly.
When I first tried the code I took a new pump but the ball bearings inside were broken. I first believed that the code I wrote were miswritten, but it finally was the pump that actually don’t work. It took me a little time to figure out that it was the pump and not the code.
Improving the control of the pump with Gcode¶
I wanted improve the control of the peristaltic pump with the Gcode, to have the control of the pump directly in the code and not manually with the joystick.
First I looked for a way to understand gcode, so I followed a tutorial on how to control a CNC with Arduino and grbl. Here is the tutorial on how to flash arduino with grbl. To use Arduino IDE with grbl I need to install it so according to the tutorial I installed grbl.
I started by building the electronic system with 2 motors, on for X and one for Y. With the equipment we add and thanks to some pictures on internet I plugged the shiel CNC for Arduino on the Arduino board and try to understand how to plug the motor and the power source on it.
I found on a blog how to use the shield CNC for Aduino. The shield I have is a V3, and thanks to the picture I succeed to plug eveything to the Arduino, and the writing on the shield. To plug the motor on the right side I looked for a datasheet of the motor to know which wire goes to which wire. I found this datasheet but the datas are wrong. My instructor helped to find the good side and replugged everything right. To do that we use Dupont wire. We turn the motor manually while plug to hole together with the wire, and when we feel a strength in the motor it means that the color wires go together.
So the red goes with the green, and the blue with the black. Here is the wiring I made.
I also installed Universal Gcode Sender to control the motor. And according to the tutorial I mainly followed on how to use grbl with Arduino.
I searched to learn more on G.. command in gcode. The Marlin website were really useful to understand more the gcode command. On the terminal of UGS (Universal Gcode Sender), I wrote this line to make the motor work
G21G91G1X5Y5F50
Which means :
- in millimeters
- with relative coordonate
- make a linear move
- in X, 5 mm
- in Y, 5 mm
- with a Feedrate at 50
And here is the video on how the motors are working with this line of code.
Now I understood a little bit more, I wanted to add my pump to the system. I found the Gcode command for the spindle here.
- M03 = CW Spindle
- M04 = CWW Spindle
- M05 = Spindle
I tried to look on internet to know how to plug the H-bridge to the CNC shield, for example on this blog, but after reading what is written on the shield and on the H-bridge I finally plugged together whe pin where the name seems the same and see what it is doing.
ENA with SpnEn, one In with SpnDir, and the In with the ground GND.
Here is the wiring between the H-bridge and the CNC shield for Arduino.
Here is the wiring with the motor of the pump and the H-bridge.
Here is the all wiring between the two motors, the shield for Arduino, the H-bridge, and the peristaltic pump.
Here is the focus on the wiring between the H-bridge for the pump and the shield for Arduino.
I might have plugged the wire in a wrong way because the command line doesn’t really work has they supposed to do but it still work for the device. M03 start the spindle and M04 stop the spindle. It is maybe because the current flow only in one way, that why the reverse wpindle stop the spindle actually.
Here is the video of the pump controlled by gcode.
All the files¶
Useful links¶
- Group page where all the workflow and all we have done is documented
- This website on how to use H-bridge with a L298N motor
- How to setup grbl control with Arduino
- Visual Studio Code
- Pancake recipe
- Website on how to control a potential meter with Arduino
- This website with H-bridge and Arduino
- The tutorial on how to flash arduino with grbl
- Grbl
- A blog how to use the shield CNC for Aduino
- Universal Gcode Sender
- The Marlin website
- Gcode command for the spindle here