Relay Control with Arduino

Controlling Relay using Arduino

This is the steps to control 5V 10A 2-Channel relay using Arduino.
  1.  Setting up relay and connect to Arduino
    The relay module has 3 pin header and 4 pin header. Make sure 3 pin header is connected as the picture below (JD-VCC and VCC should be connected.).
    Each relay has 3 outputs and the switch symbol on the left side is the default configuration of the relay. The center pin is connected to the bottom pin.
    Next, connect Arduino and relay. I used jumper cable and connected only IN1 pin that controls ch1 relay port. IN2 (ch2 relay port is not used.)
    I used GPIO7 pin to control relay switch, and 5V pin and GND pin are connected.
    Then, you can connect USB to PC.
    Hardware setup is done and next is to run the program.


  2.  Launch Arduino IDE and open the "Blink" example project.
    Go to "File > Examples > 01.Basics > Blink", and it generates new window with the "Blink" project.
    This project is basically toggling GPIO13 pin every 1ms. You can simply reuse this code to toggle relay on and off from the GPIO7 pin in my case, then save the project as you want.
    You will see IN1 LED on relay module toggles and hear the clicking noise from relay that basically tells you the output is switched. When GPIO is "HIGH", 2 and 3 pins are connected, and when GPIO is "LOW", 1 and 2 pins are connected.

Hardware:
Arduino UNO
Relay


Reference:     

CC3200 with Energia

CC3200 with Energia (Arduino IDE like environment)

Energia is very similar framework to Arduino IDE that support TI MSP430 LaunchPad and also other TI LaunchPad including CC3200. I have been using CCS6 to build my CC3200 projects, but as one of the Arduino user, I tried to establish this Energia IDE to see how it works. Here is the steps.
  1.  Install Windows driver
    Download "cc3200_drivers_win.zip" from the following link and execute DPinst.exe for Windows 32bit or DPinst64.exe for Windows 64 bit after unzip the package.http://energia.nu/files/cc3200_drivers_win.zip
    Make sure CC3200 board is not connected when install the driver.
    You can connect the board after the installation, and the board will be recognized automatically. 


  2.  Install Energia
    Download the latest package from the following link.http://energia.nu/download/
    Unzip the energia-0101EXXXX-windows.zip file to a desired location.
  3.  Hardware setup
    To make it work with Energia, you need to modify the board setting. However, this is not so complicated and basically just change the jumper setting of CC3200 LaunchPad and use single wire to connect 2 pins which is top pin of JP8 and bottom pin of SOP2 with the USB connector facing up.
    You can see the details here.
  4.  Launch Energia and run a project
    Double clike Energia.exe. You will see the following which is very similar to Arduion IDE except the color. 
















    |

    Select "Tool > Boards > LaunchPad w/ CC3200"
    .

















    Select "Tool > Serial Port > COMxx". In my case, it is COM33.














    Select "File > Examples > 1.Basics > Blink".



    It will launch new window as below, and click "Verify" to compile.
    After it is successfully compiled, click upload button and you would see the red LED (P64) blinking around every 2 seconds.





Hardware:
CC3200 Launchpad

Reference:     
How to set up Energia on Windows
Upgrading the CC3200 Firmware
CC3200 Jumper Settings

CC3200 Capture Compare PWM (CCP)

CC3200 Capture Compare PWM (CCP)

I needed to use external clock to count up/down the timer for my CC3200 project. CC3200 support this as I can see in the section 9.3.2.2 "Input Edge Count Mode" of CC3200 technical reference manual. The implementation was not so difficult, and here is how I tested it.
  1.  Assign GPIO pin and CCP/timer
    I decided to use GPIO0 pin
    (PIN_50) on CC3200 launchpad, and use the pin as GP_CCP00 that is assigned as timer0 clock input. Refer to technical reference manual for "pin mux config mode value". In my case, Pin 50 should be "7" to configure it as timer capture port.



    You can also refer to the same manual to see which timer that GP_CCP00 is connected. GT_CCP00 I use is for 16-bit timer 0 as below.




    The block diagram shown before the above table is quite useful to understand how it is internal connected.




    Based on above configuration, I added following lines
    in the pin configuration file.
    //
    // Enable Peripheral Clocks
    //
    MAP_PRCMPeripheralClkEnable(PRCM_GPIOA0, PRCM_RUN_MODE_CLK);

    //
    // Configure PIN_50(GPIO00) for EXTCLK GPIOInput
    //
    MAP_PinTypeGPIO(PIN_50, PIN_MODE_0, false);
    MAP_GPIODirModeSet(GPIOA0_BASE, 0x01, GPIO_DIR_MODE_IN);

    //
    // Configure PIN_50 for TIMERCP0 GT_CCP00
    //
    MAP_PinTypeTimer(PIN_50, PIN_MODE_7); // refer to datasheet pin list

  2. Configure Timer and Interrupt registers
    This is the configuration for my edge count timer and timer interrupt.
    void EXTCLKInit(P_INT_HANDLER EXTCLKInterruptHdl)
    {
        //
        // Register timer interrupt hander
        //
        MAP_TimerIntRegister(TIMERA0_BASE,TIMER_A,EXTCLKInterruptHdl);

        //
        // Configure the timer in edge count mode
        //
    MAP_TimerConfigure(TIMERA0_BASE,(TIMER_CFG_SPLIT_PAIR|TIMER_CFG_A_CAP_COUNT_UP));

        //
        // Set the detection edge
        //             
    MAP_TimerControlEvent(TIMERA0_BASE,TIMER_A,TIMER_EVENT_POS_EDGE);

        //
        // Set the reload value
        //
        MAP_TimerLoadSet(TIMERA0_BASE,TIMER_A,0xffff);

        //
        // Set Match Count Value for Timer Interrupt
        //
        MAP_TimerMatchSet(TIMERA0_BASE,TIMER_A,374);
    }
    You can change MAP_TimerMatchSet parameter to tune the timing. My setting is "374".
  3. Configure Interrupt handler
    This is the interrupt handler that is called by the above timer interrupt.
    For the quick test purpose, you can just add LED toggle function.

    void EXTCLKIntHandler(void)
    {
        //Clear EXTCLK Timer Interrupt Flag
        ClearEXTCLKInt();    // Toggle LED
        //LED1 = 1; //LED on

        //LED1 = 0; //LED off
    }
     
Hardware:
    CC3200 Launchpad
Summary:


Reference:     
CC3200 Technical Reference Manual

NGX LPC4330 Xplorer Board using LPCXpresso

NGX LPC4330 Xplorer Board using LPCXpresso

I got NGX LPC4330 Xplorer board, but it took a while to figure out the debug/program method
. The reason was that it actually came with LPC4337 mounted on the board, and I needed to change some configuration to make it work as below.

  1. Download NGX LPC4337 Xplorer board sample projects (LPCopen)
    Go to LPCware website and download "NGX Xplorer LPC4330 board" package for LPCXpresso. In my case, it is version 2.12.
    http://www.lpcware.com/content/nxpfile/lpcopen-software-development-platform-lpc43xx-packages

    *** You can also find LPC4337 NGX package in the LPCXpresso IDE package. ***
    This package does not include freertos examples that I wanted to use, so I used above package. In my case, the file is located as below.
    C:/nxp/LPCXpresso_6.1.2_177/lpcxpresso/Examples/NXP/LPC4000/LPC43xx/NGX_LPC4337-Xplorer.zip
  2. Load blinky project and change configuration in the property
    I loaded "freertos_blinky" project.
    Right click the project and select "Properties" and go to
    "C/C++ Build > MCU settings".
    Change the target to LPC4337 and press "OK".

    Then build the project and if it builds without errors, it is good to go.
  3. Using ULINK-ME and debugIf you are using ULINK-ME for debugger, change the debug configuration.
    Right click the project, select "Debug As > Debug Configurations..".
    Make sure the correct axf file is selected in the left window (freertos_blinky.axf), and go to "Debugger > Target Configuration". In the "Configuration Option", select "Debug Protocol" and change the value from "JTAG" to "SWD". Then press "Debug".

     


    Now the debug session starts and you will see LEDs on the board start blinking after "Resume" button is pressed.

Hardware:
    NGX LPC4330 Xplorer Board
    ULINK-ME

Reference:     

Texas Instruments CCS (Code Composer Studio) Debug Session Error

Texas Instruments CCS (Code Composer Studio) Debug Session Error

I was trying to run one of the example project using the CC3200 launchpad and installed all the necessary tools as document explains. However, when I try to launch the debug session, it gives me dialog saying "You require a target configuration to start a debug session. Do you want to create a new target configuration file and open it in the editor?" as below.
  



When I click "No", it just close it and do nothing, and selecting "Yes" turns to the following target configuration editor.


I did not know why the sample code did not run debug session as is, but here is the solution. 

  1. Open "Target Configurations" window
    From the menu, go to "View" -> "Target Configurations". You will see a window come out right side of screen.


  2. Import the existing configuration
    Right click "User Defined" folder and select "Import Target Configuration".



    Look for "CC3200.ccxml" file under CC3200 SDK folder.
    In my case, it is located "C:\ti\CC3200SDK_1.0.0\cc3200-sdk\tools\ccs_patch



    Select the file and press "Open" and it will ask you if you copy the file or link the file.
    I just copied the file and it is copied under working space.



  3. Set the configuration as default
    Now you will see "CC3200.ccxml" under "User Defined" folder in the "Target Configurations" window. Then right click the file and select "Set as default".





    After you see the file name displayed as above, you are good to go.
    Hope this helps :) 
Hardware:
    CC3200 Launchpad
   
Summary:


Reference:     

[AKM Chip Booster] Audio ADC AK5704 PCB Design

Designing a PCB prototype with AK5704 is not so difficult and I show an example with my design. People who are not familiar with AK5704,...