Recommended Posts

Hi I need to read a pulsed output with my vision V130-33-TR6. The pulsed output consists of 100mS pulses and I need to measure the frequency of these pulses. Pulse frequency is between 100ms and 10s (it's the pulsed output from an electricity meter to give the number of kW directly proportional to the pulse frequency)

At the minute I am connecting the pulse to a digital input and using the 1.25mS interrupt to measure the time between the rising edge of the input but the output value jumps around a bit due to the error margins i.e. measuring once every 1.25mS.

To measure the time between rising edges I am simply incrementing a MI during each 1.25mS interrupt and multiplying it by 1.25 to get the time in mS. I know there are timers that count down from a preset value but is there a way of more accurately measuring the time between rising edges i.e. starting a timer that increases until I reset it.

I could use a large timer a subtract the value it reaches from the preset value but this is a bit untidy and leaves room for error if the timer reaches zero before I read it and timers only read down to deciseconds.

I looked at the HSC frequency measurement but I am unsure how to exactly use these.

I could also average a few values but more accurate measurement in the first place would be preferred.

My other small issue is how do I specify the number of decimal places a MF is displayed to on screen as I only need 2, not the full number.

Share on other sites

• MVP 2014

Reading the frequency of relatively slow pulses is always a grumpy sort of problem.

Firstly, I think your approach is as good as any. The HSC frequency measurement has a maximum timebase of 1 second, and will give a lot of zero readings on this type of signal.

With a measurement resolution of 1.25ms on a minimum pulse length of 100ms, you should not see a huge variation due to the timebase (approximately 1.25%).

I do think one of the problems with this is the human expectation of what the data should look like. With a slow signal like this, you can see the natural variation in the signal. If you filter the signal, it seems even slower. In contrast, a fast signal can be filtered, and still look fast to the human observer.

However if you want a smooth signal, you will almost certainly need to filter it. Maybe use a filter of 5-10 values, by calculating the values as you currently are and averaging them together (use the FB filter block). At higher rates of kWh usage the values will come more quickly, and your filter will give a faster response.

Share on other sites

Thank you, I didn't realise there was a filter FB. That's a nig help

Share on other sites

There is one other small trick that might help give you a little better resoution, but ultimately your scan time is going to limit you.

Look at Utils > Debug > Interval >

You will find a block for Interval Start and Interval End. They give a very precise meaurement of time between two events.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×