Page 1 of 1

[Circuit Network] Store the lowest value of a signal

Posted: Mon Apr 06, 2020 7:42 pm
by gutyina70
I want to store the lowest value of the accumulators, with a reset option. This is to get a rough idea how does my solar panel and accumulator setup keep up with the factory, I can add alerts if it like reached < 30% etc... But I can't figure out how to get the basic idea working.
If you don't understand what I'm trying to say, read the pseudo code:

Code: Select all

// accumulator variable can change any time, to anything between 0 and 100
accumulator := ?

// start with the highest value, because it is only going to decrease
minAccumulator := 100

// reset variable can change any time to true or false
reset := false

while true:
  // reset minAccumulator to default max 100
  if reset:
    minAccumulator := 100
    reset := false
    
  // if the current accumulator value is less then the last measured minimum accumulator value, then the minimum value will be the current one!
  if accumulator < minAccumulator
    minAccumulator := accumulator
I'd appriciate any tutorial, help or solution from you! :)

Re: [Circuit Network] Store the lowest value of a signal

Posted: Mon Apr 06, 2020 8:42 pm
by Amarula
You can read accumulator value through the circuit network; it is hardcoded defaults to the alpha key "A".

The circuit cookbook shows how to make a latch using the circuit network: one decider sets the value, for example, whenever the accumulator value A is less than the current minimum. The second decider resets the minimum value to 100 when you choose, for example when you change the reset value in a constant combinator from zero to one.

Here is the relevant section of the wiki: https://wiki.factorio.com/Tutorial:Circ ... team_power
The link shows the accumulator value being read directly to control power; scroll down a page to the instructions for making the latch.

If this isn't enough for you to figure out on your own, let me know and I will try to help you get it working.

Re: [Circuit Network] Store the lowest value of a signal

Posted: Mon Apr 06, 2020 10:44 pm
by Khagan
Amarula wrote: Mon Apr 06, 2020 8:42 pm You can read accumulator value through the circuit network; it is hardcoded to the alpha key "A".
A minor quibble: 'A' is the default channel for accumulator level, but it isn't hardcoded. You can set it to anything you like in the accumulator's panel (and put values from different accumulators on different channels).

Re: [Circuit Network] Store the lowest value of a signal

Posted: Tue Apr 07, 2020 7:28 am
by gutyina70
Amarula wrote: Mon Apr 06, 2020 8:42 pm You can read accumulator value through the circuit network; it is hardcoded to the alpha key "A".

The circuit cookbook shows how to make a latch using the circuit network: one decider sets the value, for example, whenever the accumulator value A is less than the current minimum. The second decider resets the minimum value to 100 when you choose, for example when you change the reset value in a constant combinator from zero to one.

Here is the relevant section of the wiki: https://wiki.factorio.com/Tutorial:Circ ... team_power
The link shows the accumulator value being read directly to control power; scroll down a page to the instructions for making the latch.

If this isn't enough for you to figure out on your own, let me know and I will try to help you get it working.
Thanks for your help, I managed to figure it out with the RS latch, here's what I build:

Re: [Circuit Network] Store the lowest value of a signal

Posted: Tue Apr 07, 2020 2:32 pm
by Amarula
Khagan wrote: Mon Apr 06, 2020 10:44 pm
Amarula wrote: Mon Apr 06, 2020 8:42 pm You can read accumulator value through the circuit network; it is hardcoded to the alpha key "A".
A minor quibble: 'A' is the default channel for accumulator level, but it isn't hardcoded. You can set it to anything you like in the accumulator's panel (and put values from different accumulators on different channels).
Thank you! I'll have to check that out...