adccommunitymod (AutomationDirect) asked a question.

Click plc and pointer indexing

Created Date: February 26,2016

Created By: notfet

**** This post has been imported from our legacy forum. Information in this post may be outdated and links contained in the post may no longer work.****

I have a sensor I want to create trend data for. To graph to my Cmore panel from a Click plc. a For-Next loop would be perfect for this however I do not see a way to index the addresses. that leaves the only option of creating a rung(or three) for each point of data. And a subroutine is out since I'm already in one but even then I would have to create a rung for each address. That would mean 100-200 rungs just for a chart. Is there another way to accomplish this without changing plc's?


  • adccommunitymod (AutomationDirect)

    Created Date: February 26,2016

    Created by: Tinker

    The CLICK "Single Copy " instruction allows indirect addressing. That is the only place the CLICK allows indirect addressing so it is somewhat limited, but still possible.

    I previously left a simple example here: https://forum.automationdirect.com/showthread.php?t=15056

  • adccommunitymod (AutomationDirect)

    Created Date: February 27,2016

    Created by: notfet

    That program does what I described. What I want to do is index the pointer i.e. df1,df2,df3,df4,etc... is does not seem possible to do that. I may have to do it the long way around. but if anyone can think of an ingenious solution I am open to suggestions

  • adccommunitymod (AutomationDirect)

    Created Date: February 27,2016

    Created by: Tinker

    Perhaps you looked at the OP's program, I (the second post) just posted a screen shot where I end up with: Copy Single Src DF30 Des DF

    DS10 being the pointer

    you would of course change actual addresses to suit.

  • adccommunitymod (AutomationDirect)

    Created Date: February 27,2016

    Created by: kewakl

    I have a sensor I want to create trend data for. To graph to my Cmore panel from a Click plc. a For-Next loop would be perfect for this however I do not see a way to index the addresses. that leaves the only option of creating a rung(or three) for each point of data. And a subroutine is out since I'm already in one but even then I would have to create a rung for each address. That would mean 100-200 rungs just for a chart. Is there another way to accomplish this without changing plc's?

    The whole action of a ForNext loop happens in ONE scan .

    You can create your own index in a ForNext loop.

    Rung 1

    Clears any existing count in the LoopCount

    Sets an origin for the beginning of destination into DF for your samples

    Rung 2

    Begins the ForNext Loop with a max of 10 (DS1)

    Rung 3

    Tracks the loop count (not including the ZERO count)

    Rung 4

    Calcs the offset into DF for the destination

    Rung 5

    Copies the Source (DF1) to DF through DF

    -where and equate to the value of DS3 at that count in the ForNext loop

    Rung 6

    Terminates the ForNext loop

    I am not sure whether the FOR instruction or the NEXT instruction provides the internal increment/evaluation of the ForNext loop's index, so I did not attempt to describe that.

    This snippet assumes that your scaled input for analog resides in DF1, and you wish to log that into DF101-DF110.

    Trigger

    ------]^ ^

    ------------------------------------------ NEXT

    I have NOT tested this on a real CLICK.

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: February 27,2016

    Created by: kewakl

    Perhaps you looked at the OP's program, I (the second post) just posted a screen shot where I end up with: Copy Single Src DF30 Des DF

    DS10 being the pointer

    you would of course change actual addresses to suit.

    nice masking tip.

  • adccommunitymod (AutomationDirect)

    Created Date: February 27,2016

    Created by: kewakl

    this should do the opposite of my first snippet

    This snippet assumes that your logged data resides at DF101-DF110. and you wish to copy it to DF1. (however useful this would be since DF1 will get overwritten 10 times each scan that the ForNext loop is enabled)

    Trigger

    ------]^ ^ DF1

    ------------------------------------------ NEXT

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: February 27,2016

    Created by: kewakl

    This should copy the desired number of items from a location beginning at DF to a destination beginning at DF (offset by 1) so it will perform a controlled/triggered block copy from DF ... to DF ... --

    depending on how many times Trigger is turned on, and when Init_TEMPVars is turned on.

    This lets you control the interval of the Trigger and the initialization of the temporary variables.

    Be careful that your src offset does not reach into your dst range.

    The red code is an dirty example of a Src/Dst/Index error trap.

    Init_TEMPVars

    ------]^

    DS1 299 Trigger

    -------]>

    Trigger

    ------]^ ^ ^ ^ DF //copy

    //src to dst

    A counter could be used for the DS1 math. It would require a more complicated control branching than a MATH instruction.

    again, I haven't tested this on a CLICK

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: February 27,2016

    Created by: notfet

    I did look at the program and did not see what is posted in the screen shot. I think that will do what I need, However since all I want to do in index the pointer the Hex values should be omitted correct? It seems all that is for is indexing the drum instructions in the subroutine. The for next loop is out since I will be looking at a 1sec clock(500ms on 500ms off) so here is what I end up with for the pointer.

    Rung 1

    Rung 2 Result DF10

    Rung 3 )]

    Rung 4 to 104 math for charting purposes.(Maybe I could index this as well.

    I know the use of the brackets is crude please excuse them but that's the general idea correct?

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: May 28,2018

    Created by: tony51

    I'm sure you have this figured out by now.

    I 've done this, using a DS register as the pointer for indexing, say set DS101 to 300

    Then on input for sample grab, I set another bit (for debounce, not needed if clock based), and copy the value I want to DD

    once my debounce timer is done, if DS101 is less than max samples, add 1 to DS101

    if DS101 is greater than or equal to max sample, set if back to 300 (beginning).

    5 rungs, including return from subroutine and first scan to initialize to handle whatever amount of samples.

    You can add a timestamp as well and do averaging, like a moving average with the same idea.

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: February 26,2016

    Created by: notfet

    I have a sensor I want to create trend data for. To graph to my Cmore panel from a Click plc. a For-Next loop would be perfect for this however I do not see a way to index the addresses. that leaves the only option of creating a rung(or three) for each point of data. And a subroutine is out since I'm already in one but even then I would have to create a rung for each address. That would mean 100-200 rungs just for a chart. Is there another way to accomplish this without changing plc's?

    Expand Post