From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Example Code

Moving Message Board Example Code

Code and Documents

Attachment

Summary:

The goal of the initial program (“MMB.vi”) was to make a LabVIEW implementation of a moving message board (like a marquee board) to display and scroll changing information to test operators who were positioned some distance from a computer monitor.  I progressed to displaying and scrolling a message after first figuring out how to display a random pattern, scroll a point, and then scroll a column. To display a message, I needed to be able to define how each character looked.  So I created “Character Maker.vi”, which allowed me to create or edit characters easily, and to generate the information needed to define each character in the configuration file.  Initially (i.e. in Version 3 and prior) “MMB SubVI.vi” allowed a message to be displayed and scrolled in a window without any of the “MMB.vi” controls being visible.  Version 4 adds significant functionality as the following modes of operation are now available: displaying a non-scrolling message, displaying a message which fades in or fades out, displaying a blinking message, displaying a message that appears to fly up from the bottom or fall down from the top, displaying a message which dissolves in or dissolves out, and displaying a random pattern.   “Test and Make Batch.vi” allows the user to change modes of operation and parameters to test out how the moving message board will perform.  If desired, an array can be created which will store sets of operation modes and corresponding parameters.  This array can be written to a file (called a batch parameters file) which can then be processed by the “Run Batch.vi” program to process each set of operation modes and corresponding parameters to create a moving message board display with multiple modes of operation.  An example of this and of all the features can be observed in this four minute video: http://www.youtube.com/watch?v=GBUuUzIXmVg.

There is no magic to these programs or any monumental breakthroughs in LabVIEW coding.  It is just a fun way to use LabVIEW to simulate something we all have seen, a moving message board.  I believe it is a novel approach in that it allows the user to create the character set to be used.  This allows the freedom to make the moving message board display anything that can be represented by an array of Boolean LED’s, not just the ASCII characters.  The other novel thing to be noted is the use of an integer to represent a column of Boolean LED’s.  This makes the “bookkeeping” in the code easier and allows the configuration file to be streamlined.

As I see it, there are the following shortcomings to the code:

  1. I used stacked sequence structures in the “MMB.vi” code for the “1 point” and “column” displays so that the display would be cleared correctly when required.
  2. There is minimal use of subVI’s.  I could have made better use of subVI’s, especially in the “MMB SubVI.vi” program, but chose not to so that I could see the flow of the logic in the code in one area without having to constantly open up subVI’s.  The block diagram can be viewed by only scrolling sideways, though.
  3. Error trapping or handling is not complete, but is much better than in previous versions.  The good thing is that there are not many places where the code could create errors.  For example, if the message to be displayed contains characters that are not defined in the configuration file it will simply not display them.  Also, if the configuration file does not exist, it is created, which does not throw an error, but also does not display the message since the characters are not defined in the new configuration file.
  4. Some of the terminal locations on the “MMB SubVI.vi” icon/connector were moved, and there were other terminals added to account for the additional features.  I apologize to users who have downloaded previous versions because the new version of “MMB SubVI.vi” will probably break code if inserted without redoing some connections.  Hopefully, though, the added features will compensate for the frustration encountered.  If not, I’ll give you a full refund. 🙂

Function:

  1. MMB.vi (Moving Message Board):
    1. INTRODUCTION:  This program will display a message on the moving message board display based on the user's input.  It simulates a moving message board made up of an array of LED's or lights.  The user can cause it to display a random pattern of Boolean LED's either turned off or on,  a single Boolean LED point scrolling across the display from right to left, a scrolling column of Boolean LED's that can individually be turned on or off, or the message that is entered into the Message control.  Any of these options can be repeated as many times as desired by toggling the "Repeat" Boolean Control.  There is also a "Milliseconds to Wait" control, which adjusts the scrolling delay so that the scrolling looks smooth.  Foreground and background colors can be changed via color box controls.
    2. DISPLAYING A MESSAGE:  If the user chooses to display a message, a configuration file is used which defines how the ASCII characters in the message look.  This configuration file can be created with the help of the "Character Maker.vi", which allows the user to edit a 17x17 array of Boolean LED's and then generate the key-value pairs to be used in the configuration file to define a given character.  The configuration file defines how each character in the "Message" box gets displayed.  It can be used to make the letters look different (like using a different font) or could be used to make the letters look like something different entirely.  For example, you could make the letter "A" display a picture of a fish.
  2. Character Maker.vi: This program is used to design characters and then generate the corresponding key-value pairs to enter into the configuration file under a corresponding section.  So, when the user requests a given character to be scrolled across the Moving Message Board display, the corresponding key-value pairs will be read from the configuration file and processed to produce the scrolling letter.  The program has the ability to load the key-value pairs from an existing character (a section in the configuration file), and then display the corresponding character in the Character array.  At this point, the Character array can be modified and a new set of key-value pairs can be generated, if desired.  Of course the Character array can be used to make any design, not just the characters from the keyboard.  The user could, for example make a picture of a fish in the Character array and map that to the letter "A".
  3. MMB SubVI.vi:
    1. INTRODUCTION: This program is a subVI implementation of the Moving Message Board program.  It simulates a moving message board made up of an array of LED's or lights.  It has multiple modes of operation.
    2. REQUIREMENTS: The calling VI should pass the following inputs to it: the path of the configuration file, a string with the message to be displayed, an integer with the delay time, an integer with the repeat or hold value, and an enum with the operating mode.
    3. RECOMMENDED: The following can be passed if desired, but this is not required: a cluster with the "on" color of the LED's in the display, a cluster with the "off" color of the LED's in the display, a cluster containing the LED width and height, and a cluster containing the display size width and height (based on number of LED's in the array).
  4. Test and Make Batch.vi:  This program has two purposes as follows:
    1. Firstly, it tests the functionality of "MMB SubVI.vi", which is a subVI implementation of "MMB.vi", the Moving Message Board VI. The user defines the parameters in the top section of the front panel.  The parameter set can be tested to ensure proper operation via the "Test" button.  When the "Test" button is clicked, it will pass the following inputs to the subVI: the path of the configuration file (a required input), a string with the message to be displayed (a required input), an integer with the delay time (a required input), an integer with the repeat or hold value (a required input), a cluster with the "on" color of the LED's in the display (a recommended input), a cluster with the "off" color of the LED's in the display (a recommended input), an enum with the operating mode (a required input), a cluster containing the LED width and height (a recommended input), and a cluster containing the display size width and height (based on number of LED's in the array, a recommended input).
    2. The second purpose of this program is to build a batch file with each row being a set of parameters to be used via the "Run Batch.vi" and "MMB SubVI.vi" files.  The user defines the parameters in the top section of the front panel.  The parameter set can be tested to ensure proper operation via the "Test" button.  When the parameters are correct, the "Generate Line" button will transfer them to the batch parameters array in the lower section of the front panel.  The "Delete Last Line" button will remove the last line from the batch parameters array.  The "Clear All" button will completely clear the array.  The "Load File" button will load an existing batch parameters array and display it.  The "Write File" button will write the batch parameters array to a file.  The "Stop" button will end program execution.
  5. Run Batch.vi: The purpose of this VI is to run a batch parameters file.  The user should simply enter the path and filename of the batch parameters file and then click the "Run Batch" button.  The "Stop" button can be used to end execution of the program.  On the coding side, the program will read in the batch parameter file, which will typically be a tab-delimited text file (if it was made with the "Test and Make Batch.vi" program).  The file is read into a 2-D array of strings and then a for-loop is used to strip out one row of the batch parameters array at a time.  Each separate parameter is stripped out of that row, and then converted into the data type required by the "MMB SubVI.vi" program.  The parameters are then sent to the "MMB SubVI.vi", it executes, and then the next row from the 2-D string array is processed until all rows have been sent and executed.
  6. MMB.ini: This is the configuration file which is used to generate the characters in the Moving Message Board programs. Each section defines an individual character, with the section name being the corresponding ASCII code.  For example, the capital letter “A” is ASCII value 65.  Under each section is a number of key-value pairs which define how each character is going to be displayed.  However many columns of Boolean LED’s are used to define the character, that is how many key-value pairs there will be, and the key names will start with “a” and proceed up the alphabet to an ending letter as required by the number of used columns.  A maximum of 17 columns (corresponding to letter “q”) can be used.
  7. There are other support VI’s (i.e. subVI’s) which are used in the VI’s mentioned above and which do not function on their own.  They are as follows: “Non-Functioning.vi”, “Too Big.vi”, and “Too Many Characters.vi”.

Steps to execute code:

  1. Unzip the “Moving Message Board.zip” file and run the desired VI.
  2. For “MMB.vi”:
    1. Click the “Random” button to display a random pattern of Boolean LED’s either turned off or on.
    2. Click the “1 Point” button to see a single Boolean LED point scrolling across the display from right to left.  You can adjust the slider to change the point’s position.
    3. Click the “Column” button to see a scrolling column of Boolean LED’s that can individually be turned on or off.
    4. Enter a message in the “Message” control and then click the “Display Message” button to scroll the message across the display.  This requires the characters you use in your message to be defined in the configuration file, which is identified in the “Config Path” control.
    5. Any of the above options can be repeated as many times as desired by toggling the “Repeat” Boolean Control.
    6. There is also a “Milliseconds to Wait” control, which adjusts the scrolling delay so that the scrolling looks smooth.
    7. LED On Color and LED Off Color can be changed via color box controls.
    8. Click the “STOP” button to end program execution.
  3. For “Character Maker.vi”:
    1. Click the LED’s in the Boolean Character array to turn them on/off and design how the character will appear in the moving message board display.
    2. Click the “Make Config” button to translate the 17-column Character array into up to 17 rows of key-value pairs in the String indicator.
    3. Copy these key-value pairs and paste them into the configuration file under the appropriate section to define how the character will appear in the moving message board display.
    4. Alternatively, click the “Load Config” button to load an existing set of key-value pairs from the specified configuration file and display the pairs in the String indicator.  This will also display the appropriate character in the Character array.
    5. Use the “Clear” button to clear both the Character array and the String indicator.
  4. For “MMB SubVI.vi”:
    1. Call “MMB SubVI.vi” as a subVI from another VI.  An example of this is done in “Test and Make Batch.vi.”
    2. Pass the required inputs to the subVI.  These include the following:
      1. Configuration file path.
      2. Message to be displayed.
      3. The delay time.
      4. The repeat/hold value.
      5. The mode of operation.
    3. Optionally, pass any recommended inputs to the subVI.  These include the following:
      1. LED on color.
      2. LED off color.
      3. The LED width and height.
      4. The display size width and height (based on number of LED's in the array).
  5. For “Test and Make Batch.vi”:
    1. Use the portion of the front panel above the dark horizontal line to test the performance of a set of parameters.  Alter any of the parameters above the line and click the “TEST” button to see how they would perform.  Clicking the “TEST” button simply sends all the parameters to the “MMB SubVI.vi” program and runs it.
    2. The portion of the front panel below the dark horizontal line is used to create or edit a batch parameters file as follows:
      1. Click the “Generate Line” button to transfer the parameters above the dark horizontal line into the last line of the array.
      2. Click the “Delete Last Line” button to remove the last line in the array.  This can be done multiple times, and can even be used to delete the header row.  If this happens, please click the “Clear All” button (see below) to replace the header row, as the row is required for the “Run Batch.vi” program for function correctly.
      3. Click the “Clear All” button to clear the array, except for the header information.
      4. Click the “Load File” button to load an existing batch parameters file into the array.
      5. “Click the “Write File” button to write the existing array to a batch parameters file.
      6. Click the “STOP” button to end program execution.
  6. For “Run Batch.vi”:
    1. Enter the path and filename of the batch parameters file, or click the browse button to find the path and filename.
    2. Click the “Run Batch” button and the program will read the batch parameters file and send each line’s parameters to “MMB SubVI.vi” to execute, one line at a time.

Other Example Code Used:

Portions of the following example code submissions were used in the Moving Message Board code:

  1. Programmatically Read Monitor Resolution: http://decibel.ni.com/content/docs/DOC-8371.  This is used at the start of the “MMB SubVI.vi” program to determine the monitor resolution of the monitor that will display the moving message board.
  2. How to Return the Index of a Mouse Select Array Element: http://decibel.ni.com/content/docs/DOC-6406.  This is used at the start of the “MMB SubVI.vi” program to determine the left, right, top and bottom coordinates of the moving message board display front panel.
  3. Programmatically Set Front Panel Size and Position: http://decibel.ni.com/content/docs/DOC-13727.  This is used at the start of the “MMB SubVI.vi” program to set the moving message board display front panel size to the minimum required and to center it in the primary display.
  4. Playlist Shuffler: http://decibel.ni.com/content/docs/DOC-13704.  This is used to randomize the 2-dimensional integer array used in the “Dissolve In” and “Dissolve Out” modes of operation in the “MMB SubVI.vi” program.

Screenshots:

MMB.vi:

MMB.jpg

Character Maker.vi:

Character Maker.jpg

MMB SubVI.vi:

MMB SubVI.jpg

Test and Make Batch.vi:

Test and Make Batch.jpg

Run Batch.vi:

Run Batch.jpg

MMB.ini:

Config File.jpg

VI Snippet:

The only code that is useful as a snippet is the code to call "MMB SubVI.vi".  Here it is, using front panel controls for the inputs:

MMB Sub.png

VI attached below...

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
GRamy
Member
Member
on

Great effort, really good application... i liked it

AlphaTreo
Member
Member
on

Thanks!  I was really hoping people would download this code and make more character sets.  If you use it and do so, please upload the new character set here.

Himanshu_Goyal
Active Participant
Active Participant
on

Good Job....

Thanks and Regards
Himanshu Goyal | LabVIEW Engineer- Power System Automation
Values that steer us ahead: Passion | Innovation | Ambition | Diligence | Teamwork
It Only gets BETTER!!!
AlphaTreo
Member
Member
on

Thanks!  Do you have an application to use this program for?

Contributors