Jump to content




Nuclear Reactor Control System

utility

  • You cannot reply to this topic
38 replies to this topic

#1 Hexicube

  • New Members
  • 30 posts
  • LocationThe moon

Posted 08 June 2012 - 03:52 PM

I've been working on a simple utility that manages a nuclear reactor for you. I am currently trying it out on my private tekkit server running 3.0.4, but it looks to be working OK.
Software works as intended for me, you should have it set to startup just in case the server restarts or something and you find a lovely crater where your reactor used to be...
The second version is currently untested...


Right now it takes two redstone inputs to work out the reactor temperature state (cold, warm, or hot), and gives two outputs (one toggles the reactor, another is a bundled wire output for whatever you want).
It now also accepts an optional input from an MFE/MFSU(should be the first of a chain of storage units with the redstone output set to emit if partially filled) to work out if the reactor ran out of cells or the storage is full.
The second version uses a single bundled cable for all input/output, if you do not want to use an optional in/out then set it to 0 (the reactor will think it is empty if you disable the storage state signal, but this has no adverse effects).
Protip: You can set the storage state input to be a lever, which will basically act as a manual override shutoff switch. You could also do this with an OR gate, so the reactor continues to monitor the EU storage.


The input and output sides are freely change-able from the top of the code, as well as the three colours it uses within bundled cables for the outputs. The two temperature inputs are hooked up by using Thermal Monitors on the reactor, preferably with the cold heat level being lower than the hot.
The second version only has one side for all wiring, but the side is still configurable.

Here's the code:
Spoiler

Here's some better commented code that only uses one bundled cable (untested):
Spoiler

Here's a couple of images showing my setup (they're a bit big, also only first software version):
Spoiler


Feel free to change it as you see fit or make suggestions as to improving it, but I suggest you use this as a startup file as computers tend to do a fresh reboot on a server restart (from what I've noticed). If you do use this in a project, mentioning me would be nice, thought I don't enforce it...just don't say you made it! :)/>

Also, if you're a bit confused, here's a world I made (flatmap/creative) showing how to set up the reactor with the newer software version:
https://dl.dropbox.c...r%20Control.zip

#2 Hexicube

  • New Members
  • 30 posts
  • LocationThe moon

Posted 09 June 2012 - 09:18 AM

Just noticed the "Cells Depleted" text wouldn't show, I've moved that little bit of code up to remidy this.

#3 yoskaz01

    Featured on Reddit!

  • New Members
  • 92 posts

Posted 09 June 2012 - 09:43 AM

just a small suggestion,

if you want to show the actual temperature and number of cells in the reactor, consider using ccSensors.
check the peripheral page.

#4 Hexicube

  • New Members
  • 30 posts
  • LocationThe moon

Posted 09 June 2012 - 10:09 AM

I would, but I'm using tekkit, so I'd rather try and use what I have. I was fully aware of ccSensors before-hand. :)/>

#5 Hexicube

  • New Members
  • 30 posts
  • LocationThe moon

Posted 09 June 2012 - 12:00 PM

Just changed the program to include a redstone signal stating that the energy storage is full. You don't really need to hook up this input, but it forces the reactor to turn off when it has been on for 3 seconds.

#6 Hexicube

  • New Members
  • 30 posts
  • LocationThe moon

Posted 17 June 2012 - 09:56 PM

Changed it to use the storage input to detect if the reactor ran out of cells, instead of the low temperature input. There's currently a quirk in energy storage units where if you set it to emit on partially full you get 1 tick of redstone current when the EU exceeds the packet size...as such, it's not advised to run a reactor which produces more EU/t than the storage unit is giving out.

Also, you should have a chain of MFEs/MFUs, as the first to be powered in the chain(and thus the last filled) can be set to emit when partially full to inform the manager if storage is getting full or not, rather than using the emit if full option and wasting a bit of EU.

#7 Paukinra

  • New Members
  • 1 posts

Posted 19 June 2012 - 08:25 AM

Hey, been trying to get this to work but I keep getting this error when trying to run the program as startup:

bios:206: [string "startup" ] : 26 : '=' expected

Any ideas what mgith be wrong?


Also, I am a little confused as the which cables I need and where they go, whould it be possible to get a pretty picture? :(/>

#8 Hexicube

  • New Members
  • 30 posts
  • LocationThe moon

Posted 23 June 2012 - 12:28 PM

View PostPaukinra, on 19 June 2012 - 08:25 AM, said:

Hey, been trying to get this to work but I keep getting this error when trying to run the program as startup:

bios:206: [string "startup" ] : 26 : '=' expected

Any ideas what mgith be wrong?


Also, I am a little confused as the which cables I need and where they go, whould it be possible to get a pretty picture? :P/>
I'll make some nice pictures to help with setting it up. As for the problem, I'd double check you entered it right, it works perfectly fine for me with vanilla tekkit and no extra APIs.
[edit] Done, if you want I could make a fresh world and construct a setup using the default settings for download...

#9 WarBird

  • New Members
  • 1 posts

Posted 27 June 2012 - 07:08 PM

The color coded lights are a good idea, but itd be nice to know what each mean, Im assuming that blue means either cold or no cells, and that red means its going to blow. I assume white means that its on, the last white from what I can see means storage full, and green means ?
I am also having trouble figuring out how you got the MFSU containers linked up to the computer. I am not sure if not having the containers linked is the problem, but, the system always reports the cells being depleted.

#10 elustran

  • New Members
  • 3 posts

Posted 28 June 2012 - 10:20 AM

I like the basic idea of this, but I wanted to do a few things differently. I basically used some of your code and format as a base - mostly the tick loop and the outline of the screen clearing function (It's still a - and added my own control language. It's pretty messy - I probably should have written a couple of functions to call on instead of writing everything individually in a big if-elseif chain. At least I commented a fair bit. I'd love some ideas for cleaning it up. I've debugged it as much as possible and I think it works, mostly.

Basically, I wanted to run everything from a bundled cable so I could put the terminal wherever without extra cables sticking out of it, provide for power-on detection of thermal sensors and coolant, leave as much space as possible for water in the reactor chamber, and output to a monitor. The monitor output part I put in a startup routine with the startup routine on disk, but the program on the computer.

Startup routine:

This will check for a monitor next to the computer and use that for output if its available.
Spoiler

Reactor code:

This checks the status of a low and high heat sensor, reactor activity, if the battery is full, if coolant has power, if thermometers have power (for remote thermometers), and cable breakage. It outputs signals indicating the computer is on, whether to activate coolant, whether to deactivate the reactor, and whether to activate an alarm. Input signal wires could easily lead to both the computer and a signal light.

This system is intended to have a redstone torch near the reactor chamber powering a wire in the cable to detect if the cable is intact (no signal means a cable breakage). There is a signal indicating that the computer is on, which could be used in conjunction with redstone/redwire gates for various external signal overriding purposes. The system is also intended to be attached to a buildcraft/industrialcraft ice cooler (or a ridiculously OP EE-based one if you're lazy). For the thermal sensors, you should use an AND gate from a power detector cable on both of them so if either loses power, you'll get a warning. There are also provisions for an override switch should something fail.

Spoiler


#11 Hexicube

  • New Members
  • 30 posts
  • LocationThe moon

Posted 28 June 2012 - 02:47 PM

View Postelustran, on 28 June 2012 - 10:20 AM, said:

I like the basic idea of this, but I wanted to do a few things differently. I basically used some of your code and format as a base - mostly the tick loop and the outline of the screen clearing function (It's still a - and added my own control language. It's pretty messy - I probably should have written a couple of functions to call on instead of writing everything individually in a big if-elseif chain. At least I commented a fair bit. I'd love some ideas for cleaning it up. I've debugged it as much as possible and I think it works, mostly.

Basically, I wanted to run everything from a bundled cable so I could put the terminal wherever without extra cables sticking out of it, provide for power-on detection of thermal sensors and coolant, leave as much space as possible for water in the reactor chamber, and output to a monitor. The monitor output part I put in a startup routine with the startup routine on disk, but the program on the computer.

Startup routine:

This will check for a monitor next to the computer and use that for output if its available.
Spoiler

Reactor code:

This checks the status of a low and high heat sensor, reactor activity, if the battery is full, if coolant has power, if thermometers have power (for remote thermometers), and cable breakage. It outputs signals indicating the computer is on, whether to activate coolant, whether to deactivate the reactor, and whether to activate an alarm. Input signal wires could easily lead to both the computer and a signal light.

This system is intended to have a redstone torch near the reactor chamber powering a wire in the cable to detect if the cable is intact (no signal means a cable breakage). There is a signal indicating that the computer is on, which could be used in conjunction with redstone/redwire gates for various external signal overriding purposes. The system is also intended to be attached to a buildcraft/industrialcraft ice cooler (or a ridiculously OP EE-based one if you're lazy). For the thermal sensors, you should use an AND gate from a power detector cable on both of them so if either loses power, you'll get a warning. There are also provisions for an override switch should something fail.

Spoiler
Well, your version is certainly interesing...the reason I didn't use bundled cables for input was because it was initially individual wires because I didn't understand the API and then couldn't be bothered to change my reactor layout.

I assume it works just as well as my original program does, so the ideas you gave within the code is nice, but I think all the functionality my current version provides should suffice...but I don't mind anyone using yours for the extra bits n pieces.

I haven't really looked over it in detail, but one instance where you can clean up the code a bit:
rs.setBundledOutput(cableside, klaxon + computeron + nukepower)
cablestate = klaxon + computeron + nukepower
Could be written as:
cablestate = klaxon + computeron + nukepower
rs.setBundledOutput(cableside, cablestate)
There are probably other instances of improving it, but right now I'll be improving my program to account for bundled cable output...once I deplete my cells so my reactor doesn't explode! :P/>



View PostWarBird, on 27 June 2012 - 07:08 PM, said:

The color coded lights are a good idea, but itd be nice to know what each mean, Im assuming that blue means either cold or no cells, and that red means its going to blow. I assume white means that its on, the last white from what I can see means storage full, and green means ?
I am also having trouble figuring out how you got the MFSU containers linked up to the computer. I am not sure if not having the containers linked is the problem, but, the system always reports the cells being depleted.
The colours of the output merely represent what colour wire it uses. These can be hooked up to any colour light you want.
White shows the reactor is active (I used a red lamp), black is inactive (green lamp), blue states the reactor may be out of uranium (blue lamp) and red states the MFSU storage is full (white lamps, makes reactor inactive).
You don't actually need to hook up any of these, the output cable is a completely optional cable to make it possible to see the status of the reactor without entering the computer next to it, which is useful for factories containing multiple reactors.

As for hooking up the MFSUs, I will upload another picture to help with preparing them.
Basically, the power from the reactor goes into the first MFSU, which has its redstone output set to "Emit if partially filled". This MFSU also sends its power to other MFSUs, which keeps it empty so the redstone signal quirk works as intended. Using MFSUs for this allows any amount of reactor power output from ~64EU to ~256EU, but any value that can be expressed as 2^n (1, 2, 4, 8, 16, 32, etc.) will not work due to the way the quirk works. Any value under 64 might cause the reactor to keep thinking the cells are empty for a moment or two. Any value over 256 might cause the reactor to think the energy storage is full for a moment or two. Any value over 512 is guaranteed to cause the reactor to think it's full and will cause the reactor to constantly flick between on and off until the cells run out or it actually fills the storage.
Note that MFEs and batboxes also work, but they have lower EU input/output so I would recommend just using MFSUs. Also, if your reactor doesn't blow up a baxbox from directly energy input, you really need to improve the design!

#12 elustran

  • New Members
  • 3 posts

Posted 28 June 2012 - 09:51 PM

View PostHexicube, on 28 June 2012 - 02:47 PM, said:

Well, your version is certainly interesing...the reason I didn't use bundled cables for input was because it was initially individual wires because I didn't understand the API and then couldn't be bothered to change my reactor layout.

I assume it works just as well as my original program does, so the ideas you gave within the code is nice, but I think all the functionality my current version provides should suffice...but I don't mind anyone using yours for the extra bits n pieces.

I haven't really looked over it in detail, but one instance where you can clean up the code a bit:
rs.setBundledOutput(cableside, klaxon + computeron + nukepower)
cablestate = klaxon + computeron + nukepower
Could be written as:
cablestate = klaxon + computeron + nukepower
rs.setBundledOutput(cableside, cablestate)
There are probably other instances of improving it, but right now I'll be improving my program to account for bundled cable output...once I deplete my cells so my reactor doesn't explode! :P/>
Ha, yeah, I thought about that change too, but I had already done it the other way before it occurred to me I'd need to save the cable state for later if I wanted to add a bit to it, which I did for the coolant monitor portion. If you look, the only time I ever used it was at the very end to power on cooling - at that point I was just "Meh. It works." Main thing I'm wondering is if I should have made separate functions to call on within the elseif chain or if it actually runs faster to just leave it like it is...

Quote

As for hooking up the MFSUs, I will upload another picture to help with preparing them.
Basically, the power from the reactor goes into the first MFSU, which has its redstone output set to "Emit if partially filled". This MFSU also sends its power to other MFSUs, which keeps it empty so the redstone signal quirk works as intended. Using MFSUs for this allows any amount of reactor power output from ~64EU to ~256EU, but any value that can be expressed as 2^n (1, 2, 4, 8, 16, 32, etc.) will not work due to the way the quirk works. Any value under 64 might cause the reactor to keep thinking the cells are empty for a moment or two. Any value over 256 might cause the reactor to think the energy storage is full for a moment or two. Any value over 512 is guaranteed to cause the reactor to think it's full and will cause the reactor to constantly flick between on and off until the cells run out or it actually fills the storage.
Note that MFEs and batboxes also work, but they have lower EU input/output so I would recommend just using MFSUs. Also, if your reactor doesn't blow up a baxbox from directly energy input, you really need to improve the design!
That was one part of your original code that I really didn't get (which is why I didn't wind up including it in mine), and after that explanation, it's starting to make more sense. But I'm wondering, is there a problem with simply pumping reactor output into a line of MFSUs and ANDing their output signals to indicate they're all full? Was there some sort of trick you were trying to exploit?

#13 Hexicube

  • New Members
  • 30 posts
  • LocationThe moon

Posted 28 June 2012 - 10:39 PM

View Postelustran, on 28 June 2012 - 09:51 PM, said:

Ha, yeah, I thought about that change too, but I had already done it the other way before it occurred to me I'd need to save the cable state for later if I wanted to add a bit to it, which I did for the coolant monitor portion. If you look, the only time I ever used it was at the very end to power on cooling - at that point I was just "Meh. It works." Main thing I'm wondering is if I should have made separate functions to call on within the elseif chain or if it actually runs faster to just leave it like it is...

That was one part of your original code that I really didn't get (which is why I didn't wind up including it in mine), and after that explanation, it's starting to make more sense. But I'm wondering, is there a problem with simply pumping reactor output into a line of MFSUs and ANDing their output signals to indicate they're all full? Was there some sort of trick you were trying to exploit?

I would expect having it right in there makes it a bit quicker, though with the sleep calls and the small amount of code the difference is insurmountable.

The MFSUs was a trick I discovered with the "Emit if partially filled" setting. Basically, the MFSU emits if it is holding over 512 EU (packet size) but is not full. The way the MFSU is coded causes it to emit 1 tick of redstone signal before sending out its EU that same tick, and my program picks it up to work out 3 possible states from 1 signal. No signal is considered an empty reactor, constant signal is full MFSU, and fluctuating signal is neither. The reason you have to chain the MFSUs is because the first one in the chain (which gives out the signal) needs somewhere to send that power, so it doesn't emit a constant signal.
I only discovered this because I thought it would only emit once it passed about half full. :P/>
You could easily just have the 2nd one in the chain set to emit when full, but that would have the effect of causing the program to think the reactor is empty. However, this has no effect on the usual running of things, as a full reactor or an overheat overrides this and turns it off.


Also, if you didn't initially notice, I added a second version of my code that only uses a single bundled cable, to avoid all the mess. :)/>

#14 elustran

  • New Members
  • 3 posts

Posted 29 June 2012 - 06:16 AM

View PostHexicube, on 28 June 2012 - 10:39 PM, said:

View Postelustran, on 28 June 2012 - 09:51 PM, said:

Ha, yeah, I thought about that change too, but I had already done it the other way before it occurred to me I'd need to save the cable state for later if I wanted to add a bit to it, which I did for the coolant monitor portion. If you look, the only time I ever used it was at the very end to power on cooling - at that point I was just "Meh. It works." Main thing I'm wondering is if I should have made separate functions to call on within the elseif chain or if it actually runs faster to just leave it like it is...

That was one part of your original code that I really didn't get (which is why I didn't wind up including it in mine), and after that explanation, it's starting to make more sense. But I'm wondering, is there a problem with simply pumping reactor output into a line of MFSUs and ANDing their output signals to indicate they're all full? Was there some sort of trick you were trying to exploit?

I would expect having it right in there makes it a bit quicker, though with the sleep calls and the small amount of code the difference is insurmountable.

The MFSUs was a trick I discovered with the "Emit if partially filled" setting. Basically, the MFSU emits if it is holding over 512 EU (packet size) but is not full. The way the MFSU is coded causes it to emit 1 tick of redstone signal before sending out its EU that same tick, and my program picks it up to work out 3 possible states from 1 signal. No signal is considered an empty reactor, constant signal is full MFSU, and fluctuating signal is neither. The reason you have to chain the MFSUs is because the first one in the chain (which gives out the signal) needs somewhere to send that power, so it doesn't emit a constant signal.
I only discovered this because I thought it would only emit once it passed about half full. :P/>
You could easily just have the 2nd one in the chain set to emit when full, but that would have the effect of causing the program to think the reactor is empty. However, this has no effect on the usual running of things, as a full reactor or an overheat overrides this and turns it off.


Also, if you didn't initially notice, I added a second version of my code that only uses a single bundled cable, to avoid all the mess. :)/>
Cool - it's very useful to see the commenting. I'm not sure if it will cause a problem for you or not, but since you mentioned the code was untested, I thought I'd mention this - I never used rs.getBundledInput in my code since I'm pretty sure it gets *all* the active bits on the cable and doesn't let you test for a single color. I wound up using rs.testBundledInput to get the boolean for only the bit I wanted to check for.

#15 Hexicube

  • New Members
  • 30 posts
  • LocationThe moon

Posted 29 June 2012 - 02:16 PM

View Postelustran, on 29 June 2012 - 06:16 AM, said:

View PostHexicube, on 28 June 2012 - 10:39 PM, said:

View Postelustran, on 28 June 2012 - 09:51 PM, said:

Ha, yeah, I thought about that change too, but I had already done it the other way before it occurred to me I'd need to save the cable state for later if I wanted to add a bit to it, which I did for the coolant monitor portion. If you look, the only time I ever used it was at the very end to power on cooling - at that point I was just "Meh. It works." Main thing I'm wondering is if I should have made separate functions to call on within the elseif chain or if it actually runs faster to just leave it like it is...

That was one part of your original code that I really didn't get (which is why I didn't wind up including it in mine), and after that explanation, it's starting to make more sense. But I'm wondering, is there a problem with simply pumping reactor output into a line of MFSUs and ANDing their output signals to indicate they're all full? Was there some sort of trick you were trying to exploit?

I would expect having it right in there makes it a bit quicker, though with the sleep calls and the small amount of code the difference is insurmountable.

The MFSUs was a trick I discovered with the "Emit if partially filled" setting. Basically, the MFSU emits if it is holding over 512 EU (packet size) but is not full. The way the MFSU is coded causes it to emit 1 tick of redstone signal before sending out its EU that same tick, and my program picks it up to work out 3 possible states from 1 signal. No signal is considered an empty reactor, constant signal is full MFSU, and fluctuating signal is neither. The reason you have to chain the MFSUs is because the first one in the chain (which gives out the signal) needs somewhere to send that power, so it doesn't emit a constant signal.
I only discovered this because I thought it would only emit once it passed about half full. :P/>
You could easily just have the 2nd one in the chain set to emit when full, but that would have the effect of causing the program to think the reactor is empty. However, this has no effect on the usual running of things, as a full reactor or an overheat overrides this and turns it off.


Also, if you didn't initially notice, I added a second version of my code that only uses a single bundled cable, to avoid all the mess. B)/>
Cool - it's very useful to see the commenting. I'm not sure if it will cause a problem for you or not, but since you mentioned the code was untested, I thought I'd mention this - I never used rs.getBundledInput in my code since I'm pretty sure it gets *all* the active bits on the cable and doesn't let you test for a single color. I wound up using rs.testBundledInput to get the boolean for only the bit I wanted to check for.
Totally forgot about that...I will have to change it to testBundledInput! :)/>

#16 Hexicube

  • New Members
  • 30 posts
  • LocationThe moon

Posted 29 June 2012 - 02:25 PM

Changed second program to use testBundledInput instead of getBundledInput, and fixed a typo in the config section.

#17 HelenB

  • New Members
  • 27 posts

Posted 06 July 2012 - 01:35 PM

View PostHexicube, on 23 June 2012 - 12:28 PM, said:

View PostPaukinra, on 19 June 2012 - 08:25 AM, said:

Hey, been trying to get this to work but I keep getting this error when trying to run the program as startup:

bios:206: [string "startup" ] : 26 : '=' expected

Any ideas what mgith be wrong?


Also, I am a little confused as the which cables I need and where they go, whould it be possible to get a pretty picture? :P/>
I'll make some nice pictures to help with setting it up. As for the problem, I'd double check you entered it right, it works perfectly fine for me with vanilla tekkit and no extra APIs.
[edit] Done, if you want I could make a fresh world and construct a setup using the default settings for download...

Please do because I can't get my head around any of this and ccSensors is buggy and wont let me do what I want it to do. I'd like to learn from a save because I'm a visual learner and I need to see things in action and discover them to get my head around things.

#18 Hexicube

  • New Members
  • 30 posts
  • LocationThe moon

Posted 06 July 2012 - 02:44 PM

View PostHelenB, on 06 July 2012 - 01:35 PM, said:

View PostHexicube, on 23 June 2012 - 12:28 PM, said:

View PostPaukinra, on 19 June 2012 - 08:25 AM, said:

Hey, been trying to get this to work but I keep getting this error when trying to run the program as startup:

bios:206: [string "startup" ] : 26 : '=' expected

Any ideas what mgith be wrong?


Also, I am a little confused as the which cables I need and where they go, whould it be possible to get a pretty picture? :P/>
I'll make some nice pictures to help with setting it up. As for the problem, I'd double check you entered it right, it works perfectly fine for me with vanilla tekkit and no extra APIs.
[edit] Done, if you want I could make a fresh world and construct a setup using the default settings for download...

Please do because I can't get my head around any of this and ccSensors is buggy and wont let me do what I want it to do. I'd like to learn from a save because I'm a visual learner and I need to see things in action and discover them to get my head around things.
I made a world showing the software and all of the option wiring hooked up (uses second version of software)...see first post...
Also, I fixed some bugs in the code for the second software, 5 misnamed variables...

#19 Hexicube

  • New Members
  • 30 posts
  • LocationThe moon

Posted 06 July 2012 - 02:55 PM

Just realised I didn't hook up the reactor to the MFSUs in the example world, fixed it...

#20 HelenB

  • New Members
  • 27 posts

Posted 06 July 2012 - 03:38 PM

View PostHexicube, on 06 July 2012 - 02:55 PM, said:

Just realised I didn't hook up the reactor to the MFSUs in the example world, fixed it...

Woah it's quite EPIC! I filled my reactor up to the brim with Uranium and the system controlled it! :P/>

I can improve your setup. Use glass fibre cable from the reactor to the MFSUs instead of that green insulated cable.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users