Page 1 of 1

[0.12.24] [Twinsen] Circuit network problem (feedback loops and biestables)

Posted: Thu Mar 03, 2016 2:37 pm
by Pellomari
I know a thing or two about circuit networks in factorio. I also know a little about digital electronic, so i thounght that i would be able to do some crazy automations. As it turns out, i found a problem in the circuit network that has an easy solution.

THE PROBLEM

The problem is how the circuit network works. It doesnt allow you to do some things properly. A lot of circuits with feedback don't act as you would expect them to do. For example, i wanted to have a memory bit. For that, I made a RS biestable (if you don´t know what that is, it's an electronic concept, google it). It is a bit of memor. Output 1 or 0.

http://imgur.com/NKVkveH

Both deciders are exactly equal. The green wires on the left are the Set and Reset of the biestable. The green wire on the right is the output. The red wires are the feedback wires. When a signal arrives to the Set input, the output is 1, and keeps beeing 1 until a signal arrives to the Reset. When this happens, the output is 0, until the Set signal changes it. In other words, it is a bit of memory.

It works fine in most cases, but there is a problem: when the Set and Reset signals are one tick long (every second is divided in 60 ticks, wich means that the circuit network is updated 60 times a second). When that happens, it goes crazy. It's not stable at all. Every tick, the output changes. At tick "n", both feedback wires (the red ones) are 0, wich means no signal. At tick "n + 1" both feedback wires are equal to 1. At tick "n + 2" both are 0 again, etc. It keeps in that loop until its cancelled by an input signal.

I wouldn't call that a bug, because it does exactly what it is suposed to do because of how the circuit network works (comparing tick "n" with tick "n - 1", if im not mistaken).

IMPORTANCE OF THAT PROBLEM

That problem is minor. A lot of people won't even notice it, and the game is perfectly playable even if it's not fixed. But, if it get's fixed, it will allow really complex automations. I would like to make the biggest and most badass completely automated factory. Without a propper way of having memory in the circuit network, it´s almost imposible (a smart chest with a smart inserter is too slow, too expensive and requires a lot of space. And it is awful).
It would give us a better tool to design and have fun in factorio. (offtopic: Or you could just add a programmable logic controller :D)

POSIBLE SOLUTIONS

The ideal solution would be to redesing how the circuit network works. Of course, that's a lot of work, a lot of bugs will pop out of nowhere and I understand that that's not a viable solution (yet, with the game being in alpha).

Fast solution number 1: make a new combinator. It would be just a bit of memory. If x input, output 1, and keep outputing 1 until y input comes. If y input, output 0, and keep outputing 0 until x signal comes.

Fast solution number 2: add a "double tick wire". That wire would send the signal for one more tick than a normal wire would.

First post, and english isn´t my native language, so you´ll have to be forgiving with me.
If you made it this far, you'r a champion! have a good day :D!

Re: [0.12.24] [Twinsen] Circuit network problem (feedback loops and biestables)

Posted: Thu Mar 03, 2016 3:03 pm
by Twinsen
I would say the logically it works exactly as the real-world SR latch, just that the real SR latch is much faster.

The solution to your problem is a different way to make a faster memory module. See it near the bottom of https://www.factorio.com/blog/post/fff-88 (search for "memory cell")

You can probably also make a "double tick wire" using some smart combinator setup(nothing simple comes to mind).

Re: [0.12.24] [Twinsen] Circuit network problem (feedback loops and biestables)

Posted: Thu Mar 03, 2016 3:30 pm
by Pellomari
Well, my point with the post wasn't "how to do a memory cell". The point was that, if in that simple loop i showed there is this problem, im more complex loops there could be that kind of problems too. I don't, maybe there are no problems at all and im just overthinking about it. Maybe everything can be made with the proper design.
Thanks for the answer. That memory cell is really smart. I did think about it, but i didn't use deferent wires for the inputs and the feedback :D.
The "double tick wire" can be made connecting a decider combinator on parallel with the wire you want to be "double tick". That way, the signal that goes through the decider arrives one tick later. But it´s awful.

Re: [0.12.24] [Twinsen] Circuit network problem (feedback loops and biestables)

Posted: Fri Mar 04, 2016 9:02 am
by Pellomari
I had time to think about what Twinsen said. And he is right. The logic works as it should. The "problem" i found was caused by a very short signal. I don´t know enough about electronics to be sure, but i think that, in real life, very short signals can be problematic too. It just makes sense. The signal needs some time to reach from one point to the other, even if the distance very short. So, if you keep that in mind, you can program whatever you want.
As far as i'm concerned, no bugs, no problems. Case solved.
Thank you again for your fast and helpful answer.

Re: [0.12.24] [Twinsen] Circuit network problem (feedback loops and biestables)

Posted: Mon Mar 07, 2016 3:54 pm
by Twinsen
I'm happy to hear there is no conceptual problem with the combinators :)