Assign values to signal

Post all other topics which do not belong to any other category.
fuinril
Burner Inserter
Burner Inserter
Posts: 15
Joined: Wed Feb 21, 2018 10:50 pm
Contact:

Assign values to signal

Post by fuinril »

Hello everyone,

I have a small problem to submit to you :

I have a blue signal wich takes values through a loop (101, next tick 102, next tick 105 and so on)

I have a predetermined signal set (let's say signal 0 to 9) which all are equal to 1.

My goal is to assign each different value of the blue signal to a signal of the set.

Basically :

blue == 101
if ('0' == 1) '0'=101
else if ('1' == 1) '1'=101
...

Same thing for blue==102, 103, etc.... It is not possible to make any condition on a specific value of the blue signal as the value can be anything from 101 to 999.

Any idea ?
4xel
Fast Inserter
Fast Inserter
Posts: 108
Joined: Fri May 26, 2017 3:31 pm
Contact:

Re: Assign values to signal

Post by 4xel »

fuinril wrote: if ('0' == 1) '0'=101
else if ('1' == 1) '1'=101
There are ways to translate this idea directly into combinators. For example, you can run, for each element in the set and in parallel, the instruction :

if '0' =/= 1 and '1' == 1, '1' = 'blue'
(exemple instruction for '1')

To implement the above instruction you can use three combinators :
If '0' =/= 1, 'A' = 1
If '1' == 1 'A' = 1
And then with the output of the other 2 combinators as additional input,
If 'A' == 2, '1' = 'blue'

There are issues with this approach :
  • 3 combinators by element
  • you have to loop the output to the input, since you're using it. So you're effectively creating an undesired memory cell. There are usually ways to break such impomptous cell, but it can give headache.

It is not possible to make any condition on a specific value of the blue signal as the value can be anything from 101 to 999.
The easy solution seems to make a condition on an auxiliary signal. Run a clock with signal say 'T', which goes 0,1,2,3,4,5,6,7,8,9 and loops, and have 9 combinators which goes like :

"If ('T' == 0) '0' = 1" chained with " 'anything' = 'blue' * 'anything' " (or " '0' = 'blue' * 1", but less general)
"If ('T' == 1) '1' = 1" chained with " 'anything' = 'blue' * 'anything' " (or " '1' = 'blue' * 1", but less general)
"If ('T' == 2) '2' = 1" chained with " 'anything' = 'blue' * 'anything' "
etcaetera

The " 'anything' = 'blue' * 'anything' " can be shared among the entries, but you need as many combinators as element of your set otherwise, and you need to know the set in advance.

With this solution, you probably want to set the signal of the set to 0 initially, rather than to 1). And you can use values between 1 and 100 for blue if all that prevented you to do so was the previously locked value 1.

You can chain with a memory cell if you need persistency (adding is easy, erasing old data in real time in a system sensitive to the tick can be tricky).


I don't see any simple way around knowing the predetermined set in advance, but I do see at least 2 very complicated ones if you're interested, which probably can't be used at a period of one tick.
fuinril
Burner Inserter
Burner Inserter
Posts: 15
Joined: Wed Feb 21, 2018 10:50 pm
Contact:

Re: Assign values to signal

Post by fuinril »

Ok, it's definitively way more complicated than this but you gave me a shove in the right direction ! Thank you !

Image

Now I have all the blue values assigned to the signal set, each value being "reserved" if already assigned.

2 issues remain however (maybe 3... not sure about the last one).

- The first one is I send the blue signal directly into the new mountage, so a specific value can take forever before beeing assigned (or never on specific values I think). The reason is the loop which assign the values to the blue signal run from 0 to 1000 while the new mountage loop from 0 to 24, so if a specific value of the blue signal never match a "free" signal timer for whatever matemathic reason it will not be assigned...

-> I think one way to overcome this is to not increment the loop of the blue signal until either the value is 0, or the value is already assigned, or the new mountage clock reset. The only difficulty I forsee here is the reset cause I will never know at which value it starts.... I will think about it.

-> delete a value from a signal. Here I'm at a loss and have no idea for now

-> the third is I'm not actually 100% sure the "already assigned" check will always work due to tick dependency. I tested the mountage with 30 values and it worked 100% but I have the feeling it's possible, especially if I create a loop for assigning values, cause when the next tick of the clock will start, the first signal will not be already assigned and so it will pass the unicity test....

Some work and thinking are still required but it's definitively a huge step your advices allow me to do !
Post Reply

Return to “General discussion”