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.
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.
NOTE: Installing LabVIEW requires an NI account. Your LabVIEW installation and any NI software keys will be tied to the account you create.
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.
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.
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.
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.
NOTE: It is important you plug the Analog Discovery 2 into your PC's USB port before you proceed to the next step.
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.
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.
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.
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.
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.
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.
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).