Skip to main content

Joystick-Controlled Industrial Automation System



 Joystick-Controlled Industrial Automation System


This project can be used to control up to four industrial electrical appliances with the help of a joystick and an Arduino Nano board. The block diagram of the joystick-controlled industrial automation system is shown in Fig. 1.





Block Diagram 

Fig. 1: Block diagram of the joystick-controlled industrial automation system


                   The circuit diagram of the joystick-controlled industrial automation system is shown in Fig. 2. It is built around Arduino Nano (Board1), 5V regulator 7805 (IC1), four npn transistors (T1 through T4), joystick module (JM1), transformer (X1), four 12V single-changeover relays (RL1 through RL4) and a few other components.

Fig. 2: Circuit diagram of the joystick-controlled industrial automation system


Joystick module 

Joysticks are available in different shapes and sizes. A typical joystick module is shown in Fig. 3. This joystick module provides analogue voltage outputs. Output voltage changes according to direction of the shaft. You can get direction of shaft movement by interpreting voltage changes using a microcontroller (MCU).


Fig. 3: Joystick module

This joystick module has two axes: x and y. Each axis is controlled by shaft of the potentiometer mounted on of the joystick module. potentiometer outputs VRx and VRy at connector CON1 are variable points. VRx and VRy act as the voltage divider.

When joystick shaft is in normal position, it is in standby mode. When it is moved along horizontal axis (right and left), voltage at VRx pin changes. Similarly, when it is moved along vertical axis (up and down), voltage at VRy pin changes. So, we have four different output signals for four directions of the joystick, which are connected to two analogue-to-digital converter (ADC) input pins A0 and A1 of Arduino Nano.

When the shaft is moved, voltage on each pin goes high or low depending on direction. The joystick module also comes with one push-button switch for interruption purpose (this function is not used here). The joystick module is interfaced with Arduino Nano, which comes with an inbuilt ADC, as shown in Fig. 2.

Arduino Nano drives four relays (RL1 through RL4) through its pins D2, D3, D4 and D5.

Power supply

Regulated power supply is designed with a full-wave rectifier circuit. It consists of D1 and D2 (1N4007) rectifier diodes, capacitors C1 and C2, IC1 7805 and 230V AC primary to 12V-0-12V, 750mA step down transformer (X1). In this project, mainly two voltages are required: 12V and 5V. 12V DC is used for relays, and 5V for Arduino Nano MCU.


Arduino Nano



It is a small board compatible with ATMEGA328 MCU. It has the following features:

  • Operating voltage (logic level): 5V
  • Input voltage (recommended): 7V-12V
  • Input voltage (limits): 6V-20V
  • Fourteen digital I/O pins (of which six provide PWM output)
  • Eight analogue input pins
  • DC current per I/O pin: 40mA
  • Flash memory: 32kB (ATmega328), of which 2kB is used by bootloader
  • SRAM: 2kB (ATmega328)
  • EEPROM: 1kB
  • Clock speed: 16MHz

  • Operation

When the joystick module is in ideal state, digital value for both VRx and VRy is 512. ADC of Arduino is ten-bit, and digital value varies from 0 to 1023 levels according to analogue voltage received from the joystick. Ideally, the joystick is in midpoint or standby mode, so value shows is 512.

Case 1

When you move the shaft in x-left direction, digital value is less than 50. In this condition, pin D2 of Board1 is made high from the program, BC547 transistor T1 conducts, relay RL1 is energised and load connected across RL1 turns on. Diode D3 is used as freewheeling diode to eliminate back EMF.

Case 2

When you move the shaft in x-right direction, digital value is greater than 900. In this condition, pin D3 of Board1 is made high, BC547 transistor T2 conducts, relay RL2 is energised and electrical load/device connected across RL2 turns on.

Case 3

When you move the shaft in y-down direction, digital value is less than 50. Here, pin D4 is made high, BC547 transistor T3 conducts, relay RL3 is energised and load connected across RL3 turns on.

Case 4

When you move the shaft in y-up direction, digital value is greater than 900. Here, pin D5 of Board1 is made high, BC547 transistor T4 conducts, relay RL4 is energised and load connected across RL4 turns on.

Software program 

Main operation is done by the software program loaded into the internal memory of Arduino Nano. The program is written in Arduino programming language or sketch. Arduino IDE 1.6.8 is used to compile and upload the program.



ATmega328P on Arduino Nano board comes with a pre-programmed bootloader that allows you to upload a new code to it without using an external hardware programmer.

Connect Arduino Nano board to the PC and select the correct COM port in Arduino IDE. Compile the program/sketch (joystick_control.ino) and select the correct board from Tools->Board menu in Arduino IDE. Upload the sketch to load the program to the internal memory of the MCU. The sketch is at the heart of the system and carries out all major functions. In this project, external header files are not required for programming. It is a simple way to detect joystick values, and compare VRx and VRy values using if-else ladder functions to control four appliances.

Construction and testing

An actual-size PCB layout of the joystick-controlled industrial automation system is shown in Fig. 4 and its components layout in Fig. 5. Connect the power supply from the transformer to the PCB at X1. Connect joystick output wires to the PCB at JM1. After loading the program into Arduino Nano, as described earlier, mount it on the PCB on the space provided for it. Switch on the power supply. Now you can move the shaft left, right, up and down to control the electrical appliances. The prototype is shown in Fig. 6.

Fig. 4: PCB layout of the joystick-controlled industrial automation system

Fig. 5: Components layout for the PCB



Fig. 6: prototype


Code 

//Include the necessary libraries
#include <Joystick.h>

//Define the joystick pins
#define x_axis A0
#define y_axis A1
#define button 2

//Define the relay pins
#define relay1 3
#define relay2 4
#define relay3 5
#define relay4 6

//Create an instance of the Joystick object
Joystick_ Joystick;

void setup() {
  //Initialize the serial communication and joystick object
  Serial.begin(9600);
  Joystick.begin();

  //Configure the joystick pins as input
  pinMode(x_axis, INPUT);
  pinMode(y_axis, INPUT);
  pinMode(button, INPUT_PULLUP);

  //Configure the relay pins as output
  pinMode(relay1, OUTPUT);
  pinMode(relay2, OUTPUT);
  pinMode(relay3, OUTPUT);
  pinMode(relay4, OUTPUT);

  //Set the relay pins to their default state (off)
  digitalWrite(relay1, LOW);
  digitalWrite(relay2, LOW);
  digitalWrite(relay3, LOW);
  digitalWrite(relay4, LOW);
}

void loop() {
  //Read the joystick values and button state
  int x_value = analogRead(x_axis);
  int y_value = analogRead(y_axis);
  int button_state = digitalRead(button);

  //Map the joystick values to a range between -127 and 127
  int x_mapped = map(x_value, 0, 1023, -127, 127);
  int y_mapped = map(y_value, 0, 1023, -127, 127);

  //Send the joystick values to the computer via serial communication
  Serial.print("X: ");
  Serial.print(x_mapped);
  Serial.print(", Y: ");
  Serial.print(y_mapped);

  //Check if the button is pressed
  if(button_state == LOW) {
    Serial.println(", Button: PRESSED");
    
    //Turn on the relays based on the joystick position
    if(x_mapped > 0) {
      digitalWrite(relay1, HIGH);
    } else {
      digitalWrite(relay1, LOW);
    }
    
    if(x_mapped < 0) {
      digitalWrite(relay2, HIGH);
    } else {
      digitalWrite(relay2, LOW);
    }
    
    if(y_mapped > 0) {
      digitalWrite(relay3, HIGH);
    } else {
      digitalWrite(relay3, LOW);
    }
    
    if(y_mapped < 0) {
      digitalWrite(relay4, HIGH);
    } else {
      digitalWrite(relay4, LOW);
    }
  } else {
    Serial.println(", Button: RELEASED");
  }

  //Send the joystick values to the computer via joystick HID emulation
  Joystick.setXAxis(x_mapped);
  Joystick.setYAxis(y_mapped);
  
  //Delay to prevent sending too many joystick packets
  delay(10);
}



Comments

Popular posts from this blog

Weather Station Using Arduino & DHT11

Weather Station Using Arduino & DHT11      Introduction: Weather monitoring is an important task in many industries and applications. In this project, we are going to build a weather monitoring station using Arduino Nano, DHT11 sensor, 16x2 LCD display, and I2C module. The DHT11 sensor will be used to measure temperature and humidity, and the results will be displayed on the 16x2 LCD display with the help of the I2C module. Hardware Required:

Understanding the Basics of Resistors: A Beginner's Guide

  Understanding the Basics of Resistors: A Beginner's Guide Introduction: Resistors are one of the most basic and fundamental components used in electronic circuits. They play a vital role in controlling the flow of current in a circuit and have a wide range of applications in everything from simple LED circuits to complex electronic systems. In this blog post, we will dive into the world of resistors, exploring what they are, how they work, and the different types of resistors that are available. What is a Resistor? A resistor is an electrical component that is used to regulate the flow of electrical current in a circuit. It is designed to have a specific resistance value, which is measured in ohms (Ω). The resistance value of a resistor determines how much current can flow through it, with higher resistance values limiting the current flow, and lower resistance values allowing more current to flow. Resistors are passive components, which means that they do not generate or amplify

Revolutionizing Home Automation: Empowering Smart Living through Seamless Control and Advanced Monitoring

Revolutionizing Home Automation: Empowering Smart Living through Seamless Control and Advanced Monitoring Introduction : Welcome to the forefront of modern living, where our innovative home automation project is reshaping the way we interact with our homes. Our mission is to bring convenience, efficiency, and security to homeowners through a comprehensive system that leverages the power of cutting-edge technology. By integrating internet networking, sensor data, and cloud-based storage, our project ensures real-time updates and effortless user control. With a focus on simplicity and accessibility, our solution is designed for all, regardless of technical expertise. Join us on this journey as we explore the extensive capabilities of our home automation project. Project Overview: At the heart of our home automation project lies the vision of creating a smart ecosystem that seamlessly connects various aspects of the home. By interlinking appliances, sensors, and user devices through inter