Proteus arduino relay

Основы ПО ISIS Proteus, работа с платформой Arduino

В этой статье я хочу поделиться своим опытом и, в основном, рассказать как можно использовать ПО Proteus.

Начнем с информации для общего понимания.

Если всё очень сильно упростить, то Proteus Design Suite — это набор программ для проектирования электронных схем. ISIS Proteus — это одна из программ в данном пакете и именно она представляет больший интерес.

Зачем вообще нужен ISIS Proteus?

А нужен он для моделирования электронных схем. Вы, наверное, спросите — зачем мне изучать и использовать ISIS Proteus, если есть множество других программ, которые позволяют делать это. И я вам отвечу — ISIS Proteus может моделировать работу программируемых устройств: микропроцессоров, микроконтроллеров, DSP и проч. Вы только представьте, вы можете не покупая микроконтроллеры создать, проверить и отладить свой проект без малейшего вложения в покупку МК и прочих компонентов (например: резисторы, транзисторы, светодиоды, моторы, реле и т.д.).

Что понадобится для этого проекта?

Сначала — специализированное ПО. Поскольку в этом проекте я использовал Arduino, мне понадобится среда разработки Arduini IDE. https://www.arduino.cc/en/software — тут вы можете скачать его с официального сайта. Далее нам необходимо будет установить Proteus Design Suite. https://www.youtube.com/watch?v=td4D7BzbX2Q — в этом видео продемонстрировано, как правильно это сделать, всё просто и ничего лишнего.

Примечание: да, я знаю, что на данный момент вышла уже 8-я версия Proteus-а, но у меня и моих знакомых постоянно возникали проблемы с ней. Поэтому будем использовать 7-ю.

Что будем делать после установки?

7-я версия Proteus-а имеет в себе огромную библиотеку компонентов на любой вкус и цвет, но платформ Arduino в ней сначала нет. Нам необходимо это исправить. Скачать одну из таких библиотек можно на этом сайте -https://www.theengineeringprojects.com/2021/03/download-proteus-library-of-arduino-modules.html . Лучше скачивайте версию 2.0.

После скачивания вам нужно распаковать эти файлы и переместить в корневую папку Proteus-а. . \Labcenter Electronics\Proteus 7 Professional\LIBRARY — именно в эту папку нужно распаковать данную библиотеку. https://www.youtube.com/watch?v=YF13YaGg3Mo — видео по теме.

Готово, теперь в библиотеке компонентов мы можем найти основные варианты платформы Arduino.

Теперь нам необходимо написать код для нашего проекта. В свою очередь, для демонстрации возможностей Proteus-а я возьму готовый код из примера, которые хранятся в IDE Arduino, а именно — Blink.

Обязательно нужно поставить галочку «Компиляция» в настройке Arduino IDE. Таким способом мы сможем получить бинарный файл с расширением .hex.

Далее мы компилируем нашу программу и для удобства из панели вывода сразу копируем в буфер ссылку на .hex файл. Пример на скриншоте ниже, но не переживайте, этот файл находиться в корневой папке проекта.

После написания кода и его компиляции нам необходимо построить схему в ISIS Proteus. Можете, конечно, посмотреть пару видео для того что бы разобраться в самой программе.

Вот такая простая схемка у меня получилась. Также нам нужно указать путь к бинарной прошивке Arduino, для этого необходимо двойным кликом по графическому компоненту ARD1 открыть его параметры и в разделе «Program File» указать путь к .hex файлу, который мы получили в ходе компиляции кода.

После того как мы указали путь к прошивке, нажимаем кнопку «Play» и наблюдаем мигание светодиода.

Думаю, что суть работы я достаточно просто изложил. Для того, что бы у вас была мотивация работать далее с этой программой и изучать её функционал ниже вы можете увидеть один из проектов, который я делал. Это схема имитации работы лифта. Как видите, здесь есть кнопки для вызова лифта, экран(на нем выводится номер этажа и другая полезная информация из других режимов работы системы), светодиоды(они дублируют информацию о положении лифта) и еще много других интересных систем.

Источник

Guide for Relay Module with Arduino

This article shows how to control mains voltage with the Arduino using a relay module. We make a brief introduction to the relay module and build a simple project example with the Arduino. The example we’ll build shows how to control a relay module with an Arduino and a PIR motion sensor.

By the end of this tutorial, you should be able to control any electronics appliances with your Arduino using a relay module.

Introducing the Relay Module

A relay is an electrically operated switch that can be turned on or off, letting the current go through or not, and can be controlled with low voltages, like the 5V provided by the Arduino pins.

Controlling a relay module with the Arduino is as simple as controlling any other output as we’ll see later on.

This relay module has two channels (those blue cubes). There are other models with one, four and eight channels. This module should be powered with 5V, which is appropriate to use with an Arduino. There are other relay modules that are powered using 3.3V, which is ideal for ESP32, ESP8266, and other microcontrollers.

Get a relay module:

Relay Pinout

The following figure shows the relay module pinout.

The six pins on the left side of the relay module connect high voltage, and the pins on the right side connect the component that requires low voltage—the Arduino pins.

Mains voltage connections

The high-voltage side has two connectors, each with three sockets: common (COM), normally closed (NC), and normally open (NO).

  • COM: common pin
  • NC (Normally Closed): the normally closed configuration is used when you want the relay to be closed by default, meaning the current is flowing unless you send a signal from the Arduino to the relay module to open the circuit and stop the current.
  • NO (Normally Open): the normally open configuration works the other way around: the relay is always open, so the circuit is broken unless you send a signal from the Arduino to close the circuit.

If you just want to light up a lamp occasionally, it is better to use a normally-open circuit configuration.

Pin wiring

The low-voltage side has a set of four pins and a set of three pins.

The set at the right consists of VCC and GND to power up the module, and input 1 (IN1) and input 2 (IN2) to control the bottom and top relays, respectively.

The second set of pins consists of GND, VCC, and JD-VCC pins. The JD-VCC pin powers the electromagnet of the relay.

Note: notice that the module has a jumper cap connecting the VCC and JD-VCC pins; the one shown here is blue, but yours may be a different color. The jumper cap allows you to choose whether the circuit is physically connected to the Arduino circuit or not, and you can choose to have it on or not. With the jumper cap on, the VCC and JD-VCC pins are connected. That means the relay electromagnet is directly powered from the Arduino’s power pin, so the relay module and the Arduino circuits are not physically isolated from each other (this is the configuration we’ll use). Without the jumper cap, you need to provide an independent power source to power up the relay’s electromagnet through the JD-VCC pin. That configuration physically isolates the relays from the Arduino with the module’s built-in optocoupler.

The connections between the relay module and the Arduino are really simple:

  • GND: goes to ground
  • IN1: controls the first relay (it will be connected to an Arduino digital pin)
  • IN2: controls the second relay (it should be connected to an Arduino digital pin if you are using this second relay. Otherwise, you don’t need to connect it)
  • VCC: goes to 5V

Example: Controlling a Lamp with a Relay Module and PIR Motion Sensor

In this example, we create a motion sensitive lamp. A lamp lights up for 10 seconds every time motion is detected.

Motion will be detected using a PIR motion sensor. If you are not familiar with the PIR motion sensor, you can read the following post:

To control the lamp with mains voltage we’ll use a relay module in normally-open configuration.

Safety warning

Before proceeding with this project, I want to let you know that you’re dealing with mains voltage. Please read the safety warning below carefully.

Warning: when you are making projects that are connected to mains voltage, you really need to know what you are doing, otherwise you may shock yourself. This is a serious topic, and we want you to be safe. If you’re not 100% sure what you are doing, do yourself a favor and don’t touch anything. Ask someone who knows!

Parts required

Here’s the needed parts for this example:

You can use the preceding links or go directly to MakerAdvisor.com/tools to find all the parts for your projects at the best price!

Copy the following code to your Arduino IDE and upload it to your Arduino board.

Warning: you shouldn’t upload new code while your Arduino is connected to the relay.

How the code works

First, we create variables to hold the pin the relay IN1 pin is connected to and to save the relay state:

The PIR motion sensor is connected to pin 2 :

We need to create some auxiliary variables to handle timers with the PIR motion sensor. The lastDebounceTime variable saves the last time motion was detected. The debounceDelay saves how much time the lamp should remain on after motion is detected (here we’re setting 10 seconds = 10000 milliseconds)

In the setup() , we set the relay as an OUTPUT and turn it off by default:

Because we’re using a normally open configuration, there is no contact between the COM and NO sockets unless you trigger the relay. The relay is triggered when the input goes below about 2 V. That means if you send a LOW signal from the Arduino, the relay turns on, and if you send a HIGH signal, the relay turns off; it works with inverted logic.

Set the PIR motion sensor as an interrupt:

Whenever the PIR motion sensor is triggered, it calls the detectMotion() function declared at the end of the code to turn the relay on:

In the loop() , we check whether 10 seconds have passed since the relay is on. If that condition is true, we can turn the relay off.

Schematic

Assemble all the parts as shown in the schematic diagram.

Warning: do not touch any wires that are connected to mains voltage. Also make sure you have tighten all screws of the relay module.

The lamp is connected to the relay using a normally open configuration. The Arduino controls the relay through pin 8 ( pin 8 is connected to the relay IN1 pin). Finally, the PIR motion sensor is connected to pin 2 .

Demonstration

After uploading the code and wiring the circuit, you can test your setup.

When motion is detected, your lamp lights up. If there isn’t motion for 10 seconds, the lamp turns off.

Wrapping Up

Controlling a relay module with the Arduino is as simple as controlling an output – you just need to send HIGH or LOW signals using an Arduino digital pin. With the relay module you can control almost any AC electronics appliances (not just lamps).

We hope you’ve found this guide useful. If you like this project, you may also like our premium Arduino course:

We have more than 60 free tutorials and projects with the Arduino. If you’re looking for a guide for a specific module, we probably have what you’re looking for.

Finally, you can also get access to our FREE resources here.

Источник

2 Relay Module Interfacing with Arduino

Hello everyone! I hope you all will be absolutely fine and having fun. Today, I am going to provide a detailed discussion on 2 Relay Module Interfacing with Arduino. First of all I would like to explain you that what is relay and how to use it and then we will move forward towards 2 relay module interfacing with Arduino. I have already controlled relay with 555 timers. 2 relay module consists of two relays. Relay is basically an electronic device or a switch which is used to open and close the circuits electronically. A relay controls an electric circuit by opening and closing contacts in another circuit. When the relay contact is normally open (NO), there will be an open connection when the relay is not energized. When the relay contact is normally closed, there will be a closed connection even when the relay is not energized. We can use relays to control the smaller currents in different electronic circuits. 2 relay module has two relays. One relay can control two AC/DC device simultaneously. That means 2 relay module can control four AC/DC devices at a time. 2 relay module is normally used to control the DC motors in different projects e.g. robotics, automation, embedded projects etc. It can control two DC motors simultaneously. Moreover, we can also use it for different applications e.g. to control DC/AC fans, AC/DC lights, AC/DC bulbs and a lot more. The further detail about 2 relay module interfacing with Arduino will be given later in this tutorial.

2 Relay Module Interfacing with Arduino

1. Relay Proteus Simulation
  • I have also designed relay simulation in Proteus ISIS.
  • Relay Proteus ISIS simulation is shown in the figure given below.

2. 2 Relay Module Components
  • A complete list of the components used while designing 2 relay module is shown in the figure given below.

3. 2 Relay Module Input Pins
  • 2 relay module has five (5) input pins in total, each perform different action.
  • All of its pins are provided in the table shown in the figure below.

4. 2 Relay Module Input Pins Description
  • We must know about the functions of each pin.
  • 2 relay board/module input pin functions are listed in the table shown in the figure below.

  • Both IN1 and IN2 comes from the micro-controller (Arduino UNO in this case).
  • IN1 pin controls the 1st relay attached on 2 relay module.
  • IN2 pin controls the 2nd relay attached on 2 relay module
5. 2 Relay Module Output Pins
  • 2 relay module has three (3) output pins for each relay.
  • Its output pins are given in the table shown in the figure given below.

6. 2 Relay Module Output Pins Description
  • Each output pin of 2 relay module has its own functions.
  • 2 relay module pin functions are listed in the table given in the figure shown below.

  • NO pin is normally open pin and device attached to this pin will not work if the relay is not energized.
  • COM is a common pin i.e. ground pin.
  • NC is normally closed pin and device attached to this pin will start working even if the relay is not energized.
7. 2 Relay Module Compatibility
  • 2 relay module is compatible with different micro-controllers.
  • Some of those micro-controllers are provided in the table shown in the figure given below.

8. 2 Relay Module Circuit Diagram
  • Circuit diagram of 2 relay module is given in the figure shown below.

9. 2 Relay Module Interfacing with Arduino Wiring Diagrams
  • First you should have a look at Relay Interfacing With Microcontroller using ULN2003A, you will get a better idea about its interfacing with different micro-controllers.
  • Wiring diagram for 2 relay module interfacing with Arduino is shown in the figure given below.

10. 2 Relay Module Interfacing with Arduino Actual Diagrams
  • I have provided the complete wiring diagram for 2 relay module interfacing with Arduino.
  • Wiring diagram is shown in the figure given below.

11. 2 Relay Module Interfacing with Arduino Source Code & Description
  • If you are new to Arduino software then you must have a look at How to write Arduino code.
  • You just need to copy and paste the source code given below in your Arduino software.
  • The complete source code for 2 relay module interfacing with Arduino is given below.
  • First of all I have defined relay pins.
  • Then I have changed the mode of these pins to output.
  • After that I have turned on and off both of the relays with the delay of 1 sec or 1000 msec.
  • So, that was the brief description about the source code for 2 relay module interfacing with Arduino.
  • You can download the wiring diagram and complete Arduino source code here by clicking on the button below.
12. 2 Relay Module Features
  • The most common features associated with 2 relay module are provided in the table shown in the figure given below.

13. 2 Relay Module Application
  • 2 relay module applications are given in the table shown in the figure below.

In the tutorial 2 Relay Module Interfacing with Arduino, we have learnt about the components used in the design of 2 relay module. We have also learnt about the 2 relay module interfacing with Arduino. I have provided the complete Arduino source code, you can control this module using the same code. I hope you have enjoyed the tutorial. If you have any problem you can ask us in comments. Out team is 24/7 available for you. I will share different informative engineering topics in my upcoming tutorials. So, till my next tutorial, take care and bye :)

Источник

Adblock
detector