Use M-Series cards with DAQmx in Matlab!

Hi DAQers!
Who is this message for?
For all people wanting to use their M-Series cards (and/or NI_CAQmx drivers) with Matlab.
Content:
Basic introduction into importing DAQmx into Matlab. Simple AI (analog input), advanced AI (synchronous)
and simple AO solutions are displayed with Matlab source code.
Motivation:
There's probably little disagreement that the new M-Series cards are superior to the old E-Series cards.
However, Matlab does (as of February 2005) not support either directly.
By buying the Data Acquisition Toolbox you can access most of the E-Series' functions from within Matlab.
But this will not help you with your new M-Series card! But it is possible to use M-Series cards with Matlab.
First step
Start by loading the NI dll:
funclist = loadlibrary('nicaiu.dll','nidaqmx.h','alias','myni')
(You can choose any alias as long as it is a legal variable name.)
If your version of Matlab is too old to provide the "loadlibrary" function directly, download it here:
http://www.codeproject.com/dll/MatlabGenericDll.asp?df=100&forumid=26247&exp=0&select=972623
After importing, you see the list of available functions.
You can also display them by
libfunctionsview('myni')
That's basically it. By using the National Instruments NI-DAQmx C Reference manual and libfunctionsview('myni')
you have access to those functions. One special thing you need to keep in mind is the fact that pointers
work differently in Matlab than in C. This problem can be solved by using the Matlab function "libpointer".
Sometimes Matlab does not require a pointer when C would. But I found that it does not hurt to
specify a pointer in this case. Whether Matlab expects a pointer can be seen in the output
created by libfunctionsview('myni')
The general syntax for calling DAQmx functions is:
[outputarguments]=calllib(alias,NIDAQmx_functionname,inputarguments)
My next message will show a function I wrote that enables basic and advanced analoginput.
Jens

Hi!
As promised, my Matlab function to use the M-Series card with Matlab.
I have the bad habit of programming in German and English at the same time.
I tried to correct that for this posting. I hope I succeeded!
I wrote this function to suit my needs -which it does.
Feel free to modify it to suit yours.
Jens
Edit: I just saw that my m-File is longer than 5000 characters! #duh#
Sorry!
I'll see if I can get a download up!
Here's the abbreviated m-file without synchronous AI:
function messmatrix=NImess(synchron,trigger,numofchans,samprate,samptime)
funclist = loadlibrary('nicaiu.dll','nidaqmx.h','alias','myni');
disp('NI: Create Tasks')
taskh1=uint32(1);
[a,b,taskh1] = calllib('myni','DAQmxCreateTask','master',taskh1)
taskchans1=['Dev1/ai0:' num2str(numofchans-1)];
[a,b,c,d] = calllib('myni','DAQmxCreateAIVoltageChan',uint32(taskh1),taskchans1,'',-1,-10,10,DAQmx_Val_Volts,'')
nsample=samprate*samptime; %
disp('NI: Config Sample Clock')
[a,b]=calllib('myni','DAQmxCfgSampClkTiming',taskh1,'',samprate,DAQmx_Val_Rising,...
DAQmx_Val_FiniteSamps,nsample)
disp('NI: Config Digital edge start trigger')
if trigger==1
[a,b]=calllib('myni','DAQmxCfgDigEdgeStartTrig',taskh1,'/Dev1/PFI0',DAQmx_Val_Rising );
else
[a]=calllib('myni','DAQmxDisableStartTrig',taskh1)
end
disp('NI: Start task(s)')
[a]=calllib('myni','DAQmxStartTask',taskh1)
DAQmx_Val_GroupByScanNumber = 1;
readarray1=ones(numofchans,nsample);
readarray1_ptr=libpointer('doublePtr',readarray1);
sampread=0;
sampread_ptr=libpointer('int32Ptr',sampread);
empty=[];
empty_ptr=libpointer('uint32Ptr',empty);
arraylength=nsample*numofchans; % more like "buffersize",
disp('NI: Reading Data!')
[a,readarray1,sampread,empty]=calllib('myni','DAQmxReadAnalogF64',taskh1,-1,-1,...
DAQmx_Val_GroupByScanNumber,readarray1_ptr,arraylength,sampread_ptr,empty_ptr);
disp('NI: Stop task')
[a] = calllib('myni','DAQmxStopTask',taskh1);
disp('NI: Clear task(s)')
[a] = calllib('myni','DAQmxClearTask',taskh1);
messmatrix=[readarray1'];
disp('NImess finished')

Similar Messages

  • On E series Card with 2 counters I want to generate a fixed length pulse train and want to continuously monitor it.

    On E series Card with 2 counters I want to generate a fixed length pulse train and want to continuously monitor it.

    Depending on the software you are using, there are many shipping examples and example programs on the web that illustrate generating a finite pulse train. The E series boards have the DAQ-STC counter/timer chip, and so make sure you search for DAQ-STC examples. I have included links to a LabVIEW example and Measurment Studio Example in Visual Basic.
    Generate finite pulse train in LabVIEW.
    http://eagle.ni.com/stage/we/niepd_web_display.DISPLAY_EPD4?p_guid=B45EACE3DA2156A4E034080020E74861&p_node=DZ52328&p_submitted=N&p_rank=&p_answer=&p_source=Internal
    Generate finite pulse train in Visual Basic with Measurement Studio
    http://eagle.ni.com/stage/we/niepd_web_display.DISPLAY_EPD4?p_guid=B45EACE3D96156A4E034080020E74861&p_node=DZ52328&p_submitted=N&p_rank=&p_answe
    r=&p_source=Internal

  • Why can't we use iTunes gift cards with family sharing? After Christmas, we now have lots of account credit we can't use. Very frustrating.

    Why can't we use iTunes gift cards with family sharing? After Christmas, we now have lots of account credit we can't use. Very frustrating. There is no option found for using account credit.

    I just logged out of my daughter's account and back in, and now it works. Deducted from gift card account balance. So I hope this is resolved.

  • Hello i try to use another SIM card with my iphone 4s now it said i need to unlock the phone with my Sim carrier

    Hello i try to use another SIM card with my iphone 4s now it said i need to unlock the phone with my Sim carrier ... here is what it says below
    The SIM card inserted in this iPhone does not appear to be supported.
    The SIM card that you currently have installed in this iPhone is from a carrier that is not supported under the activation policy that is currently assigned by the activation server. This is not a hardware issue with the iPhone. Please insert another SIM card from a supported carrier or request that this iPhone be unlocked by your carrier. Please contact Apple for more information.

    So..  You need to contact the carrier for the iPhone's original sim card, and request they unlock it.  The carrier is the only one that can unlock the sim of the iPhone.

  • I want to use the sound card with LabView

    Hi. Who can help me, I want to use the sound card with LabView, I have found the function but I can't use it. Thanks.

    Christi,
    In LabVIEW 6.1 I found some examples they use those sound VIs. They are located in \examples\sound folder. Those examples should give you a good overview how to use the VIs.
    Hope this helps
    Roland

  • I cannot use my pci5112 card with LV ver. 6.0

    I'am trying to use my pci5112 card with LV 6.0 using the DAQ solutions. I get a message saying that I have not configured any DAQ devices. When I launch MAX I see the card there and the test panels are ok.
    I have the niscope1.6 driver installed.
    Any ideas?
    Thank you in advance.

    The PCI-5112 can only be programmed with NI-Scope. That's why the PCI-5112 does not work with the DAQ Solution Wizard.
    Fortunately, there are lots of good examples for NI-Scope in LabVIEW. You can find these in the C:\Program Files\National Instruments\LabVIEW 6.0\examples\instr\niScope directory. I would recommend starting with the Configured Acquisition example and then going from there depending on the needs of your application.
    Hope this helps,
    Jack

  • Hi i dont know why i couldnt able to purchase any apps from apple store or in itunes store using my debit card with which i used to buy before ?

    Hi i dont know why i couldnt able to purchase any apps from apple store or in itunes store using my debit card with which i used to buy before ?

    I don't know why but I suspect you are located in the Indian sub continent.   Debit cards appear to be a problem here and while many are accepted in other countries, India seems to be an exception.   Go to ...
    Apple - Support - iTunes - Contact Us   ... and ask for help.

  • Can  i use SLE4428 smart card with java card developmentkit 2.1.2

    Can i use SLE4428 smart card with java card developmentkit 2.1.2
    plz reply

    No. SLE4428 is memory card and not Java Card.

  • How to use another SIM card with my AT&T Iphone

    I have to go in france and use a French office' sim card from another provider than AT&T. But here, I've got all my professional, and private, mail box and conatct on it.
    How have I to do in order to use this other sim card in my Iphone? I don't want to buy another cell phone for only few weeks in year !
    When I was in france my provider was agree to unlock my old iphone before leaving the country. that's why that was easy for me to use it in US with an AT&T sim card. But now, they change my oldest 3g with a new one, it is impossible for me to have the same situation ...
    and I'm a AT&T customer since more two years ...

    There is no way to use a phone locked to AT&T with another provider.  AT&T does not unlock iPhones for anyone.  Ever..

  • Itunes - How to use a credit card with a remaining gift card balance

    In iTunes, I'm running into an issue where I have a gift card that is tied to my account and i have 4$ left on the card. I want to buy a song using my credit card, and I have successfully entered my credit card information into my account, but I don't know of a way to explicitly buy a iTunes song and charge my credit card rather than having it pull from my gift card's remaining balance.
    Please let me know if there is explicitly charge your credit card even with a remaining gift card balance. In recent songs that I've bought, iTunes has been automatically defaulting to use my registered gift card rather than the credit card I have on file.

    I'm having a similar issue: just redeemed a gift card for $25. I can see it in the upper right corner. Yet when I select a song to download, I am (again) asked to sign in and select a credit card to use. I don't want to use a credit card, I want to use the $25 card. This hasn't happened to me before now. If I click the 'redeem gift card' option in the credit card screen, it correctly says that that card has already been redeemed.

  • HT3702 can you use a debit card with itunes?

    hi, i am wanting to use a debit card from hdfc to make purchase on itunes. when i was living in the usa, making purchases with the debit card went smoothly but here in india despite it being an 'international' card it doesnt seem to go through and is rejected. my card works for many other sites including flipkart and amazon. not sure why apple doesnt accept debit cards

    As far as I know debit cards are no longer accepted as a valid payment method - they are not listed on this page and there have been a number of posts recently about them being declined. Do you have a credit card that you could use instead ? They are generally considered safer when used on sites where the card details are stored. The card also needs to have been issued by a bank in your country and be registered to exactly the same name and address as you have on your iTunes account.

  • "How to use an Appplicom card with Labview and a Seimens PLC"

    Hi, I am using an applicom card type PCI1500-PFB to communicate with a Seimens S7-300 CPU315-2DP plc. I am using this simply to display in a labview front panel the outputs of the plc and may in the future use switches on the front panel to control the inputs of the plc. How do I do the communication? I have setup the applicam card and have comms with the plc I think. I am trying to use data socket to communicate to the plc via the applicom card. Any suggestions?
    Thanks
    Tom

    There�s a fair bit of documentation on NI�s site regarding the Applicom card.
    The following doc does a pretty good job summarizing Applicom's PCCONF and PCINIT, and the use of ReadWait and WriteWait to ensure you�ve got communication with the between the PLC and the Applicom card:
    http://zone.ni.com/devzone/conceptd.nsf/2d17d611efb58b22862567a9006ffe76/5913e03f551de3f786256a32005b4586?OpenDocument
    Since it doesn�t sound like you�re using the LV DSC module, you can stop reading once it gets into connecting to Lookout Objects.
    Once you�re sure you�ve got comm, you can do some quick tests in LabVIEW using front panel datasocket connections as shown on page 11-12 of the following:
    http://www.ni.com/pdf/manuals/323241a.pdf
    From there, it all depends on
    the complexity of your system. If simple, you could just stay with front panel connections, or you could move to programming with the Datasocket Read and Write functions.
    ... and if you get to the point that Datasocket is too slow and cumbersome, you might want to look at the LV DSC module:
    http://ni.com/labview/labviewdsc/what_is.htm?node=10418
    =====================================================
    Fading out. " ... J. Arthur Rank on gong."

  • Cannot use seconf graphics card with Hp envy Recline

    The HP recline has 2  display adapters , INtel integrated 4600 and Nividia Gt730A. I tried to force use of the Nividia card by selecting it in the nividia control panel as the default card but it does not work. I ran dxdiag and it still show intel as the default card.
    I  tried to run 3DMark11 buy selecting Nividia but it wont run and I gethis error message:
    "Workload Single init returned error message: No outputs found on DXGI adapter"
    3Dmark11 will run with either Auto or Intel graphics card selected (but with very poor frame rates )
    So now I am not sure whether the GT730 is working of not  or is there something wrong with DXGI? , DX11? 
    Advise please.

    The 3D mark11 support forum informed that this is normal.  Explanation is as follows:
    Quote:
    "This is due to how your system is set up. The dedicated video card has no outputs - it isn't connected to a monitor. Instead your system uses some fairly elaborate gaffer tape in the video driver to render things in the dedicated card, then copy them to the integrated card video buffer which then displays them to the monitor.
    In systems like this only "auto" will work. It should still use the dedicated card (score should be different from using just the integrated one forced). "
    End Quote:
    At end of the 3DMark 11 Tests , the summary did indicate that GT730A was used .  So it's not really an issue but rather the way the dual graphics cards work in the HP Envy Recline.

  • Can I use my credit card with a foreign iTunes Store.

    Hi,
    I am currently living in Malaysia.
    I was originally using the Singaporean iTunes Store, and I have many apps purchased from that store.
    My question is: can I use my Malaysian Visa with the Singaporean iTunes Store?
    I previously used a Singaporean Visa credit card for purchases.
    is it possible to use a Malaysian Visa card for purchases as well?

    The Complete Guide to Using the iTunes Store
    "Although you can browse the iTunes Store in any country without being signed in, you can only purchase content from the iTunes Store for your own country. This is enforced via the billing address associated with your credit card or other payment method that you use with the iTunes Store, rather than your actual geographic location."

  • I can't use my debit Card with my Apple ID.

    Help Me Please. i can't use my debit card pay for iTunes store
    "This credit card cannot be used with iTunes Store. Please use another credit card."
    if you lock my debit card please unlock if you can. thank you 
    <Personal Information Edited by Host>

    The debit card must be the type of debit card that can also be used as a credit card and contains one of the logos listed in that article (Visa, Mastercard, American Express, etc.). Otherwise, that would be correct.
    Having familiarity with the message the OP is receiving, he/she can contact the iTunes Store directly to inquire about why the message is being received, and they may be able to provide some clarification on what is going on. In the meantime, a different card that has one of those logos that is applicable for their country of residence will have to be used.
    If the message says something alone the lines of "your credit card was declined," it would be an issue that would have to be resolved by the financial institution instead.

Maybe you are looking for

  • Running BDK1.1 in JDK1.5.0

    I tried to run BDK1.1 located in .\beans\beanbox\run.bat, using JDK1.5.0 (my environment is winXP), but there are error messages in the console: C:\Program Files\Java\bdk1_1\beans\jars\buttons.jar: jar load failed: java.lang.Error: java.beans.In tros

  • How do i disable the open/save image dialog box in firefox? I want to directly save the image file to the drive.

    How do i disable the open/save image dialog box in firefox? I want to directly save the image file to the drive without clicking on save option everytime when saving an image. I'm using firefox ver 35.0.1 for windows 7.

  • Mousewheel won't open link in new tab

    I used to be able to click on a link with my mousewheel and Firefox would open the link in a new tab. This has stopped working. I'm using Windows 7 Pro and Firefox 36.0.1 Which settings should I check. Windows seems OK, I'm using the same old mouse a

  • Stacking openvpn connections with systemd

    I have many openvpn servers,I am trying to stack multiple openvpn connections one though the other, that is I want tun1 to go through tun0. If I enter the commands in order and wait for the interfaces to come up before proceeding, it works. I switch

  • Installed uverse and now email suspended

    "upgraded to Uverse for phone and internet. Unable to recieve or send emails and get message that att.net account suspended....Thiis is my business acconut and this is killing my business!!!!!! How do I get this turned back on? I did not want to loos