Hi @ all
brauch mal n paar Profis hier !!
sollte diesen Ansi C Code in Auto It zum laufen kriegen.
Spoiler anzeigen
/*********************************************************************
*
* ANSI C Example program:
* ReadDigPort.c
*
* Example Category:
* DI
*
* Description:
* This example demonstrates how to read values from a digital
* input port.
*
* Instructions for Running:
* 1. Select the digital port on the DAQ device to be read.
* Note: The Data Read indicator is in hexadecimal.
*
* Steps:
* 1. Create a task.
* 2. Create a Digital Input channel. Use one channel for all
* lines. In this case, the port itself acts as an individual
* channel.
* 3. Call the Start function to start the task.
* 4. Read the digital data. This read function reads a single
* sample of digital data on demand, so no timeout is necessary.
* 5. Call the Clear Task function to clear the Task.
* 6. Display an error if any.
*
* I/O Connections Overview:
* Make sure your signal input terminals match the Port I/O
* Control. In this case wire your digital signals to the first N
* digital lines on your DAQ Device.
*
*********************************************************************/
#include <stdio.h>
#include <NIDAQmx.h>
#define DAQmxErrChk(functionCall) if( DAQmxFailed(error=(functionCall)) ) goto Error; else
int main(void)
{
int32 error=0;
TaskHandle taskHandle=0;
uInt32 data;
char errBuff[2048]={'\0'};
int32 read;
/*********************************************/
// DAQmx Configure Code
/*********************************************/
DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
DAQmxErrChk (DAQmxCreateDIChan(taskHandle,"Dev1/port0","",DAQmx_Val_ChanForAllLines));
/*********************************************/
// DAQmx Start Code
/*********************************************/
DAQmxErrChk (DAQmxStartTask(taskHandle));
/*********************************************/
// DAQmx Read Code
/*********************************************/
DAQmxErrChk (DAQmxReadDigitalU32(taskHandle,1,10.0,DAQmx_Val_GroupByChannel,&data,1,&read,NULL));
printf("Data acquired: 0x%X\n",data);
Error:
if( DAQmxFailed(error) )
DAQmxGetExtendedErrorInfo(errBuff,2048);
if( taskHandle!=0 ) {
/*********************************************/
// DAQmx Stop Code
/*********************************************/
DAQmxStopTask(taskHandle);
DAQmxClearTask(taskHandle);
}
if( DAQmxFailed(error) )
printf("DAQmx Error: %s\n",errBuff);
printf("End of program, press Enter key to quit\n");
getchar();
return 0;
}
hab schon mal angefangen aber sehe kaum chancen, weil ich ANSI C nicht kenne
Spoiler anzeigen
#cs ----------------------------------------------------------------------------
ANSI C Example program:
ReadDigPort.c
Example Category:
DI
Description:
This example demonstrates how to read values from a digital
input port.
Instructions for Running:
1. Select the digital port on the DAQ device to be read.
Note: The Data Read indicator is in hexadecimal.
Steps:
1. Create a task.
2. Create a Digital Input channel. Use one channel for all
lines. In this case, the port itself acts as an individual
channel.
3. Call the Start function to start the task.
4. Read the digital data. This read function reads a single
sample of digital data on demand, so no timeout is necessary.
5. Call the Clear Task function to clear the Task.
6. Display an error if any.
I/O Connections Overview:
Make sure your signal input terminals match the Port I/O
Control. In this case wire your digital signals to the first N
digital lines on your DAQ Device.
#ce ----------------------------------------------------------------------------
;#include <stdio.h> ; fällt glaube ich weg, da nicht benötigt in autoit
#include <NIDAQmx.h> !! ?? kenn ich nicht .. scheint aber wichtig zu sein ..
#define DAQmxErrChk(functionCall) if( DAQmxFailed(error=(functionCall)) ) then _Error(); else ; ?? absolut keine ahnung ..
; main
Global $error = 0 ; int32
Global $taskHandle = 0 ; TaskHandle
Global $data ; uInt32
Global $errBuff[2048] = '\0'; char
Global $read ; int32
;----------------------------------------------
; DAQmx Configure Code
DAQmxErrChk(DAQmxCreateTask("", &taskHandle));
DAQmxErrChk(DAQmxCreateDIChan(taskHandle, "Dev1/port0", "", DAQmx_Val_ChanForAllLines));
;----------------------------------------------
; DAQmx Start Code
DAQmxErrChk(DAQmxStartTask(taskHandle));
;----------------------------------------------
; DAQmx Read Code
DAQmxErrChk(DAQmxReadDigitalU32(taskHandle, 1, 10.0, DAQmx_Val_GroupByChannel, &data, 1, &read, NULL));
;----------------------------------------------
MsgBox(0, "", "Data acquired: 0x%X\n" & $data);
Exit
Func _Error()
If DAQmxFailed($error) Then
DAQmxGetExtendedErrorInfo($errBuff, 2048);
ElseIf $taskHandle = 0 Then
;----------------------------------------------
; DAQmx Stop Code
DAQmxStopTask($taskHandle);
DAQmxClearTask($taskHandle);
;----------------------------------------------
;### Tidy Error: If/ElseIf statement without a then..
ElseIf DAQmxFailed($error)
MsgBox(0, "DAQmx Error: %s\n", $errBuff);
EndIf
;printf("End of program, press Enter key to quit\n");
;getchar();
Return 0;
EndFunc ;==>_Error
ich denke mal dass die include zwingend erforderlich ist, kann ich diese auch in autoit anbinden =?
oder muss ich die dann auch neu schreiben ?
quelle folgt ... http://www.fileuploadx.de/282213
.. vielleicht kann mir ja jemand helfen ..
danke !!