Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| daq-and-datalogging:documents:using-mcc-daq-digital-io [2023/06/14 05:45] – created Scandiweb | daq-and-datalogging:documents:using-mcc-daq-digital-io [2023/07/27 21:28] (current) – Arthur Brown | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== TechTip: | + | ====== TechTip: |
| - | + | ||
| - | ===== Acquiring an Analog Waveform | + | |
| **Objective**\\ | **Objective**\\ | ||
| - | To show how to capture an analog waveform | + | To show how to write to a single digital I/O bit using an MCC data acquisition device and various software platforms. |
| **Intended Audience**\\ | **Intended Audience**\\ | ||
| - | Data acquisition system developers who need to digitize an analog waveform over time, and seek to understand | + | Data acquisition system developers who need to monitor or control digital states, and seek to understand |
| **Overview**\\ | **Overview**\\ | ||
| - | For very slowly changing analog phenomena, it can suffice to sample the signal rather infrequently, and often it is acceptable for the time delta between samples to vary, since the primary need is to obtain the present state of the signal. In such cases, a rather simple “software polling” of each AI channel may suffice. However, if the signal changes rapidly with respect to elapsed time, or if a frequency component of the signal is of interest to the user, much faster A/D sampling is required. In fact, not only is faster sampling required, but having a uniform | + | Digital signals, by definition, are those which can represent just two states, such as on or off. Examples include a warning lamp being lit or dark, a door being latched or unlatched, and a relay being closed or open. Numerically |
| - | MCC’s AI DAQ devices incorporate on-board timing circuits | + | In some applications you will want to control |
| - | An application developer will want to scope out the project from the perspective of both AI sampling duration and data access needs. In other words, | + | A common question is “how fast should |
| - | For a non-continuous scan, independent | + | While real-world digital signals are predominantly unidirectional, DAQ devices usually offer bi-directional capability so as to be adaptable to a wider set of applications. Generally, a DAQ device’s digital ports will power up as inputs. You will need to set (i.e. configure) |
| - | *AI channel numbers | + | For a software-paced digital output operation, independent |
| - | *Number | + | |
| - | *Clock rate | + | |
| - | *Input range | + | |
| - | *The memory buffer | + | |
| - | In addition to the A/D data, an error code is returned.\\ | + | The following information must be specified: |
| - | The examples below show how to perform a non-continuous scan using the [[ https:// | + | *Port Number |
| + | *Port Direction | ||
| + | *Data value to output | ||
| + | |||
| + | And the following information is returned: | ||
| - | **Universal Library**\\ | + | |
| - | The following example shows how to perform a non-continuous scan using the Universal Library | + | The examples below show how to perform a non-continuous scan using the Universal Library™, UL for Android™, NI LabVIEW™, DASYLab®, |
| - | LowChan = 0\\ | + | **Universal Library**\\ |
| - | HighChan = 0 ' | + | The following example shows how to first configure, and then control, a digital output using the Universal Library |
| - | Count = 50000 ' | + | |
| - | Rate = 50000 ' | + | |
| - | Range = MccDaq.Range.Bip10Volts ‘Specify the +/- 10V input range\\ | + | |
| - | ULStat = DaqBoard.AInScan(LowChan, HighChan, Count, Rate, Range, MemHandle, Options)\\ | + | |
| - | + | ||
| - | The sample data is returned to a buffer in PC memory at the provided handle, while the error code is returned as the value of ULStat.\\ | + | |
| - | + | ||
| - | Next we copy the data from the memory buffer to a local program array, named ADData:\\ | + | |
| - | + | ||
| - | ULStat = MccDaq.MccService.WinBufToArray(MemHandle, ADData, FirstPoint, Count)\\ | + | |
| - | + | ||
| - | Up until now, the data has been transferred | + | |
| - | + | ||
| - | ULStat = DaqBoard.ToEngUnits(Range, | + | |
| + | < | ||
| + | PortType = MccDaq.DigitalPortType.AuxPort ‘Specify which digital port | ||
| + | Direction = MccDaq.DigitalPortDirection.DigitalOut ‘Specify the output direction | ||
| + | ULStat = DaqBoard.DConfigPort(PortType, | ||
| + | BitNum = 0 ‘Specify which bit in the port to control | ||
| + | BitValue = 1 ‘Specify the value to write | ||
| + | ULStat = DaqBoard.DBitOut(PortType, | ||
| + | </ | ||
| **UL for Android**\\ | **UL for Android**\\ | ||
| - | The following example shows how to perform | + | The following example shows how to configure and control |
| - | lowChan = 0;\\ | + | < |
| - | highChan | + | DigitalPortType |
| - | mode = ChannelMode.SINGLE_ENDED; // | + | DigitalDirection |
| - | range = Range.BIP10VOLTS; //Specify | + | mDioDevice.dConfigPort(DigitalPortType, |
| - | samplesPerChan | + | bitNum |
| - | rate = 50000; //Specify the per-channel clock rate\\ | + | bitState |
| - | mUnit = AiUnit.VOLTS; //Specify voltage units\\ | + | </ |
| - | actualScanRate = mAiDevice.aInScan(lowChan, highChan, mode, range, samplesPerChan, | + | |
| - | + | ||
| - | Collect the values by calling the aInScan () function. The data is returned in the array named mScanData.\\ | + | |
| **NI LabVIEW**\\ | **NI LabVIEW**\\ | ||
| - | The following example shows how to perform | + | The following example shows how to control |
| - | {{https:// | + | {{https:// |
| DASYLab\\ | DASYLab\\ | ||
| - | Non-programmers can consider | + | Non-programmers |
| - | + | ||
| - | The following example worksheet shows an Analog Input module with its output | + | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | {{https:// | + | |
| - | + | ||
| - | Double-clicking on the Analog Input module opens a dialog box you can use to enable the desired channels, | + | |
| - | + | ||
| - | {{https:// | + | |
| - | + | ||
| - | **DAQami**\\ | + | |
| - | The following example shows the DAQami Acquisition page, where you set the Sample Rate and Sample Count.\\ | + | |
| - | + | ||
| - | {{https:// | + | |
| - | + | ||
| - | The resulting | + | |
| - | {{https:// | + | {{https:// |
| + | Double clicking on the Switch module allows you to access a menu where you can specify how often the switch position will be monitored. Below we see that 1 Hz is selected, resulting in digital output bit D0 on the DAQ hardware being updated every second to match the operator’s selection.\\ | ||
| - | More Information\\ | + | {{https:// |
| - | Please contact Measurement Computing Corporation if you have any questions or if you would like any further information.\\ | + | |
| - | Knowledgebase: [[https://kb.mccdaq.com/Default.aspx | kb.mccdaq.com]]\\ | + | **More Information**\\ |
| - | Phone: 508-946-5100\\ | + | Please reach out to our support team on the Digilent Forum if you have any questions: [[https://forum.digilent.com/]] |
| - | Fax: 508-946-9500\\ | + | |
| | | ||
| - | Additional TechTips are available | + | Additional TechTips are available |

