How to make a minimum hold circuit?

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
Sostratus
Manual Inserter
Manual Inserter
Posts: 3
Joined: Mon Oct 28, 2024 11:03 pm
Contact:

How to make a minimum hold circuit?

Post by Sostratus »

Trying to design a circuit that monitors an input and remembers the minimum observed value. If it works, it will be a useful tool for checking if other builds are doing what I expect.

I tried a 3 combinator setup (plus a 4th to make the input generic). There's an arithmetic combinator acting as the memory cell to hold the minimum. There's an arithmetic combinator subtracting the stored minimum from the input. And there's a decider combinator which, if the difference is negative, injects this difference into the memory cell. First I initialize the memory cell to some arbitrary high value using a constant combinator before I connect it to the rest of the circuit.

I thought that would be all I need, but in practice it over-corrects and drives itself down to negative values. Maybe it's some kind of propagation delay issue? Any ideas how to solve it?

Blueprint of my prototype:

Code: Select all

0eNq9lkGv2jAMgP9KlMukLSAolD2Qdph24sBpu6EnFFpDvbVJl6S8McR/n5MWKG/wxtDTg0vqxI792bKz48u8gtKgcnyy4ynYxGDpUCs+4Z8Vk85BUTrmNCvkD2CSJWiSCkmSSces0wYsrYEVqLCoCqaXFswGUoaqrBzbSLLfZd/oBJ2scsdkWYI01ps0lWIK1tLhBgQrwWSytCytwG9aXQArjS6lP6AVSyGXW8Gm7wqmNN1dGehywTHRyvLJfMctrpXMfRxKFkABSIMuK8Bh0kl0sUQlyV++Jx2Vwi8+6e8fBQfl0CHUJsLHdqGqYgmGDoiDKX+Jk8q1DQleaos1rB0ne51R3I0F3/LJ4KEb0z2k5YzOF0vI5AZJhc5ZSLyKPV/T3QenBF9h7sA8lzaebCvKhKbLf1YyJ2dJpLQpKHB/X1FKE5yb8E9BUPnM9qPe/pH+5FJJEMEszjP9lVKXS3fMGnTXXeadJx6W6VVItFwDW1arFXiEf6GKxMvUL8AatlGlaGoYfDK8DO5kd0HbKR4prtBYtzhl321L78cGjasClsax+kQHZJL5IiD4ZGZxyGxgrKkIZQPlPWnqyhGP221P+f4q5C9abcAQz5oxlfgaFBhMWGP+AtXB3VTHb0x12kJ6s9LMK7WZd+5gPnuJucyTUNnUVtCXLqiEqhjcE4BqEiFVWjey9NDELmVieG8rGPZfvxX8k8j/dYee/4UGQa3RLnwQK5lbuEZ1qihUMv8bTOjU4MIIICrGoVofZwHtSZbhOmvGwCWu8b0V3nB9uwqfXWwavfMC/vDKBTyDQpstSyDPw8SEAjy3yyP3OuXR8c4UEkzB3Ia4dyPixugzvu2v+T24/XiuYT4f8LfoXmU6XQV8rYbwJG3rIeI369aAluVg/QNHqqbE231C0COFxHjWXNA3+O8ELExTp+tUndJI+aGwnoipD2reF30Rif6jmEdiQH+/GpAkFsOwGohRkA2DLKJVTBojMQir+hzZQ3qnUWin15zguVxC7kuoKZNM56l/UDkd6AlO08gGIvEoGg/H43gYfRxED/39/g+eDnwb
feng
Inserter
Inserter
Posts: 43
Joined: Sat Jun 25, 2016 1:17 pm
Contact:

Re: How to make a minimum hold circuit?

Post by feng »

I also could need something similar, so I gave it a try.
grafik.png
grafik.png (119.81 KiB) Viewed 657 times
It works on single tick base. Saving the lowest value of multiple signals, also if signals disappear from input.

Consisting of 3 groups:
- lowpass filter (left decider): comparing memory cell signal with input.
- memory cell (upper decider) + arithmetic combinator (center) for updating the memory cell by adding the difference of memory cell value and input value.
- loopback (lower decider): looping back memory cell values into memory cell if one of the input signals become 0.

Green input of lowpass filter is your input for your signals.

Hope it works for you,

Cheers

Code: Select all

0eNrNVsGO2yAQ/RVrzqSSMUkbS+19pe21l1VkYXuyQbXBApw0ivzvHXCarNJ05V1F6coHj4F5PB6PwQcomx47q7SH/AA1usqqziujIYcH3fU+aXDtk2eLqJOdsggMVGW0g/zpAE49a9mETC1bpJQaK1WjnVWmLZWW3lgYKEHX+AvydFgxQO2VVzjmx499ofu2REsD2Cs4DDrj1EjtAAS3WDDYQ86zT3OaoyZu1dibcgZE0VvTFCVu5FZRelxdBC2or45ALrS+/CJKa2WdL84L8/suENoq63tqOTEcR8xQVpuwRCLaSRuJ5vCNhr3EKTT6nbE/43wWa8i97ZFBVBXytWwcDkEc03uS/FLbSRSG1TAM7C9J+dskFaOk4lJScX9FHQact+e9LnzU+qR82IbLqaZtFruNU77+B6dQ6wRV/uGn7F1HdP4B/HSDE3q3Tb/q0hEDi+OUUtdweydctdtVJ4gTprTKb1r0qppkhqnF5Qx74Yc7FxTTIe3ceCXO4I/gH7UwxeoQLurgiKeUhSdbsRiJY5QxztJjJGLE6S0YpyiL49IY8VNbFnMJWXlsaWnnvwYGjSyRdIBHs0Pnkx+S+lzyHVtj99S9ReuiePMFX4rlci7454x/SYfhN7Rd7vA=
BaggyK
Inserter
Inserter
Posts: 42
Joined: Fri Mar 01, 2019 12:22 pm
Contact:

Re: How to make a minimum hold circuit?

Post by BaggyK »

It is possible with two decider combinators. Using red wires link the outputs of both combinators, to the both inputs of the combinators. Using green wires link the inputs of both combinators together. Then also link the outputs of both combinators together using green wires.

One combinator setup if item on red <= item on green or item on green = 0 then output item with count from red.
The other combinator setup if item on red > item on green or item on red = 0 then output item with count from green.

In other words, output smallest value (ignoring zero), with feedback on red to hold last value.

Code: Select all

0eNrVVFFu2zAMvYrBbzWYHXtbBPS76MewAySB4VhsS9SSPFlOFwQ6wA6yi+0ko5QiSJN0LdafFv4wRZGPj9QDt7DqRuwdGQ9yCwqH1lHvyRqQ8I0M6VFn64ZjMo3auk3WYtdNFmZhrk0/epldOUSTPZDDhfk++kPf6HACAqi1ZgA538JAt6bpYiHTaOQKCltS6C5aq1dkGm8dBE4wCn+CzMNSABpPnnCXnw6b2ox6hY4DxD9wBPR2oF0nW2C4GYdvQJZVOam4iGLG7e66FMAUvbNdvcK7Zk2cnoaRQGu+UwloiN7DE1O6ITf4+qSxvnFseKb0KXY0YEx7MewQrDboH6y7T0UdKpDejSjgNs4W5E3TDXiMfJqTwvZJESEE8VrWPM3oidOUcAkv8TtXi1/QJlE8I4Cjiq/pOSxD6uFIDMX/iaF6t2J4Mv0/v37DR9fH2bd8oz7Oai4k3LiSIuo8F7koRL4U8/jnL1lTtqbJKtkq2SpS3HTJufuyO1p+00cypGAvsmuPOu42dURSwI+x6ViYF3ttRLKPTg421mlu8WR6iTNFVHmwkwWsmUQCqT4Xs3I2q8riy7T4mofwF43f/QI=
Sostratus
Manual Inserter
Manual Inserter
Posts: 3
Joined: Mon Oct 28, 2024 11:03 pm
Contact:

Re: How to make a minimum hold circuit?

Post by Sostratus »

Thank you both! The two circuits seem to agree on their results. BaggyK's design has the advantage of being smaller, but feng's design appears that it could be used for an arbitrary number of inputs.

Changing it to a maximum hold circuit on the 2 combinator design was as easy as flipping the less thans and greater thans. Have to think about some more how to convert the 4 combinator design.

Some background, my plan for this was to watch a buffer on Gleba, which I want to be as small as possible to minimize spoilage but not to be empty to ensure demand is being met.
Zaflis
Filter Inserter
Filter Inserter
Posts: 520
Joined: Sun Apr 24, 2016 12:51 am
Contact:

Re: How to make a minimum hold circuit?

Post by Zaflis »

Remember that you can use selector combinator to output the smallest signal from all input signals, no matter how many. I'll assume the memory cell will be the attached decider combinator to it then.
Post Reply

Return to “Gameplay Help”