Introduction: Adding Nobs to the Analog Discovery 2 Using LabVIEW

In my project, I used LabVIEW to interface with 3 Pmod ENC's connected to a WF32 to control a LabVIEW project I made called LabForms. This project lets you access the analog scope and wavegen functionalities of the Analog Discovery through LabVIEW. The LabVIEW code uses the LabVIEW driver for the Analog Discovery 2. Refer to my instructable " Analog Discovery 2 USB Oscilloscope + LabVIEW(2016 update)" where I walk through the Labforms user interface, the goal of the project was to create a project similar to Digilent Waveforms in LabVIEW.

img_8338

Many people prefer using physical knobs to configure a scope rather than using a mouse. In this project, I will show you how I used Pmod ENC's 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.

Step 1: Materials

Hardware

Software

fw4f9eaiscbo0yr-medium

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

Step 2: Software Setup

  1. Install WaveForm
  2. Install LabVIEW
    • Installing LabVIEW will allow you to both run and edit the LabForms project.
  3. Install NI-VISA
  4. Download and install the LabVIEW driver for the Analog Discovery 2
  5. Download LabForms_ENC.vi (attached below)

Step 3: 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 the files you need to start programming a chipKIT™ board with the well-known Arduino API

Refer to this instructable "How to Install chipKIT Core" before continuing, it will walk you through this process.

Step 4: Firmware Setup

  • Download the LINX_PMOD_ENC.ino file attached below
  • Open this file with Arduino IDE
  • Select Tools> Board > chipKIT WF32
  • Select Tools> Port > then select your 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 5: 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 ENC's and then run a wire from the ground bus to the pin directly to the left of that pin.

    pin-diagram-cropped

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

    screen-shot-2016-09-27-at-2-34-11-pm

    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 Pmod ENC to digital pins on the WF32.

    Step 6: AD2 Setup

    1. Using some of the jumper pins supplied with the Analog Discovery to 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 into one of your PC’s USB port.fvd74wxiscbo20e-medium

    Note: It is important you plug the Analog Discovery into your PCs USB port before you proceed to the next step.

    Step 7: LabVIEW Setup

    First, download and unzip and open the PmodENC_project zip file attached below. Once it is open you will see that this LabVIEW code is set up for up to 3 Pmod ENC's. In this project, we use three encoders so you will want to set the number of encoders to 3. The delay is used to debounce the encoder, I have found that 50ms works best. The momentum value is used to prevent bouncing from affecting your results, it is best to set this value to 2. Input your pin Values for the DO channels connected to the A, B and Switch pins of each of your Pmods.

    Step 8: Using Labforms

    One of the knobs controls time, if it's switch is to the left it will adjust the sample rate and if its switch is to the right it adjusts the base.

    screen-shot-2016-09-29-at-1-02-43-pm

    The next knob controls offset, if its switch it to the left it controls offset for Channel 1 and if its switch is to the right it controls offset for Channel 2

    screen-shot-2016-09-29-at-1-03-06-pm

    The final knob controls range, if its switch it to the left it controls range for Channel 1 and if its switch is to the right it controls range for Channel 2

    screen-shot-2016-09-29-at-1-03-18-pm

    Each Pmod ENC has an integral push button in the encoder shaft. This button toggles between "standard" and "fine" adjustment modes. In standard adjustment mode, when the encoder shaft is rotated it scrolls through the list of preset options in that specific field.

    screen-shot-2016-09-29-at-1-03-53-pm

    When you switch to fine mode you will be able to make finer adjustments. If you select the settings tab you can select the size of the fine modes increment.

    screen-shot-2016-09-29-at-1-01-31-pm

    Since 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).

    screen-shot-2016-09-29-at-1-13-01-pm

    Step 9: The End

    Thank you for reading my instructable, if you are interested in making this project yourself but don't have the right supplies you can purchase the LabVIEW physical computing kit with chipKIT WF32. This kit includes a copy of LabVIEW 2014 home edition, a WF32, and everything you will need to run LINX 3.0 and start making projects. Also if you are a student the Analog Discovery 2 has an academic discount available. Please comment with any questions or comments you may have.

    Comments

    About This Instructable

    1,194views

    33favorites

    License:

    Bio: I graduated from Washington State University with a degree in Bioengineering.
    More by Austin Stanton:LIRC - LabVIEW - Remote ReplacementLIRC - LabVIEW - Raspberry PiLIRC - LabVIEW - Sending a Remote Command From LabVIEW
    Add instructable to: