Feeding a packaging machine with a frequency driver with Arduino

Feeding a packaging machine with a frequency driver with Arduino

filling system v1
Feeding a packaging machine with a frequency driver

In the dairy industry, packaging machines are used to package food in containers such as yogurt, milk, etc. They are usually integrated into more complex systems, and they are fed by a tank that contains the product (usually milk). In this project we will design a system composed of a tank with milk, a packaging machine, a valve to open and close the way to the machine, and a PID formed by a flow meter and a pump controlled by a frequency driver. In addition, the system has a buzzer to alert to operators of the plant in case of alarms. The system is as shown below:    

Logic followed on the application

The packaging machine has a digital output that will be connected to the PLC. Whenever the packaging machine needs more product to be packaged, the digital output will be activated.

The system is based on two main states:

  1. Request product from packaging machine. The PLC must:
  • Open the feeding valve.
  • Perform a flow regulation at 800 l / h with a PID loop.
  • Alert through the buzzers to the operators of the plant.
  1. No request product packaging machine. The PLC must:
  • Close the feeding valve.
  • Stop the feeding pump (flow rate to 0).

In addition, regardless of the status of the packaging machine, the PLC shall monitor the level of the milk tank and, if the tank is empty, communicate an alarm. However, the most interesting part of this project since the programming point of view is the PID to develop in order to control the flow that feeds the packing machine. Let’s see a picture below:

PIDThe used PLC is an M-Duino, which monitors the flow through an analog input of 0/10Vdc, and, based on the setpoint and the measured value, calculates an output using a PID algorithm that is sent to the VFD that controls the pump.
Code Here we see the code developed in Arduino:

// Industrial Shields by BOOT & WORK CORP.
// Powered by Opiron Electronics -www.opiron.com-
// Jan.2015 technical information for newsletter
// This sketch demonstrates how to use a PID with 
// an M-Duino PLC. The sketch is inspired in a
// real project of a food plant, where we have to 
// feed a packaging machine with milk.
// PID explanation: The purpose of the pid is to 
// to control a loop with a flowmeter and a pump 
// controlled by a frequency driver. The VFD has
// an analog input where we can send the setpoint
// Keywords: PID, industrial automation, frequency driver
//////////////////////////////
//// PLC: M-DUINO MODULE ////
//// Number of Digital inputs: 3 
//// Number of Digital outputs: 2
//// Number of Analog inputs: 1
//// Number of Analog outputs: 1
//// you need to configurate the correctly switch position for running like digital / analog or PWM mode.
//////////////////////////////
//// M-Duino Pins Used:
//// Q0.0 --- PIN 36 --- Digital Output (24Vdc) --- Open order to Feed Valve 
//// Q0.4 --- PIN 40 --- Digital Output (24Vdc) --- Buzzer ON / OFF
//// I0.0 --- PIN 22 --- Digital Input (24Vdc) --- Feed Valve Opened Ok 
//// I0.3 --- PIN 25 --- Digital Input (24Vdc) --- Low Switch Level Sensor
//// I0.4 --- PIN 26 --- Digital Input (24Vdc) --- Product Demand from Packing Machine
//// I0.9 --- PIN A2 --- Analog Input (0/10Vdc) --- Feed Flowmeter signal
//// I0.10 --- PIN A3 --- Analog Output (0/10Vdc) --- Setpoint to VFD
//libraries
#include
//Pins defintion
#define Valve_Output 36 // Open order to Feed Valve
#define Buzzer 40 // Buzzer ON/OFF
#define Valve_Input 22 // Feed Valve Opened Ok
#define LSL 25 // Low Switch Level Sensor
#define Product_Demand 26 // Product Demand from Packing Machine
#define FlowMeter A2 // Feed Flowmeter
#define FrequencyDriver A3 // Setpoint to Frequency Driver
// Other constants
#define intervalValve 10000
// Variables
unsigned long Valvetime; // We use time to check if Valve opens when we have sent an Open Order
unsigned long Pumptime; // We use time to check if Pump starts when we have sent a Run Order 
double Setpoint, Input, Output; // PID Values
unsigned long PIDwindowStartTime; // Use it to compare PID Window Time
unsigned long ValvewindowStartTime; // Use it to compare Valve Opening time
boolean valvefail; // 0 = Valve OK, 1=Valve fails
// Objects
PID FlowPID(&Input, &Output, &Setpoint,kp,ki,kd, DIRECT);
void setup() 
{ //Configuration is here:
//Pin settings
 pinMode(Valve_Output, OUTPUT);
 pinMode(Buzzer,OUTPUT);
 pinMode(Valve_Input ,INPUT);
 pinMode(LSL, INPUT);
 pinMode(Product_Demand, INPUT);

 //turn the PID on
 FlowPID.SetMode(AUTOMATIC);
 Setpoint=800;
 // Ini variables

 valvefail=0;

} // End setup
void loop() { // The code in loop() runs repeatedly:
if (LSL) // Alarms check I: LSL
{
 digitalWrite(Valve_Output,LOW);
 digitalWrite(Buzzer, HIGH);
}
else if (valvefail) // Alarms check II: Valve can't be opened
{
 digitalWrite(Valve_Output,LOW);
 digitalWrite(Buzzer, HIGH);
}
else if (Product_Demand) // If no alarm exists, we can send product 
 {
 digitalWrite(Buzzer,LOW);
 Input = analogRead(FlowMeter);
 FlowPID.Compute();
 analogWrite(FrequencyDriver, Output);
 digitalWrite(Valve_Output,HIGH);
 if (Valve_Input==0) //We wait for the Opened confirmation from the valve
 {
 if(millis() - ValvewindowStartTime>intervalValve) //We count 10s until the Valve is Opened. If the Valve doesn't return the opened confirmation, we send an alarm 
 { 
 ValvewindowStartTime += intervalValve;
 valvefail=1;
 }
 } // end If Valve_Input
 else if (Valve_Input==1)
 {
 valvefail=0; 
 } // end Valve_Input==1
 } // end If Product Demand
} // end loop

POWERED BY OPIRON ELECTRONICS
Comments are closed.