From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

MATRIXx

cancel
Showing results for 
Search instead for 
Did you mean: 

SystemBuild interpolation blocks: Is there a way to use the build-in interpolation blocks without defining the table values as %variables or within the block itself?

This question is about the Autocoding of SystemBuild interpolation blocks.

 

Autocode generation of the SystemBuild interpolation blocks use the real parameter array RP[] as hardcoded table lookup values.  I want to be able to changes these table values as part of a calibration.   I'm not using percent variables except as constants.  I'm using readwrite variable as calibration tables.  These calibration tables in the readwrite blocks need to be interpolated. 

 

I want to know if there is a way to use the built in interpolation function while passing the table values in from a readwrite block (not as a constant or as a percent variable defined within the interpolation block itself).  If this isn't possible, then I can write my own interpolation routines for the arrays defined in the Read/Write blocks, but I want to know if is it possible to write one procedural macro block that would handle arrays of all array sizes (I have table/arrays defined in the read/write blocks that are of different lengths).   Blocks in SystemBuild have to have the number of inputs defined, so I don't see how I could have one macro that would address arrays of different lengths.  An example of this would be great to have.

 

 

0 Kudos
Message 1 of 2
(9,652 Views)

Unfortunately there is not a built in interpolation function you can call to create one generalized procedural interpolation block because AutoCode will always inline the interpolation algorithm in the generated code.

AutoCode can inline the algorithm because the input and output tables are guaranteed to be continuous in memory because they are parameters. If the input and output tables were inputs and not continuous it would

be impossible to inline the interpolation algorithm in the generated code. The inputs would have to be copied to

continuous memory before calling a generalized interpolation callout function.

 

I tried creating a linear interpolation BlockScript block with the input and output table as an inputs but ran into an error where soft indexing the inputs inside a while statement is not allowed. This another case where BlockScript

can not guarantee the inputs are continuous and errors to be on the safe side.

 

Some interpolation algorithms require the input table to be linearly increasing or decreasing and this check is done

when entering the input table paremter  in the interpolation Block dialog. If you created you macro interpolation block would you check the validity of the input table for every time point? Or would your interpolation do a linear

search through input table instead of the faster binary search.

 

In the short term, the only way to create a generalized interpolation block is to write it as a UserCode Block

where the input and output tables are inputs to the block. When writing the algorithm you will need to know whether the inputed tables are stored row-wise or column-wise when coming from the ReadWrite Variable block.

 

Note: if using MATRIXx 7.1.8 or higher you can use the same UserCode Block source code for both AutoCode and

SystemBuild simulator by creating a UserCode Block instance in your SuperBlock diagram with the parameter 

'Interface Type' set to 'AutoCodeFixed'.

 

In the future we are planning to create some new SystemBuild blocks where the parameters are inputs instead of just Block defaults or percent variables.

I would also like to add another UserCode Block example showing how to implement a linear interpolation block

where the inputs include the interpolation tables.

 

 

 

0 Kudos
Message 2 of 2
(9,636 Views)