Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Super basic reactor and turbine control script
- turbine = peripheral.wrap("BiggerReactors_Turbine_0")
- reactor = peripheral.wrap("BiggerReactors_Reactor_0")
- -- Basically we just want to PID power to 0 by way of control rod insertion
- -- First, let's see what we've got...
- -- Reactor:
- -- ambientTemperature
- -- connected
- -- active
- -- setAllControlRodLevels
- -- battery
- -- fuelTemperature
- -- controlRodCount
- -- setActive
- -- fuelTank
- -- coolantTank
- -- apiVersion
- -- getControlRod
- -- stackTemperature
- -- casingTemperature
- -- Actually, I might want to PID the casingTemperature to a certain level instead
- -- Just below steam generation so I can easily add more
- -- That should be 373.15k
- -- Turbine:
- -- connected
- -- rotor
- -- battery
- -- fluidTank
- -- setActive
- -- setCoilEngaged
- -- apiVersion
- -- active
- -- coilEngaged
- reactor.setActive(true)
- while(true) do
- local targetTemp = 373.15
- local steamScalar = 1/100
- -- We might need to adjust this up for when we need steam
- targetTemp = targetTemp - (turbine.fluidTank().input().amount() * steamScalar)
- print("Target temp: " .. targetTemp)
- local controlMult = 0.1
- local controlRodChange = (reactor.casingTemperature()-targetTemp) * controlMult
- reactor.setAllControlRodLevels(reactor.getControlRod(0).level+controlRodChange)
- print("Control rod change: " .. controlRodChange)
- -- Now try to keep the turbine at 1800 rpm
- if turbine.rotor().RPM() > 1800 and turbine.active() then
- turbine.setActive(false)
- elseif turbine.rotor().RPM() < 1800 and not turbine.active() then
- turbine.setActive(true)
- end
- -- And turn on the coils when we need power
- if turbine.battery().stored() > 0 and turbine.coilEngaged() then
- turbine.setCoilEngaged(false)
- elseif turbine.battery().stored() == 0 and not turbine.coilEngaged() then
- turbine.setCoilEngaged(true)
- end
- coroutine.yield()
- end
Advertisement
Add Comment
Please, Sign In to add comment