Spurious results on a periodmeter using Timer capture on PSOC5 LP

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hi,

It’s my first post . I’m having trouble with a periodmeter on PSOC5 LP, on a cy8ckit-059 kit.

The input square wave is on the capture input of Timer_1.

The period is calculated as the difference between 2 successive values of the capture register of Timer_1.

The result is used to set the value of a VDAC (full sacle = 4.080V)

The timer clock is set to 1MHz, so for frequencies of 4kHz to 16 kHZ  (period 256µs downto 62µs) there should be no overflow of the 8 bit value of the VDAC.

The result is ok, except for some spurious values, as shown on the oscillograms.

Upper trace is the input signal ( 0..5V), lower trace is the output of de VDAC1.

Can anyone see if I’ve done something wrong ?

Thank you for your help

Bernard

0 Likes
5 Replies
Vasanth
Moderator
Moderator
Moderator
250 sign-ins 500 solutions authored First question asked

Hello Bernard,

In your design as the timer clock is at 1MHz, the timer count is going to overflow and restart from initial count. For 4KHz input clock this can happen upto 250 times. When we capture the old and new value before and after overflow, the measurement of old-new can be a spurious value. I am suspecting this to cause the issue.

Best Regards,

VSRS

0 Likes
Anonymous
Not applicable

Hello VRSR, thank you for your answer.

I'm not sure to understand it very well : what do you mean by 'the timer clock is going to overflow and restart from initial count.' ?

Can you explain a bit more?

Thank you, regards

Bernard

0 Likes
Vasanth
Moderator
Moderator
Moderator
250 sign-ins 500 solutions authored First question asked

Hi,

I meant timer count. I have corrected previous response.

Best Regards,
Vasanth R S

0 Likes
Anonymous
Not applicable

Hi,

I'm not sure about your answer : at 1Mhz, the period of the timer clock is 1µs. At 4kHz, the period of the input signal is 250µs. The timer count will decrease by 250. When it overflows,  the calculated value should be correct.

To see if the error comes from the overflow, I changed th number of bits of the timer to 32. The overflow will occur every 4295 s (more than on hour), but I still get the same spurious results .

Has anyone an idea of what happens?

Thank you!

Bernard

0 Likes
Vasanth
Moderator
Moderator
Moderator
250 sign-ins 500 solutions authored First question asked

Hello Bernard,

I somehow missed follow the thread. Could you please change the data type of the variable from int to uint and see the response?

Best Regards,
VSRS

0 Likes