Added: vine farm gantry controller
authorOlav Bakke Svendsen <mail@olavbs.no>
Tue, 14 May 2024 00:37:29 +0000 (02:37 +0200)
committerOlav Bakke Svendsen <mail@olavbs.no>
Tue, 14 May 2024 00:37:29 +0000 (02:37 +0200)
vines/gantry-harvester.lua [new file with mode: 0644]

diff --git a/vines/gantry-harvester.lua b/vines/gantry-harvester.lua
new file mode 100644 (file)
index 0000000..6529a25
--- /dev/null
@@ -0,0 +1,43 @@
+-- xy gantry with deployer and shears
+
+-- timings
+-- works with 64 RPM
+local vertical_tick   = 0.5
+local horizontal_time = 4.5
+local stanby_time     = 60*30
+local rows            = 10
+
+-- redstone IO
+local enable      = "front" -- input:  true -> enable
+local y_gearshift = "left"  -- output: true -> move home
+local y_clutch    = "top"   -- output: true -> disengage
+
+local reset = function()
+  for _, out in pairs({y_gearshift, y_clutch}) do
+    rs.setOutput(out, false)
+  end
+end
+
+local up = function()
+  rs.setOutput(y_gearshift, true)
+  rs.setOutput(y_clutch, false)
+  os.sleep(vertical_tick)
+  rs.setOutput(y_cluctch, true)
+end
+
+local harvest = function()
+  for i = 1, rows-1 do
+    up()
+    os.sleep(horizontal_time)
+  end
+  reset()
+end
+
+while true do
+  if rs.getInput(enable) then
+    harvest()
+    os.sleep(standby_time)
+  else
+    os.pullEvent("redstone")
+  end
+end