Skip to content

Interfacing IR Sensor with DE0 Nano FPGA

Introduction:

An IR sensor, also known as an infrared sensor, is a device that detects infrared radiation emitted by objects. It works by measuring the intensity of infrared light in its surrounding environment. IR sensors are widely used in various applications, including proximity sensing, motion detection, temperature measurement, and remote control systems. When combined with the DE0 Nano FPGA (Field Programmable Gate Array), the IR sensor can be integrated into a larger system for advanced processing and control. The DE0 Nano FPGA provides a programmable platform that enables customization and flexibility in designing and implementing complex functions, making it an ideal companion for IR sensor applications. Together, the IR sensor and DE0 Nano FPGA can enable innovative solutions in automation, robotics, security systems, and more.

Problem Statement

Interfacing IR Sensor with FPGA board. When the IR Sensor senses obstruction or vice versa it should indicate it through the glowing of LED.

Requirements

  1. De0 Nano FPGA board
  2. IR Sensor - MH-B
  3. Jumper wires

Working

The IR sensor's working with the DE0 Nano FPGA involves utilizing the FPGA's capabilities to process and respond to the sensor's output. The IR sensor detects infrared radiation emitted by objects and generates an electrical signal, which is received by the FPGA through the "ir" input. Within the FPGA, the Verilog code processes this signal. When the "ir" input is low (indicating the presence of an object), the code sets the "led" output to high, turning on an LED connected to the FPGA. Conversely, when the "ir" input is high (indicating no object), the code sets the "led" output to low, turning off the LED. By integrating the IR sensor with the DE0 Nano FPGA, the sensor's data can be processed and used to control other components or perform specific actions based on the proximity of objects.

Circuit Diagram

  1. Connect Vcc of IR Sensor to 3.3V pin GPIO-0 DE0 Nano
  2. Connect GND of IR Sensor to GND pin GPIO-0 DE0 Nano
  3. Connect OUT of IR Sensor to GPIO_00 pin GPIO-0 DE0 Nano
Altera Cyclone IV FPGA DE0-Nano

Code

Copy and paste the following code into IR.v or download it from here:

v
module IR (clk,ir,led);
  input clk;
  input ir;
  output reg led;

  always @(posedge clk) begin
    if (ir == 0) 
    led = 1;
    else led = 0;
  end
endmodule

Output

After dumping the code to the FPGA, the IR proximity sensor will continuously monitor its surroundings. The LED will be turned on when an object is detected within its range. If no object is detected, the LED will remain off.

Conclusion

By implementing the provided Verilog code, an IR proximity sensor has been successfully integrated with the DE0 Nano FPGA. The code enables the FPGA to receive input from the IR sensor and control the state of an LED based on the detected proximity of objects. This integration allows for the development of applications such as proximity sensing, motion detection, and object recognition. The flexibility and programmability of the FPGA open up possibilities for customization and advanced processing, making it a suitable platform for various automation, robotics, and security systems.