From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
06-23-2008 03:44 PM
06-24-2008 03:37 PM
Hello JSInc,
06-24-2008 04:50 PM
06-25-2008 06:54 PM
Hi JSInc,
Yes this can be done in C# using callbacks instead of while loops. I would look at modifying the ContAcqVoltageSamples_IntClkAnalogStart example program because this example would have the callbacks already set up. There are a few adjustmentst that you can make to the code to recreate the LabVIEW example you previously found.
The first change would be to make the task type FiniteSamples when configuring the sample clock Timing specs. You will also need to make sure that the Samples /Channel input on the form is what is used for the number of samples to read when configuring the sample clock.
The next change to make is in the code, after you configure the task, there is a function that verifies the task. You can copy and paste to repeat this task, but change Verify to Commit, so that the task is commited as I stated inmy previous post.
The last edit you will need to make is, in the AnalogInCallback, you will want to add a myTask.start (); after the myTask.stop(); This is what creates the element of retriggerability. When we first start the task it waits until the analog trigger to acquire a finite amount of samples, display the sample, stop the task, and then start the task again so that it is waiting for the next analog trigger.
I hope this explanation helps,
Mallori M.
07-03-2008 10:41 AM
07-04-2008 12:04 AM
07-04-2008 02:48 PM
Hello Mallori,
It seems like if I do not do the last edit, the code is already functioning as expected as the Labview example. Any comment?
Thanks,
JSInc
07-07-2008 02:36 PM
Hi JSInc,
Sorry about that, you might need to add the stop task to the callback as seen in the attached image. If you are expecting to only trigger once each time you hit the start button, then it should work fine without the stop and start tasks. However, if you want the retriggerability, where you only push the start button once but each time a rising edge is seen a finite number of samples is taken, then I believe that you will need the stop and start tasks. However, if the program is working to your satisfaction, then you can just keep this in mind in case you need to change the behavior later down the road.
Regards, Mallori M.
07-07-2008 03:08 PM
07-08-2008 04:13 PM
Hello JSInc,
To accomplish a millisecond level start delay in C#, you should change the StartTriggerDelayUnits to either SampleClockPeriods or Ticks. Suppose I was using a 1MHz sample clock, and I wanted to have a start trigger delay of 1 millisecond. The code to configure my start trigger delay might look something like this:
//Configure Start Trigger Delay
DelayUnits = StartTriggerDelayUnits.SampleClockPeriods;
myTask.Triggers.StartTrigger.Delay = Convert.ToDouble(1000);
The number of sample clock periods should be the number of millisecond delay you want times 1000 for a 1MHz sample clock.
Best wishes,
Wallace F.