Announcement

Collapse
No announcement yet.

[Draft] Arduino - Control high-voltage devices using Relay Expansion Board - PES-2601

Collapse
X
Collapse

  • [Draft] Arduino - Control high-voltage devices using Relay Expansion Board - PES-2601

    This tutorial is for the upcoming PhpocExpansion library

    PES-2601 is an easy-to-use 4-port Relay Expansion Board for Arduino Uno and Mega, which allows Arduino to control high-voltage device on/off .
    Library and example for the 4-port relay expansion board are part of of PhpocExpansion library for Arduino.
    This tutorial shows how to use 4-port relay expansion board with an example of PhpocExpansion library for Arduino.


    Hardware Required



    Wiring
    • Stack PHPoC Shield or PHPoC WiFi Shield on Arduino
    • Stack relay expansion board PES-2601 on PHPoC Shield or PHPoC WiFi Shield
    • (optional) Connect the terminal block of relay expansion board to a high-voltage device.

      Click image for larger version  Name:	2601_highvoltage_device.JPG Views:	1 Size:	49.9 KB ID:	1180
      Note that relay just like a switch, you can connect positive line or negative line to relay.


    Since relay expansion board has four relays, it can control four devices simultaneously. The above images show only one device for illustration.

    Install Arduino IDE

    If you have not install Arduino IDE yet, please download and install Arduino IDE .





    Install Library
    • Run Arduino IDE.
    • Navigate to Sketch > Include Library > Manage Libraries

      {"alt":"Click image for larger version Name:\tInstall_library_1.jpg Views:\t1 Size:\t56.9 KB ID:\t1147","data-align":"none","data-attachmentid":"1147","data-size":"full"}
    • Search "PhpocExpansion" on search bar of the Library Manager.

      {"alt":"Click image for larger version Name:\tInstall_library_2.jpg Views:\t1 Size:\t23.0 KB ID:\t1148","data-align":"none","data-attachmentid":"1148","data-size":"full"}
    • Select the PhpocExpansionlibrary and press the [Install] button.

      {"alt":"Click image for larger version Name:\tInstall_library_3.jpg Views:\t1 Size:\t23.5 KB ID:\t1149","data-align":"none","data-attachmentid":"1149","data-size":"full"}
    • Restart Arduino IDE for the next step



    Source Code
    • Connect Arduino to PC via usb cable
    • Open Arduino IDE
    • Open "ExpansionRelayOutput" example
    • Compile the example code and uploads to Arduino by clicking "Upload" button on Arduino IDE
    • Open "Serial Monitor" tool on Arduino IDE to see the output log:
    • Watch four LED's state on relay expansion board. We can see these LED blink one time per second.
    • If you connected a high-voltage device to relay expansion board, you can see the device switch between on/off every second.

    Code Explanation

    At the beginning
    we need to create and four relay object:
    Code:
    ExpansionRelayOutput relay0(spcId, 0);
    ExpansionRelayOutput relay1(spcId, 1);
    ExpansionRelayOutput relay2(spcId, 2);
    ExpansionRelayOutput relay3(spcId, 3);
    where spcId is address of expansion board that are set via dip switch on expansion board.
    {"alt":"Click image for larger version Name:\tdip switch.jpg Views:\t1 Size:\t64.4 KB ID:\t1153","data-align":"none","data-attachmentid":"1153","data-size":"medium"}

    You can change it and map it to the below to know the value.

    {"alt":"Click image for larger version Name:\tdip table.jpg Views:\t1 Size:\t53.9 KB ID:\t1154","data-align":"none","data-attachmentid":"1154","data-size":"full"}



    Note that: 4-port relay expansion board is one of the expansion boards. List of expansion for arduino is available here

    In setup() function
    • Phpoc.begin() and Expansion.begin() functions must be used to initial PHPoC [WiFi] Shield and expansion board, repectively.
    • Serial.println(relay0.getName()) function is used optionally to get name of expansion board and print it to serial.
    • There are some functions has been commented.
      Code:
      	//relay0.setDelay(900);
      	//relay1.setDelay(1000);
      	//relay2.setDelay(1100);
      	//relay3.setDelay(1200);
      These functions are optional and used to set the delay time. Refer to PHPoC Shield Expansion Library Reference for more information about these functions.


    In loop() function
    There are some functions are used.
    • relay0.on(): control relay on.
    • relay0.off(): control relay off.
    • relay0.isOn(): check whether relay is on or not.
    • relay0.isOff(): check whether relay is off or not.



    See Also

    References
      Posting comments is disabled.

    Categories

    Collapse

    Article Tags

    Collapse

    Latest Articles

    Collapse

    • [Draft] Arduino - Monitor States of High-voltage Device using Input Expansion Board
      support
      This tutorial is for the upcoming PhpocExpansion library

      PES-2602 is an easy-to-use 4-port Input Expansion Board for Arduino Uno and Mega, which allows Arduino to monitor state of high-voltage device.
      Library and example for the 4-port input expansion board are part of of PhpocExpansion library for Arduino.
      This tutorial shows how to use 4-port input expansion board with an example of PhpocExpansion library for Arduino.


      Hardware Required
      • Arduino Uno
      ...
      09-11-2018, 05:38 PM
    • [Draft] Arduino - Control high-voltage devices using Relay Expansion Board - PES-2601
      support
      This tutorial is for the upcoming PhpocExpansion library

      PES-2601 is an easy-to-use 4-port Relay Expansion Board for Arduino Uno and Mega, which allows Arduino to control high-voltage device on/off .
      Library and example for the 4-port relay expansion board are part of of PhpocExpansion library for Arduino.
      This tutorial shows how to use 4-port relay expansion board with an example of PhpocExpansion library for Arduino.


      Hardware Required
      • Arduino Uno
      ...
      09-11-2018, 04:28 PM
    • [Draft] Arduino - Control DC Motor using DCMotor Controller - PES-2604
      support
      This tutorial is for the upcoming PhpocExpansion library

      PES-2606 is an easy-to-use RS-232 Expansion Board for Arduino Uno and Mega, which allows Arduino to exchange data with serial device via RS-232. Especially, Arduino does NOT use UART pins to communicate with RS-232 expansion. Therefore, users can use Arduino UART pins for other purposes. Moreover, A single Arduino Uno/Mega can communicate with multiple RS-232 expansion boards (up to 14) without using Arduino UART pins.
      ...
      09-11-2018, 01:17 PM
    • [Draft] Arduino - Control Stepper Motor using Stepper Motor Controller - PES-2605
      support
      PES-2605 is an easy-to-use stepper motor controller for Arduino Uno and Mega, which uses micro-stepping method to precisely control stepper motor. Library and example for the stepper motor controller
      09-03-2018, 04:30 PM
    • PHPoC - Configuring Network Information via Web
      support
      This example show how to create an Web app that allows to check and config network information (e.g MAC address, IP addess, ...) remotely via Web browser.


      Hardware
      • PHPoC Blue (+ USB WLAN) or PHPoC Black (+ Ethernet cable)
      • Micro USB to USB Cable (to upload source code to PHPoC Device)


      Quick Steps

      Source code of this example is a part of PHPoC Support Packet (PSP). You need to:...
      02-07-2018, 09:23 AM
    • TCP Client - HTTP GET
      support
      What is HTTP?

      HTTP means HyperText Transfer Protocol. HTTP is the underlying protocol used by the World Wide Web. The protocol defines how messages are formatted and transmitted, and what actions Web servers and browsers should take in response to various commands.
      For example, when you enter a URL in your browser, this actually tells Web browser make an HTTP request to the Web server.

      PHPoC has an embedded web server. However, this example shows PHPoC devices...
      02-02-2018, 06:27 PM
    Working...
    X