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?