- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Labels:
-
PSoC 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Not being able to see the entire code -
1) FlightTimeAvg large enough it never overflows ?
2) Samples is a variable, not a def, so that it does not get optimized out ?
3) The avg right after for() should be ok.....not sure why its behaving sensitive
to position.....
4) Measure() incing i for the array reference ? Then is i global, therefore subject
to other f()'s modification ?
5) All globals used in ISRs declared volatile ?
6) Samples ever == 1 ? Or flightime all samples equal, such that avg = sum of al
flight times....?
http://www.barrgroup.com/Embedded-Systems/How-To/C-Volatile-Keyword Volatile
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dana
1) FlightTimeAvg large enough it never overflows ?
FlightTime array gets filled with values around 500. So FlightTimeSum ends up around 5000 and FlightTimeAvg around 500. These three variables are defined as unsigned int (WORD)
2) Samples is a variable, not a def, so that it does not get optimized out ?
I've tried Samples as both a variable and constant. Same result
3) The avg right after for() should be ok.....not sure why its behaving sensitive
to position..... odd indeed
4) Measure() incing i for the array reference ? Then is i global, therefore subject
to other f()'s modification ?
"i" is only used by main function, Measure function doesn't reference array
5) All globals used in ISRs declared volatile ?
The variables Pulses, Tick, and CompleteFlag are volatile and are just incremented by Timer1, Timer2, and Comparator ISR's relatively
6) Samples ever == 1 ? Or flightime all samples equal, such that avg = sum of al
flight times....? I loaded the array intially with non zero values, samples is never 1 and avg should never equal sum
I've attached the full code minus ISR's. I'm using C29466 with CY3210 development board.
I can actually just use the sum value to represent a running average and just eliminate the division altogether. But I wanted to try and understand why I'm seeing these issues.
Thanks
Aaron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Does it work if you use a magic-number 10 instead of the Samples variable?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Using number 10 doesn't work either. If I make sample size 4 or less it works which is strange. But if I multiple by .1 instead of dividing by 10 it works fine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I do not see the interrupt code I assume you are using for delays.
Best to post the project archive.
“File” Designer
“Archive Project”
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have tried to reproduce this issue, but am unable to do so. You can try by increasing the size of LCDBuffer to 16. If that does not work, you have the option of creating a Technical Support case. To do so:
“Support & Community”
“Technical Support”
“Create a MyCase”
Also attach a minimal project which can reproduce this issue.
Thanks,
Sampath
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In my Measure() function I was trying to read the timer1 count using below command. I initially removed the line altogether and my calculations were working as expected.
readTimer = Timer1_bReadTimerSaveCV();
Then I added the line back in but changed it to Timer1_bReadTimer(); and still working fine.
Is there any reason the bReadTimerSaveCV() api could cause issues vs bReadTimer()?
Aaron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am at remote site, so w/o ice cube. But I noticed following -
1) Set up global properties with high analog power. I do not know
what your input signal looks like but start here. Analog power, opamp
bias, column buffer.....
2) Your comparator not configed with hysteresis, generally a good idea
to do that, especially in light of your using it to generate an isr.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
With regard to your read timer f()'s, when a read is done that is
captured into the compare register, and then read. The Save CV
f() restores the compare value.
Would this affect you ? It could produce a compare out to the pin
that is always high, is that what you want ? This is if a read of the
time always produced a full scale (period) value, as if timer was not
getting clocked between isr firings.
Regards, Dana.