Edge of metering using nicaiu.dll

I am trying to create a counter edge by directly calling functions in VB.NET nicaiu.dll. I am able to read the counter OK value but counties still return to the initial value set when I created the channel. For example, I create the task of counter by using DAQmxCreateCICountEdgesChan and the value of the initial counter 100000. I then read the meter using DAQmxReadCounterScalarU32. The County changes when I turn the encoder cable channel meter but returns to 100000 once the encoder stops.

The wiring is correct, because it works correctly using the Test i/o counter OR-max Panel. The number increases as I turn the encoder and never resets when the encoder stops.

Finally, I need to get this working using DAQmxCreateCILinEncoderChan but I see the same behavior when using this type of channel. For now, I use DAQmxCreateCICountEdgesChan because it is easier and mimics the function in the Test NOR-MAX Panel.

I did this job using the .NET DAQmx API. However, there are errors when my application runs on a computer with a different version of NOR-DAQmx of what was used when the application is compiled. The appeal of the DLL directly seems to eliminate problems with different versions of DAQmx.

No idea what I'm missing?

Public Class Form1

Private Declare Function DAQmxCreateTask Lib "nicaiu.dll" (ByVal TaskName As String, ByRef NITaskHandle As IntPtr) As Integer
Private Declare Function DAQmxCreateCICountEdgesChan Lib "nicaiu.dll" (ByVal TaskHandle As Integer, ByVal PhysicalChannel As String, ByVal NameToAssignToChannel As String, ByVal edge As Integer, ByVal InitialCount As UInteger, ByVal CountDirection As Integer) As Integer
Private Declare Function DAQmxReadCounterScalarU32 Lib "nicaiu.dll" (ByVal TaskHandle As Integer, ByVal Timeout As Double, ByRef ReadVal As UInteger, ByVal Reserved As IntPtr) As Integer

Private Const DAQmx_Val_Rising = 10280
Private Const DAQmx_Val_Falling = 10171

Private Const DAQmx_Val_CountUp = 10128
Private Const DAQmx_Val_CountDown = 10124
Private Const DAQmx_Val_ExtControlled = 10326

Private TaskHandle As IntPtr

Private Const STARTCOUNT = 100000
Private Const DEVICECHAN = ' DEV1/CTR0.

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

Dim ErrVal As Integer

ErrVal = DAQmxCreateTask ("ENCODER", TaskHandle)
Debug.WriteLineIf (ErrVal <> 0, "Error" & ErrVal.ToString)

ErrVal = DAQmxCreateCICountEdgesChan (TaskHandle, DEVICECHAN, "ENCODER", DAQmx_Val_Rising, STARTCOUNT, DAQmx_Val_CountUp)
Debug.WriteLineIf (ErrVal <> 0, "Error" & ErrVal.ToString)

End Sub

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick

Dim ErrVal As Integer
InVal As UInteger Dim

ErrVal = DAQmxReadCounterScalarU32 (TaskHandle, 0, InVal, Nothing)
Debug.WriteLineIf (ErrVal <> 0, "Error" & ErrVal.ToString)

Label1.text = InVal.ToString

End Sub

End Class

Try to explicitly run your task (DAQmxStartTask) after you have created the channel meter.  If you do not explicitly start your task, the appeal of reading starts the job instead, which would reset the count value.

As far as I know if only this should once (on the first read call), then maybe it something else.

Out of curiosity, have you considered using the API of VB.NET DAQmx instead of the dll unmanaged c?

Best regards

Tags: NI Hardware

Similar Questions

  • Which DLL to use for the use of NOR-PCI-6703? (nicaiu.dll or nidaq32.dll)

    Hello! I'm programming ATEasy (from Geotest Inc.). I have to incorporate a Council OR-PCI-6703 and I need the driver for it. I do not know what .dll file to use: nicaiu.dll or nidaq32.dll. What is the difference between these 2 files? What is the best for me to use? Please help me!

    It depends on if you use the traditional DAQ driver or the driver DAQmx. If you use the DAQmx driver you want to use the nicaiu.dll. This link will explain the necessary information to be able to use for your application.

    David has.

  • nicaiu.dll errors causes matlab Crash

    Hello

    Matlab 2010A using call nicaiu.dll and run the commands DAQmx. Most things work very well. However, very often (> 50% of the time) when I get home the DAQmx false or illegal settings (as I'm trying to develop and debug my code...) MATLAB will simply fail miserable, crash and often not even write a core dump before leaving. I guess it's a matter of Matlab and need to communicate with him (which I'll do it). However, I was wondering everyone here as the experience of something similar, and if something as simple as the upgrade/downgrade the version of Matlab help?

    Thank you

    By

    Hi per,.

    To allocate a string of length N, try to call blanks instead of char (n) (N). Char (n) converts the ASCII code to a character.

    In addition, you probably don't want subtract one from the length. Which causes DAQmx truncate the string and return WARNING 200026, ' string required could not fit into the given buffer. It does not DAQmx to omit the character of null terminator: the chain is always terminated by null, shorter than a single character.

    Brad

  • Skype Api for video calls using SKYPE4COM.dll in c#

    I want to integrate Skype video call on my Web site, is there any /API tutorial using SKYPE4COM.dll refer.

    Please help me give some mention the link to Skype video calls with asp.net c#. because most of the links that I checked is dead or cannot be found.

    Means im not able to use Skype call video integration in my Web site?

  • We monitor windows servers using pdh.dll and we receive "error PDH 0xc0000bc6:9 - &#62; data are not valid" a few times in the meantime.

    We monitor windows servers using pdh.dll and we receive "error PDH 0xc0000bc6:9-> the data is invalid" a few times. Need to understand what causes this and how to fix the same.

    Hello

    The question you posted would be better suited in the TechNet Forums. I would recommend posting your query in the TechNet Forums. You can follow the link to your question:

    http://social.technet.Microsoft.com/forums/en-us/winserverManagement/threads

    Hope this information helps.

  • How to use COM DLL in LabWindows

    Hello

    I have a COM .dll file that looks like this when opened with dll export viewer:

    I would like to use the Get4AxisPos function in LabWindows.

    I realized that, as I only have the .dll file, the only way to call these functions are the LoadLibrary() and GetProcAddress() functions.

    My problem is that the function Get4AxisPos is not of type exported function but COM method, so I don't know how to use it in my project LabWindows!

    My questions are: is - this will use this dll in Labwindows? If yes how?

    Thank you

    Use tools | Create the ActiveX controller... CVI to generate a range of function that contains the code of the interface that allows you to manipulate COM objects in the DLL. Search Help for "ActiveX controller Assistant" more information on this installation.

  • Using a dll with java

    I have to use a dll microsoft with java.
    This dll allows a specific signature of SMIME. I know some more details about it.
    I loaded the dll with System.loadLibrary ("cnascapi"); but I don't know what to do next.
    I tried
    cnascapi test = new cnascapi();
    but the error is "cannot find symbol: class cnascapi.

    Thank you.

    Google for JNI tutorial and/or the tutorial of the JNA.

    JNI is the traditional way to access native libraries via Java. JNA is a newer approach that is supposed to be simpler.

  • VBAI crashes when you use NiViAsrl.dll

    I hope that's not too a noob question...

    Suddenly last week, without any warning, VBAI would no longer start.  All my versions of VBAI had the same failure.  At the launch of the splash screen would declare "Initializing Plug-ins: nnnnnnn ' then" Validation Plug-ins "... and that's it.  He would just sit there, spinning my pointer mouse until a message box proclaimed "NI Vision Builder nnnn has stopped working".  The poor man never exceeded the start screen.  It did not matter what version I ran.  I tried 3.6, SP1 2009, 2010 and 2011 SP1, all had the same symptom.  I uninstalled them.  I have them re-installed.  The same problem.

    In Control Panel, I checked the event viewer, looking to learn more about the error.  Here is a list of errors have occurred within 10 seconds of the accident:

    Events:

    E1) LabVIEW information: error: 404 "Not Found" for "/ national instruments/vision/vision builder I / 4.2.0 /", folder "c:/program files (x 86) /national instruments/shared/or Server Web/www/national instruments/vision/vision builder have / 4.2.0 / ': can not access the URL

    E2) LabVIEW information: error: 404 "Not Found" for "/ national instruments/vision/vision builder I / commserver", folder "c:/program files (x 86) /national instruments/shared/or Server Web/www/national instruments/vision/vision builder have / commserver ': can not access the URL

    E3) Vision Builder.exe 4.2.0.0 NiViAsrl.dll 5.0.0.49152 4d2fa0d5 4c23895a c0000005 0000ac83 2394 01cd5ae877235c04 C:\Program Files (x 86) \National Instruments\Vision 2011\Vision Builder AI Builder.exe C:\Program Files (x 86) \IVI Foundation\VISA\WinNT\Bin\NiViAsrl.dll be9fb414-c6db-11e1-82af-0024e8840468

    -Events 1 & 2 above is generated because there is no directory ".../www/national instruments/vision/vision builder I / 4.2.0 / '.

    -Event 3 is a mystery to me.  The file is there, it is 79KB and was created 24/06/2010, but I don't know what he does.

    Issues related to the:

    T1) how to get / install directory and all the files that make up: "c:/program files (x 86) /national instruments/shared/or Server Web/www/national instruments/vision/blah blah blah blah blah?

    Q2) the above files can I?

    Q3) what is "NiViAsrl.dll?

    Q4) how can I do to re - install "NiViAsrl.dll?

    Thanks and admiration:

    T1) thanks in advance for helping me with this urgent problem.

    T2) my answer will be delayed until some time Friday morning.

    T3) your knowledge on questions such as these are worthy of high praise.

    The problem is the ini file NIvisa THAT MAX has been reading.

    I deleted the ports of

    C:\ProgramData\National Instruments\NIvisa\visaconf.ini

    Restarted

    And everything is cool.

    -That means THAT VBAI 2011 SP1 does not lock up when it starts.

    The two visaconf.ini files are attached to the inside of the. Zippers

    This problem has been noticed on June 29, note so when the software has been uninstalled in the report.  As part of my initial diagnosis that I took out the biggest dog I could find and remove all versions of the VBAI and all vision tools and tried to repair the drivers of devices August 2011 and tried to install the device drivers Feb 2012 and re VBAI 2011 SP1.  I must again rebuild acquisition vision (etc.).

    A the knowledge base article was useful for finding the location of the ini file.

    "Why do I have a conflict error when I try to rename my Serial Port in the Measurement & Automation Explo...

    Document ID: 3719MD5S

  • Using nilibddc dll with Python types

    I try to use this 'DiaDEM connectivity library' with Python to read files produced by our acquisition of data in the format *.tdms system, but examples of dll are all for C and Matlab. Has anyone else done that could give me advice? I made some progress (see below) by trial and error, but it is slow and I have to get it up and running quickly. I'm trying to reproduce the functions of the C example for reading a file (no need to write again).

    I'm using Python 2.6 on a Windows XP computer.

    Here's what I have so far:

    ------------------------------------
    # Module to manage a *.tdm and a *.tdms National Instruments TDM
    files in the format #.
    #
    types import *.

    #Define of the short names for the required dll functions
    DDCOpen = windll.nilibddc.DDC_OpenFile
    DDCNumGroups = windll.nilibddc.DDC_GetNumChannelGroups
    DDCReadGroups = windll.nilibddc.DDC_GetChannelGroups
    DDCGroupStrPropLen = windll.nilibddc.DDC_GetChannelGroupStringPropertyLength
    DDCGroupProperty = windll.nilibddc.DDC_GetChannelGroupProperty

    # File handles are pointers to 32-bit integer
    Czero = c_int (0)
    File descriptor = point (czero)

    # Retrieve a handle to the file
    DDCErrCode = DDCOpen (' Test_0919.tdms, 'PDM' file descriptor,)
    Print (DDCErrCode) # must be zero
    MyFile = real FileHandle.contents #The file handle

    # Find several groups
    grpnum = c_int (0)
    numPtr = point (grpnum)
    DDCErrCode = DDCNumGroups (myFile, numptr)
    Print (DDCErrCode)
    # Si DDCErrCode == 0: print (numptr.contents, grpnum)

    # Read groups [UNTESTED]
    groups = c_int (0) * grpnum
    grpptr = point (groups) # must be a pointer to the memory to organize grpnum
    Number of fields DDCChannelGrouphandle
    DDCErrCode = DDCReadGroups (myFile, groups, grpnum)
    Print (DDCErrCode)
    If DDCErrCode == 0: Print (groups)

    # Length of name of the Group [UNTESTED]
    namelen = c_int (0)
    nlenptr = point (name)
    DDCErrCode = DDCGroupStrPropLen (groups [0], 'name', namelen)
    Print (DDCErrCode)
    If DDCErrCode == 0: Print (namelen)

    #Make a buffer to hold the name, then get it back [UNTESTED]
    grpname = create_string_buffer(namelen+1)
    nameptr = point (grpname)
    DDCErrCode = DDCGroupProperty (groups [0], 'name', nameptr, namelen + 1)
    Print (DDCErrCode)
    If DDCErrCode == 0: Print (grpname.value)

    # Read the Group channels and get the names [UNTESTED]

    # Read the string # data values [UNTESTED]

    # Read the string of data values [UNTESTED]

    # Process the data values [UNTESTED]

    # Write data processed in a file in a different format [UNTESTED]
    ------------------------------------

    The "TESTED" sections are more or less pseudo-code representing things I have to do for now. The others work. These will be finally in a module.

    Cross-posted on some forums of Python.  Thanks in advance for any help.

    Kind regards
    Allen

    Can find out:

    http://Pypi.Python.org/Pypi/cTDMS/0.9

    or alternative link

    http://code.Google.com/p/ctdms/

    They seem to be exactly what you're looking for... (two years later)

  • The use of Dll in RT PXI

    Hi Fellows LabVIEW...

    I made a simple Dll (subtraction of two numbers) MS Visual Studios 2008 and I am the appellant in LabVIEW under target host computer. the Dll works fine.

    Subsequently, I pasted the same Dll in the drive C of 8106 RT controller PXI (OS Pharlap) under nor-rt\Systems folder and did a similar under the lens of Rt and deployed VI but VI is not working properly. (Only the values go out is not calculated)...

    What I have to do the DLL in another way for RT targets or I need to install additional toolboxes?

    Rohit

    DLL as far as I know are made for windows and if I'm not mistaken can be used in the PharlapOS

  • Sinc filter using the DLL implementation

    Dear all,

    I'm trying to implement a sinc filter to a data flow that I receive from card FPGA. The C code is already working and now I'm trying to do is to implement the same algo on LabVIEW or make DLL and use it and I'm doing the later approach (don't know which one is better, any ideas?). I use this tutorial and it works very well for me in the case of the same example IE multiplication please see the VI attached.

    I'm getting streams of raw data in the .csv file, and then I like to read this file. So what I have to do is apply a sinc filter so that every 32 points in this data set will be 1 sample for my position. I enclose you an example of a .csv file for data, a txt file of code C (for just to give you an idea of 3rd order) who work already, my dll and VI.

    More specifically I have problems about the selection of parameters for the DLL for example what should I choose in the settings of the DLL LabVIEW function that corresponds to "unsigned char * data" as well as for others, as written in the C code. If someone can provide me with some VI he created to implement the sinc function or some ideas it would be also great.
    Any help or advice you guys will be highly appreciated.

    Kind regards

    Kuhn

    There are a lot of discrepancies between what you do in your VI and that your text file watch is C code.

    (1) the order of the parameters is VERY different.

    (2) you are using int64 in the LabVIEW diagram, but int in C code. Under 32-bit Windows and 64-bit (and also Linux), an int type is ALWAYS a 32-bit value.

    (3) read you in a table 1 d of channels and proceed to the node library call as native data. This requires a handful of LabVIEW LabVIEW handles string table. Expect a VERY big difference to byte array pointer in C code.

    You convert the strings in a byte, and then configure the node library call to pass it as an array of integers not signed 8-bit, passed as a pointer of table data.

  • Edge of metering size buffer/table problem (VC ++)

    Hello

    Accidentally, I posted this in the multifunction DAQ forum so forgive me for posting this again here.

    I'm trying to make an edge stamped with PCI-6115 of counting for the application that I'm developing.

    Ideally, I initialize a buffer array, then use a sample clock time and acquire the values of a counter which will then be stored in a buffer.  After a number of samples, I would then use the DAQmxReadCounterU32 function to extract this data and perform calculations.

    However, windows gives me an error when I try to initialize the size of the stamp of table is larger than 255001, I need 264000 +.

    Essentially, it seems that only this part of the code to execute:

    error int = 0;

    TaskHandle taskHandle = 0;

    TaskHandle taskHandleCtr = 0;

    given uInt32 [260000];

    After trying initialize the array of uInt32 my program crashes saying there was an error with my exe with a popup asking me if I want to send an error report to Microsoft.

    That would be a problem of windows not afford to allocated more 255000 32bits samples for this table?  If so how can I put the table on the memory embedded amount?

    Sorry guys, it actually had nothing to do with the DAQ card.

    He was apparently C++ that limits the size of the array that I called him, which was the traditional "int a [size]".

    I used this rather to solve my problem:

    int * a = NULL;
    a = new int [10000000];

    Problem solved.

    Sorry for posting in the wrong forum and thanks to all who read this.

    Howard

  • use of dll in the mixed in win 2008 application fails, but the same sequences of app in win 2008 r2

    Hello

    Currently we have an application that follows set up, we have a module a [mixed-mode dll] compiled with / CLR Pavilion and we have another module B [native code [exe] which gives access to the module. Application B fails to run on the computer of 2008 victory while the same application runs with errors on a box of win 2008 r2. Its a 32 bit application. The only change that has happened in our env was until recently, we used VS 2008 compilers and so far, the applications ran fine on win 2008 and win 2008 r2 machines. But the application even when it is compiled with VS2010 causes the error to be seen only in a box 2008 victory.

    While trying to identify the issue, I tried to create the sample application that has a dll in mixed mode generated with the/clr option, and the content of the dll is just a global function that is exported by using _declspec (dllexport).

    The other application I wrote uses the .lib, .h and the dll of the module above to call the global function written. When I run the exe of the application fails with the same error. Just to be clear, that the projects are developed using VS2010.

    When I just removed the option/CLR using which is the compiled module the application works fine. Ask you to compile with / CLR, generate a dll in mixed mode is causing problems or if I'm missing some parameters.

    The application even when I came to win 2008 r2 env works fine, I even tried to copy projects to win 2008r2 box and tried to run it and it works fine.

    Please let me know if I could help in this regard or what cud be wrong in the env or if its sth a known issue. Also was wondering if his being caused somewhere in the Ombudsman (thunking).

    Point to note is that control never comes the code I've written, it fails while the modules are loaded even if my observations are correct.

    Here is a log of event viewer when the main application crashed...

    Signature of the problem:
    Problem event name: APPCRASH
    Application name: pscrrun.exe
    Application version: 8.53.0.0
    Application timestamp: 4fcd78fa
    Fault Module name: ntdll.dll
    Fault Module Version: 6.0.6002.18541
    Timestamp of Module error: 4ec3e39f
    Exception code: c0000005
    Exception offset: 00030226
    OS version: 6.0.6002.2.2.0.274.38
    Locale ID: 1033
    Additional information 1: e51a
    More information 2: 4c0d4d78887f76d971d5d00f1f20a433
    3 more information: e51a
    Additional information 4: 4c0d4d78887f76d971d5d00f1f20a433

    psccrun.exe - Application error
    The failed to initialize properly (0xc0000005).

    Thank you

    Kazadi.

    PS: this was already posted in dev/debugger vs MS forum and suggested to post here. [http://social.msdn.microsoft.com/Forums/en-US/vsdebug/thread/70da2119-7d82-4742-9441-c922e0660262]

    Hello

    Your question of Windows 2008 is more complex than what is generally answered in the Microsoft Answers forums. It is better suited for the IT Pro TechNet public. Please post your question in the TechNet Forum. You can follow the link to your question:
    http://social.technet.Microsoft.com/forums/en/winservergen/threads

  • Deploy using the DLL startup ".» CDF files.

    Hello

    I'm new to Labview and I would like to deploy startup DLL on a PXI target to help '. " CDF files.

    I already read this tutorial: http://www.ni.com/white-paper/12919/en/

    But there is no mention of deploy the DLL.

    As you can see on the screenshot below I have included the *. DLL file in the source files.

    When I build the application, I can see that the path of my dll has been added to appbuilder.cdf:

    ""

    But after the deployment, the target does not launch the DLL in any case.

    Finally when I manually add the path of my DLL in the StartupDLLs key in th or - rt.ini and then restart my target, it works fine.

    But the idea is to do it automatically using '. '. CDF files.

    Thanks for your help.

    Problem solved.

    I just paste the path to my DLL in my "." CDF file"between:

    [LVRT]

    StartupDLLs=c:/ni-rt/cvi/My_DLL.dll

    It seems that FTP helped my DLL in the folder "CVI".

    For this, I changed the value of 'Record of Support' of ' / or-rt/start/data "to"c:\ni-rt\cvi"in the properties of my real-time Application, section"Destination. "

  • I am not able to use the DLL

    Hi all

    I'm developing an application using LabView 8.6. I took the .net DLL reference. I have modified the DLL and tried to access the method I added in the DLL. But take when calling node, I have not found the new method. Then I copied the DLL to another folder from the new location reference. But it is made reference to former DLL and I get message "the version of the assembly, you have requested is automatically promoted to a later version by the .NET runtime". Also, in the dialog box select Builder .NET I can see the two DLLs.

    Please suggest the way so that I can be able to use the new DLL.

    Thank you best regards &,.

    Clondalkin

    Hi all

    I can be able to use the modified DLL after reboot of LabView. I think that LV guard reference DLLS used even if that we close the VI.

    Thank you

    Clondalkin

Maybe you are looking for