Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Title: ComputerCraft BigReactor Turbine automatic rate control software
- -- Author: MyrddinE
- --
- -- Purpose: Control the allowed steam input to one or more turbines, based on the energy
- -- remaining in one or more cells. Uses wired modems, one per turbine and one per cell.
- -- You can have as many cells (of different types) and as many turbines as you want. The
- -- cells must respond to 'getMaxEnergyStored' and 'getEnergyStored'; only tested with
- -- ThermalExpansion cells, but should work with other cells that support those commands.
- --
- -- For the feedback process to respond in time, you should have about 100M RF storage
- -- per turbine. Turbines take a long time to spin down and up, and a large buffer means
- -- less wasted overpower, and no power underruns. Also, since each turbine generates up
- -- to 30k RF/tick, and each cell (TE Resonant 50M) can only pass through 10K RF/tick per
- -- face, you will be throughput limited unless you go through some complicated
- -- shenanigans, so plan accordingly with extra cells. If you have lots of cells, a
- -- 2-wide 'wall' of cells passes through 10k per cell, with room on the sides for the
- -- modems. If you have lots of space and want to scrimp on the cells, you can jam in
- -- four conduits (2 in, 2 out) and a modem around each cell to halve the cells needed.
- --
- -- Wiring Diagram
- --
- -- Overflow Storage (Optional) More Power Storage (Optional)
- -- ^ | ^ |
- -- | v | v
- -- Turbines -----------------------> Buffer Bank ------------------------> Load
- -- T T
- -- | Computer |
- -- | T |
- -- +----------------+-----------------+
- -- Change this to be the side your wired modem is attached to the computer.
- modem = peripheral.wrap('back')
- mon=peripheral.wrap('top')
- -- Get the list of cells and turbines. Run once at startup. If you add or remove devices
- -- terminate and restart the program.
- name = modem.getNamesRemote()
- turbine = {}
- cell = {}
- tCount = 0
- cCount = 0
- for i = 1, #name, 1 do
- p = peripheral.wrap(name[i])
- if name[i]:match 'BigReactor' then
- tCount = tCount + 1
- turbine[tCount] = p
- else
- cCount = cCount + 1
- cell[cCount] = p
- end
- end
- mon.clear()
- mon.setCursorPos(1,1)
- mon.write(tCount," turbines, ",cCount," cells connected.")
- -- Loop forever
- while true do
- -- Add up the total (and max) power stored in the attached cells.
- energy = 0
- max = 0
- for i = 1, cCount, 1 do
- max = max + cell[i].getMaxEnergyStored('')
- energy = energy + cell[i].getEnergyStored('')
- end
- -- The emptier the cells, the faster it will set the turbines to go, up to the max of
- -- 2000mB/tick.
- rate = math.floor(2000*(1-energy/max))
- -- Set all attached turbines to the given rate. Total up how much RF they are
- -- producing at the same time, for display.
- RF = 0
- for i = 1, tCount, 1 do
- turbine[i].setFluidFlowRateMax(rate)
- RF = RF + turbine[i].getEnergyProducedLastTick()
- end
- -- Print some useful stats to the console.
- RF = math.floor(RF)
- batt = math.floor(100*energy/max).."%"
- mon.setCursorPos(1,2)
- mon.write("Buffer at ",batt," - ",rate,"mB/tick - Making ",RF,"RF/tick")
- -- Sleep for 5 seconds.
- sleep(10)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement