News:

  • March 28, 2024, 04:12:14 AM

Login with username, password and session length

Author Topic: Adding 7,200 Fifo blocks  (Read 1139 times)

jrayb

  • Full Member
  • ***
  • Posts: 46
Adding 7,200 Fifo blocks
« on: March 25, 2022, 12:14:22 PM »
I don't know an easier way to add 7,200 FiFo Blocks for a sum other than using the Math Function. It would take me a really long time to create that function. Can anyone help me with an easier route?

RBPLC

  • Hero Member
  • *****
  • Posts: 585
Re: Adding 7,200 Fifo blocks
« Reply #1 on: March 25, 2022, 12:36:57 PM »
Your question isn't clear. What exactly are you trying to do? Are you saying that you've got 7200 elements in your FIFO block and you want to sum all of these elements?

jrayb

  • Full Member
  • ***
  • Posts: 46
Re: Adding 7,200 Fifo blocks
« Reply #2 on: March 25, 2022, 12:42:36 PM »
Yes, I want to sum all of the blocks. I want to be able to have a running total of that sum. I have the FiFo Block setup & it's working properly. I just need to be able to get the sum of the FiFo blocks as they're running. I can do this with a math function. Say Fifoblockone+fifoblocktwo etc. It would take me a tremendous amount of time to create a math function to sum 7,200 fifo blocks. Thanks for your help!!

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3553
  • Darth Ladder
Re: Adding 7,200 Fifo blocks
« Reply #3 on: March 25, 2022, 01:04:42 PM »
MATH D0 "SUMR(D1, 7200)"

If you don't want to do that, I'd iterate through using a loop and indirect addressing, so the MATH expression will be manageable.

At least once you have the sum, it's much quicker to maintain.    Every time you index, add the new value and subtract the one that got pushed off. In fact, so long as you start from the beginning, and it's initially filled with zeros, you can do that while you're filling it too.

« Last Edit: March 25, 2022, 01:33:17 PM by Controls Guy »
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3553
  • Darth Ladder
Re: Adding 7,200 Fifo blocks
« Reply #4 on: March 25, 2022, 01:06:38 PM »
You also obviously should think about the possibility of overflow.  Maybe segment the result into multiple registers and build your own 64-bit number.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

jrayb

  • Full Member
  • ***
  • Posts: 46
Re: Adding 7,200 Fifo blocks
« Reply #5 on: March 25, 2022, 01:15:45 PM »
Thanks for the help guys. That did the trick ControlsGuy!!

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 5975
  • Yes Pinky, Do-more will control the world!
Re: Adding 7,200 Fifo blocks
« Reply #6 on: March 25, 2022, 01:39:35 PM »
MATH D0 "SUMR(D1, 7200)"

If you don't want to do that, I'd iterate through using a loop and indirect addressing, so the MATH expression will be manageable.

At least once you have the sum, it's much quicker to maintain.    Every time you index, add the new value and subtract the one that got pushed off. In fact, so long as you start from the beginning, and it's initially filled with zeros, you can do that while you're filling it too.

Might be a pretty decent scan bump with SUMR of 7200 elements. Loop lets you spread it out. May not be an issue if just a single scan bump though.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3650
    • Host Engineering
Re: Adding 7,200 Fifo blocks
« Reply #7 on: March 25, 2022, 01:43:38 PM »
What is the typical range of values for these D registers?  What is the Max?  Can they be negative?

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3553
  • Darth Ladder
Re: Adding 7,200 Fifo blocks
« Reply #8 on: March 25, 2022, 03:10:08 PM »
Might be a pretty decent scan bump with SUMR of 7200 elements. Loop lets you spread it out. May not be an issue if just a single scan bump though.

Yep, and you can also do a hybrid.   72 loop iterations SUMRing 100 element per.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.