Redstone Pen

Redstone Pen

6M Downloads

[feature-request] Extend TPx with delay

rysson opened this issue · 2 comments

commented

Awesome mod, thanks a lot!

Description

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

  • TP1( Y, 40) – current behavior, 2 sec pulse, started by raising edge of Y (default delay is zero)
  • TP1(Y, 60, 40) – 2 sec pulse (on) after 3 seconds (off), started by raising edge of Y

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

commented

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 :-/

commented

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,-