Author Topic: Using PulsePeriod(ch)  (Read 11992 times)

Gavin

  • Newbie
  • Posts: 5
  • I'm a llama!
    • View Profile
Using PulsePeriod(ch)
« on: September 01, 2016, 08:24:57 PM »
I would appreciate some advice on the use of PulsePeriod(ch) instruction.
From what I understand, firstly, initiate the channel using the PMON instruction.
I assume this would be accomplished in a custom function and that this function can be called using the 1st.scan bit.
This function will contain the instruction PMON 1 only. (for example)
Then, in another custom function you would use dm[1] = PulsePeriod(1), then do what ever you have to do with dm[1].
From what I read, this mechanism is free running so, if for example, your ladder is doing an Analog to Digital conversion and ch1 transitions from low to high,
the A to D conversion will not be interrupted.
Then, when you call your Pulse Period Function, the last valid pulse period will be loaded into dm[1].
I simple need to know if my air conditioning condenser fan is running above a certain speed before engaging the compressor.
Is the attached example on the right track.

Thank you
Gavin

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Using PulsePeriod(ch)
« Reply #1 on: September 02, 2016, 11:43:22 AM »
Yes your understanding of the PMON capability is perfectly right!

The PULSEFREQUENCY, PULSEPERIOD etc are handled in the background. Some input capture timers at work capturing the exact time when the pulse edge occur and when TBASIC execute the PULSEPERIOD command the actual period is computed.

Note that PULSEPERIOD(n)  returns 32-bit number so you probably want to use a 32-bit variable to store the data  since period is measured in 1us to 0.1us, so for low frequency pulse the period is a very large number.

You can use A to Z or DM32[1] to DM32[2000] to store the 32-bit PULSEPERIOD data.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS