Jump to content
OMRON Forums

Reading UserAlgo.BgCplc[i] within a CPLC

Recommended Posts

Inside a BgCPLC I have created a nodetree that was dynamically allocated. I am trying to implement a way to free up this memory when the BgCPLC is disabled.

As no code will the run when the cplc is disabled ithought of freeing the memory the next time it is enabled, therefore I need to keep track of the previeus UserAlgo.BgCplc[i] state. I thougt of having another CPLC running that stores the UserAlgo.BgCplc[i] value into a shared P variable but this seems to be an excesivelly cumbersome solution. Is there a cleaner way to achive this behaviour?

#include <stdbool.h>
static bool initialized;
int user_plcc() {
        if (prev_UserAlgoBgCplc[i] = 0 && initialized){ // if it was previusly turned off and its not the first run
        initialized = false;
    if (!initialized) // initialize the node tree
        // Constructing the tree
        root = createNode(node, num_children)     // fills the node using malloc depending on the number of children
        initialized = true;
    if (prev_UserAlgoBgCplc[i] = 0 && !initialized){ // if it was previusly turned off and its not the first run
Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...