BrainStone

Lua ReaktorSteuerung

Jan 31st, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. os.loadAPI("api/PID")
  2.  
  3. target = 13900
  4. base = 26
  5. settings = {
  6.   kp = 0.007,
  7.   ki = 0.0005,
  8.   kd = 0.000001,
  9.   maxout = base,
  10.   minout = base - 100
  11. }
  12.  
  13. pid = PID.new(settings)
  14. reactor = peripheral.wrap("back")
  15.  
  16. pid.target = target
  17. pid.input = 0
  18. pid:compute()
  19.  
  20. sleep(0.5)
  21.  
  22. while true do
  23.   pid.input = reactor.getHotFluidProducedLastTick()
  24.  
  25.   pid:compute()
  26.  
  27.   reactor.setAllControlRodLevels(base - pid.output)
  28.  
  29.   term.clear()
  30.   term.setCursorPos(1, 1)
  31.   print(pid.input)
  32.   print(base - pid.output)
  33.  
  34.   sleep(0.1)
  35. end
Add Comment
Please, Sign In to add comment