top of page
Search

SCL Triggers

  • Writer: Ivaylo Fiziev
    Ivaylo Fiziev
  • Mar 16, 2023
  • 1 min read

No. This has nothing to do with weapons. Triggers are just the way to detect when the rising/falling edge of a clock signal passes through a threshold value. Complex explanation for a simple thing isn't it? Let's make is simpler:

Let's consider the following use case: We would like to create a script that monitors its input and raises its output when the input changes from FALSE to TRUE. In all other cases the output stays low.

So how to approach this problem?

I can think of a static BOOL variable (defaults to FALSE) that stores the previous value of the clock signal. Whenever the current value is TRUE and the previous value is FALSE we can say that a rising edge is detected.

This is quite simple to implement but it would be nice to have it as a building block and reuse it where needed. Someone already had this idea in mind and this is why we have triggers. SCL triggers are just regular function blocks that implement this simple logic for you.

Currently we have a couple of them:

  • R_TRIG - a rising edge trigger

  • F_TRIG - a falling edge trigger

To make use of them you declare a static variable of type R_TRIG/F_TRIG and then call the FB like any other.


Both FBs have the same interface:

CLK - the input clock

Q - the trigger output

You can make use of them in any similar situation. Of course you should connect signals to those inputs and outputs to observe the result.


Note: If you recall timers were activated on rising/falling edge as well. Internally they rely on the same logic.



 
 
 

コメント

5つ星のうち0と評価されています。
まだ評価がありません

評価を追加

Subscribe Form

Thanks for submitting!

bottom of page