• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

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

Revision5ed12a22b36b73a0e3f758ef86d017a33046861b (tree)
Zeit2012-08-23 11:02:53
Autorarakaki <alucky4416@user...>
Commiterarakaki

Log Message

CHG: Worked. Pulse output on/off, and Change Freq, Duty when while
PulseOutput.

Ändern Zusammenfassung

Diff

--- a/daqthread.cpp
+++ b/daqthread.cpp
@@ -62,25 +62,11 @@ void DAQThread::run()
6262 DAQmxBaseGetDevSerialNum("Dev1", &serialnumber);
6363 qDebug() << QString("%1 SerialNumber is 0x%2").arg("Dev1").arg(serialnumber, 8, 16, QChar('0'));
6464
65+// DAQmxBaseResetDevice("Dev1");
66+
6567 // signal - daqmxbase ready
6668 emit daqmxbase_ready();
6769
68-#if 0
69- /*********************************************/
70- // DAQmx Configure Code
71- /*********************************************/
72- DAQmxErrChk (DAQmxBaseCreateTask("", &taskHandle));
73- // int32 DAQmxBaseCreateCOPulseChanFreq (TaskHandle taskHandle, const char counter[ ], const char nameToAssignToChannel[ ], int32 units, int32 idleState, float64 initialDelay, float64 freq, float64 dutyCycle);
74- DAQmxErrChk (DAQmxBaseCreateCOPulseChanFreq (taskHandle, ctrname, "", DAQmx_Val_Hz, DAQmx_Val_Low, (float64)0.0, pulse_freq, pulse_ducy));
75-
76- // int32 DAQmxBaseCfgImplicitTiming (TaskHandle taskHandle, int32 sampleMode, uInt64 sampsPerChanToAcquire);
77- DAQmxErrChk (DAQmxBaseCfgImplicitTiming (taskHandle, DAQmx_Val_ContSamps, (uInt64)0));
78- /*********************************************/
79- // DAQmx Start Code
80- /*********************************************/
81- DAQmxBaseStartTask(taskHandle);
82-#endif
83-
8470 while(!stopped) {
8571 if (EvtQue->isEmpty()) {
8672 msleep(100);
@@ -91,34 +77,36 @@ void DAQThread::run()
9177 switch (state) {
9278 case State_IDLE:
9379 if (event == Ev_Start) {
94-// qDebug() << "start pulse output."; // start Pulse output
9580 qDebug() << QString("start pulse output: freq = %1, ducy = %2").arg(pulse_freq).arg(pulse_duty);
9681 // int32 DAQmxBaseCreateCOPulseChanFreq (TaskHandle taskHandle, const char counter[ ], const char nameToAssignToChannel[ ], int32 units, int32 idleState, float64 initialDelay, float64 freq, float64 dutyCycle);
9782 DAQmxErrChk (DAQmxBaseCreateTask("", &taskHandle));
9883 DAQmxErrChk (DAQmxBaseCreateCOPulseChanFreq (taskHandle, ctrname, "", DAQmx_Val_Hz, DAQmx_Val_Low, (float64)0.0, pulse_freq, pulse_duty));
9984 // int32 DAQmxBaseCfgImplicitTiming (TaskHandle taskHandle, int32 sampleMode, uInt64 sampsPerChanToAcquire);
10085 DAQmxErrChk (DAQmxBaseCfgImplicitTiming (taskHandle, DAQmx_Val_ContSamps, (uInt64)0));
101- // msleep(100);
10286 DAQmxErrChk (DAQmxBaseStartTask (taskHandle));
10387 state = State_OUTPUT;
10488 }
10589 break;
10690 case State_OUTPUT:
10791 if (event == Ev_Stop) {
108- qDebug() << "stop pulse output.";; // stop Pulse
92+ qDebug() << "stop pulse output."; // stop Pulse
10993 DAQmxErrChk (DAQmxBaseStopTask (taskHandle));
94+ msleep(200);
11095 DAQmxErrChk (DAQmxBaseClearTask (taskHandle));
96+ taskHandle = 0;
11197 state = State_IDLE;
11298 } else if (event == Ev_ChgPulse) {
113- qDebug() << "change pulse freq, ducy.";; // change Pulse Freq, Ducy
99+ qDebug() << QString("change pulse freq, duty : freq = %1, ducy = %2").arg(pulse_freq).arg(pulse_duty);
114100 DAQmxErrChk (DAQmxBaseStopTask (taskHandle));
101+ msleep(200);
115102 DAQmxErrChk (DAQmxBaseClearTask (taskHandle));
116-// msleep(100);
103+ taskHandle = 0;
104+ // msleep(200);
117105 DAQmxErrChk (DAQmxBaseCreateTask("", &taskHandle));
118106 // int32 DAQmxBaseCreateCOPulseChanFreq (TaskHandle taskHandle, const char counter[ ], const char nameToAssignToChannel[ ], int32 units, int32 idleState, float64 initialDelay, float64 freq, float64 dutyCycle);
119107 DAQmxErrChk (DAQmxBaseCreateCOPulseChanFreq (taskHandle, ctrname, "", DAQmx_Val_Hz, DAQmx_Val_Low, (float64)0.0, pulse_freq, pulse_duty));
120108 // int32 DAQmxBaseCfgImplicitTiming (TaskHandle taskHandle, int32 sampleMode, uInt64 sampsPerChanToAcquire);
121- DAQmxErrChk (DAQmxBaseCfgImplicitTiming (taskHandle, DAQmx_Val_FiniteSamps, (uInt64)0));
109+ DAQmxErrChk (DAQmxBaseCfgImplicitTiming (taskHandle, DAQmx_Val_ContSamps, (uInt64)0));
122110 DAQmxErrChk (DAQmxBaseStartTask (taskHandle));
123111 }
124112 break;
@@ -139,6 +127,7 @@ Error:
139127 // DAQmx Stop Code
140128 /*********************************************/
141129 DAQmxBaseStopTask(taskHandle);
130+ msleep(200);
142131 DAQmxBaseClearTask(taskHandle);
143132 emit daqmxbase_final();
144133 }