I need to create a Hold module in core.

Discussion in 'REAKTOR' started by Michael O'Hagan, Jun 13, 2019 at 11:53 PM.

  1. Michael O'Hagan

    Michael O'Hagan NI Product Owner

    Messages:
    801
    I need to create a Hold module in core, I've been playing with a few possibilities and none of them are behaving as I would want them to.

    does anyone here have any ideas about how to build a core hold module that behaves the same as the primary one.

    I need to trigger a gate and have the 1 value held for a set duration of milliseconds.

    Thanks.
     
  2. Laureano Lopez

    Laureano Lopez NI Product Owner

    Messages:
    116
    you need it to output primary events, like the primary hold?
     
  3. Michael O'Hagan

    Michael O'Hagan NI Product Owner

    Messages:
    801
    Yes, I need it to duplicate the behavior of the primary module as closely as possible.
     
  4. Laureano Lopez

    Laureano Lopez NI Product Owner

    Messages:
    116
    this seems to make it
     

    Attached Files:

    • hold.ens
      File size:
      697.7 KB
      Views:
      13
    • Like Like x 1
  5. Michael O'Hagan

    Michael O'Hagan NI Product Owner

    Messages:
    801
    These are awesome.

    I'm really more interested in learning to build my own though, I've always had some confusion with read and write modules in core and I only partially understand how this is working.

    Did you make these?

    if so could you explain some of the structure to me where there are 2 read and write modules in serial operation.
     
  6. Laureano Lopez

    Laureano Lopez NI Product Owner

    Messages:
    116
    yep i made them. actually i just slightly modified a timer macro i had around. there are two memories. the lower one is a descending counter. the upper one is a flag to stop reading the lower one when the count has finished. when an event arrives, the flag is turned on and the counter is set to H. for every tick it's decreased until it reaches zero, then the flag is turned off. this flagging is similar to how the lin smoother [a] works (the version that stops outputting when it reaches the target).

    i've modified a bit more because it didn't quite work. the descending counter can't deal with a change of H while counting, so i've made it ascending (set to zero at start, check for <H). the conversion of H to samples seems to use truncation, not rounding. also, in the original i set the flag and the counter before the next read. this compared inconsistently with the primary version, so now i set them after. i still get an occasional difference, but can't figure why.

    btw, obc order is just this: if a read and a write happen at the same time, they must be done in the order they're connected. a read before a write means that if they happen simultaneously, the read will output before the write is done. in a feedback loop you can't write before you read, because the output of the read is used to calculate the input of the write. you have to read first, make the calculations, then write the result. if you need to set an initial value for a feedback process, usually you'd use a write-read-write -the first write for the initial value. this way, if a tick comes at the same time the process starts right away -otherwise it would start on the next tick. this is tricky with primary events though, because they're not simultaneous, except in the rare cases when they are -it twists my mind each time i have to figure it out.
     

    Attached Files:

    Last edited: Jun 14, 2019 at 5:10 AM
    • Like Like x 3
  7. Quietschboy

    Quietschboy NI Product Owner

    Messages:
    332
    Last edited: Jun 15, 2019 at 1:11 AM
    • Like Like x 2
  8. Laureano Lopez

    Laureano Lopez NI Product Owner

    Messages:
    116
    it's almost the same, plus the break function. the upper memory is the flag, the lower is the counter. the check for =N (instead of <N) is not good if N can change while holding. it sets the memories before reading as in my first version, which is the logical thing to do -i changed that later because it didn't match the primary hold. it does save some unnecessary reads of the counter though -i added that tweak to match.
     

    Attached Files: