7
1/7 www.ni.com 1. 2. 3. 4. 5. 6. Periodic Waveform Generation with RIO Enabled Hardware and LabVIEW FPGA Publish Date: Jan 14, 2010 | 7 Ratings | out of 5 3.71 Overview One major benefit of Reconfigurable I/O (RIO) technology is the ability to create custom hardware to generate analog waveforms for specific applications. This tutorial describes one common method for developing a customized periodic waveform generator using RIO enabled hardware (for this tutorial we are using CompactRIO) and the LabVIEW FPGA Module. For additional information about waveform generation with the LabVIEW FPGA Module and CompactRIO return to the main tutorial, " ." Waveform Generation with CompactRIO Table of Contents Periodic Waveform Description Periodic Waveform Applications with CompactRIO Periodic Waveform Generation Using Sine Generator Express VI Periodic Waveform Generation Using FPGA Memory Conclusion Periodic Waveform LabVIEW FPGA Examples 1. Periodic Waveform Description A periodic waveform is a waveform that repeats itself at regular intervals. The unit of regularity in a periodic waveform is called its cycle. The waveform shown below is a periodic sine wave that has a cycle of 50 samples. Periodic waveforms do not have to be sinusoidal and can be arbitrarily complex within the defined cycle. Figure 1. Periodic Waveform 2. Periodic Waveform Applications with CompactRIO Periodic waveforms of varying shapes, amplitudes, and frequencies are used for simulation and control of electronic devices across a broad range of industries. The most common types of periodic waveforms are sine, square, triangle, and sawtooth, used in a variety of applications for simulation and control of electronic devices . As an application example, sawtooth waveforms are often used to sweep the frequency of a second signal. By using a sawtooth waveform to drive a voltage-controlled oscillator, engineers can continuously sweep through specific frequency ranges. As another application example, square waves are used in acoustical testing. Because square waves contain only odd integer harmonics, an acoustic engineer is able to compare the actual sound pattern of an audio system they are testing with the familiar square wave pattern. In addition to sine, square, triangle, and sawtooth cycles, periodic waveforms can also contain complex waveform cycles that allow engineers to represent periodic noise or specific sound patterns. CompactRIO gives engineers and scientists a customizable, rugged, and portable solution for generating periodic waveforms. The LabVIEW FPGA Module combined with CompactRIO hardware, provides maximum hardware flexibility for engineers. As an example, for periodic waveform generation developers are able to customize their hardware so they have the ability to continuously change the update rate, gain, and waveform type as the program runs. Also, developers can customize their hardware triggering to suit the needs of their specific application. In addition, using the LabVIEW FPGA Module developers can easily define the timing and synchronization of FPGA functions on the same CompactRIO hardware without any knowledge of hardware design or low-level EDA tools. This is beneficial if an application requires the tight synchronization of waveform generation with other FPGA functionality such as digital I/O and analog input. We are able to generate periodic waveforms with CompactRIO hardware and the LabVIEW FPGA Module using several different methods. The first method involves the use of the LabVIEW FPGA Sine Generator Express VI. By using this Express VI we can quickly develop an FPGA program, download it to the target hardware, and have a fully functional sinusoidal generator with frequency and phase offset controls. The second method uses advanced functionality of the LabVIEW FPGA Module to load arbitrarily complex cycles of a periodic waveform to the FPGA memory. This tutorial outlines these two methods of periodic waveform generation in detail. 3. Periodic Waveform Generation Using Sine Generator Express VI First we will develop a simple sinusoidal waveform generator by using the LabVIEW FPGA Sine Generator Express VI. The advantage of using this Express VI is it allows us to quickly define our FPGA VI because of its built-in functionality. The Sine Generator Express VI performs all the low-level FPGA programming, such as memory reads and writes, so it is transparent to the programmer. This saves valuable development time and allows us to get our custom hardware up and running faster. This section describes how to create a sinusoidal waveform generator and also discusses the use of good programming practices to create scalable, maintainable, and robust FPGA code. Refer to the section, , to download the example program. Periodic Waveform LabVIEW FPGA Examples Defining Hardware with the LabVIEW FPGA Module The first step in developing a sinusoidal waveform generator is to program and configure the hardware by using the LabVIEW FPGA Module. The requirements of the hardware are to generate samples of a sinusoidal waveform and use an analog output channel to output the waveform. To accomplish this we will use the LabVIEW FPGA Sine Generator Express VI in combination with the LabVIEW FPGA Analog Output function. Figure 2 below, from our LabVIEW FPGA VI, Sine_Generation(fpga), shows the connections for the Express VI and the Analog Output function. We can specify the analog output channel by using the dialog box associated with the Analog Output function. In our case we are outputting the waveform to analog Configure Analog Output output channel 0 of the cRIO-9263 module. Upon every iteration of this While Loop it outputs one data point to the analog output channel listed in the Analog Output function.

Periodic Waveform Generation in FPGA

  • Upload
    nm2007k

  • View
    101

  • Download
    0

Embed Size (px)

DESCRIPTION

Periodic Waveform Generation in FPGA using labview

Citation preview

Page 1: Periodic Waveform Generation in FPGA

1/7 www.ni.com

1.

2.

3.

4.

5.

6.

Periodic Waveform Generation with RIO Enabled Hardware and LabVIEW FPGAPublish Date: Jan 14, 2010 | 7 Ratings | out of 53.71

OverviewOne major benefit of Reconfigurable I/O (RIO) technology is the ability to create custom hardware to generate analog waveforms for specific applications. This tutorial describes one common methodfor developing a customized periodic waveform generator using RIO enabled hardware (for this tutorial we are using CompactRIO) and the LabVIEW FPGA Module. For additional information aboutwaveform generation with the LabVIEW FPGA Module and CompactRIO return to the main tutorial, " ." Waveform Generation with CompactRIO

Table of ContentsPeriodic Waveform Description

Periodic Waveform Applications with CompactRIO

Periodic Waveform Generation Using Sine Generator Express VI

Periodic Waveform Generation Using FPGA Memory

Conclusion

Periodic Waveform LabVIEW FPGA Examples

1. Periodic Waveform DescriptionA periodic waveform is a waveform that repeats itself at regular intervals. The unit of regularity in a periodic waveform is called its cycle. The waveform shown below is a periodic sine wave that has acycle of 50 samples. Periodic waveforms do not have to be sinusoidal and can be arbitrarily complex within the defined cycle.

Figure 1. Periodic Waveform2. Periodic Waveform Applications with CompactRIO

Periodic waveforms of varying shapes, amplitudes, and frequencies are used for simulation and control of electronic devices across a broad range of industries. The most common types of periodicwaveforms are sine, square, triangle, and sawtooth, used in a variety of applications for simulation and control of electronic devices . As an application example, sawtooth waveforms are often usedto sweep the frequency of a second signal. By using a sawtooth waveform to drive a voltage-controlled oscillator, engineers can continuously sweep through specific frequency ranges. As anotherapplication example, square waves are used in acoustical testing. Because square waves contain only odd integer harmonics, an acoustic engineer is able to compare the actual sound pattern of anaudio system they are testing with the familiar square wave pattern. In addition to sine, square, triangle, and sawtooth cycles, periodic waveforms can also contain complex waveform cycles thatallow engineers to represent periodic noise or specific sound patterns.

CompactRIO gives engineers and scientists a customizable, rugged, and portable solution for generating periodic waveforms. The LabVIEW FPGA Module combined with CompactRIO hardware,provides maximum hardware flexibility for engineers. As an example, for periodic waveform generation developers are able to customize their hardware so they have the ability to continuouslychange the update rate, gain, and waveform type as the program runs. Also, developers can customize their hardware triggering to suit the needs of their specific application. In addition, using theLabVIEW FPGA Module developers can easily define the timing and synchronization of FPGA functions on the same CompactRIO hardware without any knowledge of hardware design or low-levelEDA tools. This is beneficial if an application requires the tight synchronization of waveform generation with other FPGA functionality such as digital I/O and analog input.

We are able to generate periodic waveforms with CompactRIO hardware and the LabVIEW FPGA Module using several different methods. The first method involves the use of the LabVIEW FPGASine Generator Express VI. By using this Express VI we can quickly develop an FPGA program, download it to the target hardware, and have a fully functional sinusoidal generator with frequencyand phase offset controls. The second method uses advanced functionality of the LabVIEW FPGA Module to load arbitrarily complex cycles of a periodic waveform to the FPGA memory. This tutorialoutlines these two methods of periodic waveform generation in detail.

3. Periodic Waveform Generation Using Sine Generator Express VI

First we will develop a simple sinusoidal waveform generator by using the LabVIEW FPGA Sine Generator Express VI. The advantage of using this Express VI is it allows us to quickly define ourFPGA VI because of its built-in functionality. The Sine Generator Express VI performs all the low-level FPGA programming, such as memory reads and writes, so it is transparent to the programmer.This saves valuable development time and allows us to get our custom hardware up and running faster. This section describes how to create a sinusoidal waveform generator and also discusses theuse of good programming practices to create scalable, maintainable, and robust FPGA code. Refer to the section, , to download the example program.Periodic Waveform LabVIEW FPGA Examples

Defining Hardware with the LabVIEW FPGA Module

The first step in developing a sinusoidal waveform generator is to program and configure the hardware by using the LabVIEW FPGA Module. The requirements of the hardware are to generatesamples of a sinusoidal waveform and use an analog output channel to output the waveform. To accomplish this we will use the LabVIEW FPGA Sine Generator Express VI in combination withthe LabVIEW FPGA Analog Output function. Figure 2 below, from our LabVIEW FPGA VI, Sine_Generation(fpga), shows the connections for the Express VI and the Analog Output function. Wecan specify the analog output channel by using the dialog box associated with the Analog Output function. In our case we are outputting the waveform to analogConfigure Analog Outputoutput channel 0 of the cRIO-9263 module. Upon every iteration of this While Loop it outputs one data point to the analog output channel listed in the Analog Output function.

Page 2: Periodic Waveform Generation in FPGA

2/7 www.ni.com

Figure 2: FGPA VI: Sine_Generation(fpga)

The dialog box, shown in Figure 3, allows us to quickly set-up our sine generator. This dialog box is automatically displayed once the Sine Generator Express VI isConfigure Sine Generatorplaced on the block diagram. Through this dialog box we are able to adjust a variety of sine wave parameters including frequency, amplitude, phase offset, look-up table size (number of samplesin each cycle of waveform), and amplitude resolution. Additionally, we can externally have access to the and parameters by selecting phase increment phase offset show increment terminaland . These terminals allow us to continually adjust the frequency and phase offset of the waveform as it is being generated. By using the following formulas we can takeshow offset terminalinputs for frequency and phase offset(degrees) and calculate corresponding values for and . phase increment phase offset

Figure 3. Sine Generator Configuration Dialog BoxThrough the LabVIEW FPGA VI, Sine_Generation(fpga), described above, we are able to quickly configure our hardware by using the LabVIEW FPGA Sine Generator Express VI. The hardwareis now able to generate individual samples of a sine wave, generate the samples on an analog output channel, and allow the user to continuously adjust the frequency and phase offset of thesignal. The cRIO-9263 Analog Voltage Output module has a minimum update period of 3 microseconds so by using this module we are able to generate a signal at a rate of 333,333updates/sec.

NOTE: Voltage Output with CompactRIO Analog Output ModulesThe LabVIEW FPGA Module utilizes integer math for all mathematical operations; therefore, analog output operations with CompactRIO must utilize the binary code representation of the desiredoutput voltage. The binary code representation of the desired voltage is determined by dividing the voltage by the code width of the module. The code width (or step size) is defined as thesmallest change in voltage that the system can output. Code width is calculated according to the following equation:

For instance, the cRIO-9263 analog output module is a 16-bit analog output module with a range of -10V to +10V. Therefore the code width of the module is .305176mV/step (20V / 2^16 steps).Therefore, to output 5.0 volts, you would need to divide 5.0 V by .305176mV. This division yields a binary value of 16384.

National Instruments has included a VI for each CompactRIO analog output module that does this conversion. This VI is named Convert to Binary (cRIO-XXXX), where XXXX is the modelnumber of the module. It is included in the cRIO-XXXX Support Files LLB located in the directory. This VI converts desired voltage values into the \examples\FGPA\CompactRIO\cRIO-XXXX\binary code representation of that voltage through the following equation:

Configuring the Host Interface

Page 3: Periodic Waveform Generation in FPGA

3/7 www.ni.com

The second step when developing a LabVIEW FPGA application is to create a host interface VI to communicate with the VI downloaded to the RIO hardware target. In the LabVIEW Real-TimeModule (or LabVIEW for Windows), there is a small set of functions for accessing the FPGA: Open FPGA Reference, Read/Write Control, Invoke Method, and Close FPGA Reference. Thesefunctions provide all of the necessary control over the FPGA, such as downloading, reading or writing data, and starting or stopping the VI. Integrating an FPGA VI into an application using thesefunctions alone, however, can make your application hard to read, hard to scale, and hard to maintain. By using these low-level functions as building blocks, however, you can create a set ofsubVIs which can function as an Application Programming Interface (API) for use in your host VI.

There are several benefits for creating an API for your LabVIEW host VI. One major benefit that an API provides is abstraction, which involves grouping low-level code into logical functions ordata stores. Creating the API greatly increases the usability of your FPGA VI by encapsulating the low-level functionality and increasing modularity of the code. Once the modules (subVIs) arecreated, you can simply place them into any LabVIEW Real-Time or LabVIEW for Windows application as functional nodes. In our example, shown in Figure 4, we have created four modules assubVIs: Open, Start, Set Controls, and Clear.

Figure 4. Top Level VI -> Sine_Generation(Host)This modular API allows us to easily modify our sinusoidal waveform VI and also create new host VIs that need the same functional building blocks. Let's investigate each of the four subVIs thatare contained in our host VI, Sine_Generation(Host).Opening and Closing the FPGA Hardware Execution Reference

Figure 5 shows the Open and Clear VIs of the API. FPGA_Sine_Open_Ref simply opens a , which is obtained from the Open FPGA Reference function.Hardware Execution ReferenceThis is then used throughout the host VI to specify the hardware target and corresponding FPGA VI. FPGA_Sine_Clear is called at the end of the host VIHardware Execution Referenceand stops the FPGA VI that is currently running on the target hardware and closes the .Hardware Execution Reference

Figure 5. Opening and Closing the FPGA Reference

Initializing and Generating the Sinusoidal WaveformFPGA_Sine_Start, displayed in Figure 6, initializes controls on the LabVIEW FPGA VI, Sine_Generation(fpga), and then runs the FPGA VI. By using the Read/Write Control function we areable to set the initial values of the two inputs on our FPGA VI, and . The subVIs PhaseOffset and PhaseIncrement implement the equations shown below byphase increment phase offsetusing Formula Nodes. This conversion allows us to input in hertz and in degrees.Frequency Phase Offset

Once these controls are set, the Invoke Method function specifies the action and the code runs continuously in the While Loop of the FPGA VI.Run

Figure 6. Starting the FPGA VI on the Target Hardware

Continuously Updating Waveform ParametersNow that the sinusoidal waveform is being generated, we can call FPGA_Sine_Set_Cntls, displayed in Figure 7, to continuously adjust the and controls.Frequency(Hz) Phase Offset(deg)To accomplish this, we first we use the subVIs PhaseOffset and PhaseIncrement to convert the and user values to and ,Frequency(Hz) Phase Offset(deg) phase increment phase offsetrespectively. Second, we use the Read/Write Control function to write these resulting values to the FPGA VI being run on the target hardware. By placing FPGA_Sine_Set_Cntls in a WhileLoop we are able to continuously poll these controls and write them to the FPGA VI as they change values. Additionally, a button is also polled in the same fashion, giving the user theStopability to stop the sinusoidal waveform generation when they desire.

Page 4: Periodic Waveform Generation in FPGA

4/7 www.ni.com

Figure 7. Updating the Controls on the FPGA VI4. Periodic Waveform Generation Using FPGA Memory

The previous section described how to use the LabVIEW FPGA Sine Generator Express VI for a fast way to create a sinusoidal function generator. This Express VI is great for applications that onlyneed a sinusoidal waveform output, but it often does not have the full functionality that the developer needs for periodic waveform generation. The Sine Generator Express VI only lets the userchange the frequency and offset period continuously as the waveform is being generated. In addition, the Express VI does not allow for generation of periodic waveforms with complex cycles. Byusing the advanced LabVIEW FPGA programming functions, Memory Read and Memory Write, we are able to take advantage of the onboard FPGA memory and create periodic waveforms withcomplex cycles. These functions allow the developer to load an arbitrarily complex waveform cycle with up to 8192 16-bit samples and continuously generate that cycle as a periodic waveform. Thissection outlines the creation of a periodic waveform generator that uses the FPGA onboard memory. Additionally, it discusses the use of good programming practices to create scalable,maintainable, and robust FPGA code. Refer to the last section, , to download the example program.Periodic Waveform LabVIEW FPGA Examples

Configuring the Hardware with the LabVIEW FPGA Module

As described in the previous section, Periodic Waveform Generation Using Sine Generator Express VI, the first step in developing a periodic waveform generator is to program and configure thehardware by using the LabVIEW FPGA Module. The requirements of the hardware are as follows:

- Write data to the FPGA memory (one cycle of the waveform)- Read data from the FPGA memory continuously- Output data to an analog output channel*- Allow the user to adjust the waveform frequency and amplitude while continuously outputting signal

* In our example we are using the cRIO-9263 16-bit Analog Voltage Output module

Since the FPGA onboard the CompactRIO hardware can only have one VI loaded at a time, we need to integrate all the above functionality into one LabVIEW FPGA VI. To accomplish this wewill use a case structure that has two cases. One case writes data to the FPGA memory and the other case reads data from the FPGA memory and outputs the waveform through the cRIO-9263module. Figure 8 below, from the LabVIEW FPGA VI Read_Write_Memory(fpga), shows the case of the case structure. The Memory Write VI within this case allows us to write one dataFalsevalue at a specified address each time Read_Write_Memory(fpga) is called. To write multiple waveform data points into the FPGA memory we must call Read_Write_Memory(fpga) multipletimes. By using the FPGA memory we can avoid the use of arrays in the FPGA code which can consume a large number of limited FPGA gates. By avoiding arrays, and having additional FPGAgates available, we have the ability to write a more complex FPGA program, resulting in increased hardware functionality.

Figure 8. False Case of FPGA VI: Writing Waveform Elements Into FPGA MemoryFigure 9 shows the case of the Read_Write_Memory(fpga) VI. The true case reads each data element of the stored waveform and outputs the corresponding voltage to an analog outputTruechannel at a specified update rate. Within this case there are three additional LabVIEW structures, a While Loop, For Loop, and Sequence Structure.Let's first take a look at the Sequence Structure which has two sequences. The first sequence has a Loop Timer that can be configured in microseconds, milliseconds, or tick counts. We havespecified microseconds in our example, giving us exact hardware timing to control the update rate at which each data point of the waveform is output. The control feeding theUpdate PeriodLoop Timer allows us to change the microsecond interval between each data point as the waveform is being generated. The cRIO-9263 has a minimum update period of 3 microseconds whenoutputting data to one analog output channel. This corresponds to a maximum update rate of 333,333 updates/sec. The second sequence of the Sequence structure has a Memory Read VIfollowed by a gain multiplication and an Analog Output function. The Memory Read VI has an input called and every time the VI is called it reads one data value in the FPGA memory atAddressthe specified address. The data is then multiplied by the integer control , and the resulting value is passed to the Analog Output function. By using the dialog boxGain Configure Analog Outputassociated with the Analog Output function, an analog output channel can be specified. In our case we are outputting the waveform to analog output channel 0 of the cRIO-9263 module. Everytime this Sequence structure executes it outputs one data point to the analog output channel list in the Analog Output function.The next structure is a For Loop that repeatedly calls the Sequence structure and outputs every data element in the waveform. The For Loop iterates a fixed number of times according to thecontrol . The iteration terminal of the For Loop tells the Memory Read VI what address to read on the current loop iteration. For example, if there are 100 elements stored# Waveform Elementsin the FPGA memory then the control would be set to 100 and the iteration terminal would start at the integer 0. The For Loop would run for 100 iterations, reading FPGA# Waveform Elementsmemory addresses 0-99 and output the data values stored at each address space. Additionally, each time the For Loop iterates it reads the two controls within the Sequence structure: Update

and . This allows the user to change the values of these controls and adjust the waveform as it is being continuously generated.Period GainThe final structure in the case is the While Loop. This allows the waveform generation to continuously repeat cycles until the button is pressed.True Stop

Page 5: Periodic Waveform Generation in FPGA

5/7 www.ni.com

Figure 9. True Case of FPGA VI: Reading Waveform Elements and OutputtingThrough the LabVIEW FPGA VI, Read_Write_Memory(fpga), described above we are successfully able to fulfill all our hardware requirements and configure our FPGA. The program is able towrite data to the FPGA memory, read data from the FPGA memory, output data to an analog output channel, and allow the user to continuously adjust the frequency and amplitude of the signal.

NOTE: Voltage Output with CompactRIO Analog Output ModulesThe LabVIEW FPGA Module utilizes integer math for all mathematical operations; therefore, analog output operations with CompactRIO must utilize the binary code representation of the desiredoutput voltage. The binary code representation of the desired voltage is determined by dividing the voltage by the code width of the module. The code width (or step size) is defined as thesmallest change in voltage that the system can output. Code width is calculated according to the following equation:

For instance, the cRIO-9263 analog output module is a 16-bit analog output module with a range of -10V to +10V. Therefore the code width of the module is .305176mV/step (20V / 2^16 steps).Therefore, to output 5.0 volts, you would need to divide 5.0 V by .305176mV. This division yields a binary value of 16384.

National Instruments has included a VI for each CompactRIO analog output module that does this conversion. This VI is named Convert to Binary (cRIO-XXXX), where XXXX is the modelnumber of the module. It is included in the cRIO-XXXX Support Files LLB located in the directory. This VI converts desired voltage values into the \examples\FGPA\CompactRIO\cRIO-XXXX\binary code representation of that voltage through the following equation:

Configuring the Host Interface

After completing our FPGA VI and configuring the hardware, we must create a host interface VI to communicate with the FPGA VI as we did when using the Express VI. In our example, shownin Figure 10, we have created five modules as subVIs: Open, Load, Start, Set Controls, and Clear.

Figure 10. Top-Level VI -> Periodic_Output_Memory(Host)This modular API allows us to easily modify our periodic waveform VI and also create new host VIs that need the same functional building blocks. Let's investigate each of the five subVIs thatare contained in our host VI, Periodic_Output_Memory(Host).Opening and Closing the FPGA Hardware Execution Reference

Just as with the our sinusoidal waveform generator example, we have Open and Clear VIs. FPGA_Periodic_Open_Ref simply opens a , which is obtainedHardware Execution Referencefrom the Open FPGA Reference function and FPGA_Periodic_Clear is used to stop the FPGA VI currently running on the target hardware and close the .Hardware Execution Reference

Figure 11. Opening and Closing the FPGA ReferenceLoading the Periodic Waveform Cycle to FPGA Memory

FPGA_Periodic_Load, displayed in Figure 12, allows us to load a waveform cycle into FPGA memory. Before going into the details and functionality of this VI we should first discuss differentmethods to create a waveform cycle. The control that sends the waveform cycle into FPGA_Periodic_Load is a dynamic data type that is converted to a 1-D array ofWaveform Inputdoubles. This gives developers the flexibility to generate and read a waveform from a variety of different formats. In our example we generate one cycle of a waveform by using the BasicFunction Generator VI. This VI allows us to generate a sine, square, triangle, or sawtooth wave and also has inputs for DC offset, frequency, amplitude, phase, and square wave duty cycle.If the developer has a more complex waveform cycle that they'd like to generate then they have several options. First, they can read a waveform from a file by using the Read LabVIEWMeasurement File Express VI which allows them to read comma or tab-delimited spreadsheet files. Second, if they have a binary or ASCII file they'd like to read a waveform cycle from, theycan use the LabVIEW File I/O functions. Finally, if the developer does not want to read a waveform from a file they can generate a waveform array in LabVIEW.

Once a waveform cycle is created or read from a file, it then needs to be loaded to the FPGA memory. Remember from our LabVIEW FPGA VI, Read_Write_Memory(fpga), we have tocontinuously call the false case to write multiple data values into memory. To do this we use a For Loop that calls a Read/Write Control function and Invoke Method on each iteration. The

Page 6: Periodic Waveform Generation in FPGA

6/7 www.ni.com

Read/Write Control function allows us to update the two controls, and , on the FPGA VI. After updating these controls, we use the Invoke Method function and specify theAddress Dataaction as to execute the FPGA VI on our target hardware. Each time the For Loop iterates it writes a data value from our Waveform Input array to the FPGA memory at the addressRunspecified by the iteration terminal. By using the LabVIEW Array Size function we are able to set the loop count terminal on the For Loop. The subVI Convert to Binary (cRIO-9263) takes aninput voltage (+-10V) and converts it to the binary code (-32768 to +32767) that is accepted by the cRIO-9263 Analog Output Module.

Figure 12. Loading the Waveform Cycle to FPGA MemoryInitializing and Generating the Periodic Waveform

FPGA_Periodic_Start, show in Figure 13, initializes controls on the LabVIEW FPGA VI, Read_Write_Memory(fpga), and then runs the FPGA VI in the true case. By using the Read/WriteControl function the we are able to set the initial values of the two controls, and . Once these controls are set, we specify the action with theUpdate Period # Waveform Elements RunInvoke Method function and the code runs continuously in the true case of the FPGA VI. Remember that this true case continuously reads data from the FPGA memory and outputs thecorresponding voltages on a specified analog output channel of the cRIO-9263 Analog Output Module.

Figure 13. Starting the FPGA VI on the Target Hardware

Continuously Updating Waveform ParametersOnce the periodic waveform is being generated, we can then call FPGA_Periodic_Set_Cntls, displayed in Figure 14, to continuously adjust the frequency and amplitude. This isaccomplished by using the Read/Write Control function to write the values of the two controls, and , to the FPGA VI being run on the target hardware. By placing this VIUpdate Period Gainin a While Loop we are able to continuously poll these controls and write them to the FPGA VI as they change values. Additionally, a button is also polled in the same fashion, givingStopthe user the ability to stop the waveform generation when they desire.

Figure 14. Updating the Controls on the FPGA VI5. Conclusion

CompactRIO gives engineers and scientists a customizable, rugged, and portable solution for periodic waveform generation. The LabVIEW FPGA Module, and CompactRIO hardware providesmaximum flexibility for the developer. In this tutorial we have outlined two methods for creating periodic waveform generators. By using the LabVIEW FPGA Sine Generator Express VI we are able toquickly design our FPGA VI and configure the target hardware. This Express VI performs all the low-level FPGA programming, such as memory reads and writes, so it is transparent to theprogrammer saving valuable development time. For more advanced periodic waveform generator functionality we use the FPGA memory. The FPGA memory can be accessed by using MemoryRead and Memory Write FPGA VIs, allowing us to create complex periodic waveform cycles. The periodic waveform generators that we outlined throughout this tutorial can be downloaded below.For additional information about waveform generation with the LabVIEW FPGA Module and CompactRIO return to the main tutorial, " "Waveform Generation with CompactRIO

See Also:Waveform Generation with CompactRIO6. Periodic Waveform LabVIEW FPGA ExamplesSee Also:Sinusoidal Waveform Generation with LabVIEW FPGA (Sine Generator Express VI)Periodic Waveform Generation with LabVIEW FPGA (Memory Read and Write)