cancel
Showing results for 
Search instead for 
Did you mean: 
Knowledge Base

Example Code

Top Contributors
Sort by:
Overview This VI will programmatically get general information about all the cards in your system that use the VISA, DAQ, or MI drivers.   Description This VI will programmatically get general information about all the cards in your system that use the VISA, DAQ, or MI drivers. This information includes: Device Name Product Type Chassis Number PXI Slot Number Serial Number VISA Resource reference   Requirements Software LabVIEW 2012 or compatible NI-DAQmx 9.5.5 or compatible Hardware NI Multifunction DAQ Device   Steps to Implement or Execute Code 1. Run the VI. 2. Get the DAQmx device name.   Additional Information or References   **This document has been updated to meet the current required format for the NI Code Exchange.**  
View full article
Overview This example is designed to show how it may be possible to remove higher-frequency noise from a waveform without explicit use of a filter.   Description The code uses two different methods of averaging that allow waveforms to be cleaned and smoothed out. The first method demonstrates the the use of point-by-point averaging to slightly reduce the noise present in a waveform. It does this by taking a set number of points and averaging them together to create one new point in their place. It does this for each point on the waveform and results in a much smoother curve if enough points are used. Increasing the number of points produces a smoother curve, but as the number increases the phase will slowly begin to shift relative to the input waveform and the amplitude of the waveform will decrease. However, it can be very useful in situations where a perfectly clean signal is not required.   The second method produces a much nicer output, but is designed for repeating signals that remain in phase from one iteration to the next. This method adds the previous instances of the waveforms to the new one, creating a "total", and then divides by the number of waveforms added together to acheive an "average" waveform. This example does not limit the number of waveforms that are added together, but an acutal implementation may want to limit this number to prevent overflow errors.   Requirements Software LabVIEW 2010 or compatible Hardware None required     Steps to Implement or Execute Code Download and run the attached VI. Change the values of the different controls to get an understanding of how some of the averaging code behaves.     Additional Information or References   Screenshot of the front panel while the code is in action:     And a screenshot of the block diagram:       **This document has been updated to meet the current required format for the NI Code Exchange.**
View full article
Overview The example demonstrates how to create sweep signal that  vary in frequency, amplitude and shape. Description: One seemingly simple, and very common DAQ application is to generate a signal which can vary in frequency, amplitude and shape. The following example does just that! Steps to implement or execute code To implement this example: Define the Analog Output channel. Configure the type, frequency and amplitude. Run the VI. (Optional) Turn on the Highlight Execution to see the flow of the VI Requirements Software LabVIEW 2012 or compatible NI-DAQmx 16.0 or compatible Hardware cDAQ with C series Analog Output Module   **This document has been updated to meet the current required format for the NI Code Exchange.**
View full article
Overview The example demonstrates how interface with HC-SR04 sensor. Description: The HC-SR04 sensor uses sound waves to help compute the distance of an object by sending out ultrasonic sound waves to an object and measuring the time it takes to come back to the sensor. The sensor sends out about eight 40 kHz pulses and waits for an object to bounce the waves back to the receiver.  It then outputs a high pulse proportional to the time it takes for the sound waves to be sent and received. To use the sensor, a continuous pulse train is generated by a counter output task with a set high time and low time.  A 100 uS pulse send on the TRIG line triggers the HC-SR04 module to start sending the ultrasonic pulses followed by a 100 ms low time.  A voltage high is sent on the ECHO line until the sound waves bounce back to the receiver. Since the speed of sound at sea level is known to be about 13397 inches per second we can use the high time of the ECHO line and the ratio of inches per second to get the distance traveled by the sound wave.  To get the object distance we need to divide by this by two.  This can be simplified into a single multiplication since the only unknown variable is the high time. Steps to implement or execute code To implement this example: Define the trigger and Echo terminal Run the VI Requirements Software LabVIEW 2012 or compatible NI-DAQmx 16.0 or compatible Hardware cDAQ with C series that have counter feature module or compatible DAQ devices.   **This document has been updated to meet the current required format for the NI Code Exchange.**
View full article
Overview The example demonstrates how acquire data from magnetometer Description: A Gaussmeter or Magnetometer is used to measure the presence and strength of a magnetic field.  A hall effect sensor is commonly used.  In this documentation, the Allegro 1302 is used although the 1301 is shown in the schematics.  The author preferred the specifications of the 1302.  Gaussmeters are effective for measuring the quality of ferrite magnetic cores, air coils, EMC.  The hall effect sensor creates a voltage from the magnetic field.  From this, we can calculate the magnetic field from the formula given in the specifications sheet provided by Allegro.  Once this is achieved, a multitude of statistics can be performed on the information.  Steps to implement or execute code To implement this example: Choose the physical channel, samples per cycle, minimum, maximum values, description and volts.   Start the program without any magnetic field influencing the sensor Use the voltage reading to get the base voltage.  The base voltage is the initial voltage or V0.  Sometimes the base voltage is not the same as in the datasheet of the sensor. Use the sensor datasheet to find V/G. In the setup, choose to save the results to a text file or not. Use the toggle to start and pause he program.  To execute this example: Define the analog input channel parameter in setup tab. Configure the sensor setting. Set whether you want to record the data or not. Run the VI Open Help tab for more information Requirements Software LabVIEW 2012 or compatible NI-DAQmx 16.0 or compatible Hardware cDAQ with C series analog Input Module or compatible DAQ devices.   **This document has been updated to meet the current required format for the NI Code Exchange.**
View full article
Overview The example demonstrates how to synchronize analog input and do buffered duty cycle/frequency counter measurements. Description: The goal of this VI is to synchronize Analog Input and Buffered Duty Cycle/Frequency Counter Measurements. This is done by generating a pulse train and using that as the sample clock source for two previously mentioned tasks. There is also another pulse train that is generated and physically looped back into counter measurement task so you can control what it is that you're expecting. Steps to implement or execute code To implement this example: Set the front panel parameter. Run the VI To execute this example: Install the required software. Connect the DAQ hardware that supports the Counter and Analog Input features Confirm the connection with the MAX with TestPanel Open the VI and refer the Implement Steps Requirements Software LabVIEW 2012 or compatible NI-DAQmx 16.0 or compatible Hardware cDAQ with C series Counter Input Module or compatible DAQ devices.   **This document has been updated to meet the current required format for the NI Code Exchange.**
View full article
Overview The example demonstrates how the VI do finite retriggerable Analog Input Read Description: This example performs a finite retriggerable AI acquisition and then reads all samples on the buffer after the trigger source has stopped.  A counter output is used to generate the trigger for the AI task.  Steps to implement or execute code To implement this example: Configure the front panel for Analog Input, counter and trigger physical channel Run the VI To execute this example: Install the required software. Connect the DAQ hardware that supports the counter,analog input, and PFI features Confirm the connection with the MAX with TestPanel Open the VI and refer the Implement Steps Requirements Software LabVIEW 2012 or compatible NI-DAQmx 16.0 or compatible Hardware cDAQ with C series Counter Input and analog input modules or compatible DAQ devices.   **This document has been updated to meet the current required format for the NI Code Exchange.**
View full article
Overview This program will allow you to create a continuous pulse train with a duty cycle that varies in accordance to an acquired input voltage using only DAQ hardware.   Description In this example, You can supply the input voltage by simply wiring the selected analogue output to the corresponding analogue input and then adjust the Input Voltage dial in order to see the effects, but this "simulated" controlling voltage source can also be disabled if you wish to provide it by other external means.   Steps to implement or execute code Choose an Analogue Output, two Analogue Inputs and one Counter on your DAQ device for which the program can use. Wire the Analogue Output to the first Analogue Input and the Counter Output to the second. On the front panel select the chosen Analogue Output on your device within the "Simulated Source (AO)" drop down list, both Analogue Inputs (in the order mentioned above) within the "Analogue Inputs" drop down list and the chosen Counter within the "PWM Counter" drop down list. Run the program and vary the "Input Voltage" dial on the front panel. You should be able to observe the pulse width varying in accordance to the voltage. Requirements Software LabVIEW 2012 or compatible NI-DAQmx 16.0 or compatible Hardware cDAQ with C series Counter Input and Analog I/O or compatible DAQ devices   **This document has been updated to meet the current required format for the NI Code Exchange.**
View full article
Description This application demonstrates how to use DAQmx to create multiple PWM channels and have runtime-control over Frequency and/or Duty Cycle.   Steps to implement or execute code To implement this example: Set the physical channel of the counter Determine the frequency Run the VI (Optional) Turn on the Highlight Execution to see the flow of the VI To execute this example: Install the required software. Connect the DAQ hardware that supports the Counter features Confirm the connection with the MAX with TestPanel Open the VI and refer the Implement Steps Requirements Software LabVIEW 2012 or compatible NI-DAQmx 16.0 or compatible Hardware cDAQ with C series Counter Input Module   **This document has been updated to meet the current required format for the NI Code Exchange.**
View full article
Description: This example configures a DAQmx Counter Task for Hardware-Timed Single Point PWM measurements on an X Series DAQ card. It imitates HWTSP Pulse Measurement, except it will not throw an error if there is no pulse (0% duty cycle or 100% duty cycle). Steps to implement or execute code Rename your X Series DAQ Card to 'Dev1' in Measurement and Automation Explorer. Attach your PWM Signal to specified port on Front Panel (PFI9). Run the VI.View the Duty Cycle Measurement I/O Connections Overview: Connect a PWM signal to the terminal specified in PWM Signal Indicator on the Front Panel. This defaults to PFI9. Requirements Software LabVIEW 2012 or compatible NI-DAQmx 16.0 or compatible Hardware cDAQ with C series Counter Input Module and Analog Output   **This document has been updated to meet the current required format for the NI Code Exchange.**
View full article
Overview This VI starts a hardware timed digital output and input task running at different rates using a dummy analog input task. Description: This examples was developed for an M series device, two counters are used to generate the sample clocks for the I/O tasks. Steps to implement or execute code To implement this example: Configure the front panel. Run the VI To execute this example: Install the required software. Connect the DAQ hardware Confirm the connection with the MAX with TestPanel Open the VI and refer the Implement Steps Requirements Software LabVIEW 2012 or compatible NI-DAQmx 16.0 or compatible Hardware cDAQ with C series or compatible DAQ devices   **This document has been updated to meet the current required format for the NI Code Exchange.**
View full article
Overview This example was derived from the example DAQmx - Measure Angular Position - Buffered - Counter Clock. Along with acquiring the angular position over time Description: This example shows how to process in the data in a producer consumer architecture. The processing done in this example is calculating the average velocity during the acquisition. If this processing is not desired, change this code to match what you would like to do. Steps to implement or execute code To implement this example: Set the physical channel of the counter Determine all the physical channel for the encoder and timing. Run the VI (Optional) Turn on the Highlight Execution to see the flow of the VI To execute this example: Install the required software. Connect the DAQ hardware that supports the Counter features Confirm the connection with the MAX with TestPanel Open the VI and refer the Implement Steps Queues breakdown: Creates the queue to store the data that needs to be sent between the loops. Places an element into the queue in order to pass it to the other loop. Takes an element out of the queue. Closes the queue Clock Breakdown: Creates the Counter Output task. Takes the frequency the buffered acquisition will acquire at and which counter to use. Sets up the timing for the task. Starts the Task Monitors the task to see if there is any errors. Clears the Task. Encoder Breakdown: Creates the Encoder task. Setups what terminals A, B, and Z will be as well as other configuration sets for this task. Sets up the timing for the task. Uses the clock generated by the Counter output task for the acquisition. Starts the Task Reads X values from the buffer. The number samples read is controlled by the Samples to Read input Clears the Task. Requirements Software LabVIEW 2012 or compatible NI-DAQmx 16.0 or compatible Hardware cDAQ with C series Counter Input Module   **This document has been updated to meet the current required format for the NI Code Exchange.**
View full article
Overview: Demonstrates a method of synchronizing the frequency of two counters by utilizing a third counter. Description: While it is relatively simple to align the rising edges of two counters by using a start trigger, it can become more complicated when a user wants to change the frequency or duty cycles of the counters on the fly.   One way to accomplish this is to use a third counter as the source of ticks for the two counters, and then change the number of high ticks and low ticks of the two counters separately in order to change their duty cycles. This example allows two counters to generate a continuous pulse train, where the rising edges and frequency are aligned, but the duty cycle of the two pulses can differ and be changed on the fly. Requirements: LabVIEW 2012 or compatible. NI-DAQmx 15.5.1 or compatible. DAQ device with at least 3 counters. Instructions: Specify all control values on the front panel. For more information, click on Help >> Show Context Help and hover your pointer to the controls. Run this VI. **This document has been updated to meet the current required format for the NI Code Exchange.**
View full article
Overview: Demonstrates on internally routing digital pulses generated from a Counter Output to the Counter Input and updating the digital pulse frequency on the fly. Requirements: LabVIEW 2012 or compatible. NI-DAQmx 15.5.1 or compatible. DAQ device with at least 2 counters. Instructions: Specify all control values on the front panel. Run this VI. Verify the pulse frequency from the indicator. Block Diagram Steps: Creates channel to generate digital pulses. Sets the channel to be continuously sampling data. Programs the hardware as much as possible according to the task configuration. Transitions the task to running state to begin generation. Allows the user to update the pulse frequency on the fly. Clears the task and displays any error occurs. Block Diagram Steps: Creates channel to generate digital pulses. Sets the channel to be continuously sampling data. Internally route the generated signal to the default source pin of the counter. Transitions the task to running state to begin generation. Continuously updates the frequency measurement on the front panel. Clears the task and displays any error occurs. **This document has been updated to meet the current required format for the NI Code Exchange.**
View full article
Overview Demonstrates on programmatically implement an Auto-Zero for the SCXI voltage acquisition and set the delay between samples to account for the additional settling time when using a filter. Description This VI allows the user to program autozero SCXI voltage measurements using LabVIEW and it is intended to be used as a SubVI in line with other DAQmx VIs in your program.  Measured DC Offset is the output of this VI. When the VI is called, it connects all inputs to GND and bundles the current timing parameters into a cluster. Specified number of samples will be taken from each and average value of these samples will be computed.   The expected GND value (typically 0 V) will be subtracted from the calculated average. Finally, the inputs and the timing parameters will be set back to their initial values. Many SCXI modules have a built-in autozero function, but they don't give the user access to adjust the delay time to compensate for the settling  that the filters can introduce.   Requirements: LabVIEW 2012 or compatible. NI-DAQmx 15.5.1 or compatible. Instructions: Place this VI in line with the DAQmx VIs in your code, before the Start Task VI. Run the Main VI. Block Diagram Steps: Connects inputs to GND. Specifies the coupling for the channel and how often to measure ground. NI-DAQmx subtracts the measured ground voltage from every sample. Reads from the previously configured timing parameters and bundles them to a cluster. The configuration includes: i. whether the task acquires or generates a finite number of samples or if it continuously acquires or generates samples. ii. the number of samples to acquire or generate. iii. the sample timing type. iv. sample clock rate. v. sample clock source. vi. sample clock active edge. Sets number of samples per channel, sample mode and sample rate. Programs the hardware as much as possible according to the task configuration. Sets the delay time. Transitions the task to running state to begin measurement. Reads the data. Computes the mean of the values in the input sequence X. Stops the task and returns it to the state it was in before the DAQmx Start Task VI ran. Disconnects inputs from GND Loads original task timing. Programs the hardware as much as possible according to the task configuration. Sets the delay time.   **This document has been updated to meet the current required format for the NI Code Exchange.**
View full article
Overview: Demonstrates on acquiring thermistor measurement with NI-9219. Description: Since the NI-9219 is a viable option for thermistor readings but does not support thermistor tasks, this code shows one way to get the thermistor measurements using the NI-9219. This VI utilizes a resistance task to acquire data from the 2-wire thermistor using internal excitation.   Then, it converts the resistances to a voltage by multiplying the values by the excitation current, to ensure the correct values are passed into Convert Thermistor Reading.vi. Requirements: LabVIEW 2012 or compatible. NI-DAQmx 15.5.1 or compatible. C Series Universal Analog Input Module : NI-9219 Instructions: Set all the control values on the front panel. Run this VI.   Block Diagram Steps: Creates a task and adds virtual channels to that task if you specify them in the global virtual channels input. Creates channels to measure resistance. Sets the sample clock with number of samples to acquire, sample mode and sampling rate. By wiring -1 to number of samples per channel terminal, NI-DAQmx determines how many samples to read based on if the task acquires samples continuously or acquires a finite number of samples. The output of the task is resistance measurements with an array of waveform data type.  The multiplication by the excitation current converts the resistances to voltage so that the correct values are passed into Convert Thermistor Reading.vi. Converts a thermistor voltage into a temperature. **This document has been updated to meet the current required format for the NI Code Exchange.**
View full article
Overview This example demonstrates how to count digital events on a digital port of an M-Series card using correlated DIO.    Description This program correlates a digital input task to the analog input sample clock, creating a buffered hardware timed acquisition on a digital port.  The program then compares samples from each port to the previous sample, and a change in a digital line increments a count value in software.   Steps to implement or execute code To implement this example: Set the physical channel Define the encoder setting Define the timing parameter Run the VI (Optional) Turn on the Highlight Execution to see the flow of the VI To execute this example: Install the required software. Connect the DAQ hardware Confirm the connection with the MAX with TestPanel Open the VI and refer the Implement Steps Requirements Software LabVIEW 2012 or compatible NI-DAQmx 16.0 or compatible Hardware cDAQ with C series or compatible   **This document has been updated to meet the current required format for the NI Code Exchange.**
View full article
Overview This vi collects chronoamperometry data and chronoabsorptometry data simultaneously to yield quantitative spectroelectrochemical data in the form of absorptivity (extinction coefficient) vs. wavelength plots.  A correction for edge-diffusion can be applied to the chronoamperometry data which is then integrated to yield charge vs. time data.  From the integrated data, charge values are assigned to each spectrum collected.  The program does a least-squares analysis of the absorbance vs. charge data at each wavelength, and with some additional input will yield the absorptivity vs. wavelength plot of the electrode product.   The data can be later re-analyzed using one of two other packages available on the NI site, depending on whether there is a kinetically-important intermediate (or not).   Detailed documentation is provided within each vi and in the readme.txt file included in the zip file.  This procedure is described in detail in an upcoming issue of Inorganic Chemistry (reference: Inorg. Chem. , Article ASAP, DOI: 10.1021/ic1012654, Publication Date (Web): September 13, 2010).   To be absolutely clear, this vi calculates absorptivity or extinction coefficient from absorbance data and charge data which are collected simultaneously over time during a chronoamperometry experiment.  Absorptivity, e, is related to absorbance via Beer's Law A=ebc where b is path length (cm) and c is concentration (M).  When the term "spectrum" is used herein, I specifically mean an e vs. wavelength plot.   Caveats and Additional Notes  The suite of programs was originally designed for a Princeton Applied Research Potentiostat interfaced by a GPIB connection (device 14) to a PC which also has an NI-USB 6251.  An analog potentiostat will work fine with slight modifications to the program which remove the GPIB functions.   The hardware is set up as follows: An analog output from a NI-USB 6251 is attached to the external input of the potentiostat and it controls the potential applied to the cell. A pair of analog input channels (run as one task) records the applied potential and applied current from the potentiostat's E-output and I-output respectively. A digital output channel from the 6251 is attached to the trigger input of an Ocean Optics USB-4000 fiber-optic spectrometer, and the spectrometer's software is configured to automatically record spectra upon receiving trigger signals (specifics are in the readme.txt file.)  This application does not use the Labview Ocean Optics driver. In a typical run, the current which passes through the electrode as a result of a potential step is recorded (chronoamperometry) while spectra of the solution at the electrode surface are recorded simultaneously (chronoabsorptometry).  We usually record 20 spectra over a 10-second period, but we have pushed it down to 10 spectra over 2 seconds. The cell design uses a bright source like an LS-50 Ocean Optics Tungsten Lamp, a "dip probe" from which the mirror has been removed, and the USB 4000 detector.  The dip probe is positioned so that its light shines on and is reflected from something like a 3 mm Pt disk electrode.  It is important to have enough signal so that a spectrum can be collected in less than 15 milliseconds, and careful alignment is required.  It is also important to stir or agitate the solution between scans.  Details of a cell used for this purpose have been published.   Detailed description: This set of vi's is used to collect and do some initial processing of simultaneous chronoabsorptometry / chronoamperometry data.  A pair of separate packages are provided for further data processing depending on whether or not there is a detectable intermediate present.  The data collected by this vi can be used to determine the spectra of electrode products.  Two cases have been developed so far: A separate program can be used to collect absorptivity vs. wavelength information about a single electrode product for a 100% chemically reversible or 100% chemically irreversible electrode reaction. A similar but again, separate set of data analysis vi's is available for the case of an electrode reaction which involves an intermediate which decays into a final product by a first or pseudo-first order process.  Basically, if cyclic voltammetry can detect the process at scan rates of 500 mV/s or less, the spectrum of the intermediate and the product can be obtained.  Some smoothing may be required.   The end result of this approach is absorptivity vs. wavelength data for electrode products.  This approach is based on equations developed to remove any arbitrary interactive spectral subtraction of the starting material from difference data.  This quantitative approach yields absorptivity information which is often lacking in other spectroelectrochemical methods, and provides information on the same timescale employed by cyclic voltammetry. The method: The specifics of the method have been described elsewhere (currently in press in the journal Inorganic Chemistry).  The general functions of the data collection program are: The technique uses a fiber-optic spectrometer to take light to and from an electrode surface.  Labview controls a potentiostat to apply a chronoamperometry waveform, to trigger the spectrometer, and to record potential-current-time data from the spectrometer. The vi integrates the current and figures out how much charge has been passed through the electrode at each point in time when a spectrum is recorded.  An optional edge correction can be applied which corrects for edge-diffusion... to take advantage of this feature you need to have measured the diffusion coefficient of the starting material and the physical radius of your electrode.  The chronoamperometry vi's previously posted on the National Instruments site  [Chronoamperometry Data Collection and Basic Analysis by Mike Shaw] can help. The set of spectra and the charges are processed by a least squares plot of absorbance vs. charge at each wavelength to yield a "change in absorptivity vs. wavelength" plot.  If a spectrum of the starting material at known concentration and pathlength is available, and if the electrode area is known, then the absorptivity vs. wavelength plot of the electrode product is saved.   Spectrometer setup: The spectrometer software must be configures separately.  We have used Ocean Optics spectrometers with their OOIBase or Spectrasuite programs.  The vi is configured to read "tab-delimited ascii files with header" and the filenames should be set to autoincrement.  The filenames should be of the format "filename.00001.abs" and should be absorbance files. We usually use a bright source such as a tungsten lamp (e.g. LS-50 from Ocean Optics) which gives strong signals in the 380-950 nm range so that a good spectrum can be obtained in less than 15 milliseconds.  We take a dark spectrum, and then a reference spectrum and set the software to absorbance mode.  The technique relies on difference data so it is OK to take a reference spectrum with the sample present. The trigger is then set to the software setting.  Then the file saving options are set to record every spectrum, the filename is set to the proper format (above... put a period after your filename like "filename." and set to autoincrement), the file type is set to ASCII tab delimited with header.  Put your new files in a new directory.  It might be a good idea to set the maximum number of files recorded to a value like 1000, so that if you make a mistake, the harddrive does not get filled with useless spectra. Spectrasuite will be unresponsive while it is waiting for a trigger signal.  When you are done with it, or need to change something, I would close the program (it won't close completely until you send a trigger signal), and use the Measurement and Automation Explorer to send a trigger signal which will close the program.   Absorbance file format File format should be tab-delimited text file generated by Ocean Optics OOIBase or Spectrasuite program. The wavelength vs. absorbance pairs should begin on the 18th line.  The last line should read:  >>>>>End Processed Spectral Data<<<<< The files should be named according to name.XXXXX.txt.  In Spectrasuite, this can be accomplished automatically when setting up the files to be automatically recorded in a directory on the software trigger setting.  Note that the period before and after the XXXXX is important, as A_vs_Q.vi strips the text before and after the periods so as to come up with a set of numbers, each of which corresponds to a spectrum which is read into a separate array. Examples of files are included. Data and Spectrocoulometry_data_workup.vi program courtesy of M. Shaw, Department of Chemistry, SIUE.  All vi's are provided "as-is" with no expectation or implication of warranty or troubleshooting. Description of vi's: The main vi is called  "Data_Collection_amperometry_absorptometry.vi".  When it runs, there is a pause at the beginning so that the user can double check if the setup is correct, and also to decide whether or not to run the edge correction vi.  During initial data collection, it is recommended that the edge correction not be used.  When all the sub-vi's have run, the result is displayed on the front panel of this vi.   Here is a screenshot of the block diagram:   The first frame (not shown) simply allows for a pause so the user can make sure the cell is on, has been stirred, and everything else is ready.  The overall program calls subvi's as follows: 1.  VIS_NIR_PULSE3.vi collects simultaneous chronoamperometry/chronoabsorptometry data 2.  The user can choose to do an edge correction or not.  Probably best not to bother during the experiment      Better to do edge correction after all the data has been collected in a separate data analysis step... use the      "Data Workup" vi's provided separately. 3.  A vs Q.vi performs least squares analysis of absorbance vs. charge data at each wavelength... can provide     a difference spectrum, or with some more information, the actual absorptivity vs. wavelength plot of the     electrode product. 4.  Displays the final spectra information on the front panel as an XY graph.   After the program is complete, I would make sure that all the files that correspond to a single run are collected in a single directory. That may mean moving the spectral files which were collected by Spectrasuite into the same directory where you saved the potential-current-time data and also the final absorptivity vs. wavelength data.  I usually create a directory using the current date, and create a bunch of subdirectories called "attempt1", "attempt2", "attempt3" etc in addition to a directory called "spectra" where Spectrasuite can deposit the data files it collects.  After each experiment I make sure the data files are collected together because it is usually very difficult to disentangle them at the end.   Between each run you must stir the sample to make sure the solution at the electrode is fresh.   The sub-vi's run as follows:   (1) "VIS_NIR_PULSE3.vi"allows the user to set up a double-potential-step chronoamperometry experiment where the electrode starts out at some rest potential, applies the waveform, and then returns to the rest potential.  Here is a screenshot of the front panel: The "rest potential should be set to a value where no current flows through the electrode (not always "zero").  It is best to have the final potential (E-3) be the same as the rest potential for 2 milliseconds.  The other two potentials should be set to the same value for the balance of the time.  In the example above, the entire experiment is set for 10 seconds total, but one could change that to 2 seconds by making "Tau-1" be 1000 ms.  The total time needs to be the same as "Samples to read" divided by "input rate".  The vi assumes that the potentiostat is a Princeton Applied Research instrument (e.g. PAR 273A or 263A or Versastat II) connected via GPIB at address 14.  If not, the vi will still work, but the rest potential will be stuck at zero.   The user should set the current range sensitivity setting so that current-overloads don't happen.  For a 3mm Pt disk electrode with a 1 mM solution of ferrocene in 0.1M NBu4PF6/CH2Cl2, a setting of -4 works well.  This setting corresponds to full scale on the potentiostat being 1E-4 amps per volt measured (~2V max).  For lower concentrations, a more sensitive setting (i.e. "-5") might be required.   Once all the parameters have been set up for the experiment, the user will click on the "collect data NOW" button.  The vi will set up the PAR potentiostat via GPIB to apply the external potential supplied through the external input from the NI-6251 board, then it will apply the potential.  It will measure the potential and current reported by the potentiostat via the external outputs while sending a series of trigger signals to the spectrometer to measure spectra.   This vi then saves the time, potential and current data in a tab delimited spreadsheet file which the user specifies via a dialogue box which opens after data collection.  It is a good idea to enter the filename within a single minute after the dialogue box opens, otherwise the potentiostat might hang.  If this happens, just shut off the potentiostat and turn it back on again.   The measured current and potential will briefly be displayed and then the vi will close as the next subvi executes. The block diagram consists of a stacked sequence structure with 8 frames, each of which has comments explaining the various functions. To summarize: Frame 0:  Sets up a PAR potentiostat at address 14 to apply externally supplied potentials with the cell on and to not autorange. Frame 1:  Sets up potentiostat's current scale. Frame 2:  Sets up potentiostat's rest potential. Frame 3:  Takes the "Tau times" the potentials, the data collection rate, and the number of samples, and generates a waveform which corresponds to chronoamperometry. Frame 4: Sets up the various input and output channels, applies the potential program and trigger program, and reads in current and potential data.  The raw data is  displayed and saved as a temporary file.  The spectrometer software needs to be configured separately.  There is extensive notation on this frame.  Users will need to make sure their DAQmx task names are configured and named correctly.  I have used "E and I output" to measure the potentials on two analog input channels,  "Spectrometer_trigger" for a digital output, and "Applied_E" as the analogue output which is connected to the external input of the potentiostat.  This vi is a modification of an I/O application provided with Labview and is similar to what is used in my "Cyclic Voltammetry with an analogue potentiostat" example.  The user will need to make sure  that the tasks configured are set up right.  There is a digital output for the trigger signal to the spectrometer, an analog output to control the potential applied by the potentiostat, and a task which comprises two analog inputs from the potential and current outputs of the potentiostat, respectively.   The final waveform data is saved as a temporary file after data collection when a dialogue box opens which asks the user for a filename. You will need a c:\temp directory. Here are left and right side screen shots of the frame         Frame 5:  This frame opens the temporary file, and integrates the current and picks out the charge values which correspond to times at which spectra were recorded. These charges are passed on to the next vi. Frame 6:  This frame completes the conversionof current to amps and saves the time-potential-current data in its final form as a spreadsheet file. Frame 7:  Turns the cell off and deletes the temporary file from c:\temp   The vi usually collects an extra spectrum, so ignore the last spectral file when processing.   "VIS_NIR_PULSE3.vi" calls a couple of other sub vi's: (A)  "Get Terminal Name with Device Prefix.vi" is included here, although it is also found in:  C:\Program Files\National Instruments\LabVIEW 8.2\examples\DAQmx\_Utility\_Utility.llb or the equivalent library in your machine.   (B)  "Ocean_Optics_Trigger_Signal.vi" constructs a digital waveform to control when the trigger signal is sent to the Ocean Optics Spectrometer.  It uses the total time allottedfor the scan and the scan rate to build an array of "on" signals, and substitutes the "off" times into the array based on how many spectra are to be recorded, and how long (in milliseconds) the trigger signal needs to be on for.  The array is then converted into the waveform used in the main program.   (C)  Similarly, "pulse waveform generator.vi" takes a resting potential, three applied potentials and three times (tau) which to apply each potential and constructs an analog waveform appropriate for double potential step chronoamperometry.  This vi thus has flexibility for future applications (such as a cyclic absorptometry application currently being developed) .  These values are fed to this vi from the front panel of "VIS_NIR_PULSE3.vi", but this vi could be used on its own for double potential step chronoamperometry with minor modification (e.g. removing the spectrometer trigger stuff).     (2) The "Edge_correction.vi" program applies a correction to the chronoamperometry data to yield the charges that correspond to each spectrum recorded.  For small electrodes, edge diffusion can result in a systematic and increasing error in the charge obtained when current vs. time data is integrates, as described by Heinze.  This vi is optional during data collection, but should be applied when the final data analysis is underway.  It requires the diffusion coefficient of the starting material which can be obtained from a separate chronoamperometry experiment.  This vi has been described in detail in a separate document called "Chronoamperometry Correction for Radial Diffusion: Chronocoulometry" .   (3) The  "A_vs_Q.vi" performs a linear least squares analysis of the absorbance vs. charge data at each wavelength.  The user can choose between a difference spectrum format, and the actual absorptivity of the product vs. wavelength plot.  For the latter you will need a spectrum of the starting material at known concentration and path length, as well as the electrode area (as determined by chronoamperometry) and the diffusion coefficient of the analyte... I usually just look at the difference spectrum and wait until later to process the data.  This vi saves the final spectrum as a spreadsheet file.  The various columns are wavelength, absorptivity, and relative standard deviation.     Here is a screenshot of the front panel: During data collection, I would: Enter the filename for the starting material's UV-VIS-NIR data (tab delimited file from Spectrasuite) in the green box. Enter the starting material's concentration and path length in the green box. Decide whether you want a difference spectrum (change in absorptivity), or the absolute absorptivity vs wavelength graph. I strongly suggest a difference spectrum.  If you select to do a difference spectrum, then the path length and concentration become irrelevant, and you just need any valid spectrum's path entered in the green box.  This is useful if you have not yet measured the spectrum of your starting material.  The path length to enter in the green box is NOT the path length you have during the spectro-e-chem experiment (which is mathematically irrelevant) but the path length of the sample you measured your starting material's spectrum with. In the blue box, you need to enter the spectra data you just collected.  The upper path box is for the first spectrum, and the lower path box is for the final spectrum.  As described under "Spectrometer setup" your files will have names similar to "sample.00XXX.abs" where the "XXX" corresponds to the number of the spectrum automatically saved upon the spectrometer's receipt of the trigger signal.  There may be one extra spectrum collected, so make sure you enter in the same number of spectra as you requested in the data collection vi. Click on "Calculate Spectrum" and the green XY graph will just display the absorptivity (from Beer's law, your starting material's spectrum, path length, and concentration), while the blue graph will display the change in absorptivity that occurs at the electrode surface due to the consumption of starting material and formation of product. Ideally, the spectrum of the product is just the difference spectrum added to the spectrum of the starting material (by spectrum I mean absorptivity vs. wavelength plot). The program will ask you for a filename and it will save your absorptivity vs. wavelength file where you specify. You can return to the main front panel display by clicking on "exit program."  Alternately, you can click on the stop button, make adjustments to your parameters and run the sub-vi again until you are satisfied.   The block diagram consists of a stacked sequence structure with 3 frames.   Frame 0:  Pauses the program until the filenames and other data have been entered correctly. Frame 1:  Prompts the user for a filename for the final absorptivity vs. wavelength file Frame 2:  This frame does a lot.... (1)  Loads the spectra into an array. (2)  Performs a least squares analysis of Absorbance vs. Charge at each wavelength.  (3)  Calculates starting material absorptivity data from a representative spectrum recorded at known concentration and known pathlength. (4)  Calculates the absorptivity of the product. Frame 3: Pauses the program while the user inspects the graphs.   Here is a screenshot of part of Frame 2: This part of Frame 2 (above) loads the starting material's spectrum into an array.  It also loads all of the spectra between (and including) the first and last spectra specified by the user into another single array.   This part of Frame 2 (above) performs a least squares analysis at every wavelength (Y-values) vs. the charge (X-values) for the arrayed spectra.  There will be one charge which corresponds to each spectrum.  In a usual run, there are about 2000 wavelengths analyzed at each of these charges.  Ideally, charge increases with the square root of time.  While regression analysis is part of many versions of Labview, I programmed this function because the regression analysis is not part of every version of Labview.     In this part of Frame 2 (above), the starting material's spectrum, path length and concentration are converted in absorptivity.  There is a correction from the molarity units in Beer's law to the moles per mL units required for the Cottrell Equation.  The loop at the bottom of the frame translates the regression slopes at every wavelength into absorptivity values.  These arrays are then fed into XY graphs and the data is saved. Steps to implement or execute code To implement this example: 1. Run the VI Requirements Software LabVIEW 2012 or compatible NI-DAQmx 16.0 or compatible Hardware cDAQ with compatible C Sries     Previous and current (CHE 0911537) support by NSF is gratefully acknowledged for this work.
View full article
Overview The example Demonstrates how to achieve 2-edge analog separation on a card when the counters are not available, or the signal is not TTL Description: Attached is code to achieve 2-edge analog separation on a card when counters are not available, or the signal is not TTL.  Please note that the code require the first signal in the scan list to reach the analog level.  Originally the second signal expected was a digital signal, which is why the control is labeled digital level. Steps to implement or execute code To implement this example: This assumes that the analog signal is the first channel in the scan list, and the analog level is reached before the digital pulse comes. Set the physical channel to be used (Optional) Define the rest of the parameters as needed Run the VI (Optional) Turn on the Highlight Execution to see the flow of the VI To execute this example: Install the required software. Connect the DAQ hardware that supports the Analog Input features Confirm the connection with the MAX with TestPanel Open the VI and refer the Implement Steps Requirements Software LabVIEW 2012 or compatible NI-DAQmx 16.0 or compatible Hardware cDAQ with C series Analog Input Module   **This document has been updated to meet the current required format for the NI Code Exchange.**
View full article
Overview The example demonstrates how the VI obtains the frequency of a control input and converts it to a rotational speed measurement Description: This examples shows how to convert the data obtained from a Counter Frequency Measurement to an encoder Rotational Speed (either RPM or rad/s), it uses a subVI to convert the data based on the encoder pulses per revolution Steps to implement or execute code To implement this example: Set the physical channel of the counter Determine the number of the pulses per revolution Run the VI (Optional) Turn on the Highlight Execution to see the flow of the VI To execute this example: Install the required software. Connect the DAQ hardware that supports the Counter features Confirm the connection with the MAX with TestPanel Open the VI and refer the Implement Steps Requirements Software LabVIEW 2012 or compatible NI-DAQmx 16.0 or compatible Hardware cDAQ with C series COunter Input Module   **This document has been updated to meet the current required format for the NI Code Exchange.**
View full article