This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software: TI-RTOS
Hello , I have a problem of measure frequency
I used timer capture mode with P2.1(TA1.1) to get input singal (which is almost 0~266Hz function wave);
But the Precision is not accurate.
And I measure the same freq for 1HZ frequenct that i get a random value for my variable (timer_temp) value; It is random
so please help me to debug.
1.The problem is timer is not 0.5us for clock;(I see that is almost equal 0.50766u s for one timer clock)
2.All the frequency range is not accurate.... assume the 255Hz , the code will get 240~266Hz....
I can't find the bug please help me thx.
This is my project.
So, if the accuracy range is almost 1%.
Then if i measure the solid freq of 266hz it may get 266 +-1% ?
So i will get almost 263hz~268hz?
But i can't find the reason of my code bug.
If i can't find , then i will no goal to debug
if i change another MCU maybe resolved this problem?
It look like such DCO cause the error on the result.
If in the normal,the DCO clock may be has 5% range of error.
so , i think i can change the mcu to test. At the same code to tesy by msp430F5529.
the result maybe difference.
Do u have suggestion, if i used msp430F5529 to replace the mps430g2553?
but my code use 2MHz to measure the frequency;
and the Analyte is only 0~266hz.My source is big than 7518 Magnification;
As you say ,the Precision should be the 0.1%;
So my result should be 266hz but the result is not it has a range about 258~270hz ,
when i used the solid AC power supply which is supply the 266Hz and 5.0 AC voltage to measure.
1. enable/configure timer for capture interrupts (e.g. falling edge)
postive edge is i am used.
2. store the timer value of the first capture event (1st falling edge)
yes,but why can't clear the timer value ?
3. store the value of 2nd capture event (2nd falling edge)
yes,but why can't used 2nd-1nd(zero)??
4. build the difference between 2nd and 1st capture event ( ideally, with 266Hz and perfect 2MHz this should be as stated 7518, with DCO calibration accuracy, this can minimum 7443 - 7593. If there is a temperature deviation from the value the DCO has been calibrated at, there will be additional errors, and from DCO modulation, there will be also some error (have you calculated that portion?))
I am measure the square wave which is always repeat for freq (range is 0~266HZ)
Hello,
the point about clearing the timer is the following:
1. It is not needed, as due to the 16Bit CPU architecture and 16bit Timer length, the difference is even correct with any starting value of the timer unless you have more than one transition through FFFFh. That's why there is the overflow flag, indicating this case.
2. Even more important one for the accuracy. When clearing the timer, the only chance to do so is by interrupt. Interrupt means, there is a certain latency between the actual capture event and the execution of the clear of the timer. Dependent on which instruction is being executed, whether there are potentially some other interrupts active and served, and even with RTOS, there are higher latencies probable. If using the capture as intended, you avoid these errors.
"yes,but why can't used 2nd-1nd(zero)??"
As mentioned above the CPU based clearing of the timer introduces errors difficult to control.
for point 4.
Sorry, but you have not answered the question on the device temperature. Please keep in mind, the DCO drifts also over temperature. Actually I also need to correct myself. The DCO calibration accuracy, please see the device datasheet is at 30degC +/-3%
Best regards
Peter
But if i store the 1st & 2st value,that may be complicated for cal the time if the over_flow occur;
that may be many situation ;
such like
if the
1.TACCR1(1st)>TACCR1(2nd) ---> OVER_FLOW??
=> not over_flow => t = TACCR1(2nd)-TACCR1(1st);
=> over_flow => t = TACCR1(2nd)-TACCR1(1st)+over_flow_times*65536;
=> over_flow => t = TACCR1(2nd)-TACCR1(1st)+???
if over_flow_value has a range; how can i sure that where is it go?
such like over_flow_time > 40 --> over times =0;
2.TACCR1(1st)<TACCR1(2nd) ---> the value is native; occur OVER_FLOW
=>time = 65536-TACCR1(1st)+TACCR1(2nd);
=>over_flow need to dec 1;
--------------------------------------------------------
such the first 1 => build 3 situation. and the priority is fst;
that i will consider the situation 1 to design the situation 2
=> that may be many formula , so how can i design?
------------------------
The temp may be 25'C~40'C;
if the tol may be 3%.
This project maybe have a big trobule;
266*1.03 =>273.98
266*0.97 =>258.02
if the tol is sure, ,my result is such this data
As fst I say and post , I measure the 266HZ get almost 258~270HZ....
Hi,
sorry, but you still have not understood my statement about the 16bit format of the Timer and the 16bit architecture of the CPU, which inherently solves the problem with the single overflow.
To try to explain it based on an example:
Keep in mind the range of the 16Bit values is from 0h - FFFFh
Please see here the behavior of a 16bit timer with a 16bit CPU.
So as you can see, as long as the measured pulse length does not exceed the length of one FFFFh timer period the flip from FFFFh to 0h does not generate an error when calculating the difference, which is definitely not the case with 266Hz.
Best regards
Peter
OK,u want to Explanation.
That measure the (0000H~FFFFH)--->(0~65536)=>1 value =0.5us
(0~65536)=>(0~32.767ms) the capture is low error.
It mean the value of ( inf ~30) ,it mean the feq bigger than 30HZ ,the signal is almost ok?
but the result is not equal the Theory.
and if i want to measure the Following singal which is 32.767ms(30hz), the capture may overflow
so how can i fix in my code??
**Attention** This is a public forum