Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Continuous patern generation with PCI 6534 using CSharp

Hello,
 
I am using a PCI 6534 board and I want to generate a continuous pattern from onboard memory. The software has to be written in CSharp.
 
I have found the following code example that is supposed to do this in C++ 6.0
 
DAQmxCreateTask("",&taskHandle)
DAQmxCreateDOChan(taskHandle,"Dev1/port0","",DAQmx_Val_ChanForAllLines)
DAQmxCfgSampClkTiming(taskHandle,"/Dev1/PFI0",1000.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,1000)
DAQmxGetDOUseOnlyOnBrdMem(TaskHandle taskHandle, const char channel[], bool32 *data);
DAQmxSetWriteRegenMode(TaskHandle taskHandle, DAQmx_Val_AllowRegen );
DAQmxWriteDigitalU32(taskHandle,8,0,10.0,DAQmx_Val_GroupByChannel,data,NULL,NULL)
DAQmxStartTask(taskHandle)
//keep doing until stop or error
DAQmxStopTask(taskHandle);
DAQmxClearTask(taskHandle);
 
But I have a hard time finding .Net equivalent functions. Attached is the CSharp code I have been able to come up with. I would appreciate if someone could review this code and point me in the right direction.
 
I have found very few .Net base source code for NI-DAQmx. If someone could point me to some example code that would greatly help.
 
Thanks,
 
 
Vincent
 
 
 
 

 
0 Kudos
Message 1 of 4
(3,764 Views)
Hello Vincent,

The DAQmx examples for C# install by default to the following location:

C:\Program Files\National Instruments\MeasurementStudioVS2003\DotNET\Examples\DAQmx

Within this folder, if you navigate to Digital\Generate Values\WriteDigChan_ExtClk, you will find an example for a finite externally clocked digital output.  This could easily be modified to continuous internally clocked digital output by changing the parameters of the ConfigureSampleClock function.  Take a look at this example and let us know if you have any questions. 

Best regards,
0 Kudos
Message 2 of 4
(3,756 Views)
Jarrod
 
I did look at the example you mentioned. I was able to produce the code I attached in my previous posting based on that example. Unfortunately I haven't been able to find an example illustrating the transfer of data to on board memory to then generate a pattern based on the data in on board memory.
 
The code that I attached is my attempt to solve that problem but the DAQmx .Net documentation is very poor. It explain what a method or property is but in most cases there it does not expain how to use it.
 
Could you please look at the code I attached in my previous post and answer the following questions:
 
Do I need the following line MyTask.Stream.WriteRegenerationMode = WriteRegenerationMode.AllowRegeneration;
since I used SampleQuantityMode.ContinuousSamples in the ConfigureSampleClock call? If the call is not needed what is it used for?
 
It seems to me that the following properties MyTask.Stream.TotalSamplesGeneratedPerChannel, MyTask.Stream.Buffer.OutputOnBoardBufferSize must always have identical values and must be the same as the last parameter pasted to the ConfigureSampleClock call. If it is true then why are those two properties user settable? Is setting the second properties what determines that data written goes to on board memory and not the computer memory? And what happens if both OutputOnBoardBufferSize and OutputBufferSize are set?
 
For the method digitalMultiChannelWriter.WriteMultiSamplePort how does the second parameter needs to be layed out? If I want to use two 16 bit channels do I need to have a buffer composed of 16 bit with each consecutive values for each channels or do I need to enter 32 bit values which will be split between the two channels?
 
Any other advice would be appreciated.
 
Thanks,
 
Vincent
0 Kudos
Message 3 of 4
(3,747 Views)
Hello Vincent,

Let me try to simplify what you need to do.  The only changes you should have to make to the example I previously mentioned are the following:

1.  Change the sample timing type to continuous rather than finite:
    (set the sampleMode parameter in the ConfigureSampleClock function to SampleQuantityMode.ContinuousSamples).
2.  Change the clock source to internal:
    (set the signalSource input to an empty string "")

I mentioned these changes in my last post.  There are two other changes to make if you want to enable looping from onboard memory:

3.  Set the property MyTask.DOChannels.All.UseOnlyOnBoardMemory to true.
4.  Set the property MyTask.Stream.WriteRegenerationMode to WriteRegenerationMode.AllowRegeneration.

That should be all that you need to program this application.  Some of the other functions you mentioned are unnecessary.  Let me know if you have any further questions about this.

Best regards,
0 Kudos
Message 4 of 4
(3,734 Views)