Go to Parker.com
  • Sign in
Technologies
  • Aerospace
  • Climate Control
  • Electromechanical Group
  • Filtration
  • Fluid and Gas Handling
  • Hydraulics
  • IoT
  • Pneumatics
  • Process Control
  • Sealing and Shielding
Other Groups
  • Parker Indego
Blogs Forums Knowledge Bases
Parker Community
Parker Community
  • Technologies
    • Aerospace
    • Climate Control
    • Electromechanical Group
    • Filtration
    • Fluid and Gas Handling
    • Hydraulics
    • IoT
    • Pneumatics
    • Process Control
    • Sealing and Shielding
    Other Groups
    • Parker Indego
    Blogs Forums Knowledge Bases
  • User
  • Site
  • Search
  • User
Home Technologies Electromechanical Group Electromechanical - Industrial Electromechanical Industrial Knowledge Base Variable size arrays
Electromechanical - Industrial
  • Technologies
  • Electromechanical Group
  • Electromechanical - Industrial
  • More
  • Cancel
Electromechanical - Industrial
Electromechanical Industrial Knowledge Base Variable size arrays
  • Electromechanical – Industrial Support Forum
  • Electromechanical Industrial Knowledge Base
  • Members
  • Sub Groups
  • More
  • Cancel
  • New
Electromechanical - Industrial requires membership for participation - click to join
  • Electromechanical Knowledge Base & Frequently Asked Questions
  • Motion and Machine Controllers-
    • ACR Controllers+
    • PAC120+
    • PAC340+
    • PAC320 (Discontinued)-
      • 3rd Party Samples+
      • Embedded Xpress+
      • Errors+
      • Hardware+
      • PAM IDE+
      • Programming Tips-
        • ANY Data Type
        • C0046: Identifier 'xxxx' not defined - precompile error in PAM 1.3.0
        • How can I monitor cycle time in the PAC?
        • How do I use function block methods in CFC?
        • How to make comments in PAC software
        • How to program a Start, Stop, Reset Cold from within a PAC project
        • IDE Login Status
        • IDE User Management
        • Known issue with MC_Stop and MC_Home in PAM 1.3.0
        • Programming Tip: Save Time by reusing Code (Export / Import Programs & Function Blocks)
        • Programming Tip: Save Time on Naming Variables through Export/Import Mappings .csv
        • Variable size arrays
      • Web Visualization+
      • Quick Start and Online Training Videos
      • Adding New Devices
      • Auto Addressing enabled by default
      • Cam and Gear Program Sample & Video
      • Common PACIO Troubleshooting Tips
      • Compax3 Linear servo motor settings with PAC
      • Default IP Address 192.168.10.50 subnet 255.255.0.0 (X2 port)
      • Reading G Code from a file to develop a CNC machine
      • Error: Red triangle on EtherCAT axes/devices when ModBus or ProfiNet connects
      • FTP support
      • How can I send ASCII strings to or from the PAC?
      • How do I configure and gear to the PACIO-454-01 Module?
      • How do I upgrade a Parker Automation Manager (PAM) project from 1.3.0 to 1.4.0?
      • How do I use variables in G code?
      • How to Add ModbusTCP to PAC project (PAC as ModbusTCP slave)
      • How to Set and Get Time / Date / Time Zone Pre-1.4
      • How to Update Devices and their Descriptor files
      • How to Update PAC project without Parker Automation Manager software?
      • How to Update a PAC Firmware? Flashback instructions
      • How to Upload a Program?
      • How to Use the InteractX OPC Quick Client with the PAC
      • How to set up EtherNet/IP Communications with an Allen Bradley PLC
      • How to set Scaling for Parker Mechanics
      • How to use the Outputs on the Compax3-I31 or P series (EtherCAT)
      • IO settings for EtherCAT_Master: How to see IO update while in Stop
      • Log Data to a File
      • Minimum Internet Explorer version for Xpress and Visualization options
      • PAC CNC & Multi-Axis Capabilities, Samples & Video demos
      • PAC CNC visualization
      • PAC System Time Access and Edits
      • PAC Web Visualization with Internet Explorer: missing browser feature HTML5-Canvas Webvisu
      • PAC with .Net or LabView or InteractX: Using OPC DA Server
      • PAC with Modbus: What addresses for tags?
      • Reading Torque from Pseries drive
      • Remanent Variables: Retain vs Persistent Retain
      • Retentive Memory details
      • SDO Read / Write PAC to/from Compax3 I31
      • SMC_ERROR.SMC_FB_WASNT_CALLED_DURING_MOTION
      • Sample Continuous Function Chart CFC Program: time based counter
      • Sample Continuous Function Chart CFC Program: Basic Motion (Power, Home, Cycle)
      • Sample Ladder Logic LD Program: Basic Motion (Power, Home, Cycle)
      • Sample Ladder Logic LD Program: Time based counter
      • Sample SFC Program: time based counter
      • Sample Stuctured Text ST Program: Time Based Counter
      • Sample Structured Text ST Program: Basic Motion (Power, Home, Cycle)
      • Single Axis Sample Program with Visualization
      • Two Axis Sample Program with Visualization
      • Using the PAC as a Modbus TCP Master Device
      • Using the PAC as a Modbus TCP Slave Device
      • VIDEO: Run an AC30V an AC Induction motor via EtherCAT with a PAC
      • VIDEO: PAC with Compax3 EtherCAT part 1: EtherCAT connections & Device Selection
      • VIDEO: PAC with Compax3 EtherCAT part 2: Complete Configuration
      • VIDEO: PAC with Compax3 EtherCAT part 3: Setting EtherCAT Master and DS402 scaling
      • VIDEO: PAC with Compax3 EtherCAT part 4: Download & Test in C3 ServoManager
      • Video: Parker's PAC, the Automation Controller Based on IEC61131-3
      • What's the 16# in the axis scaling default of 16#10000?
      • Working with recipes in the PAC
      • Does the PAC have a first scan flag?
      • Error when switching Active Application
      • Using tappets during cam motion
      • WebVisualization not working in PAC terminal (PTA)
      • Can I open an edit and download a PAM 1.3.0 project using PAM 1.4.0?
      • Does PAC act as a OPC-UA server or client, or both?
      • How do I upgrade the PAC from OPC-DA to OPC-UA?
      • How do I use OPC-UA with the PAC?
      • PACIO-441-01 analog current input module
      • Sample code for PACIO-442-02 and PACIO-441-02 analog modules
      • What ports get used with PAC Ethernet connections?
      • C0032: Cannot convert type 'Unknown type: 'ADR(Device.Application.PLC_PRG.x)' to type 'POINTER TO BOOL'
      • CSV Reader Library for the PAC
      • Do I have to upgrade my PAC 1.3.0 Firmware to work with a PAM 1.4.0 project?
      • eCL Homing notes with PAC via EtherCAT
      • EtherCAT communication between the PAC and AC30 drive
      • How to add images to a visualization in WebVis
      • How to reset the EtherCAT bus
      • Parker Tap Adapter for EoE communications
      • User Management in the Parker Automation Controller
      • Using MC_TouchProbe with Compax3 Series Drives
      • Using MC_TouchProbe with P Series Drives
      • Webvis toolbox missing tabs (Codesys calls them tags) - Added alarms but no Alarms Display tool in toolbox.
    • 6K (Discontinued)+
  • General Technology Information+
  • Virtual Engineer+
  • Visualization and Human Machine Interface (HMI)+
  • Servo Drives and Servo Drive/Controllers+
  • Stepper Drives and Stepper Drive/Controller+
  • Gearheads+
  • AC and DC Drives and Inverters+
  • Servo Motors+
  • Step Motors+
  • Linear and Rotary Positioners+
  • Electric Cylinders+
  • T-Slot Aluminum Framing+
  • C3 + Xpress + ETH+
  • How can I stay updated on Parker electromechanical and drives product news?
  • Legacy (Discontinued)+
  • Other+
  • Memorandum: Information on EPA ban of Persistent bioaccumulative toxin (PBT)
  • What replaces the Gemini GV6K servo drive controller?
Wiki Actions
  • Share
  • More
  • Cancel
Community Quick Links
  • Home
  • Technologies
    • Aerospace
      • Supplier Resource Center
    • Climate Control
    • Electromechanical Group
      • Electromechanical - Industrial
      • Electromechanical – Mobile
    • Filtration
    • Fluid and Gas Handling
    • Hydraulics
    • IoT
      • Mobile IoT
    • Pneumatics
      • Pneumatic Industrial
      • Pneumatics Mobile
    • Process Control
    • Sealing and Shielding
  • Other Groups
    • Parker Indego
      • Parker Indego Instructors
      • Parker Indego Therapists
      • Parker Indego Distributors
  • Community Blogs
  • Community Forums
  • Community Knowledge Bases
Follow Us
  • Follow Parker Hannifin on social media

Follow Parker Hannifin on social media:

Variable size arrays

Print Friendly and PDF

There are times when application code needs to be able to process a data set but the programmer cannot determine how large that data set will be at the time of application design.

An example is a function block that maps one set of values to another. This can be useful for several purposes:

  • Ballscrew compensation
  • Calibration of a sensor, like a thermistor
  • Compensating for nonlinearity in test equipment

Function blocks that perform this type of operation may need to use data sets with very different sizes.

Consider a Parker XY cartesian robot with two precision 406XR ballscrew stages. For greater accuracy, the ballscrews (or even the linear encoders if applicable) can be mapped with a laser interferometer on a granite table, providing the customer with a data set that correlates the stage's measurable position to the position indicated by the interferometer (which is much more accurate).

If the stages are different lengths, they will have compensation maps with different numbers of elements. Trying to handle both cases with a fixed-size array could end up being inefficient and clunky.

Variable-Length Arrays

Parker Automation Manager (PAM) provides an elegant way to handle this. Rather than declare an array input to a function block like this:

alrDataSet : ARRAY [1..5000] OF LREAL;

Consider declaring the input as an input/output array of any undefined size like this:

alrDataSet : ARRAY [*] OF LREAL;

This allows the user to pass in an array of any length as a reference rather than as a standard input. You can do this for arrays of one, two or three dimensions:

alrDataSet : ARRAY [*] OF LREAL;
alrDataSet : ARRAY [*,*] OF LREAL;
alrDataSet : ARRAY [*,*,*] OF LREAL;

Determining Boundaries

PAM offers the user two operators for finding the size of the array. These are the UPPER_BOUND and LOWER_BOUND operators. These are essential for making sure that the function block does not try to read from or write to an array index that does not exist. The syntax for these operators is given below:

UPPER_BOUND(<array_name>,<dim>);
LOWER_BOUND(<array_name>,<dim>);

The two arguments are the name of the array and the dimension of the array. The name is simply the name as it was declared in the declaration editor (for instance, alrDataSet like in the example given before). The dimension can be 1, 2 or 3 depending on which dimension of the array you want to measure. The return type for UPPER_BOUND and LOWER_BOUND is always DINT. An example for using the array boundaries is given below.

// Array boundary example.
FUNCTION_BLOCK ArrayExample
VAR_IN_OUT
    alrDataSet : ARRAY [*] OF LREAL;
END_VAR

VAR
    diIndex : DINT;
END_VAR

// Modify the values in the data set.
FOR diIndex := LOWER_BOUND(alrDataSet,1) TO UPPER_BOUND(alrDataSet,1) DO
    alrDataSet[diIndex] := diIndex;
END_FOR

The example iterates through the first (and only) dimension of alrDataSet and writes the values 1, 2, 3 and so-forth to the array. You could use an array of any reasonable size as an input to this function block (keep in mind processing time and RAM limitations).

Checking for Valid Input

In order to avoid throwing an exception at runtime, it is necessary to make sure that an array is present on the input. There is a simple way to do this. If there is no array present at the input, the array will be equal to zero.

// Verify that the array is valid.
IF alrDataSet <> 0 THEN
    // Array input is OK.
ELSE
    // Array input not present. Put error-handling here.
END_IF
  • Share
  • History
  • More
  • Cancel
Anonymous
Related
Follow Us
  • Follow Parker Hannifin on social media

Follow Parker Hannifin on social media:

Parker Hannifin Parker Hannifin

  • Products
  • About Parker
  • Investors
  • Community
  • Careers

Global Operations Global Operations

  • Divisions
  • Sales Companies
  • Worldwide Locations
  • Distribution Network
  • ParkerStore™ Network

Company Information Company Information

  • Newsroom
  • Event Calendar
  • Working with Parker
  • Product Brands
  • History

Global Support Center Global Support Center

  • Support
  • CAD
  • Where to Buy
  • Contact Parker
  • Manage Online Orders
© Parker Hannifin Corp 2022
  • Site Map
  • Safety
  • Privacy Policies
  • Terms and Conditions
  • Community Terms of Use
ENGINEERING YOUR SUCCESS.