fCPU


Factorio Customizable Processing Unit. Allow to write any logic on low level machine code. The fCPU acts like a programmable microcontroller with a vector coprocessor that supports many useful instructions.

Content
9 months ago
0.18 - 2.0
11.4K
Logistic network Circuit network

b Filter conflicts

9 months ago

I'm writing fairly simple code using memory as arrays:

mov m1@1 1[item=iron-plate]
clr mem

mov r1 2
mov m1@1 1[item=iron-plate]

And I get the error "Filter conflicts with filter in slot 1".

Why is this happening? Am I doing something wrong?

I also notice that clr does not completely clear values ​​from memory. They remain in the form of vectors, as an example, where r2 will have an unclear value.

mov m1@1 1[item=iron-plate]
clr mem
mov r1 2
mov m1@1 1[item=copper-plate]
fid r2 m1 [item=iron-plate]

9 months ago

Hello, AnyWayThanks
Thank you for report.
This bug appear after migration to Factorio 2.0 (logistic filter requests), when trying to write identical signals in different places.
Will be fixed soon.

9 months ago

I'm getting the same problem

4 months ago
(updated 4 months ago)

I can confirm that this is still an issue. Is there any update on when this might be fixed? I love using this mod to control my Realistic Reactors setup, but my control rod CPU keeps erroring. Below is my code in case it will help you. Forgive the bad note-taking; I'm still polishing the code. If I replace the CPU it seems to fix it for a bit.

; --- Initialization ---
clr
sst r1 [virtual-signal=signal-reactor-core-temp] ; Input signal type (temperature)
sst r2 [virtual-signal=signal-controlrods-target] ; Output signal type (target rod position)
sst r3 [virtual-signal=signal-controlrods-current] ; Input signal type (current rod position)
sst r4 [virtual-signal=signal-state-scramed] ; Input signal type (scram state)
sst r5 [virtual-signal=signal-state-starting] ; Input signal type (starting state)
mov r16 -1[virtual-signal=signal-controlrods-target] ; Initialize control rod command (r16)

ssv r6 10 ; Rod Increase Amount (now decrease)
ssv r7 5 ; Rod Decrease Amount (now increase)
ssv r8 950 ; High Temp Limit
ssv r9 700 ; Proactive High Temp
ssv r10 630 ; Proactive Low Temp
ssv r11 3 ; Proactive Temp Increase Rate
ssv r12 -4 ; Proactive Temp Decrease Rate
ssv r20 20 ; Temperature history length
clr mem1 ; Clear memory channel 1 (for temperature history)
ssv r31 200 ; 5 seconds in ticks (60 ticks/second * 5 seconds)
ssv r32 0 ; Counter for stuck -1 condition

:loop
; --- 1. Read Input Signals ---
fid r13 green [virtual-signal=signal-reactor-core-temp] ; Read current temperature
fid r14 green [virtual-signal=signal-controlrods-current] ; Read current rod position
fid r15 green [virtual-signal=signal-state-scramed] ; Read scram state
fid r17 green [virtual-signal=signal-state-starting] ; Read starting state

; --- 2. Store Temperature History ---
mov r21 0 ; reset index
:store_loop
tgt r21 1
tge r21 r20
beq r21 r20 :store_loop_end

mov r29 r21 ; Copy r21
dec r29 ; Calculate r21 - 1

mov r30 mem1[29] ; Read from previous cell
mov mem1[21] r30 ; Write to current cell

inc r21
jmp :store_loop

:store_loop_end
mov r29 20
dec r29
mov mem1[29] r13 ; Store current temp

; --- 3. Calculate Average Temperature ---
xavg r18 mem1 ; Calculate average temperature

; --- 4. Calculate Temperature Rate of Change ---
mov r29 20
dec r29
mov r28 mem1[29] ; Load the oldest temperature from history
sub r19 r18 r28 ; Calculate temp rate; --- 5. Handle Starting State ---
tgt r17 0
jmp :set_rods_to_1 ; If r17 > 0, jump to set rods

jmp :check_scram ; Otherwise, skip and check scram

:set_rods_to_1
mov r16 -1[virtual-signal=signal-controlrods-target] ; Set rods to -1 if starting
jmp :output_rods

:check_scram
; --- 6. Handle Scram State ---
tgt r15 0
jmp :set_scram_rods ; If r15 > 0, set scram

jmp :control_rods_logic ; Otherwise, continue

:set_scram_rods
mov r16 -100[virtual-signal=signal-controlrods-target] ; Set rods to -100 if scrammed
jmp :output_rods

:control_rods_logic
; --- 7. Control Rod Adjustment Logic ---
; --- Safety Scram ---
tgt r13 r8 ; Absolute safety limit
beq r13 r8 :scram
; --- Proactive Control ---
tgt r19 r11 ; If temp rate is high
jmp :check_high_temp ; If true, check high temp

jmp :check_withdraw ; If not, skip to withdraw check

:check_high_temp
tgt r18 r9 ; and average temp is high
beq r18 r9 :insert_rods ; If true, insert rods
; band r22 r19 r18
; tgt r22 1
; beq r22 r22 :insert_rods
; --- Cautious Withdrawal ---
:check_withdraw
tlt r19 r12 ; If temp rate is decreasing
tlt r18 r10 ; and average temp is low
band r23 r19 r18
tgt r23 1
beq r23 r23 :withdraw_rods

; --- No Adjustment ---
jmp :output_rods

:insert_rods
add r16 r16 r6 ; Increase insertion (reduce power)
tlt r16 -100 ; Check for max insertion (most negative)
tgt r16 -1 ; Check for min insertion (least negative)
beq r16 r16 :output_rods
mov r16 -100[virtual-signal=signal-controlrods-target] ; Set rods to max insertion
jmp :output_rods

:withdraw_rods
sub r16 r16 r7 ; Decrease insertion (increase power)
tgt r16 -1 ; Check for min insertion (least negative)
tlt r16 100 ; Compare with max (most negative)
beq r16 r16 :output_rods
mov r16 -1[virtual-signal=signal-controlrods-target] ; Set rods to min insertion
jmp :output_rods

:scram
mov r16 -100[virtual-signal=signal-controlrods-target] ; Emergency shutdown (or the correct scram position)
jmp :output_rods

:output_rods
; --- 8. Stuck Rod Check ---
teq r16 -1
beq r16 r16 :check_stuck_counter
jmp :reset_stuck_counter

:check_stuck_counter
inc r32
tgt r32 300 ; 30 seconds (60 ticks/second * 30 seconds)
blt r32 300 :output_rods_continue
mov r16 1[virtual-signal=signal-controlrods-target] ; Override to 1 if stuck
mov r32 0 ; Reset counter

:reset_stuck_counter
mov r32 0

:output_rods_continue
mov out4 r16 ; Output the control rod command to out4
slp r31 ; Sleep for 5 seconds
jmp :loop

New response