Author Topic: Time Measurement  (Read 6272 times)

CWO2ET

  • Newbie
  • Posts: 2
    • View Profile
Time Measurement
« on: March 13, 2007, 05:34:35 PM »
Hello everyone,

I'm new at PLC programming and have a question about measuring time with a PLC.  I'm using 2 thru beam sensors connected to a T100MD-888 PLC to measure the speed of randomly passing objects.  I want to start a clock when the object passes through the first beam and stop the clock when the object passes through the second beam.  I then want to send that measured time to a custom function to calculate the speed of the object.

I understand how to set up the custom function for the speed calculations, but I'm having a problem developing a program that measures time and sends it to the function.  Any help would be greatly appreciated.  

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3171
    • View Profile
    • Internet Programmable PLCs
Re:Time Measurement
« Reply #1 on: March 13, 2007, 07:58:06 PM »
There are actually many ways to do so.  You could use a clock pulse to trigger a counter after object pass thru first beam and then stop it when object pass thru second beam

     Beam1                      RLY1
|----||-----------------------[Latch]
                        |       CTR1
                        +----[RSCtr]

    RLY1   Clk:0.1s              CTR1
|----||-------||--------------[Upctr]

     Beam2                      RLY1
|----||-----------------------[Clear]
                        |     SpeedCal
                        +-----{dCusF}


CTR1 will contain n x  0.1s  which is the time the object spent travelling between beam1 and beam2.  Th speed computing custom function can use the value CTRPV[1] for computation.
« Last Edit: March 13, 2007, 07:58:38 PM by support »
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

CWO2ET

  • Newbie
  • Posts: 2
    • View Profile
Re:Time Measurement
« Reply #2 on: March 14, 2007, 10:05:30 AM »
Thanks for the help.  I'll incorporate this into my program and see how it works out.  

I also have a question about interrupts.  If I want to detect objects moving in opposite directions, can I use an interrupt that goes to a subroutine that changes the on and off order of the sensors?

For example, if the objects are moving right to left, Sensor 1 turns the timer on and Sensor 2 turns the timer off.  If the objects are moving left to right, then S2 turns it on and S1 turns it off.  I thought about adding another sensor (S3) that will trigger the the order of the other two.  This way I could use S1 to trigger the S2/S3 subroutine for objects moving in one direction and S3 to trigger the S2/S1 subroutine for objects moving in the opposite direction.

I hope this makes sense.  Thanks again for the help.