Signal Generators

cancel
Showing results for 
Search instead for 
Did you mean: 

Configuring large abitrary sequences with NI PCI-5421

We are trying to solve the following problem with the help of a NI PCI-5421 signal generator with 256 MB of onboard memory:

- the NI PCI-5421 is used to generate an analogue input signal in order to control a piezo–driven fast-tool-servo

- the fast-tool-servo is used in a CNC-lathe for turning of microstructures

- the rotary encoder of the CNC-lathe is generating around 18.000 trigger-signal per revolution

- for each trigger, the signal generator should output a new voltage

- the voltages are encoded as 16 Bit values

- the microstructure structure which should be turned consists of ~3.000 tracks

 

According to our calculations, the amount of memory required is:

18.000 trigger * 3.000 tracks * 16 bit = 864.000.000 bit = ~103MB

 

As a start we used the following configuration for the signal generator:

arbitrary sequence mode (NIFGEN_VAL_OUTPUT_SEQ)

with burst trigger mode (NIFGEN_VAL_BURST)

For each input value a new waveform was created using niFgen_createWaveformI16. All waveform were then combined to an arbitrary sequence (niFgen_configureArbSequence).

The first problem we encountered was that each waveform requires a minimum of 8 samples to be used in burst trigger mode. Therefore we have reduced the number of triggers to stay within the memory limitations:

4.000 trigger * 3.000 tracks * 16 bit * 8 samples = 1.536.000.000 Bit = ~184MB.

For small test vectors (e.g. 4000 triggers, 10 tracks) the systems reacted as we had planned: for each (software-trigger) the signal generator emitted the right voltage level.

As we tried bigger test vectors (>400.000 waveforms) the memory used by the test application rose to >2GB after running niFgen_createWaveformI16 and completely froze the computer. Without creating the waveforms the memory used by the application stayed within our calculations.

Is there a possibility to store such large sequences on the NI PCI-5421?
How much memory is really used while generating sequences on the signal generator and can we somehow read out the amount of onboard memory which is currently used?

Would it be possible if we used another mode of the signal generator (e.g. script mode) to react to the trigger signals?

Or could the sequence be divided into multiple smaller sequences which fit into the onboard memory? (the problem with this solution would be that we cannot stop the process to upload a new sequence as we need a continuous output)

We hope that you could help us finding a solution to our problem.

Regards,

B. Sc. Lars Schönemann
Stiftung Institut für Werkstofftechnik
Hauptabteilung Fertigungstechnik

Laboratory for Precision Machining (LFM)
Badgasteiner Str.2
D-28359
Bremen

Tel.:  ++49-(0)421-218-9400
Fax:   ++49-(0)421-218-9441
Email: lars@informatik.uni-bremen.de
Web:   http://www.iwt-bremen.de/ft/

0 Kudos
Message 1 of 13
(9,245 Views)
Hello SysEngineer.

You have some excellent questions and an interesting use case. First of all, I'm glad you are pushing the limits of the NI 5421 and SMC architecture to the max, creating thousands of waveforms and sequences with thousands of steps.

Now, as to your question:

The NI-FGEN driver needs to keep track of all allocated waveforms on the device. For each waveform, it needs to know the name/handle, start address, length. This is done on the PC and takes some memory per waveform. 400,000 waveforms is a lot, so I'm not surprised the computer is having trouble keeping up.

There is a workaround though:

Everything you can do with a sequence, you can do with a script (and so much more). One of the neat features in the scripting language is that you can specify a subset of a waveform to generate. For example:

generate MyWaveform (100, 200)

will generate sample 100 through 299 of waveform MyWaveform.

Knowing this, you can download a single waveform that contains all your voltages at known locations. Then you can generate a script that can play just what you need. Keep in mind that the minimum 8 sample restriction exists when generating waveform subsets as well.

And one interesting fact about our SMC-based devices: You can replace the contents of a waveform while generation is in progress. This opens some interesting posibilities. No need to stop and restart generation as you assumed below.

Hope this all made sense. If not, let me know.

Marcos

Marcos Kirsch
Chief Software Engineer
NI Driver Software
0 Kudos
Message 2 of 13
(9,227 Views)
Thank you for your answer, this will help a lot.

Is is possible to use variables in scripts? e.g. if I want to move through a waveform step by step:

The script would look something like this:
integer i=0
integer wfmLength = 4000
repeat forever
    repeat until scripttrigger
        generate MyWaveform(i, 😎
    end repeat
    i = i+8
    if(i>wfmLength) break
end repeat

regards
Lars

0 Kudos
Message 3 of 13
(9,205 Views)
You cannot use variables in scripts. For your application, my advice would be to create the very long script programatically in LabVIEW.

For more information on Scripts, refer to the NI Signal Generators Help document.

Marcos
Marcos Kirsch
Chief Software Engineer
NI Driver Software
0 Kudos
Message 4 of 13
(9,199 Views)

Hi Lars,

Here are some more resources to help you get started on scripting....

Video webcast:

http://zone.ni.com/wv/app/doc/p/id/wv-64

App Note:

http://zone.ni.com/devzone/cda/tut/p/id/5534

Regards,



Message Edited by Support on 01-10-2008 11:14 AM
Kalyanramu Vemishetty
Automated Test Systems Engineer
National Instruments
0 Kudos
Message 5 of 13
(9,193 Views)
Hi,

somehow I cannot get this to work. Are there any examples on how to use scripting mode in C++?

I tried the following:
niFgen_Init
niFgen_clearArbMemory
niFgen_configureOutputMode(NIFGEN_VAL_OUTPUT_SCRIPT)
niFgen_configureSampleRate

niFgen_AllocateNamedWaveform
niFgen_writeNamedWaveformI16
niFgen_WriteScript
with script:
Script testScript
    Repeat until scriptTrigger0
        Generate waveformName subset(0,8)
    end repeat
    Repeat until scriptTrigger0
        Generate waveformName subset(8,8)
    end repeat
    Repeat until scriptTrigger0
        Generate waveformName subset(16,8)
    end repeat
end Script
this sould generate a subset of my waveform until scriptTrigger0 is received then continue with generating the next subset until scriptTrigger0...

niFgen_configureTriggerMode(NIFGEN_VAL_STEPPED)
niFgen_setAttributeViReal64(NIFGEN_ATTR_ARB_GAIN, gain)
configureSoftwareEdgeScriptTrigger("scriptTrigger0")

after niFgen_InitiateGeneration I'm trying to send a software trigger to the NI PCI-5421:
niFgen_sendSoftwareEdgeTrigger("", NIFGEN_VAL_START_TRIGGER)
which fails in script-mode (however worked in sequence mode before) showing no response of the signal generator
I tried several combinations of values for sendSoftwareEdgeTrigger
i.e.
NIFGEN_VAL_AUTOMATIC as "trigger" value (like in the documentation help file)
fails for both triggerID="" and triggerID="scriptTrigger0" with "Invalid value for software trigger name"

or

NIFGEN_VAL_START_TRIGGER as "trigger" value (like in the documentation help file)
with triggerID = "scriptTrigger0" it fails with "Invalid Trigger Identifier"

What am I doing wrong here?

Regards
Lars
0 Kudos
Message 6 of 13
(9,184 Views)
Unfortunately, the help file for the niFgen_SendSoftwareEdgeTrigger function is incorrect (this has been fixed in NI-FGEN 2.5).  Defined values for the trigger parameter are NIFGEN_VAL_START_TRIGGER and NIFGEN_VAL_SCRIPT_TRIGGER.  You want to specify NIFGEN_VAL_SCRIPT_TRIGGER as the trigger parameter and "scriptTrigger0" as the triggerID, like so:
 
niFgen_SendSoftwareEdgeTrigger(viSession, NIFGEN_VAL_SCRIPT_TRIGGER, "scriptTrigger0");
 
Another note about your script:  you are generating pretty small subsets (8 samples) - this may underflow if you are generating at the full rate, meaning that the device cannot fetch data fast enough to keep up with the script.  You may need to increase the size of your subset or decrease your sample rate if you get an underflow error.
 
Drew Creel
NI Software Engineer
Signal Generators Group
Drew Creel
NI Software Group Manager
RF and Signal Generators
0 Kudos
Message 7 of 13
(9,169 Views)
Ok, I'will try that. Where can I download NiFgen 2.5 or when will it be available?

I know that the sample sizes are pretty small, but otherwise the amount of data wil exceed the onboard memory. Therefore the samplerate doesn't need to be that high. I will bear this in mind if this error should occur.

Regards
Lars
0 Kudos
Message 8 of 13
(9,174 Views)

Hello again,


I tried to solve my problem in script-mode, however there I encountered new problems.

As one single script would be way to memory extensive, I tried the following:

  1. I divide my data into one block initially loaded into the memory of the signal generator and several “reload” blocks of smaller size.

  2. The device is configured for script-mode with stepped triggers.

  3. I allocate space for a named waveform on the onboard memory so that the initial block would fit in. allocateNamedWaveform(waveformName, initial->Length)

  4. I set this waveform as “streaming” waveform setAttributeViString(NIFGEN_ATTR_STREAMING_WAVEFORM_NAME, waveformName)

  5. I write the initial block to the onboard memory writeNamedWaveformI16(waveformName, initial->Length, initial)

  6. I generate a script to run through the allocated waveform generating a small subset until the next trigger arrives.
    Script myScript
      Repeat forever
       Repeat until scriptTrigger0

         Generate waveformName subset(0,8)

       end repeat
       Repeat until scriptTrigger0

         Generate waveformName subset(8,16)

       end repeat

       Repeat until scriptTrigger0

         Generate waveformName subset(16,24)

       end repeat

       ...

       Repeat until scriptTrigger0

         Generate waveformName subset(n-8,n)

       end repeat
      end repeat
    end Script

  1. After initiating the generation I monitor the available streaming memory using
    getAttributeViInt32(NIFGEN_ATTR_STREAMING_SPACE_AVAILABLE_IN_WAVEFORM, space)

  2. If the memory available is larger than the size of the reload blocks I write the next reload block to the onboard memory
    writeNamedWaveformI16(waveformName, reloadBlock->Length, reloadBlock)

This works for a couple of times, but eventually I will get the following error-message:

27.08.2007 10:40:55:             Space available: 6464

27.08.2007 10:40:55:             write next: DAQmx Error -200311 occurred:

You cannot write data outside the boundaries of your waveform.

 

Make sure you are not trying to write more data than your waveform can accomodate and that your write location and write offset are set correctly.

 

Status Code: -200311

 

For testing purposes I used the following sizes:

Initial Block: 80.000 samples

Reload Blocks: 6.400 samples

 

The size of the subsets is not a problem as the sample rate is pretty low. Therefore I do not get an underflow-error.

I hope you can help me with this.

Regards,
Lars

Message Edited by SysEngineer on 08-27-2007 03:55 AM

0 Kudos
Message 9 of 13
(9,092 Views)
Ok, I seem to have solved this myself:

The size of my initial block was not a multiple of the size of my "reload" blocks. As a consequence my program would write (with initial length = 80.000 samples and reload length = 6.400 samples) 12 blocks (-> 76800 samples) without any problem. On writing the 13th block the problems occured: Though NIFGEN_ATTR_STREAMING_SPACE_AVAILABLE_IN_WAVEFORM reported enough free space in my streaming waveform, this space was not available in one single block (as only 3200 samples at the end of the waveform were free) and the writing failed.
Raising the reload block length to 8000 samples solved my problem as now the space is always available as a continuous block.
0 Kudos
Message 10 of 13
(9,086 Views)