Introduction: Dye Mixer Plc Program/simulation

Programmable Logic Controllers,are for industrial use mostly.They are robost and expensive because the can be installed in areas with harsh weather conditions and are expected to last for longer periods of time.

Here we look at the use of a PLC in an industrial dye mixer.

Problem description

The problem is to implement an automation of a dye mixing machine.

Dye mixer operation starts by the press of a Start push-button and stops at anytime by Stop push-button press.During the operation green indicator Lamp should light permanently.

The dye from the three basic dye (Green, Red, Blue) tanks goes to the mixing tank through magnetic valves. PLC controls opening / closing of all magnetic valves. The machine has to mix a given color. The red dye is filling to mix tank for 2 s, the green one for 3 s, and the blue one for 4 s. Filling of the dye starts simultaneously with 2 s delay after the press of start push button.

If all necessary dyes are in the mixing tank, then after 3 s the mixing motor starts and mixes dye for 8 s. The motor is a 3-phase asynchronous motor that needs star-delta start up. Start-delta switching time is 3 s.

After mixing the drain magnetic valve is necessary to open immediately. If the tank becomes empty, the magnetic valve i needed to close and the mixing process has finished. The level-switch indicates if the tank is empty.

The dye mixing can be restarted by Start Push button repress.

The first to solving any electrical problem is to know the Number of I/O devices,function block and as well as their address.The program is attached and you can download and walk through and study it,you can run the simulation as well while looking at the description. This program was written using an easysoft coDesys or easy800

Both the easysoft and easy800 programs are attached here.I hope this can help people familiar with this programing environment.

For people who are not, the problem description is really catchy and can also be solved using arduino or raspberry or any other kind of microcontroller. Enjoy.

Comments

author
JulieG42 (author)2016-04-23

Hello there, I apologize for the trouble and the timing, but I am curious to know what means did you use to program this project? Iseasysoft coDesys a program that works in hand with the programmer easy800? or is it just a simulator. I was working with this code to be able to pull this project together for my final PLC but it is not working so I wondered if you program it with any type of arduino or raspberry. and lastly could you be so kind to send me any material you might have about this project please (julie.gomez001@mymdc.net)?

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address

int keys[] ={ //Stores total keypad input

1, 2, 3, 10, 4, 5, 6, 11, 7, 8, 9, 12, -3,0, -2, 14}; //"123A456B789C*0#D";

int key; //Stores most recent key pressed

boolean key_lockout=false;

int order[4];

int value=0;

//Initialize

const int vodka=3; //Based on 6v clear pump, 13.3 sec/oz (20 sec/1.5 oz)

const int gin=4; //Based on 12v black pumps, 25.3 sec/oz (38 sec/1.5 oz)

const int whiskey=5;

const int tripleSec=6;

const int tequila=7;

const int rum=8;

const int water=9;

const int simpleSyrup=10;

void setup(){

Serial.begin(9600);

lcd.begin(16,2);

pinMode(vodka, OUTPUT);

pinMode(gin, OUTPUT);

pinMode(whiskey, OUTPUT);

pinMode(tripleSec, OUTPUT);

pinMode(tequila, OUTPUT);

pinMode(rum, OUTPUT);

pinMode(simpleSyrup, OUTPUT);

pinMode(water, OUTPUT);

digitalWrite(vodka, HIGH);

digitalWrite(gin, HIGH);

digitalWrite(whiskey, HIGH);

digitalWrite(tripleSec, HIGH);

digitalWrite(tequila, HIGH);

digitalWrite(rum, HIGH);

digitalWrite(simpleSyrup, HIGH);

digitalWrite(water, HIGH);

// ------- 3 blinks of backlight -------------

for(int i = 0; i< 3; i++)

{

lcd.backlight();

delay(250);

lcd.noBacklight();

delay(250);

}

lcd.backlight(); // finish with backlight on

}

void loop(){

Beginning:

{

//-------- Write characters on the display ------------------

// NOTE: Cursor Position: (CHAR, LINE) start at 0

lcd.clear();

lcd.setCursor(0,0); //Start at character 4 on line 0

lcd.print("Enter your order");

delay(500);

lcd.setCursor(0,1);

lcd.print(" *-Clr, #-Enter");

delay(1000);

//-----------------------------------------------------------

value=0;

for (int x=0; x<4; x++){

key=getKeypad(); //Get key pressed

if(key==-1){ //If valid key not pressed restart iteration

x=x-1;

}

else{

if(key!=14 && key!=12){ //If not CLEAR or ENTER

value = (10*(value)) + (keys[key]);

delay(10);

lcd.clear();

lcd.setCursor(0,0); //Start at character 4 on line 0

lcd.print("Item #");

delay(10);

lcd.setCursor(6,0);

lcd.print(value);

delay(500);

}

else if(key==14){ //If ENTER, exit

x=4;

}

else if (key==12){ //If CLEAR, restart

x=-1;

}

}

}

lcd.clear();

lcd.setCursor(0,0);

lcd.print(" Press # to");

delay(10);

lcd.setCursor(0,1);

lcd.print("Confirm drink");

delay(10);

lcd.setCursor(14,1);

lcd.print(value);

do{

key=getKeypad();

}

while(key!=12 && key!=14);

if(key==12){ //Restart ordering process

goto Beginning; //Return to the beginning of loop()

}

else if(key==14){

lcd.clear();

lcd.setCursor(0,0); //Start at character 4 on line 0

lcd.print(" Confirmed");

delay(1000);

switch (value) {

case 1:

longIslandIcedTea();

break;

case 2:

jackAndCoke();

break;

case 3:

rumAndCoke();

break;

case 4:

capeCod();

break;

case 5:

cosmopolitan();

break;

case 6:

kamikazee();

break;

case 7:

screwdriver;

break;

case 8:

highball();

break;

case 9:

gt();

break;

case 10:

vodkaTonic();

break;

case 11:

margarita();

break;

case 12:

seaBreeze();

break;

}

delay(5); // delay in between reads for stability

}

}

}

//--------Functions-----------

int getKeypad(){ //Returns which key is pressed

int ret=-1;

boolean reset_lockout=false;

if(analogRead(A0)<120)

key_lockout=false;

else if(!key_lockout){

delay(100);

ret=15.5-(log((analogRead(A0)-183.9)/58.24)/0.1623);//+0.5;

key_lockout=true;

}

return ret;

}

// Menu

//Long Island Iced Tea

int longIslandIcedTea(){

digitalWrite(vodka, LOW);

delay(80);

digitalWrite(gin, LOW);

delay(80);

digitalWrite(tripleSec, LOW);

delay(80);

//Serial.println("In the matrix");

digitalWrite(tequila, LOW);

delay(80);

digitalWrite(rum, LOW);

delay(80);

digitalWrite(water, LOW);

delay(6600);

digitalWrite(vodka, HIGH);

delay(6400);

digitalWrite(water, HIGH);

digitalWrite(gin, HIGH);

digitalWrite(tripleSec, HIGH);

digitalWrite(tequila, HIGH);

digitalWrite(rum, HIGH);

for (int x=0; x<3; x++){

lcd.clear();

lcd.setCursor(0,0); //Start at character 4 on line 0

lcd.print("Add 1oz Sour Mix");

delay(10);

lcd.setCursor(0,1);

lcd.print(" then MIX");

delay(5000);

lcd.clear();

lcd.print("Add ice and ");

delay(10);

lcd.setCursor(0,1);

lcd.print("top with coke");

delay(3000);

}

}

//Jack and Coke

int jackAndCoke(){

//2 oz of whiskey

Serial.println("Jack and Coke");

digitalWrite(whiskey, LOW);

delay(10);

digitalWrite(water, LOW);

delay(4500);

digitalWrite(water, HIGH);

delay(33500);

digitalWrite(whiskey, HIGH);

lcd.clear();

lcd.setCursor(0,0); //Start at character 4 on line 0

lcd.print("Add ice and 2-5");

delay(10);

lcd.setCursor(0,1);

lcd.print("ounces of Coke");

delay(8000);

}

//Rum and Coke

int rumAndCoke(){

//2 oz of rum

Serial.println("Rum and Coke");

digitalWrite(rum, LOW);

delay(10);

digitalWrite(water, LOW);

delay(4500);

digitalWrite(water, HIGH);

delay(33500);

digitalWrite(rum, HIGH);

lcd.clear();

lcd.setCursor(0,0); //Start at character 4 on line 0

lcd.print("Add ice and 2-5");

delay(10);

lcd.setCursor(0,1);

lcd.print("ounces of Coke");

delay(8000);

}

//Cape Cod

int capeCod(){

//2 oz of vodka, 3 oz cranberry juice, lime wedge

Serial.println("Cape Cod");

digitalWrite(vodka, LOW);

delay(10);

digitalWrite(water, LOW);

delay(4500);

digitalWrite(water, HIGH);

delay(15500);

digitalWrite(vodka, HIGH);

for (int x=0; x<3; x++){

lcd.clear();

lcd.setCursor(0,0); //Start at character 4 on line 0

lcd.print("Add ice & 2-3 oz");

delay(10);

lcd.setCursor(0,1);

lcd.print("Cranberry Juice-");

delay(3000);

lcd.clear();

lcd.setCursor(0,0); //Start at character 4 on line 0

lcd.print("and a lime wedge");

delay(3000);

}

}

//Bay Breeze

int bayBreeze(){

//2 oz of vodka, 5 oz cranberry juice, 2 oz pineapple juice (or equal parts ~2.5 oz each), lime wedge

Serial.println("Bay Breeze");

digitalWrite(vodka, LOW);

delay(10);

digitalWrite(water, LOW);

delay(4500);

digitalWrite(water, HIGH);

delay(15500);

digitalWrite(vodka, HIGH);

for (int x=0; x<3; x++){

lcd.clear();

lcd.setCursor(0,0); //Start at character 4 on line 0

lcd.print("Add ice & 4-5 oz");

delay(10);

lcd.setCursor(0,1);

lcd.print("Cranberry Juice");

delay(4000);

lcd.clear();

lcd.setCursor(0,0); //Start at character 4 on line 0

lcd.print("and 2oz of");

lcd.setCursor(0,1);

lcd.print("Pineapple Juice");

delay(3000);

}

}

//Cosmopolitan

int cosmopolitan(){

//1 1/2 ounces vodka or citrus vodka, 1 ounce Cointreau orange liqueur, 1/2 ounce fresh lime juice, 1/4 ounce cranberry juice

Serial.println("Cosmopolitan");

digitalWrite(tripleSec, LOW);

delay(10);

digitalWrite(vodka, LOW);

delay(10);

digitalWrite(water, LOW);

delay(13000);

digitalWrite(water, HIGH);

delay(7000);

digitalWrite(vodka, HIGH);

delay(5323);

digitalWrite(tripleSec, HIGH);

for (int x=0; x<3; x++){

lcd.clear();

lcd.setCursor(0,0); //Start at character 4 on line 0

lcd.print("Add 1/2 oz lime");

delay(10);

lcd.setCursor(0,1);

lcd.print(" Juice and MIX");

delay(4000);

lcd.clear();

lcd.setCursor(0,0); //Start at character 4 on line 0

lcd.print(" Top with");

lcd.setCursor(0,1);

lcd.print("Cranberry Juice");

delay(3000);

}

}

//Kamikazee

int kamikazee(){

//1 1/2 -1 ounces vodka, 1 ounce lime juice, 1 ounce triple sec, Lime wedge for garnish

//shake

Serial.println("Kamikazee");

digitalWrite(tripleSec, LOW);

delay(10);

digitalWrite(vodka, LOW);

delay(10);

digitalWrite(water, LOW);

delay(13000);

digitalWrite(water, HIGH);

delay(7000);

digitalWrite(vodka, HIGH);

delay(5323);

digitalWrite(tripleSec, HIGH);

for (int x=0; x<3; x++){

lcd.clear();

lcd.setCursor(0,0); //Start at character 4 on line 0

lcd.print("Add 1 oz Lime");

delay(10);

lcd.setCursor(0,1);

lcd.print(" Juice and MIX");

delay(4000);

lcd.clear();

lcd.setCursor(0,0); //Start at character 4 on line 0

lcd.print(" Add Ice");

lcd.setCursor(0,1);

lcd.print("and lime wedge");

delay(3000);

}

}

//Screwdriver

int screwdriver(){

//1 1/2 -1 ounces vodka, 5 oz orange juice

Serial.println("Screwdriver");

digitalWrite(vodka, LOW);

delay(20000);

digitalWrite(vodka, HIGH);

for (int x=0; x<2; x++){

lcd.clear();

lcd.setCursor(0,0); //Start at character 4 on line 0

lcd.print("Add Ice and ~5");

delay(10);

lcd.setCursor(0,1);

lcd.print("oz Orange Juice");

delay(3000);

}

}

//Highball

int highball(){

//1.5 ounces whiskey, ginger ale

Serial.println("Highball");

digitalWrite(whiskey, LOW);

delay(38000);

digitalWrite(whiskey, HIGH);

lcd.clear();

lcd.setCursor(0,0); //Start at character 4 on line 0

lcd.print(" Add Ice and");

delay(10);

lcd.setCursor(0,1);

lcd.print(" Ginger Ale");

delay(8000);

}

//Gin and Tonic

int gt(){

//1.5 ounces gin, 2.25 tonic or 2:3, 1/4 oz lime juice

Serial.println("Gin and Tonic");

digitalWrite(gin, LOW);

delay(38000);

digitalWrite(gin, HIGH);

for (int x=0; x<3; x++){

lcd.clear();

lcd.setCursor(0,0); //Start at character 4 on line 0

lcd.print("Add Ice, 2-5 oz");

delay(10);

lcd.setCursor(0,1);

lcd.print("of Tonic and...");

delay(3000);

lcd.clear();

lcd.setCursor(0,0); //Start at character 4 on line 0

lcd.print(" 1/4 oz");

lcd.setCursor(0,1);

lcd.print(" Lime Juice");

delay(3000);

}

}

//Vodka Tonic

int vodkaTonic(){

//1.5 ounces vodka, 3-4.5 tonic, 1/4 oz lime juice

Serial.println("Vodka Tonic");

digitalWrite(vodka, LOW);

delay(20000);

digitalWrite(vodka, HIGH);

for (int x=0; x<3; x++){

lcd.clear();

lcd.setCursor(0,0); //Start at character 4 on line 0

lcd.print("Add Ice, 2-5 oz");

delay(10);

lcd.setCursor(0,1);

lcd.print("of Tonic and...");

delay(3000);

lcd.clear();

lcd.setCursor(0,0); //Start at character 4 on line 0

lcd.print(" 1/4 oz");

lcd.setCursor(0,1);

lcd.print(" Lime Juice");

delay(3000);

}

}

//Margarita

int margarita(){

digitalWrite(tripleSec, LOW);

delay(10);

digitalWrite(tequila, LOW);

delay(10);

digitalWrite(water, LOW);

delay(13000);

digitalWrite(water, HIGH);

delay(12700);

digitalWrite(tripleSec, HIGH);

delay(12870);

digitalWrite(tequila, HIGH);

for (int x=0; x<3; x++){

lcd.clear();

lcd.setCursor(0,0); //Start at character 4 on line 0

lcd.print("Add 1/2 oz of");

delay(10);

lcd.setCursor(0,1);

lcd.print("Lime Juice &...");

delay(3000);

lcd.clear();

lcd.setCursor(0,0); //Start at character 4 on line 0

lcd.print(" MIX");

lcd.setCursor(0,1);

lcd.print(" then add ice ");

delay(4000);

}

}

//Sea Breeze

int seaBreeze(){

//1.35 Vodka, 4 Cranberry juice, 1 Grapefruit juice

Serial.println("Sea Breeze");

digitalWrite(vodka, LOW);

delay(18000);

digitalWrite(vodka, HIGH);

}

author
ironhide707 (author)2016-04-17

Hi

I need to do this PLC mixer with arduino for a presentation, any help please

author
rargüello motta (author)2015-08-20

Hey thanks for the upload! but it seems that the software don't recognize some of the files. Might be my software... but anyways thanks for the upload.

problem.jpg
author
rmikel made it! (author)rargüello motta2015-08-21

Surprising! it should work with Xsoft. Please can you check your PLC configuration at the target settings.? from the Library manger also check the POU's and be sure all the necessary function blocks are included for the "standard.lib". for the "FUNCTION SysCallbackRegister : BOOL register". if it is not there add it by right clicking and choosing add Library and then search the name after adding a library remember to rebuild all. and see if you have the same problems. please let me know if this solves your problem not. :)

configsettings..pngstanddard lib.pngsyscallback.png

About This Instructable

1,219views

8favorites

License:

Bio: bachelors degree in Electrical Engineering, love developing hardware systems on both microcontrollers and PLC.
More by rmikel:Ardunio Smoke And Gas Sensor(MQ-2)Arduino servo control using Ultrasonic sensorArduino I2C
Add instructable to: