Been working on trying to better understand PID so I built a very basic version for a factory Im going to build
Reply chain from #28
local speed_controller = peripheral.find("redstoneIntegrator")
local tally = 0
local speed = 0
local tick_timer
local function every_tick()
tick_timer = os.startTimer(0.05)
while(true) do
event, timer = os.pullEvent("timer")
if timer == tick_timer then
tick_timer = os.startTimer(0.05)
if tally > 0 then
tally = tally - 1
end
end
end
end
local function main_loop()
while(true) do
local new_speed = 5 -- here is your code setting speed
if tally <= 117 then
--(we don't want to ever reach 128)
if speed != new_speed then
speed_controller.setAnalogOutput("north", new_speed)
tally = tally + 10
end
end
os.sleep(0)
end
end
parallel.waitForAny(every_tick, main_loop)
This conversation is on Discord · Reply there