A Conveyor Belt Control System with an Arduino PLC and a Rasberry PI Panel PC HMI

A Conveyor Belt Control System with an Arduino PLC and a Rasberry PI Panel PC HMI


Conveyor belts are very common in industry: we can find them in different industries like mining, food & beverage or chemicals.  They are used to deliver heavy materials from one place to another. In this project we will make a control system based on M-Duino PLC hardware that can be controlled through an SCADA / HMI software for food industry.


The application to be developed must ensure that a conveyor belt works properly:

  1. Must verify that the conveyor runs all the time.
  2. If a problem occurs, must alert to the operators of the plant.

To fulfill the requirements, the conveyor system has sensing devices like photoelectric and inductive sensors, lights and relay’s. Specifically, the hardware devices to be programmed and its function are as follows:

  1. Photoelectric sensor: Detect each manufactured product.
  2. Inductive motion sensor: Detect motion of motor.
  3. Relay’s output: Stop motor motion if an error occurs.
  4. Strobe lights: Alert if an alarm occurs.

The system is as shown below:



We are going to program the M-Duino as it follows in the next part of this tutorial.

  1. For the photoelectric sensor, we are going to use interrupts in the rising mode. Each time that we have a new interruption, a new manufactured product has been detected.
  2. To detect that the motor is running we will use interrupts in rising mode as well. Each time that we have a new interruption, we can count a new cycle loop detected.
  3. We are going to use three strobe lights, two of them to alarm if a failure occurs:
  • If the motor has stopped.
  • If a production failure occurs, that it means that we don’t detect products through the photoelectric barrier for more than 30 seconds).
  1. The last strobe light comes from another part of the plant, and indicates that we have product demand, so the conveyor belt should be working. We are going to use relays to stop motors if an alarm occurs.


// Industrial Shields by BOOT & WORK CORP. // Powered by Opiron Electronics -www.opiron.com- // Feb.2015 technical information for newsletter // This sketch demonstrates how to program some // digital input / output signals through an M-Duino // PLC. The sketch is inspired in a real project of a // food plant, where we have to control a conveyor belt. // Keywords: Conveyor Belt, industrial automation. ////////////////////////////// //// PLC: M-DUINO MODULE //// //// Number of inputs: 2 //// Number of outputs: 4 //// 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) — Motor Failure Strobe //// Q0.1 — PIN 37 — Digital Output (24Vdc) — Product Demand Strobe //// Q0.2 — PIN 38 — Digital Output (24Vdc) — Product Failure Strobe //// Q0.3 — PIN 39 — Digital Output (24Vdc) — Stop Motor //// I0.0 — PIN 22 — Digital Input (24Vdc) — Photoelectric Barrier sensor, when active, a new product crosses the photoelectric barrier //// I0.1 — PIN 23 — Digital Input (24Vdc) — Inductive sensor, when active, a new loop detected in the motor //Pins defintion #define Motor_Failure_Strobe 36 // Alert if a motor failure alarm occurs #define Product_Demand_Strobe 37 // Alert if a product order is required #define Production_Failure_Strobe 38 // Alert if a production failure occurs #define Stop_Motor 39 // If an alert is detected we will stop the conveyor belt #define Photo_sensor 22 // Photoelectric sensor to detect manufactured products #define Ind_sensor 23 // Inductive sensor to detect the motion in the motor //Thresholds and constant interval times #define MINSPEED_THRESHOLD 500 // We consider that the minimum speed when the motor runs is 500 rpm, if a less speed is detected, we must alert and stop the plant #define time_photo_limit 4500 // We consider an interval of 4,5 seconds as the limit between each product can cross the photoelectric barrier #define rpm_interval 60000 // 1 minute // Variables volatile unsigned int rpm; // Variable to count the speed of the motor, consider rpm as revolutions per minute boolean Alarm; // Variable that says if we are in an alarm state or not unsigned long time_photo; // Variable to count the time between each product cross the photoelectric barrier unsigned long prevTime_rpm; // Variable to count each 60s the rpm of the motor // Functions void speedcount(); void manufacturing(); void setup() // Configuration is here: { // Pin settings pinMode(Motor_Failure_Strobe, OUTPUT); pinMode(Product_Demand_Strobe, OUTPUT); pinMode(Production_Failure_Strobe,OUTPUT); pinMode(Stop_Motor,OUTPUT); pinMode(Photo_sensor, INPUT); pinMode(Ind_sensor, INPUT); // Thresholds settings rpm=MINSPEED_THRESHOLD; // Initial speed value initialized with a higher value of minimun motor speed to disable an initial alarm // Interrupts attachInterrupt(Ind_sensor, speedcount, RISING); // Pin 2 attachInterrupt(Photo_sensor, manufacturing,RISING); // Pin 3 // Variables Alarm=0; } // End setup void loop() // The code in loop() runs repeatedly: { if(millis() – prevTime_rpm > rpm_interval) // Each 60 seconds we reinitialize rpm’s to 0 { prevTime_rpm = millis(); rpm=0; } if (rpm<MINSPEED_THRESHOLD) // Alarms Check I: Motor doesn’t work at the proper speed { digitalWrite(Motor_Failure_Strobe,HIGH); digitalWrite(Stop_Motor,HIGH); Alarm=1; } if(time_photo>time_photo_limit) // Alarms Check II: The manufactured products doesn’t cross the photoelectric barrier { digitalWrite(Production_Failure_Strobe,HIGH); digitalWrite(Stop_Motor,HIGH); Alarm=1; } else if (Product_Demand_Strobe) // Nonmal Conditions { Alarm=0; digitalWrite(Motor_Failure_Strobe,LOW); // The Failure Strobes must be off digitalWrite(Production_Failure_Strobe,LOW); digitalWrite(Stop_Motor,LOW); // The Motor must be running } // End Normal Conditions } // End loop void speedcount() // This function is executed each time that we have a new interrupt { rpm++; // Speed up! } // End speedcount() void manufacturing() // This function is executed each time a new product crosses the photoelectric barrier { time_photo=0; // When a new product crosses the photoelectric cell, the counter must reset } // End manufactuing()

Comments are closed.