You are on page 1of 23

l

P R O T E U S
WITH
M I T A P P

I N V E N T O R
CONTROL RELAY CIRCUIT
WHAT IS A RELAY CIRCUIT CREATING THE SIMULATING
CONTROL RELAY? IN PROTEUS APP THE RELAY
INTRODUCTION

After discussing MIT App Inventor, its editor interface, and its application
to the Proteus circuit, we will discuss Relay Control in Proteus using MIT App
Inventor.

WHAT IS A CONTROL RELAY?

A Control Relay, also known simply as a relay, is a switch or an


electromagnetic switch. In a Control Relay, an electrical current pass via a
conducting coil, which opens or closes a switch. Moreover, it protects the
circuit current. By using a control relay instead of a simple switch device,
users may automatically isolate or change the state of an electric circuit
diagram.

Figure 1: A Relay-controlled circuit.


Control relays play a primary role in modern electrical devices. Their name
implies that they are power-supply elements for other electrical components
like motors and power plants.

CREATING A RELAY CIRCUIT IN PROTEUS

In this Module, we will demonstrate a Relay-controlled circuit.


We will simulate it in Proteus Design Suite, which we will control
using MIT App Inventor. The output would focus on relay-controlling
two components: which are the electric motor and the light bulb.

STEP 1

Open the Proteus Design Suite Software.


• Click New Project, then enter the project name.
• Click Next, then click DEFAULT, and then click Next again.
• Select No PCB Layout, then click Next again.
• Select No Firmware, then click Next again.
• Review the details, then click Finish.
Right-click on the Editing Window, click Place, then
Component, then From Libraries. In the Libraries, search
STEP 2
and select all components needed for the circuit.

These components are:


- Diode (1N4007) - Bluetooth HC-05
- Bipolar Transistor (2N2222) - Alternator
- Arduino UNO - Relay
- Lamp or Bulb - Motor
- Resistor

STEP 3

STEP 3

Build the Relay Circuit of the light bulb or lamp. Place the
lamp on the Editing Window. Then place the Relay and the
Alternator. The Alternator would power the lamp once the Relay
function.
Build the Relay circuit of the electric motor.
Place the electric motor and the relay switch on
the Editing Window. Since the electric motor is
STEP 4 DC-powered, we need to connect the two pins of
the electric motor to the coil and the switch part
of the switch relay. Once we power the magnetic
coil, the electric motor will run.

STEP 5
Place the Bipolar Transistor STEP 5
below the switch relay. Connect
the lower pin of the switch relay
to the collector pin of the
transistor. Then connect the 10k-
ohm resistor to the base of the
Bipolar Transistor. After that,
link the emitter pin to the
ground terminal, and place a
diode parallel to the relay pins.

Like what we did in the lamp


circuit, we will also place Bipolar
STEP 6 Transistor in the electric motor
circuit. The connections are the same
with the lamp circuit. After copying
the circuit connections from the lamp
circuit, we will connect the lower pin
of the switch part of the switch relay
to the emitter pin of the transistor.
Then, we will connect the two relays
by creating a wire connection on their
upper pins. Add a DC generator on
this wire.
STEP 7

Place the Arduino and the Bluetooth HC-05 module on the Editing
Window. Connect the TXD and the RXD pins of the Bluetooth module to the
RXD and TXD module of the Arduino, respectively. Then connect the Pin 5
of Arduino to the resistor of the Lamp circuit while connecting the Pin 6 to
the resistor of the motor circuit.

CREATING THE APP IN MIT APP INVENTOR

STEP 1

Go to the MIT
App Inventor website
( http://ai2.appinvent
or.mit.edu/ ). Click
New Project, write
your desired project
name, and click OK.
STEP 2

Edit the Screen 1 on the


Design Editor. Then, add a label
on the screen, click the Label in
the User Interface tab, and drag
it to the Viewer. In the Label,
write the name of the app and
edit its properties on the
Properties section.

STEP 3

Add a List Picker on the Viewer. Select List Picker on the User
Interface tab, then drag it on the Viewer. Write “Select Bluetooth
Connection” and edit its properties on the Properties section. This list
picker would allow us to select Bluetooth devices.
STEP 4

Add a button on the viewer, and label it Disconnect. This button


would serve as the disconnect button once we are finished in our
task. Since this button will only show up if we are connected to a
Bluetooth device, we need to hide it first. To do this, uncheck the
“Visible” box in the Properties section.

STEP 5

Add a label box in the Viewer. The label this box as “LAMP”. Then we
will add two buttons that would serve as the ON and OFF of the lamp
circuit. We can select Horizontal Arrangement box in the Layout tab if we
want these two buttons be aligned horizontally. After adding the
Horizontal Arrangement box, drag the two buttons on it, and then label
them as ON and OFF. Edit their alignments and color in the Properties
section.
Add another label box in the
STEP 6 Viewer. Then label this box as “MOTOR”.
Then we will add another two buttons
that would serve as the ON and OFF of
the motor circuit. We can select
Horizontal Arrangement box in the
Layout tab if we want these two buttons
be aligned horizontally. After adding the
Horizontal Arrangement box, drag the
two buttons on it, and then label them
as ON and OFF. Edit their alignments and
color in the Properties section. After
placing the buttons, add Bluetooth
Client in the viewer.
PROGRAMMING THE APP

STEP 1

Go to the Block Editor, then click ListPicker1. The


ListPicker1 is involved in showing the list of available Bluetooth
devices. After clicking, a list of program blocks will show. Click
When ListPicker1. Before Picking block.
STEP 2

Click the ListPicker1 and select set ListPicker1.elements to


block, then attach it to the When ListPicker1. Before Picking.
STEP 3
Click the Bluetooth client, then select
BluetoothClient1.AddressesAndNames. Drag
and connect it on the right of set
ListPicker1.elements to block. These blocks
would allow the app to show the available
Bluetooth devices before we pick a
connection.

STEP 4
Click ListPicker1, then this time, click When ListPicker1.After Picking block.
Drag it in the Viewer. Then click the ListPicker1, click set ListPicker1.Selection
to block, connect it to the When ListPicker1.After Picking block. After that, click
the Bluetooth client, then select call BluetoothClient.Connect/Address and
connect it to the set ListPicker1.Selection to clock. Click ListPicker1, then select
ListPicker1.Selection" and connect it to call BluetoothClient. Connect/Address
block. These blocks would allow the app to pick and call the Bluetooth module
of the Proteus circuit.
STEP 5
Once the app connects to a device, we must make the Disconnect button
or Button 1 visible. This mechanism would allow the app user to disconnect the
device once they finished simulating the Proteus circuit. Click the Logic button
in the Blocks section, and then select the if/then block. Place it before the call
BluetoothClient. Connect/Address block. This block must be connected beside
the "if" part. Then, click Button 1, then select "set Button1.Visible to", then
attach it beside the "then" part of the "if/then" block. Click the Logic in Blocks
section, select True, then connect it beside the set Button1.Visible to block.

STEP 6

The function of Button 1 or Disconnect Button is to disconnect the device


to the Bluetooth Module. To allow disconnection, click Button 1, then select
when Button1.Click / do block. Then go to Bluetooth Client, then select call
BluetoothClient1.Disconnect, and connect it on the when Button1.Click / do
block. Since we are disconnected, Button 1 needs to be invisible. To make this
happen, go to Button 1, then select set Button1.Visible to block, then place it
under the BluetoothClient1.Disconnect block. Go to Logic in Blocks section,
then choose False, and connect it to the set Button1.Visible to block.
STEP 7

After programming the Bluetooth connectivity, we will program the ON


and OFF buttons of the lamp and the motor. The ON and OFF buttons of the
lamp are Button2 and Button3, respectively. The ON and OFF for the motor
circuit are Button 4 and Button 5, respectively. Select the When Button.Click
/do blocks for each button. Then add call BluetoothClient1.SendText block to
each When Button.Click /do block. After that, add a blank Text block to each
call BluetoothClient1.SendText block. Type the specific commands needed for
each button.
STEP 8

Once finished programming the app, click Build then Android App (apk.).
Download the app using the MIT App Companion by scanning the generated
QR code.
PROGRAMMING THE ARDUINO

STEP 1

Open the Arduino IDE.


Write String readString. Set up
your Arduino by writing
Serial.begin(9600) on the void
setup. Then, set the pins 5 and
6 by writing pinMode (5,
OUTPUT) and pinMode(6,
OUTPUT).

STEP 2

In the void loop, write while


(Serial.available ()). Set up c as a
character, and equate it to Serial.read().
Then, type readString += c.
STEP 3

We will write if statements to allow Arduino to understand the


commands that will be sent by the app. The commands to be sent by the app
are: lamp on, lamp off, motor on, and motor off. The functions of these
commands speak for themselves. The format of code for each functions are
if(readString==“command”), then digitalWrite (corresponding pin, HIGH or
LOW). The corresponding pin for the lamp is pin 5, while pin 6 is for the
motor. If the function requires turning the circuit on, the digitalWrite must
be HIGH, otherwise, it is LOW.

STEP 4

Verify then compile the Arduino code. Then click Sketch, then
select Export Compiled Library. After that, open the Sketch Folder to
know the file location of the code, which should be in .ino or .hex
format.
STEP 5

After coding, we will now upload our code. First, open your Proteus
circuit, then double-click the Arduino module. Click the folder icon
beside the Program File box. Find the location of the .hex or .ino file of
your Arduino code. Click the file and then click Open, and then OK.
SIMULATING THE CIRCUIT
USING MIT APP INVENTOR

STEP 1

Open the Proteus Relay circuit. Click the Play button on the
lower -left part of the screen.

STEP 2
Turn on the Bluetooth
Connection of the Laptop/PC of
the Proteus circuit. Then, open
the smartphone/device on which
you have downloaded the app.
Open your device's Bluetooth,
then open the app.
Click Select Bluetooth Connection, then click the
discoverable Bluetooth name of the PC/Laptop of the
STEP 3 Proteus circuit. The disconnect button would show up
you have successfully connected.

Once connected, we can now test the STEP 4


app. If you press the ON button of the
lamp, the lamp in the Proteus circuit shall
glow up. And if we press the OFF button,
the lamp would be turned off. While in the
motor, if we press the ON, the motor
would spin, and if we press OFF, it would
stop spinning. We can also turn both of
them ON simultaneously, as well as
turning them OFF.
POP-UP QUIZ
Multiple Choices

1. An electromagnetic switch primarily used in today’s electronic devices.


a. Control Relay c. Bluetooth HC-05
b. Arduino d. Alternator

2. In our relay circuit, what gives the lamp power?


a. Control Relay c. Bluetooth HC-05
b. Arduino d. Alternator

3. In MIT App Inventor, what is involved in showing the list of available Bluetooth
devices?
a. Button c. List Picker
b. Layout d. Label

4. What should be the file type of the code on Arduino?


a. hex c. pdf
b docx d. ppt

5. Which pins of the Arduino are in pinMode?


a. 1 and 2 c. 5 and 6
b. 3 and 4 d. 7 and 8

Answer:
1. A
2. D
3. C
4. A
5. C
UNIT D 2467 URDANETA RD, MAKATI, METRO
MANILA, PHILIPPINES

erovoutika@gmail.com
+(02)8370 1811

www.facebook.com/erovoutika

You might also like