- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi to all,
I took with 16 bit , 2000 samples per second, input to the adc is 2.04 v. initially it showing correct value of 69AE but after some time it is diaplaying B900, it is showing same value for any input after dispalying correct value after some time, i am not able to find where i went wrong. here i am attaching the Project.please let me know
Thanks
Solved! Go to Solution.
- Labels:
-
PSoC 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Unfotunately the indentation of your source-file has got lost, so it is difficult to read.
What I found at first sight is: in the line containing
for (i = 0; i < ADC_Sample_Index; i++)
the variable i is only an int8 (-128 to 127) while ADC_Sample_Index is declared as an int16 (-32768 to 32767). So the loop will not run as expected for ADC_Sample_Index greater 127.
Are you trying to find the maximum? That you can do easier by comparing the actual ADC-value against the current maximum. When ADC is greater, save the number of the measurement and adjust the current maximum.
Happy coding
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Unfotunately the indentation of your source-file has got lost, so it is difficult to read.
What I found at first sight is: in the line containing
for (i = 0; i < ADC_Sample_Index; i++)
the variable i is only an int8 (-128 to 127) while ADC_Sample_Index is declared as an int16 (-32768 to 32767). So the loop will not run as expected for ADC_Sample_Index greater 127.
Are you trying to find the maximum? That you can do easier by comparing the actual ADC-value against the current maximum. When ADC is greater, save the number of the measurement and adjust the current maximum.
Happy coding
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, you had several inconsistancies, like declaring i as int8 rather than uint16 (its value
ranges to 2000, its used as an index hence always +), and others.
updated main.c attached
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Anotheer issue I just found is that after the first loop through 2000 samples the outermost while willo be executed again (wich is desired) all your values you initialized with the declaration now have not the original values you'd like to have them,
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content