Author Topic: Pulsewidth measurement  (Read 14601 times)

dave333

  • Newbie
  • *
  • Posts: 5
  • I'm a llama!
    • View Profile
Pulsewidth measurement
« on: March 15, 2019, 11:25:23 AM »
I want to use the pulsewidth command to measure the width of a repetitive (at different rates)
20us square pulse using a Smartile.  From the datasheet, it will only measure a pulse as low
as 100us.  If required, I can extend the length of the pulse but I wanted to ask if there is some
method I can use in software to measure the shorter pulse.

garysdickinson

  • Hero Member
  • Posts: 502
  • Old PLC Coder
    • View Profile
Re:Pulsewidth measurement
« Reply #1 on: March 16, 2019, 11:58:39 AM »
Dave,

I suspect that the data sheet is incorrect.  The default resolution of the pulse measurement system is 1.0us.  You can program the some of PM channels to work with a resolution of 0.1 us.  

This is the text from the Fx2424 user's manual:

1) To use the PM input to measure pulse width or frequency, execute the PMON statement ONCE to configure the relevant input to become a pulse measurement input. You usually put the PMON statement in the init custom function and execute it with a “1st.Scan” pulse.
2) Thereafter the pulse width (in s) or the pulse frequency (in Hz) can be easily obtained from the PULSEWIDTH(n) or PULSEFREQUENCY(n) functions. You can also obtain the pulse period (inverse of frequency) using the PULSEPERIOD function.
E.g. A = PULSEWIDTH(1) B = PULSEPERIOD(1)
C = PULSEFREQUNCY(1)
3) All PM inputs by default return the measured pulse width and pulse period in unit of microsecond. However, for those who desire better resolution, you can define PM #1 to #4 to return the measured pulse width and pulse period in 0.1 microsecond resolution by executing the following command once only during initialization:
SETSYSTEM 20, 1
Once the above statement is executed, if PUSLEWIDTH(1) - PULSEWIDTH(4) returns the value 1234 it means the measured pulse width is 123.4 s. However, PULSEWIDTH(5) and PULSEWIDTH(6) would still only return the measured width in microsecond.
A sample program can also be found on your i-TRiLOGI installation folder at: C:\TRiLOGI\TL6\usr\samples\PulseMeasurement.PC6


I'd suggest that you use the pulseperiod() function so that you measure a full cycle of the input pulse train.

Gary D*ckinson

dave333

  • Newbie
  • *
  • Posts: 5
  • I'm a llama!
    • View Profile
Re:Pulsewidth measurement
« Reply #2 on: March 18, 2019, 07:48:18 AM »
Gary:

Thanks for your response.  On page 2-10 of the design guide for the Smartile
it shows inputs 1-6 for pulse measurement as 0-10kHz. I'm hoping this is incorrect.


Dave

garysdickinson

  • Hero Member
  • Posts: 502
  • Old PLC Coder
    • View Profile
Re:Pulsewidth measurement
« Reply #3 on: March 18, 2019, 12:16:19 PM »
Dave,

I have been working with TRI's PLCs for over 15 years.  Their products have evolved and they have added significant new hardware and software features.  However their current documentation tends to be re-edits 20+ years old info.  

The 1..10Kz measurement system limits dates back to the generation of hardware that was new in about 2001.  The measurement system buried in the ASIC used for the Tile/Fx based PLCs is hardware based and uses a 10 MHz time base.  If your use the PulsePeriod() function the hardware zeros out a 32-bit hardware register on the rising edge of your input signal and then increments the register every 1 or 0.1 us until the next rising edge of your signal.  PulsePeriod returns the accumulated count.  I know this stuff because I broke the firmware in these PLCs and worked with their designers to fix it.

I suggest that you write tiny test PLC programs to figure out the details.  I'd estimate that 80% of my PLC programming is test code.

I, also, suggest that you call/email TRI's customer support.  They actually know the details of their products and have been very helpful.  

You are always welcome to pick my brain on this stuff.  My email address is in my user profile.

Gary d