Adding Knobs Using LabVIEW

In this tutorial, we will be using LabVIEW to interface with three Pmod ENCs connected to a WF32 to control a LabVIEW project called LabForms. This tutorial allows you to access the analog scope and wavegen functionalities of the Analog Discovery 2 through LabVIEW. The LabVIEW code uses the LabVIEW driver for the Analog Discovery 2. Refer to the Analog Discovery 2 USB Oscilloscope + LabVIEW (2016 update) tutorial where we walk through the LabForm's user interface. The goal of the tutorial is to create a project similar to Digilent WaveForms in LabVIEW.

Figure 1. Tutorial overview.

Many people prefer using physical knobs to configure a scope rather than using a mouse. We will be demonstrating how to use Pmod ENCs and LabVIEW to add physical knobs to the Analog Discovery 2. With these knobs you will be able to control the sample rate, base, range, and offset of both of your scopes.

Figure 2. Project setup.


NOTE: Installing LabVIEW requires an NI account. Your LabVIEW installation and any NI software keys will be tied to the account you create.

Step 1: Software Setup

  1. Install WaveForms
  2. Install LabVIEW
    1. Installing LabVIEW will allow you to run and edit the LabForms project.
  3. Download and install the LabVIEW driver for the Analog Discovery 2
  4. Download

Step 2: WF32 Setup

Once you have Arduino IDE downloaded, you will need to install the chipKIT core. The chipKIT core is a plugin for Arduino-style development environments. It contains all of the files you need to start programming a chipKIT board with the well-known Arduino API.

Refer to the tutorial on How to Install chipKIT Core before continuing if you need help with the process.

Step 3: Firmware Setup

  • Download the file
  • Open this file with Arduino IDE
  • Select Tools>Board>chipKIT WF32
  • Select Tools>Port>then select you WF32's Com port
  • Select the Upload button
  • Once it shows the upload is complete, unplug your WF32 and then plug it back in

Step 4: WF32 Circuit Setup

Figure 3. WF32 circuit setup.

First, place the Pmod ENC in the center of the breadboard. Then, connect the 3.3V pin on the WF32 to the positive bus on one side of your breadboard and then connect the negative bus on the same side to the ground (GND) pin. Next, run a wire from the voltage bus to the far right pin of each of the Pmod ENCs and then run a wire from the ground bus to the pin directly to the left of that pin.

Figure 4. WF32 pin diagram.

Next, place the slide switch on your breadboard, run a wire from your voltage bus to its left outside pin. Then use a 240k ohm resistor to connect the right outside pin to ground and then connect the center pin to digital pin 3.

Figure 5. Fritzing diagram.

Finally, connect digital pin 2 to the BTN pin of the first Pmod ENC, do the same with pin 7 for the second Pmod ENC and then pin 8 for the last Pmod ENC. Then connect Pin A, B, and SWT of each Pmof ENC to digital pins on the WF32.

Step 5: Analog Discovery 2 Setup

  1. Using some of the jumper pins supplied with the Analog Discovery 2, connect the Scope Channel 1 positive (orange wire labeled “1+”) to Waveform Generator 1 positive (yellow wire labeled “W1”).
  2. Next, attach Scope Channel 2 positive (blue wire labeled “2+”) to Waveform Generator 2 positive (yellow and white wire labeled “W2”).
  3. Attach Scope Channel 1 negative (orange and white wire labeled “1-”) and Scope Channel 2 negative (blue and white wire labeled “2-”) to the 2 ground wires (black wires labeled with a downward arrow).
  4. Plug the Analog Discovery 2 into one of your PC's USB ports.

Figure 6. Analog Discovery 2 pinout diagram.

NOTE: It is important you plug the Analog Discovery 2 into your PC's USB port before you proceed to the next step.

Step 6: LabVIEW Setup

Figure 7. LabVIEW setup.

First download, unzip, and open the PmodENC_project zip file. Once it is opened, you will see that this LabVIEW code is set up for up to three Pmod ENCs. In this tutorial, we wise three encoders so you will want to set the number of encoders appropriately. The delay is used to debounce the encoder; we have found that 50ms works best. The momentum value is used to prevent bouncing from affecting your result, it is best to set this value to 2. Inp0ut your pin values for the DO channels connected to the A, B, and switch pins of each of your Pmods.

Step 7: Using LabForms

Figure 8. Using LabForms.

One of the knobs controls time. If the switch is to the left, it will adjust the sample rate. If the switch is to the right, it will adjust the base.

Figure 9. Time control.

The next knob controls offset. If the switch is to the left, it controls offset for Channel 1. If the switch is to the right, it controls offset for Channel 2.

Figure 10. Offset control.

The final knob controls range. If the switch is to the left, it controls range for Channel 1. If the switch is to the right, it controls range for Channel 2.

Figure 11. Range control.

Each Pmod ENC has an integral pushbutton in the encoder shaft. This button toggles between “standard” and “fine” adjustment modes. In standard adjustment mode, rotating the encoder shaft scrolls through the list of preset options in that specific field.

Figure 12. "Standard" and "fine" adjustment modes.

When you switch the fin mode, you will ba ble to make finer adjustments. If you select the “Settings” tab, you can choose the size of the increments.

Figure 13. Adjustment options.

Since the sample rate was set to 50 MHz (5E+7 Hz) and its increment was set to a tenth of that value, one click to the right will increase the value 5 MHz (5E+6 Hz) to 55 MHz (5.5E+7).

Figure 14. Sample rate.