Memory cell for dummies?

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
mooklepticon
Filter Inserter
Filter Inserter
Posts: 281
Joined: Wed Mar 02, 2016 10:09 pm
Contact:

Memory cell for dummies?

Post by mooklepticon »

Can anyone help me with an explanation of a memory cell for someone who doesn't understand it very well? I understand a counter or timer. I have the single combinator counting up to once a minute and resetting. I want to read in a item ID once per minute and then keep out putting that for the entire minute, and when it resets (the 1 minute is up) it reads the item ID again. (maybe it changed, maybe not, doesn't matter.)

What I'm trying to do is get the top inventory item in my logistic Network and send that to my recycling Loop but I only want the item to change once a minute. I have everything else working just fine but the item can change very rapidly once there are several items all at the top of the list that are close in inventory count. This drives my logistic Network insane and has the Bots moving around like crazy and they are halfway there when the item is no longer requested.
mmmPI
Smart Inserter
Smart Inserter
Posts: 3974
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: Memory cell for dummies?

Post by mmmPI »

There are different ways of making a memory cell, but often time the idea is to have a combinator looping onto itself with a value that doesn't change, thus "stored" in memory. Then variation can occur depending on how you want to set and/or read this value. This means different combinators setup.

For the usecase you describe it is possible to reuse the logic you described counting up to a minute to act as trigger signal to set the value in the memory cell, and to reset it.

The memory cell can be a decider combinator looping onto itself with red wire. With an additionnal green wire connected to the input. The idea being that the red wire will hold the value ( and you can connect and "read" from there), and the green wire will recive the counter to tell when to update. ( the new value is received on the red wire)

Then the decider combinator need to be configured to check if the signal "C" on the green wire is above or equal to 1(the counter). And if so the output should be "everything" on the red wire. This means that "most of the time" the value that are present in the input are going to be present also in the output the next tick, and will cycle "holding" the value in memory.

This also means that when the counter is at 0, the memory cell will stop this cycle, the next tick nothing will be present in output. Instead it will be the time to give a new value on the red wire for the memory to store for the next minute. It is possible to do so using a second decider combinator, also connected to the counter with a green wire to its input, and to whatever value you want to read from, but this time detecting when C = 0 on the counter. And only then, outputting "Everything". On a red wire, to feed the first decider combinator.

This means that when the counter is at 0, this second decider combinator will "read" "whatever value you want to read from". And pass this on a red wire for the next tick, at the same time as when the first decider combinator condition is invalid causing it to output nothing the next tick.

When the counter is at 1, the first decider combinator again loop onto itself the value on the red wire, but this value is the one that came from the second decider combinator the previous tick.

As always when trying to describe a ""simple"" setup with word, i feel like a blueprint would help much more, so i also join a blueprint that follows what i just described to illustrate a memory cell that update a value every 300 ticks.

mooklepticon
Filter Inserter
Filter Inserter
Posts: 281
Joined: Wed Mar 02, 2016 10:09 pm
Contact:

Re: Memory cell for dummies?

Post by mooklepticon »

Thank you. This works exactly as I wished. I think I'm about halfway to understanding it!
Post Reply

Return to “Gameplay Help”