The following components are needed for this exercise (See Figure 1): ... This
exercise will use the default configuration of the LabVIEW application. 3.
Richard Haberkamp
Nikolas Roosevelt
A Practical Exercise for the ADC Janusz Zalewski, Ph. D CDA 4170, Data Acquisition & Control Spring 2009
Table of Contents 1. Equipment Connectivity
3
1.1 Required Hardware
3
1.2 Hardware Interfaces
3
4
2.1 Required Software
4
2.2 Running LabVIEW
4
2.3 Configuring LabVIEW
6
6
6
3.2 Configuring ADC VI
7
3.3 ADC Commands
9
2. System Software
3. Application
3.1 Opening ADC VI
4. References
11
5. Appendix
12
1. Equipment Connectivity 1.1 Required Hardware
The following components are needed for this exercise (See Figure 1):
SuperLogics ADC‐1 [1]
Some device to interface with the ADC‐1 (such as a battery pack)
Computer, such as a PC or Laptop, which must have an available serial port to interface with the Superlogics ADC‐1 and must also meet the minimum requirements of LabVIEW as detailed in Table 1. Table 1: LabVIEW System Requirements [2]
1.2 Hardware Interfaces To properly set up the equipment for this exercise, the user is required to connect the components as shown in Figure 1:
SuperLogics ADC‐1
Battery Pack Power Supply
Electrical Outlet
Serial (RS‐232) Connection
Computer
Figure 1: Hardware Setup 2. System Software To perform this exercise, the user is expected to have National Instruments’ LabVIEW 8.6 already installed on their computer.
Step 1: Left‐click on the Start menu button (see Figure 2).
To run the LabVIEW application, the user can follow these steps:
Figure 2: Start Menu Button
Step 2: Navigate through the Start menu. The default Start menu path of the application is Programs ‐> National Instruments ‐> LabVIEW 8.6 ‐> LabVIEW, as shown in Figure 3.
Figure 3: Locating LabVIEW in the Start Menu
Step 3: After the splash screen, you will be presented with the main dialog of LabVIEW, as shown in Figure 4.
Figure 4: Main LabVIEW Window
This exercise will use the default configuration of the LabVIEW application.
3. Application 3.1 Opening ADC VI1 After the user has opened LabVIEW, they can then open the VI used to communicate with the ADC. It is assumed that the user has a copy of the VI available on their computer. The following steps detail how to open the VI (assuming it is located on their desktop): Step 1: From the main window select File ‐> Open (As shown in Figure 5)
Figure 5: How to Open the VI 1
LabVIEW programs are commonly called Virtual Instruments, in brief VI’s
Step 2: After being presented with the Open dialog, navigate to the location where the VI is saved by left‐clicking the Desktop button in the left pane (see Figure 6).
Figure 6: LabVIEW Open Dialog Step 3: Left‐click on the name of the file, such ‘ADC‐1 RW.vi’ and then left‐click on the OK button (See Figure 7). As a result, the application will open in a window as shown in Figure 8.
Figure 7: Selecting the File 3.2 Configuring ADC VI
The VI is written to communicate with the ADC via the serial port via the default configuration. The configurable parameters are as follows: VISA resource name (port), baud rate, data bits, parity bit, stop bits, and flow control. In the event that an error is encountered while trying to communicate with the ADC, the user may need to tweak these settings from the defaults.
The default configuration is:
VISA resource name: COM1
baud rate: 19200
data bits: 8
parity: None
stop bits: 1.0
flow control: None
Figure 8: ADC‐1 RW.vi Front Panel Once any necessary configuration changes have been made, the user must left‐click the ‘Run Continuously’ button.
Figure 9: Left‐click the Second Button for ‘Run Continuously’ While the VI is running, the user may toggle the write and read switches to the ON position. This will allow the VI to write the user‐specified input to the ADC, and then read any value that may be returned. A successful communication of the default string to write value of ‘*IDN?\r\n’ will provide a read string of ‘X’ (as shown below).
Figure 10: A Successful Write then Read
3.3 ADC Commands
Provided for the user is the ability to use pre‐programmed commands instead of those that are user‐specified. The user may select one pre‐programmed commands by selecting a different option under Input Selection. There are four pre‐programmed commands available to the user: Firmware Version, Digital Input Port Status, Pulse Counter, and Receive Error Count.
There are additional commands that the user may issue with the User Input option selected. Each command specified in the string to write field must be followed by ‘\r\n’. This issues a carriage return and new line within the write string, and is required for successfully issuing commands. Additional commands the user may specify are as follows:
Table 2: ADC Command/Response Table [3]
Note: An exception to this list is the Lyxxx (D/A output) command. This table is from the equipment manual that accompanies the SuperLogics ADC‐1 R2, which is based upon firmware version 3.0. Used in this exercise is the older ADC‐1 model which uses firmware version 2.2. Using the Lyxxx command with the old firmware will provide a response of ‘X’.
3.4 Receiving Data From The ADC Using the following table in conjunction with either of the analog nibble commands, U or Q, the user can take readings from each of the analog channels. The user can read directly from a port, or take the differential between channels. Table 3: Analog Control Nibbles[3]
Table 4: Example Nibble Commands[3]
4. References
[1] SuperLogics, RS‐232 Data Acquisition Device, SuperLogics, Inc., Waltham, MA, 2002, http://www.superlogics.com/specpage.asp?Items=8000 [2] National Instruments, System Requirements for LabVIEW Development System and LabVIEW Modules, National Instruments Corporation, Austin, TX, 2009, http://www.ni.com/labview/requirements.htm [3] SuperLogics, ADC‐1 R2 I/O Module Manual, SuperLogics, Inc., Waltham, MA, December 30, 2004, http://www.superlogics.com/manuals/adc1.pdf
5. Appendix: Development of the ADC 1 Virtual Instrument The first thing that needs to be done is to download and install the most current National Instruments Device Drivers from ni.com. After this has been completed (downloading and installing normally requires one to two hours) development of the VI in LabVIEW can begin. The way to go about developing this VI is to break it up into smaller components. First, establish communications with the device. Then, add the ability to input commands and receive a response. Next, add some functionality such as buttons for common commands, combo boxes with configuration options. Finely, add the components to read in voltages from the ADC and display it numerically and as a graph. 5.1 Establishing Communications with the Superlogics ADC‐1 To begin programming, open LabVIEW following the steps outlined in section 2 of this document, System Software. Once this is done, double click on Blank VI (shown in Figure 11) to create a new LabVIEW project.
Figure 11: Opening a blank VI The front panel of a new VI will open. In order to commuicate with the ADC, we need some way to configure our VI to communicate with it. Luckelly, LabVIEW comes pre‐packaged with
several Instrument I/O VI’s. The VI’s we will mostly be using are the VISAs located in the Intrument I/O pallette of the control panel, as shown in Figure 12.
Figure 12: Control Panel showing expanded Instrument I/O palette. To allow communication between the ADC and the application, the user will have to be able to set the proper port configuration. To do this, click and drag the VISA Configure Serial Port form the Instrument I/O under Serial. Drag the VISA and drop it onto the block diagram (Figure 13).
Figure 13: Placing the Vista Configure Serial Port on the Block Diagram. This VISA allows the port settings to be established, either by constants set by the programmer, or as inputs from the user. The user should be able to choose the proper settings, so the next step is to add controls for the proper port settings. To add each of the controls right click on the front panel and drag and drop a Text Control (Figure 14) for each of the required settings: Port Name, Baud Rate, Data Bits, Parity, Stop Bits, Flow Control, and Read Frequency as shown in Figure 15.
Figure 14: Test Controls
Figure 15: Port Settings. Wire each control to the VISA Configure Serial Port as shown in Figure 16.
Figure 16: Wire controls to VISA. Command Input Now we want to be able to input commands to the ADC‐1. This will require controls to select desired commands, and a switch to write to the ADC. Add a switch to the Front panel in the same manner as adding text controls in section 5.1 as shown in figure 17.
Figure 17: Switch Control Palette This will be the Write control. Add a Case structure to the back panel from the Programming Palette as shown in Figure 18 and Figure 19. This case will be true when the Write switch is
toggled on and false when it is toggled off.
Figure 18: The Programming Palette.
Figure 19: Case structure with write toggle wired. Inside the Write case structure is another case structure. This one has a different case for each of the command options. Select another case structure from the Programming Palette
and place it inside the Write case structure as shown in Figure 19. Select the VISA Write object from the I/O palette as shown previously in Figure 12 and drop in inside the inner case structure. This will allow strings to be written to the ADC. Label this case as “User Input”, and make it the default case. This will be for when the user whishes to input a command that is not included with this application commands. Add a Text Control to the inside of this case, and wire it to the case. Add another case to the inner case structure and follow the above step for each command you wish to have included with the application. Now the VISA Configure Serial Port needs to be wired to the VISA Write as shown in Figure 20. Now the application can write to the ADC.
Figure 20: Wire the Configure Serial Port to the VISA Write. Reading From The ADC‐1 This section covers reading from the ADC. You will need a way of controlling the frequency at which the ADC is polled. This can be done with a Stacked Sequence Structure found in the Programming Palette as shown in Figure 18. Add one to the Block Diagram. Inside this, place a Numerical Control wired to a Wait counter found in the Timing Palette under Programming(Figure 21).
Figure 21: Timing Palette and Frequency Control. Now create the Case Structure to control when to read from the ADC. Place a new Case Structure on the Block Diagram and add a Read Toggle Switch as was done for the Write Case
Structure. Select the VISA Read from the I/O Palette as shown in Figure 12. Also add a Property Node inside this Case. Now the VISA Write from Section 5.2 is wired through the Frequency structure to the Property Node, and then to the Visa Read (Figure 22).
Figure 22: Write, Read and Frequency Control. Create a Text Indicator and wire it to the VISA Read. This shows the output of the ADC. Creating the Graph To create the graph, select Build XY Graph from the Express VI’s palette. Place it on the block diagram as shown in Figure 22. Since the VISA Read outputs a string, this output will have to be converted to a double to be readable by the graph function. To do this we use a String Subset function to read only 3 characters of the string, then convert that string into a number using a Hexadecimal to Number function. Both of these are found in the Programming Palette. Place these onto the Block Diagram and wire them together as shown in Figure 23.
Figure 23: The Read Case Structure. The output then needs to be converted to a double with the To Double Precision Float function. The signal is then divided by a conversion factor and wired to the Y input of the Build XY Graph VI as shown in Figure 23. The Build XY Graph is then wired to an XY Graph indicator which is placed on the Front Panel as Shown in Figure 24. Now the Application is ready to be run.
Figure 24: The Completed Application