element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
RoadTests & Reviews
  • Products
  • More
RoadTests & Reviews
Review Blogs LED Road Test - Launchpad user interface - Blog 5 - Dec 19
  • Blogs
  • RoadTest Forum
  • Documents
  • RoadTests
  • Reviews
  • Polls
  • Files
  • Members
  • Sub-Groups
  • More
  • Cancel
  • New
Join RoadTests & Reviews to participate - click to join for free!
  • Share
  • More
  • Cancel
  • Author Author: gpolder
  • Date Created: 19 Dec 2015 9:06 PM Date Created
  • Views 286 views
  • Likes 4 likes
  • Comments 1 comment
Related
Recommended
  • msp430fr4133
  • terminal
  • usb_serial_controller
  • user_interface
  • ledroadtestplus
  • launchpad

LED Road Test - Launchpad user interface - Blog 5 - Dec 19

gpolder
gpolder
19 Dec 2015

Previous Posts:

TI and Würth Elektronik LED RoadTest+ application and un-boxing - Blog 1 - Nov 10

LED Road Test - Software issues - Blog 2 - Nov 26

LED Road Test - LED PCB issues - Blog 3 - Dec 5

LED Road Test - Some words on timing - Blog 4 - Dec 15

 

Related links:

search for a PCB for Würth power leds

LED_RoadTest_Unboxing

 

Introduction

In my previous post I explained that I need six parameters for the flash controller. I decided to make a simple trial protocol so that the flash controller can be operated over a USB serial link. In the future the LaunchPad can eventually be extended with a WiFi boosterpack and IoT interface, but since that is nit the initial goal of this project, for the time being I will stick to a simple serial connection.

List of parameters:

  1. flash duration
  2. flash delay
  3. trigger duration
  4. trigger delay
  5. interval
  6. internal/external trigger

 

The delay and duration as well as the interval values are given in microseconds [us]. Since a large range is needed for these values they are declared as long integer, which is 32 bit on the MSP430. The trigger is just on or off, so we use a bool here.

 

Code

Below you find the code for the user interface. Be aware that it currently only is the user interface, no further functionality is implemented. Only the values mentioned above can be set from a command line. Also some functions for help an showing the status are implemented.

 

// Flash Controler using MSP430FR4133 LaunchPad
// (c) Gerrit Polder, 2015


String Command;
String Parameter;
long flash_duration = 0;
long flash_delay = 0;
long trigger_duration = 0;
long trigger_delay = 0;
long interval = 0;
bool external_trigger = false;


void establishContact() {
    Serial.println();
    Serial.println("  _____ _           _                          ");
    Serial.println(" |  ___| | __ _ ___| |__                       ");
    Serial.println(" | |_  | |/ _` / __| '_ \\                      ");
    Serial.println(" |  _| | | (_| \\__ \\ | | |                     ");
    Serial.println(" |_|___|_|\\__,_|___/_| |_|       _ _           ");
    Serial.println("  / ___|___  _ __ | |_ _ __ ___ | | | ___ _ __ ");
    Serial.println(" | |   / _ \\| '_ \\| __| '__/ _ \\| | |/ _ \\ '__|");
    Serial.println(" | |__| (_) | | | | |_| | | (_) | | |  __/ |   ");
    Serial.println("  \\____\\___/|_| |_|\\__|_|  \\___/|_|_|\\___|_|   ");
    Serial.println("\nSerial command shell v1.0");
    Serial.println("Copyright (c) 2015 Gerrit Polder");
    Serial.println("__________________________________________\n\n");
}


void help(){
    Serial.println();
    Serial.println("Serial command shell v1.0");
    Serial.println("Copyright (c) 2015 Gerrit Polder");
    Serial.println("help - This help info");
    Serial.println("reboot - Resets variables to their initial values");
    Serial.println("status - Displays status information");
    Serial.println("flashduration val - set flash duration val [us]");
    Serial.println("flashdelay val - set flash delay val [us]");
    Serial.println("triggerduration val - set trigger duration val [us]");
    Serial.println("triggerdelay val - set trigger delay val [us]");
    Serial.println("flashdelay val - set flash delay val [us]");
    Serial.println("externaltrigger [on/off] - set external trigger");
    Serial.println("interval val - set interval val [us]");
}


void reboot(){
  setup();
}


void status(){
    Serial.println();
    Serial.println("Flash: duration: " + String(flash_duration) + " [us] delay: " + String(flash_delay) + " [us]");
    Serial.println("Trigger: duration: " + String(trigger_duration) + " [us] delay: " + String(trigger_delay) + " [us]");
    if (external_trigger) {
        Serial.println("External trigger");
    } else {
        Serial.println("Interval: " + String(interval) + " [us]");
    }
}


void set_external_trigger(String Par) {
    if (Par.equals("on")) {
        external_trigger = true;
    } else if (Par.equals("off")) {
        external_trigger = false;
    }
}



void invalid_input(){
   Serial.println("Error in input command. Type ""help"" for available commands.");
}


void setup() {
        // start serial port at 9600 bps:
        Serial.begin(9600);
        establishContact();  // send the fun initialization data OUT; and wait for a keypress
}


void loop() {
    Command = "";
    Parameter = "";


    Serial.print("\n> ");
    while (Serial.available() == 0){} //Loop until some serial data is recieved.


    char command_temp = 0;
    bool read_parameter = false;

    while (command_temp != '\r' && command_temp != '\n'){
      while (Serial.available() < 1){}
      command_temp = Serial.read();
      Serial.print(command_temp); // echo
        if (command_temp <= 32){
          //This is the end of the base command, and the start of arguments
          read_parameter = true;
        } else if (read_parameter){
            Parameter = Parameter + command_temp;
        } else {
            Command = Command + command_temp;
        }
    }


    if (Command.equals("status")){
        status();
    } else if (Command.equals("help")){
        help();
    } else if (Command.equals("reboot")){
        reboot();
    } else if (Command.equals("flashdelay")){
        flash_delay = Parameter.toInt();
    } else if (Command.equals("flashduration")){
        flash_duration =  Parameter.toInt();
    } else if (Command.equals("triggerdelay")){
        trigger_delay = Parameter.toInt();
    } else if (Command.equals("triggerduration")){
        trigger_duration = Parameter.toInt();
    } else if (Command.equals("externaltrigger")){
        set_external_trigger(Parameter);
    } else if (Command.equals("interval")){
        interval = Parameter.toInt();
    } else if (Command.equals("")) {
        //no command, do nothing
    }
    else {
      invalid_input();
    }
}

 

 

Screen recording

Here is how this looks like when you connect to the LaunchPad using a serial console. In this case the Mac OS X screen function is used from a terminal window. Similar software on other platforms, such as hyperterm on windows will also do the job.

 

This video is unavailable.
You don't have permission to edit metadata of this video.

 

My LED PCBs are arrived, I'm planning to describe my experiences with them in the next blog.

stay tuned.

  • Sign in to reply
  • tomaja
    tomaja over 10 years ago

    Nice!

    I still didn't get my PCBs, hopefully I will soon.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube