Posted 26 October 2012 - 05:36 PM
Hello.
I have been trying to find some information on working with bundled cable and item counters for my sorting machine.
I have written a program that will wait for a redstone event and then check which colour (or colours) are active in the bundled cable.
The program will then increment the count for the corresponding item in the table.
This all works fine when the system is sorting slowly, and the pulses are infrequent.
Slow Count Pulse 5 Copper, 5 Tin
However when a whole stack of items go through the item detectors and the the item counters continuously pulse 30+ times the program starts double counting items.
Fast Count Pulse 32 Copper, 32 Tin, 32 Iron
Is this because the redstone event is triggering for both the on and off states of each colour?
Here is my Bundled Cable Layout, each item detector has a separate colour.
Any assistance in finding the cause of this would be appreciated
This is what I have written so far for testing.
I have been trying to find some information on working with bundled cable and item counters for my sorting machine.
I have written a program that will wait for a redstone event and then check which colour (or colours) are active in the bundled cable.
The program will then increment the count for the corresponding item in the table.
This all works fine when the system is sorting slowly, and the pulses are infrequent.
Slow Count Pulse 5 Copper, 5 Tin
However when a whole stack of items go through the item detectors and the the item counters continuously pulse 30+ times the program starts double counting items.
Fast Count Pulse 32 Copper, 32 Tin, 32 Iron
Is this because the redstone event is triggering for both the on and off states of each colour?
Here is my Bundled Cable Layout, each item detector has a separate colour.
Any assistance in finding the cause of this would be appreciated
This is what I have written so far for testing.
side = "right" -- bundled cable side
Items = {
{name = "Dirt", cable = colours.white, count = 0},
{name = "Coal", cable = colours.black, count = 0},
{name = "Cobblestone", cable = colours.lightGray, count = 0},
{name = "Copper", cable = colours.gray, count = 0},
{name = "Redstone", cable = colours.red, count = 0},
{name = "Lapis", cable = colours.green, count = 0},
{name = "Nikolite", cable = colours.blue, count = 0},
{name = "Silver", cable = colours.yellow, count = 0},
{name = "Gold", cable = colours.lightBlue, count = 0},
{name = "Uranium", cable = colours.magenta, count = 0},
{name = "Iron", cable = colours.lime, count = 0 },
{name = "Glowstone", cable = colours.brown, count = 0},
{name = "Tin", cable = colours.pink, count = 0},
{name = "Log", cable = colours.cyan, count = 0},
{name = "Rubber", cable = colours.orange, count = 0},
{name = "Diamond", cable = colours.purple, count = 0}
}
function counter()
local input = rs.getBundledInput(side) -- grab cable state
for i = 1, 16, 1 do
if colours.test( input, Items[i].cable) then --check each colour for active
Items[i].count = Items[i].count + 1 -- increase count for active colour
print(Items[i].name .. " - " .. Items[i].count)
end
end
end
--Main
repeat
event, param1, param2 = os.pullEvent() --wait for event
if event == "redstone" then
counter()
end
until event == "char" and param1 == "x"