Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Using the UNIX Console Target with the LabVIEW Embedded Development Module

2 ratings | 5.00 out of 5
Print

Overview

This tutorial takes you through the steps necessary to build, run and debug an application running on the UNIX Console target included with the LabVIEW Embedded Development Module. This will allow you to test applications and demonstrate front-panel debugging without having a hardware target present. The instructions here assume you already have LabVIEW 8.20 and the LabVIEW Embedded Development Module installed.

Installing and Configuring Cygwin

Cygwin is a UNIX emulation environment for Windows that includes a selection of tools to provide a UNIX-like working environment. In order to target the UNIX console from LabVIEW Embedded it is first necessary to install Cygwin.

  1. Download and run the Cygwin setup from the following website:
    http://www.cygwin.com/setup.exe
  2. When prompted for a download source select “Install from Internet”, click next.
  3. On the next setup screen leave the default settings for Root Directory, Install For All Users and Default Text File Type, click next.
  4. Select a local directory to store the downloaded installation files, click next.
  5. If you need to configure a web proxy you can do so on this page, most people will simply leave Direct Connection selected and click next.
  6. Select a mirror near you then click next.
  7. The installer will download a list of packages and then ask you to select which packages to install.

    Cygwin Setup - Select Packages

    1. Click View once to switch to the full view.
    2. Click once of the rotating arrow symbol to the left of each of the following packages:
      • gcc
      • make
      • sharutils
      • tclck
      • wget
      If you plan on using the optional Eclipse integration feature you will also need to install gdb.
  8. Click next to begin the download and installation of the selected packages.
  9. Click Finish to complete your Cygwin installation.
  10. Add Cygwin to the PATH System Variable.
    1. Click Start >> Settings >> Control Panel.
    2. Choose System.
    3. Under the Advanced tab click Environment Variables button.
    4. Edit the PATH “System Variable” by highlighting it and clicking the Edit button.
    5. Append C:\cygwin\bin; to the PATH system variable.

      Edit System Variable

Building a Simple Embedded Application

  1. Launch LabVIEW 8.20
  2. Create a new project by clicking “Empty Project”

    New

  3. Right click on the project and choose New >> Targets and Devices…

    Add Targets and Devices on Untitled Project

    Here you will see a list of all the example targets that ship with the LabVIEW Embedded Development Module. For the purposes of this example select Unix Console and click OK.
  4. Right click on the newly created Unix Console target and select New » VI.

    Project Explorer

    This will add a new VI to your project and open it ready for editing. Save your project by selecting File >> Save As.
  5. Now you are ready to write your application.

    Block Diagram

    1. Right click on the block diagram to bring up the Functions Palette and select Structures >> Timed Loop >> Timed Loop. Each timed loop spawns a new thread and has an independent loop rate and thread priority. Change the loop period to 200 ms by double clicking the timed loop to bring up the configuration dialog and changing the period value.

      Configure Timed Loop

    2. Next add an Elemental I/O Node by selecting Elemental IO >> EIO Node from the Functions Palette. The Elemental I/O node provides a hardware abstraction layer for I/O so that the programmer does not have to worry about low level details. For now select AI1 and click Add. As the Unix Console does not have any physical I/O ports we will configure the behavior of this simulated I/O later.

      New Elemental I/O

      Right click on the newly created EIO node and select Properties. The Array/Scalar property should be set to Array, Array size and Sample Frequency to 1000 and Type should be Raw binary.

      Elemental I/O Node Properties

    3. The Inline C Node allows you to include your own C code in your LabVIEW Embedded Application. You can insert an Inline C Node by selecting Structures >> Inline C Node from the Functions Palette.

      Inline C Node

      To pass a value from the block diagram to your C code, right click on the border of the Inline C Node and select “Add Input”. Double click inside the input to name the value – in this case just call the value i. Add the C statement printf(“Iteration %d\n”,i); to print out the iteration number of the loop.
    4. Add some signal processing by selecting Signal Processing >> Filters >> Bessel from the Functions Palette. Wire the output of the Elemental I/O Node to the input of the Bessel filter. Create a constant of 1000 for the sampling frequency input and create a control for the low cutoff freq. Finally build an array consisting of the original AI1 signal and the output of the filter and connect the resulting array to a Waveform Graph.

      Signal Processing

    5. Configure your front panel so that the Waveform Graph indicator and low cutoff freq: fl control line up. You may also want to replace the default numeric control with a horizontal pointer slide.

      Front Panel

      Save your VI by pressing Ctrl + S.
  6. Return to the project explorer and configure the simulated IO by expanding the Analog Input folder and right clicking on AI1 and selecting Properties

    Project Explorer

    This will bring up the IO Node Project Panel where you can set the ADC and waveform attributes. For this example set Waveform Freq. to 4, Voltage Range to 5, ADC Bits to 3 and Waveform type to Sine.

    Elemental I/O Properties

  7. Before you can build you application you must first configure the Build Specifications. In the project explorer right click on Build Specifications under the Unix target and select New >> Console Application.

    Project Explorer

    This will bring up the Console Build Specifications Properties dialog. For now we will leave the default settings for everything on the Application Information page. Click on Source Files and add “Filter Example.vi” as the Top-level VI.

    Unix Console Build Specification Properties

    Then click OK to confirm your settings.
  8. To build the project, right click the build specification and choose Build. This will generate C Code and pass it through to the Cygwin gcc compiler.
  9. To run the project without debugging, click the Run arrow on the VI. This will start the console application, but the LabVIEW front panel will not update. This is because “Run” for an embedded application only starts the embedded application, but it does not connect back to LabVIEW for embedded debugging.

    Console Window

  10. Close the console window. In order to have our embedded application connect back to LabVIEW for debugging you must enable debugging in the build specifications. Right click on your Console Application’s Build Specifications and select properties to return to the Build Specification Properties dialog. This time change the Build Configuration to Debug and Debug mode to Instrumented Debugging.

    Unix Console Build Specification Properties

    Click OK to confirm your changes.
  11. Right click the build specification and choose Debug. This will begin to update the front panel. We can see in white that we have out 3-bit data in white and the filtered signal in red. Moving the slider will alter the cutoff frequency of the filter, and you can see that the higher the cutoff, the sharper the edges get.

    Front Panel



Additional Resources

Downloads

unix_console_example.zip

2 ratings | 5.00 out of 5
Print

Reader Comments | Submit a comment »

 

Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).