msc12xx labview demo program—program description

13
Application Report SBAA125 – December 2004 MSC12xx LabVIEW Demo Program—Program Description Russell Anderson, Data Acquisition Products ............................. William Osipoff, Valuci Solutions Engineering ABSTRACT This application report discusses the general structure of the upper level VI, msc1210 demo app new buffer.vi. These explanations are intended for an audience who is familiar with general LabVIEW™ programming techniques. For additional reading, please refer to Application Report SBAA120 , Using the MSC12xx Demo Program (available for download at www.ti.com ). Contents 1 Overview of the Main Source Code .............................................................. 2 2 MAIN and Process Loops ......................................................................... 7 3 Some Important VIs............................................................................... 10 List of Figures 1 Load the Initialization File ......................................................................... 3 2 Finding the MSC12xx Port and Mode............................................................ 4 3 Prepare Hex File for Transmission to MSC12xx Device ...................................... 5 4 Skip Sending Hex Data ............................................................................ 6 5 Main and Process Loops .......................................................................... 8 6 MSC12xx LabVIEW Front Panel ................................................................. 9 List of Tables 1 Important VIs for the MSC12xx LabVIEW Demo Program .................................. 10 LabVIEW is a trademark of National Instruments. 1 SBAA125 – December 2004 MSC12xx LabVIEW Demo Program—Program Description

Upload: others

Post on 21-Apr-2022

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: MSC12xx LabVIEW Demo Program—Program Description

Application ReportSBAA125–December 2004

MSC12xx LabVIEW Demo Program—Program DescriptionRussell Anderson, Data Acquisition Products ............................. William Osipoff, Valuci Solutions Engineering

ABSTRACT

This application report discusses the general structure of the upper level VI, msc1210demo app new buffer.vi. These explanations are intended for an audience who isfamiliar with general LabVIEW™ programming techniques. For additional reading,please refer to Application Report SBAA120, Using the MSC12xx Demo Program(available for download at www.ti.com).

Contents1 Overview of the Main Source Code .............................................................. 22 MAIN and Process Loops ......................................................................... 73 Some Important VIs............................................................................... 10

List of Figures

1 Load the Initialization File ......................................................................... 32 Finding the MSC12xx Port and Mode............................................................ 43 Prepare Hex File for Transmission to MSC12xx Device ...................................... 54 Skip Sending Hex Data ............................................................................ 65 Main and Process Loops .......................................................................... 86 MSC12xx LabVIEW Front Panel ................................................................. 9

List of Tables

1 Important VIs for the MSC12xx LabVIEW Demo Program .................................. 10

LabVIEW is a trademark of National Instruments.

1SBAA125–December 2004 MSC12xx LabVIEW Demo Program—Program Description

Page 2: MSC12xx LabVIEW Demo Program—Program Description

www.ti.com

1 Overview of the Main Source Code

Overview of the Main Source Code

The main program consists of eight steps in a sequence structure, inside a case statement, nested withina while loop that is used to allow repeated program operation. The case statement allows the user tomake a graceful exit from the program when exit conditions are met.

The eight steps are:

• Step 0: Initialize default program variables.• Step 1: Load initialization file if found (see Figure 1).• Step 2: Search available ports for MSC device, and customize program settings for clock found (see

Figure 2).• Step 3: Prepare to send Intel hex file to MSC device, if MSC device is not in server mode (see

Figure 3).• Step 4: If MSC device is in server mode, set flags to disable hex file load in next step. If MSC device is

not in server Mode, send [cr] to MSC to force a response. (see Figure 4)• Step 5: Main Program—this is where the bulk of the program operations are performed. There are two

concurrently-executing while loops in this step. The largest loop is the Main Send / Receive Loop (attop of Figure 5) which controls the other loop. The smaller loop is used to automate the loading of theMSC device with the Intel hex data, and to send the command configuration strings to the MSC prior toeach run of the analog-to-digital converter (ADC). The smaller loop state is controlled by the Processvariable, with the ready state of that variable used to keep the configuration array updated prior tostarting each run of the ADC. The Program2 state is used to load the ADC with the configurationstrings immediately prior to collecting data.

• Step 6: Save Data File, if any data is in buffer.• Step 7: Update the configuration file, if manual switch is set.• Step 8: Repeat until True Exit variable is TRUE.

MSC12xx LabVIEW Demo Program—Program Description2 SBAA125–December 2004

Page 3: MSC12xx LabVIEW Demo Program—Program Description

www.ti.com

Overview of the Main Source Code

Figure 1. Load the Initialization File

MSC12xx LabVIEW Demo Program—Program DescriptionSBAA125–December 2004 3

Page 4: MSC12xx LabVIEW Demo Program—Program Description

www.ti.com

Overview of the Main Source Code

Figure 2. Finding the MSC12xx Port and Mode

MSC12xx LabVIEW Demo Program—Program Description4 SBAA125–December 2004

Page 5: MSC12xx LabVIEW Demo Program—Program Description

www.ti.com

Overview of the Main Source Code

Figure 3. Prepare Hex File for Transmission to MSC12xx Device

MSC12xx LabVIEW Demo Program—Program DescriptionSBAA125–December 2004 5

Page 6: MSC12xx LabVIEW Demo Program—Program Description

www.ti.com

Overview of the Main Source Code

Figure 4. Skip Sending Hex Data

MSC12xx LabVIEW Demo Program—Program Description6 SBAA125–December 2004

Page 7: MSC12xx LabVIEW Demo Program—Program Description

www.ti.com

2 MAIN and Process Loops

MAIN and Process Loops

Because this is only a high-level discussion, this report will only touch on significant features of the sourcecode. As with most LabVIEW programming, data typically enters at the left and exits at the right side ofthe loop, with branches typically parallel to one another.

MSC12xx LabVIEW Demo Program—Program DescriptionSBAA125–December 2004 7

Page 8: MSC12xx LabVIEW Demo Program—Program Description

www.ti.com

MAIN and Process Loops

Figure 5. Main and Process Loops

MSC12xx LabVIEW Demo Program—Program Description8 SBAA125–December 2004

Page 9: MSC12xx LabVIEW Demo Program—Program Description

www.ti.com

2.1 MAIN Loop

MAIN and Process Loops

Across the top of the Main Send / Receive Loop are the ACLK Register Update Statement (ARUS), theMenu Bar, and the Process Control Case (PCC) statements.

1. The Menu Bar Case Statement (MBCS) is in the Stop mode in this example.2. The Process Control Case Statement is in the Start Data Server mode (Case 16). The PCC, in addition

to setting important program variables, sets the value of the Process Variable, thereby controlling theAutomated Process Loop (APL).

3. Below the MBCS is a case statement (identified by the text, Find what server mode we are in) thatwatches the received data stream to determine whether the ADC is running or not. This casestatement sets the Server State variable, which is used to hide or show various panel controlsdepending upon the state of the ADC. The case statement controlled by the Server State variable canbe found to the left of this case statement.

4. Immediately below the ARUS is the VISA Input. This is where the data coming from the MSC12xxenters the Main Loop at each iteration. From here, routines to buffer the data until a complete line isreceived, as well as the data buffer routines, can be found by double-clicking on the output line on theright.

5. Below the VISA Input is the Server State Case Statement (SSCC). The sole purpose for this casestatement is to stop the ADC when a button is pressed on the front panel (see Figure 6).

At the left of the Main Loop are icons representing the user controls normally shown on the front panel. Ateach iteration, the value of each variable is compared with the previous iteration’s value. If a value haschanged and the ADC is in RUN Mode, the SSCC will set the Stop ADC variable to TRUE and the ADCstate will be brought out of RUN on the next iteration.

The area within the ellipse near the lower left of the main loop determines the inputs to the digital displayand the graph of the data in near real time. To the right of the ellipse is an area labeled ChartFormatting. This is where the scaling and other dynamic variations of the graph are performed, based onuser input and automated settings. Above this section is the area where the math for the Histogram isupdated.

Figure 6. MSC12xx LabVIEW Front Panel

MSC12xx LabVIEW Demo Program—Program DescriptionSBAA125–December 2004 9

Page 10: MSC12xx LabVIEW Demo Program—Program Description

www.ti.com

2.2 AUTOMATED PROCESS Loop

3 Some Important VIs

Some Important VIs

The Automated Process Loop (APL) has nine distinct states: Startup, Program1, Wait1, Program2, SendIntel HEX, Wait2, switch baud, Reset, and Ready. A brief discussion of each state follows.

• Startup: A place holder for the beginning of the States• Program1: Here, the contents of array1 are sent to the MSC12xx, a single character at a time, until

the array is emptied.• Wait1: This state is a debounce step required because of the speed of this loop. It functions merely to

set the Process variable to Program2.• Program2: If the MSC12xx device was found in Server Mode, this state sends the second initialization

array to the MSC12xx, one byte at a time, until finished. If the MSC12xx was not in Server Mode, itsends the Server Array to the device in preparation for loading the Intel hex data.

• Intel HEX: This state sends the Intel hex data to the MSC12xx device. Upon completion, it will enterthe Wait2 state prior to Switching the BAUD rate and Resetting the MSC12xx.

• Wait2: This state sets flags and causes entry into the switch baud state.• switch baud: This state causes a delay, calls for the reset state, and executes another delay.• Reset: This state sets flags for the Main Loop to issue an MSC12xx Reset command (via the Process

Control Case; see previous discussion), then calls for entry into the Ready state.• Ready: This state performs a lot of the background work of preparing the initialization strings

(contained in the Server Array) to be sent to the ADC to configure the ADC conditions prior to enteringthe ADC Run state. This is where the user input via the front panel controls is converted into thestrings that are sent to the MSC12xx immediately prior to the ADC Run.

Table 1 lists several critical VIs for executing the MSC12xx LabVIEW program.

Table 1. Important VIs for the MSC12xx LabVIEW Demo Program

send one character at a time.vi

Used to limit the pace of the data to the MSC12xx .

MSC1210 Command Replace with Index.vi

Used to replace values within the Server Array

MSC12xx LabVIEW Demo Program—Program Description10 SBAA125–December 2004

Page 11: MSC12xx LabVIEW Demo Program—Program Description

www.ti.com

Some Important VIs

Table 1. Important VIs for the MSC12xx LabVIEW Demo Program (continued)

msc1210 Calculate ADCON0.vi

msc1210 Calculate ADCON1.vi

msc1210 Calculate ADCON2 & 3.vi

msc1210 calculate time settings.vi

MSC1210 Command Find and Replace.vi

msc1210 calculate VOLTAGE from HEX.vi

The main math conversion routine from the hex values output by the ADC to binary, voltage, or temperature.

msc1210 update server array.vi

msc1210 calc RCAP2 from BAUD and FLCK.vi

msc1210 Set Hex or Temp mode.vi

Used to set flags for the VI msc1210 calculate VOLTAGE from HEX.vi. Primary input is Analog vs Temperatureselector

msc1210 buffer one line.vi

msc1210 reset ADC (serial).vi

This is used to reset the ADC between runs by toggling the port lines.

about vse2.vi

Used to track build version

msc1210 Calc Fdata Tdata and MOD Freq.vi

Calculates Fdata, Tdata, & Mod Freq from the input values of Clock Freq and ACLK.

msc1210 Calculate new ACLK.vi

msc1210 Find Server Clock.vi

This routine is a patch applied to substitute for actually calculating the Clock Frequency to use, until the hex code inthe MSC12xx units is fixed.

MSC12xx LabVIEW Demo Program—Program DescriptionSBAA125–December 2004 11

Page 12: MSC12xx LabVIEW Demo Program—Program Description

www.ti.com

Some Important VIs

Table 1. Important VIs for the MSC12xx LabVIEW Demo Program (continued)

msc12xx Allow Only Numeric.vi

MSC1210 Find DUT Server or Port and FCLK.vi

This is the routine that is used to find the MSC12xx port and what mode it is in (if any).

Clear Read Error.vi

In LabVIEW, an error often occurs if no data is found on a VISA read when doing high speed acquisition. This VIclears the error.

MSC12xx save or exit.vi

This VI is used to prompt the user whether to save the captured data or just exit the program.

MSC12xx LabVIEW Demo Program—Program Description12 SBAA125–December 2004

Page 13: MSC12xx LabVIEW Demo Program—Program Description

IMPORTANT NOTICE

Texas Instruments Incorporated and its subsidiaries (TI) reserve the right to make corrections, modifications,enhancements, improvements, and other changes to its products and services at any time and to discontinueany product or service without notice. Customers should obtain the latest relevant information before placingorders and should verify that such information is current and complete. All products are sold subject to TI’s termsand conditions of sale supplied at the time of order acknowledgment.

TI warrants performance of its hardware products to the specifications applicable at the time of sale inaccordance with TI’s standard warranty. Testing and other quality control techniques are used to the extent TIdeems necessary to support this warranty. Except where mandated by government requirements, testing of allparameters of each product is not necessarily performed.

TI assumes no liability for applications assistance or customer product design. Customers are responsible fortheir products and applications using TI components. To minimize the risks associated with customer productsand applications, customers should provide adequate design and operating safeguards.

TI does not warrant or represent that any license, either express or implied, is granted under any TI patent right,copyright, mask work right, or other TI intellectual property right relating to any combination, machine, or processin which TI products or services are used. Information published by TI regarding third-party products or servicesdoes not constitute a license from TI to use such products or services or a warranty or endorsement thereof.Use of such information may require a license from a third party under the patents or other intellectual propertyof the third party, or a license from TI under the patents or other intellectual property of TI.

Reproduction of information in TI data books or data sheets is permissible only if reproduction is withoutalteration and is accompanied by all associated warranties, conditions, limitations, and notices. Reproductionof this information with alteration is an unfair and deceptive business practice. TI is not responsible or liable forsuch altered documentation.

Resale of TI products or services with statements different from or beyond the parameters stated by TI for thatproduct or service voids all express and any implied warranties for the associated TI product or service andis an unfair and deceptive business practice. TI is not responsible or liable for any such statements.

Following are URLs where you can obtain information on other Texas Instruments products and applicationsolutions:

Products Applications

Amplifiers amplifier.ti.com Audio www.ti.com/audio

Data Converters dataconverter.ti.com Automotive www.ti.com/automotive

DSP dsp.ti.com Broadband www.ti.com/broadband

Interface interface.ti.com Digital Control www.ti.com/digitalcontrol

Logic logic.ti.com Military www.ti.com/military

Power Mgmt power.ti.com Optical Networking www.ti.com/opticalnetwork

Microcontrollers microcontroller.ti.com Security www.ti.com/security

Telephony www.ti.com/telephony

Video & Imaging www.ti.com/video

Wireless www.ti.com/wireless

Mailing Address: Texas Instruments

Post Office Box 655303 Dallas, Texas 75265

Copyright 2005, Texas Instruments Incorporated