MiscMFRcircuits - additional circuits for the Programmable Rednet Controller
MiscMFRcircuits is an addon for Minefactory Reloaded, it implements additional circuits for programmable rednet controller (PRC).
Some really useful circuits are hour/minute/second timer and 'bargraph' circuit, it also provides various full-32bit logic elements and ADC/DAC conversion for PRC's analog and digital modes.
PRC (and vanilla redstone!) has 2 different modes 'analog' and 'digital' which are both inherently discrete. The only difference is that vanilla redstone has 16 levels of signal: 0..15 (4-bit value) while rednet signals are full 32bit integers having 4294967296 possible levels (from -2147483648 to 2147483647).
'Digital' PRC mode just treats those values as 0 for logic 0 and 'greater than zero' for logic 1 (which is 15 redstone level).So, here goes some magic: if you have sixteen 'digital' values that could be represented as 0 or 15 you have 16 discrete signals that could be assigned to the bits of 32-bit integer. This integer could be passed through one channel of rednet cable, therefore full capacity of rednet cable is 32*16=512 digital (0 or 1) signals.
ADC 16-bit - (well, it not a 'real' ADC, all values are already represented as numbers, not continuous signal) An analog to binary decoder, converts one analog value to 16 discrete levels (0 or 15).
Bargraph has TST input - put non-zero value and it will enable all Y outputs. If A is greater than 10 or less than 0 - OL output is active. Y0 is active when A is equal or greater than 0 - it's a bit inconvenient, but you may use it for standby power.
DAC 16-bit - (digial to analog encoder) takes 16 discrete values (0 or not 0) and converts them to one 16-bit integer.
Threshold detector with hysteresis, PV is processed value, S0 - "off" setting, S1 - "on".
8 input analog adder, does X0+X1+..+X7=RSLT
Average, averages analog signal on input X over Ta pulses on input CLK
Quad 2-input analog adder, does A0+B0=Y0, A1+B1=Y1, A2+B2=Y2, A3+B3=Y3
hour/minute/second (h:m:s) timer. Ts is pulse period in seconds + Tm in minutes + Th in hours. Minimal pulse width is 1 tick, using DC input you can set duty cycle between 1% and 100%, use 0 for 1 tick width. Timer will use 1 tick width or value set via DC pin whichever is larger. Example: 1 min 40 sec period, active for 50 seconds - set Ts=40, Tm=1, Th=0, DC=50 / (1*60 + 40) = 0.5 = 50%. You may temporary pause timer by sending non-zero value to pin EN# or completely reset it by sending non-zero value to RST input. Qs sends 1-tick width pulses every second of active period, Qm - every minute and Qh pulses every hour.
4 Bus-wise circuits use 32-bit integer on the input pins:
AND2 - 2-input AND
NOT - 1-input 32-bit NOT
Gray <> Binary code conversion:
Binary to Gray code conversion
Gray to Binary code conversion
2*16 bit - Merges two 16 bit integers into one 32bit number
4*8 bit - A0 is the lowest part, A3 is the highest part of 32-bit number
8*4 bit - the same, A7 is the highest part
3 Decoders - pins are the same:
3 RAM circuits:
RAM - 1 32-bit value, write WR activated when CLK is on rising edge.
RAM - 8 32-bit values, clocked (CLK), write control (WR), address selection (ADR) and reset (RST). DT is 32-bit int, ADR is address - 0..7, all numbers less than 0 are treated as 0, all numbers greater than 7 - as 7. Write and reset are executed on rising edge of *CLK*. Set WR high to write value of DT to address ADR; when inputs WR and RST are not active the value at address ADR is present on output OUT.
RAM - 16 32-bit values, all the same (ADR - 0..15).
Character Generator ROM
Send ASCII character code 0..255 (codepage 437) to pin A - it will produce eight 8-bit numbers corresponding to that character, Y0 is top row, Y7- bottom row, least significant bit in every Y output is rightmost pixel for corresponding row.
Edge detector: same as one-shot circuit, but with rising and falling edge detection, sends 1-tick wide pulse when A changes from zero to non-zero (RI output) or vice-versa (FA output).
Quad AND2 - Quad 2-input AND, values could be 0 for logic 0 or non-zero for logic 1
All the same - output active when all pins are in the same logic state. use *CNT* (1..8) to limit the number of pins used.
Even number of pins active (non-zero)
Odd number of pins active
At least N pins active
N and only N pins active.
At least 2 of 3 pins active
5-stage Johnson counter (see datasheet for 4017) (For most purposes it would be sufficient to use 'passthrough (ring)' instead, I've completely forgot about it): for inputs LOW=0, HIGH=non-zero; for outputs: LOW=0, HIGH=15
Decade counter with 10 decoded active HIGH (15) outputs (Q0 to Q9), an active LOW (0) output from the most significat flip-flop (Q#) active HIGH and active LOW clock inputs (C0 and C1#), and an overriding asynchronous master reset input (MR).
The counter is advanced by either a LOW to HIGH transition at C0 while C1# is LOW or a HIGH to LOW transition at C1# while C0 is HIGH. A HIGH signal on input MR resets the counter to zero (Q0 = Q# = HIGH; Q1 to *Q9= LOW) independent of the clock inputs (C0, C1#).
Relay Max DT - Maximum input definite time relay; When analog signal on input I exceeds threshold setting Imx it waits for TD ticks and if I is still greater than Imx it triggers trip output TRP; Also it switches on start (or pickup) output ST for all time while I>Imx. There is pause input available - EN# - when non-zero signal is present it stops tick counting. TRP# and ST# are inverted outputs for TRP and ST. Imx and TD should be constants (0..216 - 1=65535), using variable values would make no sense - but, of course, you could make it programmable from other circuits. Use encoders (and hex calculator) to provide numbers greater than 255;
Relay Min DT - same logic here, but for I<imn< strong="">
Inv. time relay - Ye olde induction relay (kind of). When analog signal on input I exceeds I1p it starts counting adding I/(100*I1k) to internal sum every tick until that sum exceeds I1i - and then it trips. Also it will trip instantly when I exceeds (I1p*I2 / 64), I2 must be in range 64..255, any number less than 64 will be treated as 64 and all other numbers greater than 255 will be treated as 255. I1p= 1..65536 I1i= 1..65536 I1k= 1..1000 I2= 64..255
I1p, I1i, I1k and I2 should be constants unless you are making programmable relay
Automatic Transfer Switch (stand-by control) - circuit to monitor and control your power plant, it has 4 inputs:
Mok - main power source is ready. (lava or fuel in the tank, boiler is warm, energy cell has some energy, there is coal (or other fuel) in AE network, anything you like)
Sok - stand-by power source is ready.
Td- time delay in seconds (0-255) between main <> standby transition. For most purposes it should be constant.
RST- standby reset - when HIGH (non-zero) signal is received and main power source is ready (Mok) it transfer output from standby source to the main one. Set it to constant non-zero value if you want automatic transfer to the restored main supply.
and 4 outputs:
EnS 'Enable Stand-by' command to turn on stand-by power supply (activate magmatic or combustion engines, enable energy cell, start loading coal into generators or pumping lava into geothermals)
EnM (optional) 'Enable Main' command to turn on main power supply.
ALM 'Alarm' active when at least one of the power sources is not ready
ERR 'Error' or rather complete power loss - active when both power sources are unavailable.
Note: After complete power loss (both sources are unavailable) circuit will switch to the first available power source. If your power plant is running on a stand-by supply, stand-by dies out and main source appears again - circuit will switch to the main source after Td seconds.
Here are some images from my engines farm with Bargraph and DAC in action on imgur.
And 8 position 7seg doing XOR between 32bit numbers
Download: v0.5.3 (dropbox, for Minecraft 1.6.4, Minefactory Reloaded 2.7.6-2.7.9) v.0.6.0 (dropbrox, for Minecraft 1.7.10, Minefactory Reloaded 2.8.0+)
v0.6.0 - Minecraft 1.7.10 port, no new features
v0.5.3 - new circuits added: PID controller, abs function, world tick timer; NAND, NOR, XNOR, right-shift and left-shift circuits for 32-bit values.
v0.5.2 - new circuits added: Value constraint, Division, Multiplication, Division and Multiplication in one circuit combined.
v0.5.1 - API update to 2.7.6
v0.5.0 - Update to Minecraft 1.6.4 and Minefactory Reloaded 2.7.3
v0.0.0.5:- 5-stage Johnson counter- 'relay': automatic transfer switch (stand-by control)- CG ROM
BACKUP YOUR WORLD before installing this mod! Everything could happen! (although it shouldn't)
License: The MIT license.Yes, you can include this mod into your modpack (private or public).
Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included inall copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.