DAQmxRegis​terEveryNS​amplesEven​t used correctly?

I have the following code :
'Add an analog input channel to the task.
DAQmxErrChk DAQmxCreateAIVoltageChan(taskHandle, "Dev1/ai0:7", "channel1", _
        DAQmx_Val_Cfg_Default, "-10", "10", _
        DAQmx_Val_VoltageUnits1_Volts, "")
'Configure task for continuous sample acquisition and read in data
DAQmxErrChk DAQmxCfgSampClkTiming(taskHandle, "OnboardClock", frmSettings.txtRate.Text, DAQmx_Val_Rising, _
             DAQmx_Val_AcquisitionType_ContSamps, CLng(frmSetMachine.txtSamplesPerChannel.Text))
'DAQmxErrChk DAQmxCfgSampClkTiming(taskHandle, "OnboardClock", frmSettings.txtRate.Text, DAQmx_Val_Rising, _
             'DAQmx_Val_AcquisitionType_ContSamps, CLng(frmSettings.txtRate.Text) / 10#)
'DAQmxCfgAnlgEdgeStartTrig taskHandle, "channel1", DAQmx_Val_Slope1_RisingSlope, #
DAQmxCfgAnlgEdgeStartTrig taskHandle, "channel1", DAQmx_Val_Slope1_RisingSlope, triggerVolume ' 0# ' triggerPressure
   'Initiate for Acquisition Event
DAQmxErrChk DAQmxGetTaskNumChans(taskHandle, numChannels)
etc etc
DummySub DAQmxRegisterEveryNSamplesEvent(taskHandle, DAQmx_Val_Acquired_Into_Buffer, CLng(frmSetMachine.txtSamplesPerChannel.Text), 0, AddressOf EveryNSamplesCallback, Null)
I get a compile error : Invalid use of AddressOf operator.
The callback is:
Public Function EveryNSamplesCallback(taskHandle As Long, everyNsamplesEventType As Long, nSamples As Long, callbackData As Long) As Long
If I just do:
DummySub DAQmxRegisterEveryNSamplesEvent(taskHandle, DAQmx_Val_Acquired_Into_Buffer, CLng(frmSetMachine.txtSamplesPerChannel.Text), 0, EveryNSamplesCallback, Null)
I get "argument not optional" and its pointing at EveryNSamplesCallback.
How do I fix this compile error? Also, is there anything else I need to add in code, or will this event fire automatically once I get past the compile issue?
thanks,
saroj

Hi,
The callback function must be declared in a .bas module, not in the form code.
The following code comes  from the  nidaqmx\Analog In\Measure Slow Varying Signal\One Sample sample and it works !!
(better than NI original code :-) )
good luck
Thierry
In the form code :
' stop task button
Private Sub bstoptask_Click()
    DAQmxErrChk DAQmxStopTask(taskHandle)
    taskIsRunning = False
End Sub
' start measurement
Private Sub startCommandButton_Click()
    Dim sampsPerChanRead As Long
    Dim errcode As Long
    On Error GoTo ErrorHandler
    If ValidateControlValues Then Exit Sub
    startCommandButton.Enabled = False
    '  Create the DAQmx task.
    DAQmxErrChk DAQmxCreateTask("", taskHandle)
    '  Add an analog input channel to the task.
    DAQmxErrChk DAQmxCreateAIVoltageChan(taskHandle, physicalChannelTextBox.Text, "", _
        DAQmx_Val_InputTermCfg_RSE,
CDbl(Val(minValueTextBox.Text)), CDbl(Val(maxValueTextBox.Text)), _
        DAQmx_Val_VoltageUnits2_Volts, "")
    DAQmxErrChk DAQmxCfgSampClkTiming(taskHandle,
"OnboardClock", 100, DAQmx_Val_Rising,
DAQmx_Val_AcquisitionType_ContSamps, 1000)
    DAQmxErrChk
DAQmxRegisterEveryNSamplesEvent(taskHandle,
DAQmx_Val_Acquired_Into_Buffer, 100, 0, AddressOf backfonc, Null)
    DAQmxErrChk DAQmxStartTask(taskHandle)
    taskIsRunning = True
    Exit Sub
ErrorHandler:
    If taskIsRunning = True Then
        DAQmxStopTask taskHandle
        DAQmxClearTask taskHandle
        taskIsRunning = False
    End If
    startCommandButton.Enabled = True
    MsgBox "Error:" & Err.Number & " " & Err.Description, , "Error"
End Sub
In the bas module :
Public total As Long
Public arraydata(0 To 1000) As Double
Public taskHandle As Long
Public taskIsRunning As Boolean
Public Function backfonc(ByVal Hwnd As Long, ByVal lParam As Long, ByVal nSamples As Long, ByVal callbackData As Long) As Long
Dim p1 As Long
    total = total + 1   ( number of calls)
    p1 = DAQmxReadAnalogF64(taskHandle, -1, 10, DAQmx_Val_GroupByScanNumber, arraydata(0), 100, 0, ByVal 0&)
    Mainform.acquisitionDataTextBox = "callback " & total & "  val=" & arraydata(0)
End Function

Similar Messages

  • Problème avec DAQmxRegis​terEveryNS​amplesEven​t, acquisitio​n et émission simultané

    Bonjour
    J'essaye de générer et acquérir un signal simultanément. Typiquement, je relie l'entrée 0 et la sortie 0 et je reçois ce que je génére.
    J'utilise donc deux taches: une dédié à l'émission et l'autre à la réception. Pour les deux, j'utilise un déclenchement sur EveryNSamplesEvent.
    Mon problème est que lorsque que je lance les taches, avant même l'exécution de la ligne de code suivante, j'ai un compte rendu d'émission correspondant à 2 secondes d'émission (en une fraction de seconde) à ma fréquence d'échantillonnage et que mon acquisition commence elle normalement (je crois). L'émission se termine ensuite seule environ 2 secondes après la fin de la génération.
    Dans l'idéal je voudrai même que l'émission et la réception soient synchrones. Je me suis donc inspiré du code exemple SynchAI-AO.c . Dans ce code seul l'acquisition fonctionne sous EveryNSamplesEvent. Néanmoins j'utilise comme dans le code exemple la définition du trigger sur /Dev1/ai/StartTrigger et la commande DAQmxCfgDigEdgeStartTrig appliqué à la tâche émission.
    Dans l'ordre, je lance la tache d'émission puis la tache de réception. Si j'échange l'ordre, la tache d'émission a le même comportement jusqu'à ce que la tache de réception se lance. Ensuite, il semble que la fonction callback de l'émission n'est plus appelée.
    Je ne comprend pas pourquoi l'EveryNSamplesEvent de l'émission se déclenche si rapidement dès le début, avant même l'acquisition. Est-il en fait possible d'avoir deux tache fonctionnant par l'EveryNSamplesEvent ?
    Merci de votre aide

    Bonjour,
    J'ai l'impression qu'il y'a quelques incohérences dans votre explication:
    j'ai un compte rendu d'émission correspondant à 2 secondes d'émission (en une fraction de seconde) à ma fréquence d'échantillonnage
    Pourquoi parlez-vous de votre fréquence d'échantillonage? Si tous vos éléments sont générés d'un coup, au lieu d'être fait en 2 secondes, j'imagine que votre fréquence d'échantillonnage n'est pas respectée.
    L'émission se termine ensuite seule environ 2 secondes après la fin de la génération.
    Qu'entendez-vous par là? Si tous vos points ont été générés depuis 2 secondes, que considérez-vous comme la fin de l'émission?
    Dans l'idéal je voudrai même que l'émission et la réception soient synchrones. Je me suis donc inspiré du code exemple SynchAI-AO.c
    Qu'entendez-vous par là? Que voulez-vous faire exactement?
    Cet exemple implémente une AI et une AO qui sont synchronisés sur le même signal d'horloge, et démarrés en même temps par un trigger. Je pense qu'il répond donc à votre besoin.
    Pour ma part, cela me semble normal qu'il n'y ait que l'acquisition qui utilise le EveryNSamplesEvent. En effet, pour la génération, vous définissez votre tableau de points à générer, ainsi que la fréquence à laquelle ils doivent être générés, et la géénration se gère d'elle même. Ensuite, l'acquisition démarre, et vous remonte les infos seulement lorsqu'elle a reçu N Samples, cela vous évite de faire du polling sur l'acquisition.
    Ces informations vous éclairent-elles sur le fonctionnement de l'exemple?
    Cordialement,
    Olivier L. | Certified LabVIEW Developer

  • Changed AppleID p-word and now can't login to icloud on mac mini. I use correct password and I get spinning grey wheel. I know it's the correct password cause any other p-word gets error message. Also, my time capsule is blinking amber.

    Changed AppleID p-word and now can't login to icloud on mac mini. I use correct password and I get spinning grey wheel. I know it's the correct password cause any other p-word gets error message. Also, my time capsule is blinking amber. I've reset my password a few times and it doesn't help. Also have shut down completely and unplugged everything to no avail.

    Hey jamesarm97 & diegofoto,
    On August 21st, some users may have been unable to access iCloud services for a short period of time. Apple worked quickly to resolve these issues, however you two may have experienced them. To check the current status of these systems please see:
    Apple - Support - System Status
    http://www.apple.com/support/systemstatus/
    If either of you are still experiencing issues, you may want to troubleshoot with the following articles:
    iCloud: Troubleshooting web browser issues with iCloud.com
    http://support.apple.com/kb/TS4050
    iCloud: Account troubleshooting
    http://support.apple.com/kb/TS3988
    Thanks,
    Matt M.

  • IP address not used correctly at RT Ping Controllers.vi

    It seems to me that the IP address provided to RT Ping Controller.vi and RT Reboot Controller is not used correctly.
    What I do is: Set the Subnet flag true and give a numerical IP adress to RT Ping Controller.vi
    What I get is the controller information for the controllers on the subnet, even if the IP does NOT match.
    Why do I do this? I want to acquire the MAC of the controller specified by the IP to use it for the reset vi.
    What I do second is: Set the subnet flag true and give an IP address to RT Reboot Controller.vi and provide a MAC address. The IP address does not match to the controller with the MAC given. The controller with the MAC reboots, independent of having a different IP.
    What is going
    on here and how can I get the correct MAC for an IP easily (i.e., without looking it up in MAX and typing it in somewhere)?

    Try setting the Local Subnet value to FALSE and pass in the IP you want to ping. You should get just details back on the target you specified, including it's MAC address. If the IP isn't a valid RT target, you will get an error.
    When Local subnet is set to TRUE, it will attempt to ping all controllers on the local subnet (regardless of the IP address passed in)--requiring you to search the resulting array for the IP you are interested in (and yep.. it might not be there).

  • HT4059 See no free books on iBooks except old fiction. Why is this so. A matter of all kinds to be free. Please advise on how to use correctly.

    See no free iBooks except old fiction. Why is this so. Please advise on how to find and use correctly.

    What country are you in ? (This page shows what content types are available where.) Some countries currently only have free books, to be able to sell recent/current books in a particular country the publisher's need to grant Apple a license to do so. Have you got access to other ebook apps/stores in your country ?

  • Why can't I update latest version of apps. Always request applied . Although I sign in using correct password

    Why can't I update latest version of apps. Always request applied. Although I sign in using correct password. But everytime prompted with incorrect password , retrieve password

    There are plenty of apps still compatible with iOS 4.2.1. Not a majority, necessarily, but they're still out there. If the app you want requires a newer version, find another app the accomplishes the same thing.
    Of course, it may be too late for that now, since you chose to hack/jailbreak your iPhone, and it is currently a brick. As varjak paw stated, this forum will not help you with your hacked phone.

  • Optimizer not using correct execution plan

    Hi ,
    DB  version : 11.2.0.3
    My sql query ran last month 1 hour. But the same sql query today running for four hours. Looks like optimizer is not using correct execution plan. I have used tuning advisor and applied recommended sql profile and query execution is back to normal. I can see statistics are upto date for the tables. Any other factors why the optimizer is not choosing correct execution plan ?
    Thanks.

    What is the correct plan according to you? Multiple factors cause optimizer to chose a different plan. As a rudimentry example - A binary index column having low cardinality than expected, after new data has been inserted. Never ever expect your query to have same execution plan till the entire lifetime, until the underlying data does not change or nobody changes database settings.
    You have to give a lot of information if you are looking for performance tuning. Pls see following thread
    https://forums.oracle.com/message/9362003#9362003

  • Report Generation Toolkit (Word) : How to use correctly bookmark and cross-reference without "Error! Reference source not found"

    Hi,
    I try to generate a report using a template. In my template I use some cross-reference to refer to one bookmark. For exemple in the first page I created a bookmark for my name and in the header I created a cross-reference refer to my name. The problems is when I run my VI the bookmark actualise perfectly but the cross-reference refer to the bookmark can't actualise with the same value and generates an error : "Error! Reference source not found".
    Can somebody help me please!
    Nki
    Solved!
    Go to Solution.
    Attachments:
    01.jpg ‏72 KB

    Hi,
    When i create the word template, the bookmaks and the cross-reference referred to the bookmark update correctely. The problem is when I try to change the bookmark using "report generation from template vi" the bookmark change but not the cross-reference and the error generated is "Error! Reference source not found". 
    I make coople reasherch and i think they have no solution for this because : "if the text in a heading referred to in a cross-reference is revised, the cross-reference to the heading may no longer work" (http://office.microsoft.com/en-us/word-help/troubleshoot-cross-references-HP005189368.aspx).
    To "resolved" this problem I create an other bookmark in the template who have the same value white the principle bookmark.   
    I use Labview 2011 and Micosoft office 2010.

  • New ipod touch cant connect to icloud using correct email

    My daughter has a new ipod touch (5th gen) and is trying to set up icloud so she can have facetime and imessage.  it won't let her sign in using the existing apple id and account i have.  the device said an email verification was sent, and it wasn't received.  i did verify that i had typed in the correct email, not only once, but twice.  any suggestions?

    Hi melluvahess,
    Welcome to the Support Communities!
    Does your daughter already have an Apple ID?  She will need one (which is her primary email address) to keep her Facetime, iMessage, Calendars, Contacts, etc. separate from yours.  (Also, verification emails may sometimes end up in your Junk or Spam folders, so be sure to check those).
    The following articles explain the options for using different Apple ID's.  Please be sure to read the "Frequently Asked Questions" section as well so that you have a good understanding of your options:
    Using your Apple ID for Apple services
    http://support.apple.com/kb/HT4895
    There is a link in this article to create a new Apple ID:
    Frequently asked questions about Apple ID
    http://support.apple.com/kb/HT5622
    Cheers,
    - Judy

  • Mail does not use correct outgoing server

    Problem
    Mail in Mavericks (and also IOS6 snf 7) does not use the outgoing smtp server associated with the account being used. This results in either a failure to send or mail being put into the wrong "Sent" folder.
    Background
    I have most of my non-icloud mail pulled down to a home server from which my laptops and ios devices access various accounts using imap. The local home server also provides smtp and relays all mail to my ISP. Recently I have been switching from an old home server (Mac Mini) to a new one (Raspberry pi running the debian Raspbian version with fetchmail,  Dovecot and postfix setup).
    While making the changeover I had access to both the old server and the new server enabled on my laptop. Naturally the majority of the settings (Name, email address etc) were the same although the name and address of the server to be used for both incoming and outgoing mail were different. This seemed tp work fine for incoming. However when I tested outgoing mail the copy that should appear in the "sentt" box  went missing. This usually indicates some mistake in the setting of the sent mail folder on the accounts but this all checked out.
    I eventually found the missing outgoing mail intended to go through the new server in the sent box on the old server. Further trials showed that no matter what I did the outgoing would always default to the old (and therefore first set up) outgoing server.
    Deleting the old account and the old outgoing server of course should cure the problem and will eventually be the solution for me when I kill the old server. But i wanted to get to the bottom of the problem in case it reappeared in other contexts. Checking the "use only this server" box produced failure to send rather than the correct result.
    Trialing various alterntaive settings showed that the problem occurs when there are two outgoing servers with the email address in the settings and the user name on the outgoing server name being the same. I had assumed that changing the description field would distinguish between the various settings; however this did not work. Changing the Name Field did work eg by putting (O) after my name.
    It appears therefore that mail selects the outgoing server on the basis of email address (with the full name included) and user name (trrespective of the actual server or the Description that shows in the smtp server listing. In some ways this is logical but it produces problems in the context I have described and would also be a difficulty if you wanted to use an alternative server when in a different location.
    I have trawled support and elsewhere for any thing similar. Lots of mail problems (don't get me started on the way icloud loses outgoing each time you edit the list!) but I have not found any posts on precisiely this point.
    IOS devices seem to have similar problems, but a quick attempt at a similar solution does not work, and I cannot be bothered  to test the options. I will simply clean them out and put in the new accounts.
    Advice
    Grateful for any comments or advice from people who have encountered similar problems and whether my diagnosis if correct. Have I missed any obvious corrections that would clear this up. I do not know whether this is a Mavericks issue or also appears in earlier OSX versions.
    CPE

    Peter,
    Where ever the Sent and Trash folders show in the Sidebar, highlight first one, and then the other, followed by clicking on Mailbox in the Menubar, and choosing Use This Mailbox For, and choose the function.
    Keep us posted on your progress.
    Ernie

  • Wine - not using correct fonts under Xorg 7.0

    How can I tell Wine to use fonts from the correct location under Xorg 7.0? There's nothing in winecfg that I can see related to it, and no file in /etc/wine to alter...

    Snowman wrote:wine 0.9.5-1 was out today. Did you try it?
    I did indeed, but sadly it had no effect.

  • Importing videos: rename uses correct date but sorted to incorrect date folder

    Hello
    I know there is an issue with importing photos directly from a device, that's not what's happening here.
    I  import photos from my camera's SD card and I rename them as they import.  Photos and video are both renamed correctly, but only the photos are sorted correctly.  The videos seem to sort based on the additional time zone adjustment, so mostly they end up in the folder for the next day (corresponding to an additional +12 hr, as though lightroom was adding the time zone correction to the local time rather than to the GMT time).  In gallery view I need to sort by name in order to sort by capture time because the renaming is the only feature that reads the correct capture time.  Sorting by capture time uses the capture time displayed in the metadata (in the right panel in the library module), which seems unrelated to the capture time.  I think it might have somethign to do with the import time, but it doesn't match any of the properties in windows explorer.
    For example:
    I took a video at 2015-02-07 1509, and that time/date appears in it's name
    It was taken in New Zealand in a +12 hr time zone (so GMT time 2015-02-07 0309, and if we apply the time zone correction to the local time it would be 2015-02-08 0309)
    When is was auto-sorted during the import it ended up in the 2015-02-08 folder
    The lightroom metadata capture time is listed as 2015-02-08 2158
    The windows explorer date modified is 2015-02-08 1509 (the correct capture time)
    The windows explorer date created and date accessed are 2015-02-08 11:27
    Note that the camera has GPS and photos are GPS tagged, so they are linked to the time zone.  As far as I can tell the videos are not GPS tagged (no GPS coordinates in properties in windows explorer).
    I'd like for the metadata to show the correct capture time and for the videos to be sorted by that correct capture time.  Lightroo obviosuly has the ability to read the capture time correctly, because it does so for the naming.  I have no idea what's going on here and would be heaps grateful for help from the wonderful adobe forums community (you guys haven't let me down yet, you beat any customer support line I've ever tried).
    PS: This is the first of a few issues I'm having with lightroom and capture time and  videos, so if you like a challenge stay tuned as I post them all up.  I'm still going through them but briefly:
    - similar video-only issues with videos from another camera: I have to double check to see if the details are the same
    - I'm having time zone issues with screenshots and saved snapchat photos from my iphone even when they are imported from a separate folder
    - accessing the capture time of iphone screenshots/snapchat photos: they get renamed based on a capture time (either the correct or time zone offset, but always something meaningful and not a blank or random time) but lightroom won't display the capture time metadata when looking at only those images, making the time zone adjustment very difficult

    LR's support for video metadata is incomplete and buggy.  Add your vote and opinion to this thread: Lightroom: Metadata applied to videos in Lightroom isn't available in other applications.

  • App store app giving error msg "ConnectionManager::invoke::Failed to find service connection url." when using correct passord

    Hi,
    I'm using the correct apple id/pwd. I get this error msg:
    ConnectionManager::invoke::Failed to find service connection url.
    Too many tries forced me to change my pwd. Using new pwd, still getting that error msg:
    ConnectionManager::invoke::Failed to find service connection url.
    Am trying to re-download purchases I lost due to needing to do a clean reinstall to correct some mystery issue. I was able to re-download some such old purchases the other day--but not now.
    Any help much appreciated!

    There is currently a system wide AppStore issue affecting certain users: http://www.apple.com/support/systemstatus
    Nothing to do with your system in particular, it's a problem on the Apple servers.

  • IPad disabled after iOS7 install. Used correct passcode.  Now what?

    iPad 4 is disabled even though I used the correct passcode after installing iOS7.  Have never connected it to another computer. Don't even have a USB cable.  How do I gain access again?

    It is still not working.  I have had Apple support on the phone twice as each time I get through the restore process it comes up with an unexplained error (3194) which they keep telling me is because I have a firewall preventing it from happening.  This is wrong because I have removed the firewall and it still comes up with the error message and will not restore.  I now have to take it to the guys I have had look at my computers from time to time to sort it out (presumabley at my cost).   If and or when it gets to the point to restore, yes I can restore from iCloud an should get all my data ok but I shouldn't really have to go through all this drama as the iPad is only very new and still under all of it's warranties etc Completely unimpressed with this whole thing.

  • My Apple ID is incorrect in my iPhone. Did the "settings...store...tap ID shown...signout...sign back in using correct ID and the incorrect ID is still appearing when I try to sign in at the Apps Store...Help!

    My question is this...My Apple ID that appears in the AppStore log in is incorrect. I have tried the recommended "Settings...Store...Tap ID shown...sign out...sign back in w/ correct ID/password multiple times.  When I go to the Apps Store to log in, the incorrect Apple ID is still displayed...have contacted Apple support numerous times and none of the suggestions offered have worked...Help!

    I had the same thing happen today on my wife's phone.  I couldn't find any answers on the support site and of course I could not get any help from Apple since my phone was old.  I kept digging and figured out how to fix the problem.  I opened the app store app and signed out of the old id and then signed back in using my new id.  It looks like this may have fixed the problem.

Maybe you are looking for

  • Error while viewing resource palette

    I installed latest 11gR1 nightly build and included the web center extension from the nightly build. I get this error when try to view the resource palette: Performing action Resource Palette[ from oracle.jdevimpl.help.HelpWindow ] Exception while pe

  • When i open pc an adobe bridge problem denotes purging

    when i open computer an adobe bridge problem denotes purging

  • Powerbook G4 sleeping on the job

    Is it possible to have the G4 notebook not go to sleep when you close the lid but instead have it keep running. I have not been able to find any setting for that Thanks In advance

  • Use of special version

    Hello guys! I am currently working on the following business scenario: My client wants to use SEM BCS to prepare consolidation following 2 different accounting principles (let’s say P1 and P2). These 2 principles have common treatments: conversions,

  • Know when UIElement is shown on screen

    Hi there, So I have a wrap panel with a scrollbar and I'm putting a bunch of controls in them.  I would like to perform actions when the controls become visible (are scrolled into view), either just for the first time or any time. Is there a way to d