• R/O
  • HTTP
  • SSH
  • HTTPS

提交

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

QtSDK と NI-DAQmxBase (Linux) を使った単純なサンプル


Commit MetaInfo

修订版ca2a4dc1a93a5f7f0b57ffed77786cda5bf3a4bc (tree)
时间2012-08-22 15:28:00
作者arakaki <alucky4416@user...>
Commiterarakaki

Log Message

DEL: genDigPulse.c

更改概述

  • delete: genDigPulse.c

差异

--- a/genDigPulse.c
+++ /dev/null
@@ -1,102 +0,0 @@
1-/*********************************************************************
2-*
3-* ANSI C Example program:
4-* genDigPulse.c
5-*
6-* Example Category:
7-* CO
8-*
9-* Description:
10-* This example demonstrates how to generate a single digital pulse
11-* from a Counter Output Channel. The Frequency, and Duty Cycle
12-* are all configurable.
13-*
14-* Instructions for Running:
15-* 1. Select the Physical Channel which corresponds to the counter
16-* you want to output your signal to on the DAQ device.
17-* 2. Enter the Frequency and Duty Cycle to define the pulse
18-* parameters. Additionally, you can set the Initial Delay
19-* (in seconds) which will delay the beginning of the pulse from
20-* the start call; this is currently set to 0.0 in the code.
21-* Note: Use the pulseWidth example to verify you are
22-* outputting the pulse on the DAQ device.
23-*
24-* Steps:
25-* 1. Create a task.
26-* 2. Create a Counter Output channel to produce a Pulse in terms
27-* of Frequency.
28-* 3. Call the Start function to arm the counter and begin the
29-* pulse generation. The pulse would not begin until after the
30-* Initial Delay (in seconds) has expired.
31-* 4. Use the IsTaskDone function to ensure the entire pulse
32-* is generated before ending the task.
33-* 5. Call the Clear Task function to clear the Task.
34-* 6. Display an error if any.
35-*
36-* I/O Connections Overview:
37-* The counter will output the pulse on the output terminal of the
38-* counter specified in the Physical Channel I/O control.
39-*
40-* In this example the output will be sent to the default output
41-* terminal on ctr0.
42-*
43-* For more information on the default counter input and output
44-* terminals for your device, open the NI-DAQmx Base Help, and refer
45-* to Counter Signal Connections found under the Device Considerations
46-* book in the table of contents.
47-*
48-* Recommended Use:
49-* Call Configure and Start functions.
50-* Call Stop function at the end.
51-*
52-*********************************************************************/
53-
54-#include "NIDAQmxBase.h"
55-#include <stdio.h>
56-#include <time.h>
57-#include <unistd.h>
58-
59-#define DAQmxErrChk(functionCall) { if( DAQmxFailed(error=(functionCall)) ) { goto Error; } }
60-
61-int main(void)
62-{
63- // Task parameters
64- int32 error = 0;
65- TaskHandle taskHandle = 0;
66- char errBuff[2048]={'\0'};
67- time_t startTime;
68-
69- // Channel parameters
70- char chan[] = "Dev1/ctr0";
71- float64 freq = 1.0;
72- float64 duty = 0.5;
73- float64 delay = 0.0;
74-
75- // Data write parameters
76- float64 timeout = 10.0;
77- bool32 done = 0;
78-
79-
80- DAQmxErrChk (DAQmxBaseCreateTask("",&taskHandle));
81- DAQmxErrChk (DAQmxBaseCreateCOPulseChanFreq(taskHandle,chan,"",DAQmx_Val_Hz,DAQmx_Val_Low,delay,freq,duty));
82- DAQmxErrChk (DAQmxBaseStartTask(taskHandle));
83-
84- // The loop will quit after 10 seconds
85- startTime = time(NULL);
86- while( !done && time(NULL)<startTime+10 ) {
87- DAQmxErrChk (DAQmxBaseIsTaskDone(taskHandle,&done));
88- if( !done )
89- usleep(100000);
90- }
91-
92-Error:
93- if( DAQmxFailed(error) )
94- DAQmxBaseGetExtendedErrorInfo(errBuff,2048);
95- if( taskHandle!=0 ) {
96- DAQmxBaseStopTask(taskHandle);
97- DAQmxBaseClearTask(taskHandle);
98- }
99- if( DAQmxFailed(error) )
100- printf ("DAQmxBase Error %ld: %s\n", error, errBuff);
101- return 0;
102-}