Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local r=peripheral.wrap("BigReactors-Reactor_26")
- --dpr
- local z=50
- local w=60
- local pp=4
- local ppr=0
- local wyster=100
- local zadane=50
- local k=60
- local ki=0.4
- local kd=0.9
- local u=0
- local up=0
- local su=0
- local prw=0
- local il=0
- -- funkcja wlancz
- function spr(ppr)
- --wlancz
- --wylancz
- if ppr==1 then
- r.setActive(true)
- else
- r.setActive(false)
- end
- end
- --Glowna penta programu
- while true do
- local moc=r.getEnergyStored()/100000
- --function round(num, idp)
- -- local mult = 10^(idp or 0)
- -- mocz=math.floor(num * mult + 0.5) / mult
- --end
- --round(moc,2)
- --print(mocz)
- --sleep(10)
- if pp==2 then
- if moc<z then
- spr(1)
- end
- if moc>w then
- spr(0)
- end
- end --end2
- if pp==1 then
- end --end pp1
- if pp==0 then
- end --pp0
- if pp==3 then --sterowanie PID
- --poczĥA5A585tki
- function round(num, idp)
- local mult = 10^(idp or 0)
- mocz=math.floor(num * mult + 0.5) / mult
- end
- round(moc,3)
- --print(mocz)
- --sleep(10)
- --pobranie danych
- moc1=mocz
- sleep(1,1)
- local moc=r.getEnergyStored()/100000
- round(moc,3)
- moc2=mocz
- if moc1<moc2 and moc2>zadane then
- wyster=wyster+1
- print("c1")
- end
- if moc1>moc2 and moc2<zadane then
- wyster=wyster-1
- print("c2")
- end
- if moc1==moc2 and moc2==zadane then
- wyster=wyster
- print("c3")
- end
- if moc1<moc2 and moc2==zadane then
- wyster=wyster
- print("c4")
- end
- if moc1==moc2 and moc2<zadane then
- wyster=wyster-1
- print("c5")
- end
- if moc1>moc2 and moc2==zadane then
- wyster=wyster
- print("c7")
- end
- if moc1==moc2 and moc2>zadane then
- wyster=wyster+1
- print("c9")
- end
- if wyster>100 then
- wyster=100
- end
- if wyster<0 then
- wyster=0
- end
- print(wyster)
- print("1")
- print(moc1)
- print("2")
- print(moc2)
- r.setAllControlRodLevels(wyster)
- end
- if pp==4 then
- r.setActive(true)
- local izpp=2
- local mult = 10^(izpp or 0)
- local moc=r.getEnergyStored()/100000
- moco=math.floor(moc * mult + 0.5) / mult
- u=zadane-moco
- p=k*u
- su=su+u
- i=ki*su
- d=kd*(u-up)
- up=u
- il=il+1
- print("MOCo:")
- print(moco)
- print("zwyster")
- print(wyster)
- print(il)
- --print("suma")
- --print(su)
- --print(i)
- print("--------")
- sleep(0,5)
- pwr=p+i+d
- wyster=100-pwr
- if wyster>100 then
- wyster=100
- end
- if wyster<0 then
- wyster=0
- end
- r.setAllControlRodLevels(wyster)
- end
- sleep(0,1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement