stfwi / redstonepen

Minecraft mod adding a pen to draw Redstone tracks in all directions, a PLC for Redstone, and relays.
MIT License
14 stars 2 forks source link

[feature-request] Extend TPx with delay #22

Closed rysson closed 1 year ago

rysson commented 1 year ago

Awesome mod, thanks a lot!

Description

I want to propose TP extension. Add optional delay: TPx(input[, delay], pulse)

The new Pulse Timer has two phases

  1. delayTP1.ET from - TP1.DT to zero, output is 0
  2. pulse – TP1.ET from 0 to TP1.PT, output is 15

If delay (TP1.DT) is zero, than timer starts from phase 2 immediately (current behavior).

Motivation

R = TP1(Y, 60, 40) works like a two timer combination

X = TP1(Y, 60)
R = TP2(!X, 40)

New version is easier to code, and uses less timers. Even in the implementation one timer is enough. An extra delay (.DT) value is needed.

Than, instead: redstonepen-tp12

we could use: redstonepen-tp1d

stfwi commented 1 year ago

Hi rysson, it's a good feature idea - the thing is I'd like to keep the "API" quite general, so that people can do their own logic, and experiment with the PLC features. So, the TP timer is implemented like the PLC TP (e.g.: https://www.youtube.com/watch?v=8aRXSWvhycI), and we can e.g. apply instant logic to the output variable ET (elapsed time).

As a one-liner, the off-on control could be done using:

R = TP1(Y, 60) AND TP1.ET>40

On-off would be then:

R = TP1(Y, 60) AND TP1.ET<40

(This is no different from a normal TP, except that the timer now ignores inputs for 20t after switching the output off).

Would that already resolve the TP timer shortage in your setup with the current implementation?

Cheers,-

rysson commented 1 year ago

Would that already resolve the TP timer shortage in your setup with the current implementation?

Sure, you shot me :-D

It's so easy now, thanks a lot. I've forgot, then TP.ET is available :-)

EDIT: Nice video, I remember one of my university of technology lab and programming Simens PLCs! But we skipped timer :-/