Jump to content




Active Cooled Big Reactor: Turbine PID-Controller with master control and monitoring.

wireless networking peripheral

27 replies to this topic

#21 HadesDurin

  • Members
  • 16 posts

Posted 21 September 2015 - 06:15 PM

i lately start to use your program and some of my advanced computers attached to the turbines crash randomly
here is a picture on the crash massage i get

http://www.pichost.de/image/JAi

#22 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 23 September 2015 - 04:53 AM

Always the same error, with that same line number?

Have you modified the script file in any way? If so, what's the changed version look like?

#23 HadesDurin

  • Members
  • 16 posts

Posted 23 September 2015 - 07:17 AM

the line number ist mostly around 124-125
the only change i made to the pastbin code is
1.2.3 Enable remote control feature
in line 40
all other i left untouched
the computer (attached to turbine) crashes are randomly thru all 6 (i use 6 turbines) of them
and sometimes only 1 crashes and sometimes even more
the only thing thats identical is that yielding thing error
EDIT: latest computercrash http://prntscr.com/8jmdj5

Edited by HadesDurin, 23 September 2015 - 04:04 PM.


#24 HadesDurin

  • Members
  • 16 posts

Posted 23 September 2015 - 11:38 PM

here are 2 new errors i lately got

http://prntscr.com/8jrwpv

http://prntscr.com/8jrx82

Edit: newest error, after the next time i try to start it works
http://prntscr.com/8jvwuf

Edited by HadesDurin, 24 September 2015 - 09:48 AM.


#25 aadje93

  • Members
  • 9 posts

Posted 27 October 2015 - 05:38 PM

Hello, your script looks awsome! Can't wait to implement it in my power station (20 turbines to come)

But i'm very new in the "new" CC, never knew about the advanced monitors and modems etc, they look awsome to, mouse control on the monitor :D

But now to the real question;

do i need to connect a computer to the turbine, or can i just put a modem on the port? I dont like the looks of a computer on every turbine, but a modem looks good, i can put the "computers" somewhere else if thats nessecary (backroom of control room?)

I'm looking forward to your response :)

#26 Caleb Ragnarok

  • Members
  • 35 posts

Posted 02 November 2015 - 06:26 PM

You can do either, a computer, a turtle or a wired modem. I'm using a combination of all three.

#27 ultratutu9

  • New Members
  • 1 posts

Posted 25 January 2016 - 07:30 PM

How can i do for change the speed limit to disengange the coils again? Like, if the speed drops down to 1500 RPM, disengange the coils to speed up faster.

#28 El_Loko_

  • New Members
  • 1 posts

Posted 08 October 2016 - 08:53 PM

Guys,

have written a small add-on for this nice script. Thanks kla_sch I love it.

This script controls the reactor to save fuel.

The profiler will create a profile of your reactor how many steam will be created if running with rod level x
Run this script before you start the control script.
It will take some time to create the profile. Best way is to add 4 turbines set them to max speed and run the script.

http://pastebin.com/rKKiEmxm

--
-- Control an active cooled reactor from Big reactors (http://big-reactors.com/).
-- Profiler
-- run this script before running the reactor control script
-- run this script every time you change your reactor layout
--
-- Author: El_Loko_
--
-- Save as "startup"
--
--
--
-- Constant values (configuration)
-- ===============================
local rodLevel = 100
local reactor
reactor = peripheral.wrap("bottom")
local hold = 20 -- as higher the hold value that more accurate are the values
local profile = fs.open("profile.txt", "w")
reactor.setActive(true)
rod = 100
repeat
reactor.setAllControlRodLevels(rod)
sleep(hold)
print("R: " .. rod .. " Heat: " .. reactor.getFuelTemperature() .. " Steam: " .. reactor.getEnergyProducedLastTick())
profile.writeLine(rod .. ";" .. reactor.getFuelTemperature() .. ";" .. reactor.getEnergyProducedLastTick())
rod = rod - 1
if(reactor.getEnergyProducedLastTick() > 8000) then
  rod = 0
end
until rod == 0
reactor.setActive(false)
profile.close()

This is the controller. Save it as startup after creating the profile

http://pastebin.com/7aCWb3MC

--
-- Control an active cooled reactor from Big reactors (http://big-reactors.com/).
-- this is an Addon Script for kla_sch turbine script (http://www.computercraft.info/forums2/index.php?/topic/21430-active-cooled-big-reactor-turbine-pid-controller-with-master-control-and-monitoring/)
--
-- This script controls a activ cooled reactor to save fuel. It set the rod level automaticly
-- Run the profiler script before running this script
--
-- Author: El_Loko_
--
-- Save as "startup"
--
--
--
-- Constant values (configuration)
-- ===============================
-- set the Broadcast channel (make sure it is the same as the turbines)
local stateRequestChannel = 32768 -- Broadcast channel.
local loopT = 1
local rodLevel = 100
-- set the positon where your computer is conected to the reactor
-- top, bottom, left, right, back  
local reactor
local reactor = peripheral.wrap("bottom")
-- the file with the reactor profile
local profile = "profile.txt"
local reactorProfil = {}
-- Author: kla_sch
local function sendBroadcastRequest()
   local pList = peripheral.getNames()
   local i, name
   for i, name in pairs(pList) do
	  if peripheral.getType(name) == "modem" then
		 peripheral.call(name, "open", os.getComputerID())
		 peripheral.call(name, "transmit", stateRequestChannel, os.getComputerID(), "BR_turbine_get_state")
		
	  end
   end
end

-- Author: unknown
function split(pString, pPattern)
   local Table = {}  -- NOTE: use {n = 0} in Lua-5.0
   local fpat = "(.-)" .. pPattern
   local last_end = 1
   local s, e, cap = pString:find(fpat, 1)
   while s do
		  if s ~= 1 or cap ~= "" then
		 table.insert(Table,cap)
		  end
		  last_end = e+1
		  s, e, cap = pString:find(fpat, last_end)
   end
   if last_end <= #pString then
		  cap = pString:sub(last_end)
		  table.insert(Table, cap)
   end
   return Table
end

-- check if the profile is available
function file_exists(file)
  local f = io.open(file, "rb")
  if f then f:close() end
  return f ~= nil
end
-- get all lines from a file, returns an empty
-- list/table if the file does not exist
function lines_from(file)
  if not file_exists(file) then return {} end
  lines = {}
  for line in io.lines(file) do
	lines[#lines + 1] = line
  end
  return lines
end
-- tests the functions above
local lines = lines_from(profile)
-- load profile
for k,v in pairs(lines) do
   line = v
   table.insert(reactorProfil, split(line, ";"))
end

-- set rod to 100
reactor.setAllControlRodLevels(rodLevel)
reactor.setActive(true)
-- parts of this codes are from kla_sch
-- some is from me
while(true) do
  
	term.clear()
	sendBroadcastRequest()
	local steamNeeded = 0
	local tID = os.startTimer(loopT)
	repeat
	  
	turbineTable = {}
local evt, p1, p2, p3, p4, p5 = os.pullEvent()
if evt == "modem_message"
  and p2 == os.getComputerID()
  and p3 == stateRequestChannel
then
  local rState = textutils.unserialize(tostring(p4))
  if rState ~= nil
   and type(rState) == "table"
   and rState.version ~= nil
   and rState.version == "Turbine V0.1"
  then
   -- seems to be a suitable data structure
   turbineTable[rState.label] = rState
   steamNeeded = rState.fluidFlowRateMax + steamNeeded
   end
end
	
-- search the table reactorProfile for the first value wich is above
-- the needed steam value and set the rods to this level
-- very ineficent but working
for k,v in pairs(reactorProfil) do
  --print(v[3])
  if (tonumber(v[3]) > steamNeeded) then
   reactor.setAllControlRodLevels(tonumber(v[1]))
   break
  end
end
term.clear()
print("Rod Level:		" .. reactor.getControlRodLevel(0))
print("Energy Produced:  " .. reactor.getEnergyProducedLastTick())
print("Energy Requested: " .. steamNeeded)
	until evt == "timer" and p1 == tID
end

Cheers, El_Loko_





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users