I'm sure someone smarter already came up with this before, but for what it is worth, here's my take on getting more signals to do more things to be able to debug more often. I come from era where bit flag arrays stored in integers were still a thing, since then I've had a soft spot for bit manipulation.
Optional TL:DR backstory on the end ...
There are 4 signals: (A), (B), (C) and (D), they represent resource requests as trainloads, since none of these will ever go over 255, we could jam them all into single signal, then get them back out on the other side. that way we can use single signal to send requests for 4 different resources, and still know how many trainloads it'll take, so we can dispatch more than one train if need be.
The signals are 32 bit signed integer, so we can jam 4 signals that are 8 bits into single signal, and with some trickery at the end, we can have 4 - 0-255 unsigned signals on the other end, all 4 transmitted by using only single signal. Or in another words, take care of two resources on both supply and receiving ends using single signal.
Multiplexing the signals on sending end is dead easy, just take number smaller than 256 and bit-shift it right by specific number of bits, 0 for first, 8 for second, 16 for third and 24 for last, then send them out all as single signal.
De-multiplexing on the other end is just little more complicated, we start with the highest 8 bits, shift them left by 24, that gives us value of the fourth signal, we take that value, shift it right by 24 bits, and subtract the result from the main signal, that gives us first three signals without the fourth. Then we just repeat the steps shifting backwards by appropriate amount of bits to get the remaining signals.
Last bit of trickery is to convert signal (D) from signed to unsigned. If the result for signal (D) is negative, add 256, and we done.
To use the blueprint you will need Justarandomgeek's awesome Nixie Tubes, one of the mods i can't do without, thanks geek! :)
---
The next logical step would be to throw away the need for knowing how many train loads are available or requested, and use single signal as 32 flags, to track supply and requests of 16 resources at once :)
But why?:
I tend to use single large signal network for my trains that holds amount of available resources and requests for the same across the whole map, so when request comes in for load of iron ore, signal (1) increases by 1, and appropriate train station is enabled. Whichever train in the train yard, that has a load of iron ore is the closest takes off, and delivers the ore. Then it goes past nearest iron ore mine that has enough ore to fill it and refills it self, then it goes back to train yard. All this takes two signals, one is (1) and the other is (iron ore), so now I'm using two signals to manage offers and requests for single resource.
This works fine as long as you don't come up with the moronic idea where you want a factory where no more than single step in production will be done, without the results traveling by a train. This is precisely what I'm doing right now. I have few choices, i could break up the large signal network to smaller parts, but that is no fun. I like to eat my cake and keep it too. So i decided to complicate the hell out of everything, and this is the result.
Jamming more signals into your signals so you can signal more while you signal
Jamming more signals into your signals so you can signal more while you signal
Efficiency is just highly developed form of laziness.
Re: Jamming more signals into your signals so you can signal more while you signal
Since i had built the multiplexer in my playground, i couldn't resist to plug in few signal generators and see how fast it can be pushed ... not very fast i found out, it works fine for my train signals, but it balks when you start pushing multiple updates per second. So after couple of alternate versions, I've got this.
Instead of bothering with calculating the individual signals and all that subtracting, and maths in general, i decided to just give the bits a nice shove right the edge and be done with them.
The way it works:
On the left are 4 pulse generators and counters, they just there so i have something to send down the wire.
Then the 4 multiplexers, all they do is take the value of the signals A to D, and shift them by 0, 8, 16 and 24 bits respectively, and output each as the signal (BLUE).
Signal goes over the green wire to the de-multiplexers.
For example, on (A) signal, which is the lowest 8 bits, i first shift 24 bits to the left, that drops all the bits but the lowest 8 right off the edge. Then it gets shifted back 24 bits to the right. That puts them right back where they were, but all the higher bits are now zeroed out. Funny enough this makes the number a signed integer. so the decider combinator, the arithmetic combinator and the constant combinator are there to turn it back into unsigned 8 bit integer.
The rest of the signals follow the same pattern, they just get shifted by different amount to the left, and 24 to the right.
Main advantage is that each signal is now calculated independently, so no more glitches, and since there is less maths, and bit shifting is cheap in terms of CPU costs, it should be easier on the CPU hamsters![Smile :)](./images/smilies/icon_e_smile.gif)
---
In the end I've decided to use the same signal for supply and demand signaling, that means i need only two numbers per signal, that increases the available range from 0-255 to 0-65535, and i don't think I'll be managing to sit on that many trainloads of stuff for some time.
Instead of bothering with calculating the individual signals and all that subtracting, and maths in general, i decided to just give the bits a nice shove right the edge and be done with them.
The way it works:
On the left are 4 pulse generators and counters, they just there so i have something to send down the wire.
Then the 4 multiplexers, all they do is take the value of the signals A to D, and shift them by 0, 8, 16 and 24 bits respectively, and output each as the signal (BLUE).
Signal goes over the green wire to the de-multiplexers.
For example, on (A) signal, which is the lowest 8 bits, i first shift 24 bits to the left, that drops all the bits but the lowest 8 right off the edge. Then it gets shifted back 24 bits to the right. That puts them right back where they were, but all the higher bits are now zeroed out. Funny enough this makes the number a signed integer. so the decider combinator, the arithmetic combinator and the constant combinator are there to turn it back into unsigned 8 bit integer.
The rest of the signals follow the same pattern, they just get shifted by different amount to the left, and 24 to the right.
Main advantage is that each signal is now calculated independently, so no more glitches, and since there is less maths, and bit shifting is cheap in terms of CPU costs, it should be easier on the CPU hamsters
![Smile :)](./images/smilies/icon_e_smile.gif)
---
In the end I've decided to use the same signal for supply and demand signaling, that means i need only two numbers per signal, that increases the available range from 0-255 to 0-65535, and i don't think I'll be managing to sit on that many trainloads of stuff for some time.
Efficiency is just highly developed form of laziness.
Re: Jamming more signals into your signals so you can signal more while you signal
Come on, the word signal is only used 55 times on this page!
On a more serious side note, this is cool, although I have no idea how it works (I might take a look at it eventually).
On a more serious side note, this is cool, although I have no idea how it works (I might take a look at it eventually).
Last edited by Jap2.0 on Mon Jan 07, 2019 10:23 pm, edited 1 time in total.
There are 10 types of people: those who get this joke and those who don't.
Re: Jamming more signals into your signals so you can signal more while you signal
Do you really need 16 bits of accuracy? You can do a lot better if you settle for 3.
A 6-bit float has decent coverage of all the interesting numbers. And you can fit 5 of them in one signal!
Or how about a 5-bit float. You can fit 6 of them in one signal!
Re: Jamming more signals into your signals so you can signal more while you signal
the subject should have been a warning for ya, hehe
![Smile :)](./images/smilies/icon_e_smile.gif)
I did notice your signature
![Razz :P](./images/smilies/icon_razz.gif)
Last edited by DingoPD on Mon Sep 24, 2018 9:51 pm, edited 1 time in total.
Efficiency is just highly developed form of laziness.
Re: Jamming more signals into your signals so you can signal more while you signal
My thought behind it was i can track supply and demand with the same signal, since there is more signals than there is items in the game (with the extra signal tab), i should have enough signals to cover every item conceivable. as long as i use iron for iron, copper for copper .. etc. And that leaves the whole alpha, numerical and color range for extras.
This is just the global signal network, for local only purposes i can always recycle signals too
![Smile :)](./images/smilies/icon_e_smile.gif)
Edit: oh and i think i just realized why you were talking about floats (wikipedia lol) .. doing that in factorio is a bit over my head ... i do binary really well though, i got 1010 fingers
![Smile :)](./images/smilies/icon_e_smile.gif)
Efficiency is just highly developed form of laziness.
Re: Jamming more signals into your signals so you can signal more while you signal
Nah, I'm too lazy to count - I just used ctrl+f.
Also, thanks - I believe you're the first person to comment on that (which is surprising considering how much time I
There are 10 types of people: those who get this joke and those who don't.
Re: Jamming more signals into your signals so you can signal more while you signal
That is really suprising, sometimes when i read the stuff here, i get this feeling that about half the silicon design teams from both intel and amd play factorio or troll the forums for ideas ...
Efficiency is just highly developed form of laziness.
Re: Jamming more signals into your signals so you can signal more while you signal
Yeah, a lot of people who are into computers, technology, engineering, etc. are on here. I'm guessing that many of them have noticed but just haven't mentioned it.
There are 10 types of people: those who get this joke and those who don't.
-
- Burner Inserter
- Posts: 15
- Joined: Thu Mar 24, 2016 7:45 pm
- Contact:
Re: Jamming more signals into your signals so you can signal more while you signal
Hey guys,
I jumped on the logistic train wagon and needed a mux/demux for my project, and this thread inspired me.
I want to post my solution in case you still have issues with tick-delay, for suggestions as to how improve mine, and maybe to help another down the road.
(If any combinators are unclear, I can provide more details/save file)
![Image](https://forums.factorio.com/images/ext/7cf473d6ae41bef824a5d32f82b6107c.jpg)
Alt-Mode
![Image](https://forums.factorio.com/images/ext/992fba9f597d9972d8b4267b2267d594.jpg)
Description: I tried to keep everything separated in its respective sub-units.
Left: Multiplexer; A B C D will send left bit-shifted values (on Iron Ore) over red wire. Copper and Wood are signal noise (positive and negative values resp)
Right: Filter; Pull Iron ore signal from red wire, and output to Demultiplexer
Demultiplexer; Filter relevant bit frame from Iron Ore (Bitwise AND), then right shift down to original value.
(Here, I have 3 channels on 8 bits each, for up to 255 values each over A B C; 7 bits for channel D--damn sign bit. In the end, I too settled for only 2 channels per signal, affording 4095 values with some room on the signal to spare for future projects)
Here's what I've got for tick count:
Tick 0: A = 0 -> A = 1 (Initial signal, ideally the signal of what'll be filtered--Iron Ore here--to enable Each -> Each during <<)
Tick 1: Each << x -> Iron Ore (left shift to relevant frame)
Tick 2: Each > 0 -> Each (Filter)
Tick 3: Each < 0 -> Each (Filter)
Tick 4: Each - (-2^32) -> Each (Filter Output)
Tick 5: Each AND Decimal Bit Frame -> Each
Tick 6: Each >> x -> Each (Final output, Iron Ore = 1)
My main bottleneck is the filter, and would love help on a solution to filter signals in the current build (0.16.51). (Thanks in advance!)
My main constraint is the signal must be set externally (ie via constant combinator).
Currently, it works by subtracting 2^32 from any positive incoming signal, decides which new signal is now negative, then adds the 2^32 back.
Hopefully the 0.17 release has a buff to circuits (specifically being able to compare two values on the same signal from different wires). *wink* *wink*
Signal.
I jumped on the logistic train wagon and needed a mux/demux for my project, and this thread inspired me.
I want to post my solution in case you still have issues with tick-delay, for suggestions as to how improve mine, and maybe to help another down the road.
(If any combinators are unclear, I can provide more details/save file)
![Image](https://forums.factorio.com/images/ext/7cf473d6ae41bef824a5d32f82b6107c.jpg)
Alt-Mode
![Image](https://forums.factorio.com/images/ext/992fba9f597d9972d8b4267b2267d594.jpg)
Description: I tried to keep everything separated in its respective sub-units.
Left: Multiplexer; A B C D will send left bit-shifted values (on Iron Ore) over red wire. Copper and Wood are signal noise (positive and negative values resp)
Right: Filter; Pull Iron ore signal from red wire, and output to Demultiplexer
Demultiplexer; Filter relevant bit frame from Iron Ore (Bitwise AND), then right shift down to original value.
(Here, I have 3 channels on 8 bits each, for up to 255 values each over A B C; 7 bits for channel D--damn sign bit. In the end, I too settled for only 2 channels per signal, affording 4095 values with some room on the signal to spare for future projects)
Here's what I've got for tick count:
Tick 0: A = 0 -> A = 1 (Initial signal, ideally the signal of what'll be filtered--Iron Ore here--to enable Each -> Each during <<)
Tick 1: Each << x -> Iron Ore (left shift to relevant frame)
Tick 2: Each > 0 -> Each (Filter)
Tick 3: Each < 0 -> Each (Filter)
Tick 4: Each - (-2^32) -> Each (Filter Output)
Tick 5: Each AND Decimal Bit Frame -> Each
Tick 6: Each >> x -> Each (Final output, Iron Ore = 1)
My main bottleneck is the filter, and would love help on a solution to filter signals in the current build (0.16.51). (Thanks in advance!)
My main constraint is the signal must be set externally (ie via constant combinator).
Currently, it works by subtracting 2^32 from any positive incoming signal, decides which new signal is now negative, then adds the 2^32 back.
Hopefully the 0.17 release has a buff to circuits (specifically being able to compare two values on the same signal from different wires). *wink* *wink*
Signal.