Acquisition C Code Data Pc Port Serial Source Using
- faron1991
- Aug 20, 2023
- 6 min read
This demo program opens and initializes a serial terminal at 115200 baud for non-canonical mode that is as portable as possible.The program transmits a hardcoded text string to the other terminal, and delays while the output is performed.The program then enters an infinite loop to receive and display data from the serial terminal.By default the received data is displayed as hexadecimal byte values.
acquisition c code data pc port serial source using
A serial cable must be properly connected between the PC and the data logger. For example, some data loggers have two types of ports, and it is important to use the correct cabling for the one you are connected to. On Campbell Scientific data loggers, there are two types of 9-pin connectors: CS I/O and RS-232. With RS-232, you can either connect a straight-through cable between the RS-232 port on the PC and the RS-232 port on the data logger, or you can use a USB to RS-232 cable. If you are connecting to a CS I/O port, you must also use an RS-232 to CS I/O converter, such as the SC32B Optically Isolated RS-232 Interface.
The baud rate you select in the software must match the baud rate of the data logger serial port. For example, CR200-series dataloggers and CR10X dataloggers are always 9600 baud. CR1000 and similar data loggers can handle baud rates up to 115200. The CR1000 defaults to a baud rate of -115200, which means 115200 with autobaud enabled. The autobaud option tries to adjust the baud rate automatically to match the PC. Although autobaud is reliable at adjusting down the baud rate, it does have trouble adjusting up from 9600 to 115200. So, if someone else connects to your CR1000 at 9600 baud, you may have trouble connecting at 115200. After you successfully connect, you can change the baud rate setting for the serial port on the data logger.
I believe you are requesting the ability to do a low level IO log in a datalogger. It can be done with CRBasic code, but it is easier to do with a setting on the datalogger instead. The Files Manager in the Advanced settings on the datalogger allows logging traffic on a serial port to a file. There is help provided in the settings editor.
Synchronization of the data acquisition (DAQ) process relative to an external event is an important criterion in many DAQ applications. For example, you may want to collect data after receiving a pulse signal from an encoder or when the temperature of a chamber exceeds a critical value. In such instances, the DAQ system must be set up to start the analog-to-digital (A/D) conversions as soon as the external event, or trigger occurs.A triggered acquisition provides two key benefits to the user: It times the input signal relative to the trigger event so the user captures the signal only in the region of interest and thus conserves hardware bandwidth and memory.
In a posttriggered acquisition, the A/D conversions start after the DAQ hardware receives the trigger signal. The digital trigger is typically wired to the external trigger input of the I/O connector of the specified device.The following code shows how to set up a posttriggered application using NI-DAQmx functions:
Download the free ComDebug serial port monitor software. This provides many features which let you detect, and correct, communication errors. Please note that we can't offer free technical support for the free software - if you need help using it click the program's Help button or see this web page.
For additional information on programming using NI-DAQmx and text-based languages, refer to Using NI-DAQ in Text-Based Programming Environments, Python Resources for NI Hardware and Software and to the NI-DAQmx Readme.Q: With which application development environments can I use NI-DAQmx?A: NI-DAQmx for Windows works with many of the most popular ADEs. When installing NI-DAQmx, you can choose to install support for various ADEs including:
If you are using a Microsoft development environment, consider using Measurement Studio to dramatically reduce your application development time. Measurement Studio provides tools designed specifically for Microsoft Visual Basic, Visual C# .NET, and Visual C++ to bring you simplified integration with data acquisition and instrument control interfaces for easier hardware integration.
NI-DAQmx provides support for PC buses including USB 2.0, PCI, PCI Express, PXI, and PXI Express. Unlike other data acquisition drivers, NI-DAQmx provides a bus and device impartial framework to allow for the same driver and developed application to run on multiple devices. For instance, an application originally developed for use with the PCI-6229 low-cost M Series device also works with the PXI-6281 high-accuracy M Series device, the USB-6259 BNC high-speed M Series device, and more.
A: Many deployed LabVIEW and NI LabWindows/CVI data acquisition applications do not require support for all of the functionality of the NI-DAQmx driver and utilities. With NI-DAQmx version 8.6.1 and previous, you can deploy five different runtime versions of NI-DAQmx, ranging from the full-featured driver to a size-optimized runtime engine. With any version 8.7.1 or newer, the only install type selectable is Full. The additional options were removed because omitting specific features such as Measurement & Automation Explorer (MAX), makes it much harder to program the source files that use the DAQmx driver. Before choosing a limited runtime of NI-DAQmx, be aware of the difficulty in future development if building an NI-DAQmx installer with the limited selections.
Q: How does a state machine help improve the performance of NI-DAQmx?A: The NI-DAQmx task state machine keeps track of which configuration operations you need to perform before a data acquisition or generation can begin. Configuration operations include checking the configuration (verify), reserving resources (reserve), and programming the hardware (commit).NI-DAQmx implements a state machine to ensure that expensive operations such as task verification, resource reservation, and hardware programming are performed only when needed. A DAQ application can benefit from improved performance when performing explicit configuration operations outside the main acquisition or generation loop. NI-DAQmx offers explicit commands that cause a verify, reserve, or commit operation to be performed. When a task is explicitly verified, reserved, committed, or started outside an acquisition or generation loop, NI-DAQmx does not repeat these operations at every loop iteration, so overall, the application runs faster.
For additional information about each of the NI-DAQmx states, refer to the NI-DAQmx Help.Q: What are the primary factors that limit streaming-to-disk performance?A: Disk I/O bandwidth, CPU bandwidth, and bus bandwidth are the primary factors that limit streaming-to-disk performance.Disk I/O BandwidthThe typical system with an IDE drive is primarily limited by the disk throughput.Potential improvements include adding a dedicated drive or controller for streaming. A dedicated drive circumvents performance problems due to fragmentation and disk access by the OS or other application. High-speed drives and a high-speed RAID controller increase the disk I/O bandwidth.Note: Check the CPU bandwidth and bus bandwidth before investing in drives and controllers to avoid increasing disk I/O beyond what you can realistically use.CPU BandwidthFor unscaled data, processor bandwidth generally impacts performance only in systems where a high-speed RAID controller has been installed. In these systems, the CPU can impact how quickly you can retrieve and write acquired data to the disk drive. Even with a dedicated RAID controller, a portion of the CPU bandwidth is consumed while writing data to disk. For scaled data, processor bandwidth is often the limiting factor.Increasing the number of CPUs in the system and the speed of the CPUs increases the system bandwidth.Even when a CPU uses less than 100 percent, minimize tasks and operations done in parallel. Competition for scarce resources can lower streaming-to-disk performance.Finally, tune the streaming code for the particular system. For systems with multiple CPUs, executing some code in parallel may increase the throughput of the system.
Refer to the Transition Traditional NI-DAQ to NI-DAQmx tutorial in the Developer Zone at ni.com for additional help on writing counter applications in NI-DAQmx.Q: How can I do double-buffered acquisition in NI-DAQmx?A: If you are doing double-buffered I/O, you would most likely be polling the buffers to continuously acquire data. In NI-DAQmx, you can achieve this simply by using the NI-DAQmx timing function and setting the Sample Mode parameter to Continuous.NI-DAQmx uses circular buffers. For input operations, portions of data are read from the buffer while the buffer is filled. Likewise for output operations, portions of the buffer can be written to while the buffer is emptied. Using a circular buffer, you can set up your device to continuously acquire data in the background while NI-DAQmx retrieves the acquired data.
I am looking for a simple means of triggering my data acquisition software using an external TTL pulse. I need to sample data from multiple sources synchronously with a 5 Hz reference clock. The acquisition does not need real-time priority but I want to ensure that my software is triggered as soon as possible and exactly once per external clock cycle. I would prefer to do this by somehow getting an interrupt from the external trigger without needing to use a fast polling loop. As far as I can tell, you can't just use a parallel port pin for an interrupt in a modern OS like Linux. Any ideas?
Rather than use the parallel port, have you considered using a serial device? Since you have a TTL signal, you'll possibly need a level converter to convert TTL to RS232 +/- 12V levels. Once you're using a serial device, you can use the standard serial ioctl() calls to detect a change in control signal status. 2ff7e9595c
Comments