--- title: Documentation of the Open Source MFI author: Matthieu Lalin <matthieu.lalin@viacesi.fr>; tag: OSMFI --- # Open Source MFI ## 🎉 Welcome :::success This is a template for the documentation of the OSMFI ::: The document is structured in four main blocks 1. Hardware 2. Electronical 3. Software 4. Guide of utilisation # :heavy_check_mark: Hardware ## Bill of materials - ELECTRONIC EQUIPMENT: - [ ] 1x Power supply DC 220V-24V - [ ] 3x Stepper motor 17HS19-1684S-PG5 - [ ] 2x Driver DRV8825 (Pololu md20b) - [ ] 1x Load cell (DYMH-103) - [ ] 1x Force sensor amplifier (SEN-13879) - [ ] 2x Arduino nano cards - [ ] 2x LCD display - [ ] 1x Omron Solid State Relay (G3NA-210B-UTU-DC5-24) - [ ] 1x Thermocouple Amplifier AD8495 (1528-1407-ND) - [ ] 2x Push buttons - [ ] 2x Electrical resistor 220 Ohm - [ ] 2x Electrical resistor 4700 Ohm - [ ] Wires - MECHANICAL COMPONENTS: ![](https://hackmd.io/_uploads/Hkyb8qIZp.png) See the link: https://cad.onshape.com/documents/59b16c81bc51fa4513b7b3aa/w/b41da56b748dfed392686c43/e/54603c43afe217e1b0a85f45?renderMode=0&uiState=6527e1cbff8c4960ee829832 # :heavy_check_mark: Electronical ## Full wiring diagram ![](https://hackmd.io/_uploads/r1rwFYrb6.png) See the link: https://www.tinkercad.com/things/21Z0t2xGjvt-editing-components/editel?sharecode=Dp8P41lBpGLax38SC_PJbHlBYpowHJiJ5bP8Q98XGOU # :heavy_check_mark: Software ## Code for the first arduino ```arduino // Download the following libraries to run the LCD #include <Wire.h> #include "rgb_lcd.h" #include <AccelStepper.h> #define TC_PIN A0 // set the ADC pin used #define AREF 5.0 // set board voltage as 5.0 V #define ADC_RESOLUTION 10 // ADC bit resolution setting, 10 being the default value // Manipulation to convert an analogue value into a digital value to obtain a temperature. float reading, voltage; float get_voltage(int raw_adc) { return raw_adc * (AREF / (pow(2, ADC_RESOLUTION)-1)); } float get_temperature(float voltage) { return ((voltage - 1.25) / 0.005)-6; } AccelStepper stepper (AccelStepper::DRIVER, 3, 4); rgb_lcd lcd; // Definition of pins and variables const int relaisPin = 9; // Pin relay status management int sensHautPin = 7; // Pin status management motor drive button up int sensBasPin = 8; // Pin status management motor drive button down const int EtatPoidsPIN = 5; // Pin status Force applied at setpoint double Setpoint = 200; // Setpoint temperature in degrees Celsius double Input; // Temperature reading const int dirPin = 12; // Pin direction filament cutting motor const int stepPin = 11; // Pin steps filament cutting motor const int stepsPerRevolution = 200; // Number of steps motor revolution filament cutting unsigned long tempsPrecedent = 0; // Time variable unsigned long tempsPrecedent_decoupe = 0; // Time variable unsigned long intervalle = 500; // Time interval between each temperature reading (in milliseconds) unsigned long intervalle_decoupe = 15000; // Time interval between each step for filament cutting (in milliseconds) int colorR = 0; int colorG = 0; int colorB = 0; void setup() { // Declaration of motor command Input and Output pins pinMode(sensHautPin, INPUT); pinMode(sensBasPin, INPUT); // Declaration of the weight setpoint input pin pinMode(EtatPoidsPIN, INPUT); // Initialise the relay control pin pinMode(relaisPin, OUTPUT); digitalWrite(relaisPin, HIGH); // The relay is initially switched off // LCD definition lcd.begin(16, 2); } void moteurdecoupage() // Filament cutting loop { // Turns the motor to cut the filament for(int x = 0; x < stepsPerRevolution; x++) { digitalWrite(stepPin, HIGH); delayMicroseconds(1500); digitalWrite(stepPin, LOW); delayMicroseconds(1500); } } void moteursenspositif() // Motor start loop (positive direction) { stepper.setMaxSpeed(500); // Maximum speed (in steps per second) stepper.setSpeed(500); // Operating speed (in steps per second) stepper.runSpeed(); } void moteursensnegatif() // Motor start loop (negative direction) { stepper.setMaxSpeed(-500); // Maximum speed (in steps per second) stepper.setSpeed(-500); // Operating speed (in steps per second) stepper.runSpeed(); } void regulation() // Temperature control loop { //Recover values and convert them into a usable value reading = analogRead(TC_PIN); voltage = get_voltage(reading); Input = get_temperature(voltage); //Display on LCD screen lcd.setCursor(0, 0); lcd.print ("T mesure("); lcd.print ((char)223); lcd.print ("C):"); lcd.print (int(Input)); lcd.print (" "); lcd.setCursor(0, 1); lcd.print ("T cible("); lcd.print ((char)223); lcd.print ("C):"); lcd.print (int(Setpoint)); lcd.print (" "); // LCD colour management if((Input<(Setpoint-2)) || (Input>(Setpoint+3))) { colorG = 0; colorR = 255; } else { colorG = 255; colorR = 0; } lcd.setRGB(colorR, colorG, colorB); // Activation or deactivation of the relay depending on the temperature reading if (Input > Setpoint) { digitalWrite(relaisPin, 0); // Switch on the relay } else { digitalWrite(relaisPin, 1); // Switch off the relay } } void loop() // Main loop { // Timing and loop management unsigned long tempsActuel = millis(); if (tempsActuel - tempsPrecedent >= intervalle) { tempsPrecedent = tempsActuel; regulation(); } if ((digitalRead(sensHautPin) == HIGH) and (digitalRead(sensBasPin) == LOW) and (digitalRead(EtatPoidsPIN) == HIGH)) { moteursenspositif(); } if ((digitalRead(sensBasPin) == HIGH) and (digitalRead(sensHautPin) == LOW) and (digitalRead(EtatPoidsPIN) == HIGH)) { moteursensnegatif(); } unsigned long tempsActuel_decoupe = millis(); if (tempsActuel - tempsPrecedent_decoupe >= intervalle_decoupe) { tempsPrecedent_decoupe = tempsActuel_decoupe; moteurdecoupage(); } } ```` ## Code for the second arduino ```arduino // Download the following libraries to run the program #include "HX711.h" #include <Wire.h> #include "rgb_lcd.h" // Definition of load cell connection pins const int LOADCELL_DOUT_PIN = 2; const int LOADCELL_SCK_PIN = 3; const int POIDS_MESURE = 5; double POIDS; double POIDS_CONSIGNE = 500; HX711 scale; rgb_lcd lcd; void setup() { // Definition of the LCD display const int colorR = 95; const int colorG = 0; const int colorB = 183; lcd.begin(16, 2); lcd.setRGB(colorR, colorG, colorB); lcd.print("Calibration..."); // Initialise the load pin pinMode(POIDS_MESURE, OUTPUT); // Load cell calibration scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN); scale.read(); scale.read_average(20); scale.get_value(5); scale.get_units(5); scale.set_scale(200.f); // 200 for the value used to calibrate the sensor scale.tare(); scale.read(); scale.read_average(20); scale.get_value(5); scale.get_units(5); } void loop() { // Displays the weight applied on the LCD POIDS = (scale.get_units()); lcd.setCursor(0, 0); lcd.print("Poids exerce: "); lcd.setCursor(0, 1); lcd.print(POIDS,0); lcd.print(" g"); lcd.print(" "); // Conditioned extraction of the weight setpoint to the main arduino if(POIDS < POIDS_CONSIGNE) { digitalWrite(POIDS_MESURE, HIGH); } else { digitalWrite(POIDS_MESURE, LOW); } // Puts the ADC on standby scale.power_down(); delay(100); scale.power_up(); } ```` # :heavy_check_mark: Guide of utilisation ![](https://hackmd.io/_uploads/SJjTs68-a.jpg) ![](https://hackmd.io/_uploads/SyDexCLbT.jpg) For the moment, the interface is not directly interactive. If you want to modify variables for the experiment, you have to work directly on the code: ## How does it work? - PREPARATIONS 1. To begin with, you need to supply power to the power supply units and the ARDUINO card. 2. The load cell will take a few seconds to calibrate. ![](https://hackmd.io/_uploads/HyWs1R8Wp.jpg) 3. At the same time, the temperature of the casting cylinder will rise to the set temperature. 4. Once the load cell is calibrated, one of the LCD displays the weight applied to the piston. ![](https://hackmd.io/_uploads/rkSN10UW6.jpg) ![](https://hackmd.io/_uploads/rykHJCUZp.jpg) 5. Once the set temperature has been reached, the colour of the other LCD changes (the temperature is then regulated to maintain the set temperature). ![](https://hackmd.io/_uploads/r1OeAp8-a.jpg) ![](https://hackmd.io/_uploads/rkQvA6UWT.jpg) ![](https://hackmd.io/_uploads/HJqPCa8ZT.jpg) 6. The tests are ready to start - THE TEST 1. Insert the plastic shavings into the casting cylinder 2. Position the piston above the cylinder opening and start its descent using the push buttons controlling the motors. 3. Wait for each cycle (number of cycles to be chosen) of cutting the filament and take the quantity cut. 4. Weigh the quantity of each sample and average the mass 5. Calculate the MFI value 6. Repeat the experiment with different applied forces NB: The higher the MFI value of a thermoplastic, the lower its viscosity. ## Which variables change what? - If you want to change the force to be applied to the piston, you have to change the value of the following line : ```arduino double POIDS_CONSIGNE = 500; ``` (the variable "POIDS_CONSIGNE" is expressed in "g") The setpoint weight defines the state of the stepper motors: if the setpoint is exceeded, the motors stop, if it is not exceeded, the motors run. - If you want to change the time between two filament cuts, you have to change the value of the following line : ```arduino unsigned long intervalle_decoupe = 15000; ``` (the variable "intervalle_decoupe" is expressed in "ms") - If you want to change the setpoint temperature, you have to change the value of the following line : ```arduino double Setpoint = 200; ``` (the variable "Setpoint" is expressed in "°C") ![](https://hackmd.io/_uploads/S1yH-3UWa.jpg) Detail to consider: The setpoint temperature is 20°C lower than the temperature of the extruded plastic at the nozzle outlet. ## Next step ? - [ ] Integrate an interactive interface allowing the above variables to be modified without having to intervene directly on the code. - [ ] Replace the pressure buttons for raising and lowering the piston pressure plate with a 3-position button - [ ] design a tipping funnel to facilitate the insertion of plastic chips into the casting cylinder