LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Buffer Problem

I'm using a buffer to generate a pulse by frequency and duty cycle on the analog channel. I also want to be able to let the user either do continuous, by a finite amount, or by time. It works fine when the user chooses to do a continuous generator or a finite amount by number of pulses. However, if I try doing a finite amount by time I get the following error:

FATAL RUN-TIME ERROR

Array argument too small (8192 bytes). Argument must contain at least 163849 bytes (20480 elements).

The amount the argument must contain changes depending on the changes in freq and duty. I'm guessing using the buffer solution therefore isn't right for doing a finite pulse by time. I've tried using the SampClk as well but I also had problems. Can anyone suggest what might be the problem or a way of doing this?

I'm using LabWindows 7.1 and WindowsXP.
0 Kudos
Message 1 of 7
(4,046 Views)
Create a pointer to an array and initialise the next field before you use it. In doing that you never have to keep a fixed size array.

double* DataBuffer[9999];

//capture your data here

//dynamically initialise next variable field as required
FuncArr[index++]=(double*)calloc (1, sizeof(double));

Even thou DataBuffer is 9999 it's effectively NULL until initialised when needed.
Jattie van der Linde
Engineering Manager, Software & Automation
TEL Magnetic Solutions Ltd
0 Kudos
Message 2 of 7
(4,024 Views)
Thank you very much for the reply. Even though I am sendng a finite amount of pulses, while those pulses are being sent I am continually writing and sending out from card during that finite time... will this still work? Well I guess I'll try =p.... anyway, thanks again for your reply.
0 Kudos
Message 3 of 7
(4,020 Views)
Hi Sammy-

I am a bit unclear on why you're trying to perform this operation using an analog output. Have you considered using a counter to generate your pulse trains? They are fully-configurable for duty cycle and frequency. An example of how this can be accomplished in CVI can be found in the NI Example Finder (Help>Find Examples in CVI) under Hardware Input and Output>DAQmx>Generating Digital Pulses>DigPulseTrain-Cont.prj.

If you absolutely need to generate this using the analog output and have gotten the finite acquisition to work you should be able to generate the entire array for your time-based operation. Perhaps I am missing what exactly you mean by "doing a finite amount by time" for your generation, but if you know the time and frequency/duty cycle before generation begins then you should be able to generate an appropriate array based on those parameters. After this point the operation is essentially the same as the finite generation you have already successfully done.

Please let us know if you are able to implement Jattie's suggestion- it seems possible but somewhat processor-intensive.

Thanks and have a good day.
Tom W
National Instruments
0 Kudos
Message 4 of 7
(3,999 Views)
I have to do analog since I want to be able to adjust amplitude which can't be done using the counters. I'm actually having two problems. The first problem with my buffer is that I can't really seem to go above a frequency of about 10 Hz (I would think with my DAQ 6036E I should be able to get at least up to 200 Hz?). Indeed, if I decrease my sample size, then I can get generate slightly higher frequencies, however my pulse width can't be as small. Is there any other way of generating a square wave besides generating a buffer to be passed to the card? I got the pulse train timer working for the most part though there are still some bugs within my code that need to be adjusted.
0 Kudos
Message 5 of 7
(3,996 Views)

In case your DAQ board has an EXTREF pin, you could consider using the counter for generating frequency connecting its output to the EXTREF pin and using the analog output for determining output level.

In practice, the EXTREF input provides a way to specify the reference of the analog output channels. On the counter output you have basically two levels: "1" (5V) and "0" (0V). Connecting it to EXTREF pin you can use analog output channel to set the desired output voltage, that will be a portion of the reference voltage (proportional to the full scale output level of 4096 bits). That is: generating a level of 4096 bits on AO will output the full reference voltage, a value of 2048 will output 1/2 of the reference and so on.

There are some limitations in that configuration (your board must have this input, which I am not sure; you cannot output a value higher than reference voltage...) but basically this setup should give you a higher flexibility in your application.

Here [broken link removed] a link to some documentation from NI.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 6 of 7
(3,985 Views)
The card has a AO Ext Ref... I think...

Thank you for your reply... I'm going to take a look into it and see if this proves to be any better than the way I'm generating now.
0 Kudos
Message 7 of 7
(3,973 Views)