Author Topic: "Looping" through all elements of an array DP610  (Read 6162 times)

radioact

  • Guest
"Looping" through all elements of an array DP610
« on: April 26, 2015, 11:22:18 AM »
Sound straightforward right? There is a repeat until functionality right?

<Warning Rant>
The repeat until function is newer than the HWD to the DP600 so that is why there is no support for it in the display, sorry for that.
We are working on updates to the DP600 family.

Well I am using a DP610 and Danfoss has not updated the hardware file for the display for nearly 5 YEARS despite several claims they are looking into it. Turns out the updates to the DP600 family were new products (lx series). Great looking devices but does not help me support over 100 existing DP610 units I have out there. Over $100,000 of product... All i am asking for is CPP support or at the very least the looping functionality. If you look in your project directory at the generated c code, it uses loops all over the place so I know loops do work.

Sorry about that, nothing personal to anyone at Danfoss, I know its all business decisions but at this point its frustrating
</Rant>


I try to work within the limitations of the programming language but this time I have not been able to come up with an elegant solution.
I have an array, I know how many elements are in it and I want to run through the array and add them all together. A common task in most programming languages, set up a for loop and add them up. Since the DP610 does not have looping what can I do?

Idea 1: Unroll the loop
If the array is a static size then sure you can unroll the loop and add up each element manually. Not much fun to wire up but can be done. -This will not work for me as the array will vary in size.

Idea 2: Use the program loop
An array can be run through by processing one element every program loop. You use a memory block to save the current index, do the math and increment the index. Next program loop it will start at the new address and continue on. Problem is that the array I wish to add up will be modified/replaced periodically as the program runs so I will never be able to reach the end of the array before it changes. Also processing one array element per loop is too slow.

Idea 2: Combine Idea 1 and Idea 2
You can use the program loop to process several elements of the array at a time, for example add the next 4 elements. The index stored in the memory block can be incremented by 4 and the next program loop will process the next 4 elements. The problem here is that when you reach the end of the array the last bit of the array may not be exactly 4 items long. An array of 15 will have 3 blocks of 4 and a block of 3. You can add creative end condition handling but it could get messy. Still suffers from being slow if the array is long.


So does anyone have any ideas to solve this problem?

Offline Marbek_Elektronik

  • PLUS+1 Guru
  • *****
  • Posts: 350
  • Karma: +8/-0
    • Marbek Elektronik
Re: "Looping" through all elements of an array DP610
« Reply #1 on: April 26, 2015, 04:09:47 PM »
Hi,
what is maximum size of array? What is the element? (e.g.: 1024 elements of U16)

You can convert the array in an array with maximum elements and then you can use idea 1.
Idea1: you can add in a tree-architecture, making subroutines.

Please tell us the max. size of your array.

Marbek Elektronik, Dipl.-Ing. Bernd Konrad
Dienstleistung, Entwicklung, Herstellung

radioact

  • Guest
Re: "Looping" through all elements of an array DP610
« Reply #2 on: April 26, 2015, 10:55:38 PM »
At the moment, the maximum size of the array is ~480 U8. I never thought of breaking up Idea 1 into a bunch of subs that could tackle a smaller chunk of the work. That would simplify the wiring. But I should add the operations I want to do to each element is more complex then add them up, I just used that as simple example. I am actually trying to implement a CRC16 for a serial communication protocol.

I suppose it could be possible to break up the CRC calculation into smaller steps but I am not sure how to handle the variable length of the array. I don't want to pour a bunch of time into something that should be relatively simple.

I have a MC2410 in the system and I was seriously considering transmitting the date to it so that it will calculate the CRC via a CPP since it supports those but I should not have to do that.

RadioAct

Offline Marbek_Elektronik

  • PLUS+1 Guru
  • *****
  • Posts: 350
  • Karma: +8/-0
    • Marbek Elektronik
Re: "Looping" through all elements of an array DP610
« Reply #3 on: April 27, 2015, 07:40:03 AM »
But it is no problem to hard wire the "while-until-loop" in Guide, it you know the maximum elements.
I don't know if it would be a better way to program in C or in codesys.

In guide I suggest to write one step of the while-loop as a page and you ask in this page, if the module should do a calculation or not.
Then you put all this 480 pages next to another.

If this is to much work, you can make blocks of e.b. 8 pages and you will get 60 pages with 8 subpages.

I think, this should work, but I don't know the details of your schematic.
Perhaps you begin and we do it together, step by step?
Marbek Elektronik, Dipl.-Ing. Bernd Konrad
Dienstleistung, Entwicklung, Herstellung

radioact

  • Guest
Re: "Looping" through all elements of an array DP610
« Reply #4 on: April 27, 2015, 09:24:42 PM »
Sure we can work through it. Give me a couple days to get it started and I will post what I have going here.

RadioAct

radioact

  • Guest
Re: "Looping" through all elements of an array DP610
« Reply #5 on: May 08, 2015, 09:07:20 AM »
I haven't forgot about this task.
Life is, as they say, busy

I will find time to work on this as its still an issue.

RadioAct