How do i measure time in code? I want to use SR04 distance sensor.

Volvo742
2016-06-08
2016-06-10
  • Volvo742 - 2016-06-08

    Hello!

    I wonder how i can measure time in code. For example.

    time1 := clock time;
    Operation..... or some stuff
    time2 := stop clock;
    time := time2 - time1
    

    If that is possible, i can use the digital SR04 distance sensor.

    Here is the data sheet about the sensor. Look at the timing diagram.
    http://www.micropik.com/PDF/HCSR04.pdf m

     
  • frankienones - 2016-06-09

    Maybe like this ?

    [url][/url]

    Here the result is in time() format

    Frank

    IMG: Function_Block.png

    FB.txt [851 Bytes]

     
  • Volvo742 - 2016-06-10

    frankienones hat geschrieben:
    Maybe like this ?
    Function_Block.png[url][/url]
    Here the result is in time() format
    Frank

    Thank you. I will test it later today and give you a reply.

    Edit: it working.

     

Log in to post a comment.