# myRIO LED PWM Sample Project

This sample project can be used as a replacement for the default myRIO FPGA personality. All of the exsisting functionality is reproduced, in addition the ability to control the brightness of the onboard LEDs has been added. The starting code in RT Main.vi demonstrates fading of the onboard LEDs using the myRIO LED PWM API functions.

## Running This Application

1. In the Project Explorer window, open RT Main.vi.
2. Click Run for RT Main.vi.
3. Watch the onboard LEDs fade in and out.
4. Click Stop in RT Main.vi to stop the App.
5. Modify RT Main.vi to utilize the PWM API functions.

## System Requirements

### Development System

- LabVIEW Full or Professional Development System
- LabVIEW for myRIO Module
- LabVIEW Real-Time Module

### Hardware

- NI myRIO 1900
- NI myRIO 1950 (with recompilation)

## Getting Support for myRIO Tilt Sensor App

The myRIO Tilt Sensor App is provided free and open source. As such, it is not supported explicitly. For support running this application, post to the NI myRIO Forums or visit NI myRIO Support.

## Overview

This template uses a Flat Sequence structure that executes the following three frames from left to right:

1. Initialize—Initializes the application. Use this frame to initialize user interface elements like controls and indicators, variables, and the NI myRIO hardware. Initialization is not required for every application.
2. Acquire and process data—Acquires data from the NI myRIO and processes the data for presentation. The While Loop repeats the code until you click Stop or an error occurs.
3. Close—Cleans up user interface elements and variables, and resets the hardware output values to zero before the application exits. Closing code is optional.

## Modifying This Template

### Determining Your Needs

Before you customize this template for your own application, ask yourself the following questions:

- What kind of I/O channel will this application need to access? The answer to this question determines the myRIO VIs you need to use.
- What kind of data will this application need to access? The answer to this question determines what data you initialize in the Initialize frame.
- What are some errors that could occur, and how should the application respond to these errors? The answers to these questions determine the amount of error handling you need.

### Controlling the Order of Execution

This template uses the Flat Sequence structure to execute frames from left to right when all data values wired to a frame are available. The data leaves each frame as the frame finishes executing. Use sequence structures sparingly when you modify this template. Rely on data dependency or flow-through parameters to control the order of execution.

### Adding Initialization Code

In the Initialize frame, add code that initializes your application. For example, you may want to initialize the data to specific values, open a file for logging, and so on.

### Modifying the Data Acquisition and Processing Code

By default, this template uses Express VIs to acquire acceleration data from the onboard accelerometer and displays the acceleration values on a waveform chart. You can add your own code to acquire data from the NI myRIO and process the data based on your application needs. The LabVIEW for myRIO Module provides Express VIs and advanced I/O VIs for you to access I/O channels and the onboard devices.

### Adding Closing Code

In the Close frame, add code that executes after the data acquisition and processing is complete but before the application exits. Closing code commonly accomplishes the following tasks:

- Frees memory by closing any open references
- Flushes any buffers in use
- Resets the NI myRIO hardware

| Note The use of the Reset myRIO VI must be after the completion of all operations with the NI myRIO I/O channels. Otherwise, the Reset myRIO VI might return unexpected results.

### Modifying Error Handling

By default, this template stops if the Express VIs return an error or when you click the Stop button. When you customize this template, you can use the error in and error out clusters in each VI you use to pass the error information through the VI. If you want to ignore errors, you can remove the OR Function and wire the Stop button directly to the conditional terminal of the While Loop.

## LabVIEW Features and Concepts Used

- Flat Sequence Structures
- Shift Registers
- Wait Functions
- Waveform Charts
- While Loops

## Important Information

Copyright

© 2013 National Instruments. All rights reserved.

Under the copyright laws, this publication may not be reproduced or transmitted in any form, electronic or mechanical, including photocopying, recording, storing in an information retrieval system, or translating, in whole or in part, without the prior written consent of National Instruments Corporation.

National Instruments respects the intellectual property of others, and we ask our users to do the same. NI software is protected by copyright and other intellectual property laws. Where NI software may be used to reproduce software or other materials belonging to others, you may use NI software only to reproduce materials that you may reproduce in accordance with the terms of any applicable license or other legal restriction.

End-User License Agreements and Third-Party Legal Notices

You can find end-user license agreements (EULAs) and third-party legal notices in the following locations after installation:

- Notices are located in the <National Instruments>\_Legal Information and <National Instruments> directories.
- EULAs are located in the <National Instruments>\Shared\MDF\Legal\license directory.
- Review <National Instruments>\_Legal Information.txt for information on including legal information in installers built with NI products.

Trademarks

Refer to the NI Trademarks and Logo Guidelines at ni.com/trademarks for information on National Instruments trademarks. Other product and company names mentioned herein are trademarks or trade names of their respective companies.

Patents

For patents covering the National Instruments products/technology, refer to the appropriate location: Help»Patents in your software, the patents.txt file on your media, or the National Instruments Patent Notice at ni.com/patents.