Advanced Object Management
The functions used for Object Management are Object Memory Management, Load Memory Object Description, Read Memory Object Description and Read Object Registry. Each of these functions will help us to organize, identify and manage objects stored in memory, RAM and ROM. In the Section ‘Description of Onboard Functions’ we explained all the onboard dedicated functions, including Object Management functions, let’s recap the explanation for each function.
- Load Memory Object Description
This function loads a text description for a program or buffer object. The ASCII text description is useful as a quick reminder of the contents or purpose of an object stored in memory. The description is limited to 32 characters; extra characters are ignored. You can retrieve the stored description with the Read Memory Object Description function.
This function returns the ASCII text description for a program or buffer object. The ASCII text description, previously loaded with the Load Memory Object Description function, is useful as a quick reminder of the contents or purpose of an object stored in memory.
Object Memory Management
This function is used to save to ROM, delete from ROM, or free from RAM, a program or buffer object. Objects saved to non-volatile Flash ROM are available for use at any future time, even after power cycles.
Read Object Registry
This function returns a registry record for an object from the Object Registry. The Object Registry contains information on all objects stored in memory. You can store up to 32 objects in RAM and/or ROM. Each time an object is stored, a new record is created to keep track of it.

Figure 1.
In the previous picture we are setting program number “4” to have the string “Analog Feedback Program” being saved to its program description. So now you are in another scene, in which you have a program 4 in the list of objects stored in memory (the MAX onboard list for example) but you have no idea what it does or what it is, so you then want to call the Read Memory Object Description function in order to retrieve that info.

Figure 2.
The indicator called ‘Description’ will show up the same string we wrote in the previous picture, but now it is an output and we are reading this info from memory. We would then use this for as simple as just displaying the purpose of the code or to sort programs in an execution order or to know which program to pause/resume, program version comparison, etc.
Every time that we download a new program to the board it is saved in RAM, volatile memory, at this point if we would like to save any description to it now is the time to do it, since as soon as an object is passed to ROM memory we cannot change its description. The disadvantage of this RAM object is that as soon as the power goes off from the board it will be deleted. In this case we would like to save this object to ROM for future uses, even after power-up’s, or we may just want to distribute objects on other memory sectors. Saving an object to ROM, deleting an object from ROM or free an object from RAM as well, is very easy and it can be done with only one function, Object Memory Management.

Figure 3.
On this case, program 4 is “saved” to ROM. If we would have chosen ‘delete’ the object is “deleted” from ROM, and if we choose ‘free’ then we “free” (delete) that object from RAM.
The last function in Object Management is called Read Object Registry and it is used to access registry information about a particular object. For example, if we want to know the device ID, what type of object it is (program/buffer), memory address where the object space starts, and the size of the object.

Figure 4.
In this case, we are getting the registry record for index “4” (which in the case of this examples shown it represents program 4), the indicator “Registry Record” is a cluster of 4 elements: Device ID, which identifies the object number, Object Type, which will give 1 for a program or 2 for a buffer, PStart, which is the start address of the object in either RAM or ROM, and Size, which is the size of the object in words. Remember that you can have an index number from 1 to 255 and up to 32 objects stored at the same time in memory (don’t get confused with the 10 –maximum– running programs at the same moment).
What about buffers?
Like programs, buffers can be stored in RAM or ROM. The maximum buffer size is somewhat less than 64 KB (16,000 samples), since some of each sector is used for record keeping. The Object Management functions explained on this section do apply for either programs or buffers; buffers will have an object number similar to a program, in that way you will be able to identify it and ‘manage’ it in memory.
You can also manage your memory objects directly from MAX. If you go to the Onboard Memory Manager tab and choose any object you can right-click on it and select from the options so you can execute the desired action.
At this point you are now able to write onboard programs with great confidence and with good knowledge about the general theory behind it. You can make complex arithmetic operations, loop structures, control execution, manage memory objects, etc. This tutorial ends with a practical section called ‘Hands-on Example’, which will guide you on an exercise to put this knowledge in practice.
Reader Comments | Submit a comment »
Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).
