View previous topic :: View next topic |
Author |
Message |
lym Guest
|
comparison |
Posted: Wed Feb 02, 2005 7:49 am |
|
|
Can someone please give any suggestion on programming PIC16F877A.
You see, there are 6 sets of 10bits data stored in the memory of the pic using the internal ADC to convert the analog signal to digital. Then, another set of 10bits is alos goes through the same process as the 6 sets of data but is then compared with each set of data. When there is a match with any of the 6 sets of data, a high is sent out to the pins of PORTB respectively.
So now, my current problem is that the current data jus isn't able to match with any of the stored data in the memory. It's because the data keeps on varying. I have set a range of approximation to the current data so that at least the data stored in the memory would be able to match with it but it wasn't successful.
Do any of you have some ideas to make the data match with the data sotred in the memory? |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Wed Feb 02, 2005 8:00 am |
|
|
So are you saying that the ADC voltage is varying so much that is doesn't match a stored value for very long If so, you could lose some of the LSB's or design the analog portion of your circuit so that it is more stable. |
|
|
Ttelmah Guest
|
|
Posted: Wed Feb 02, 2005 9:02 am |
|
|
It'll never happen!.
There is a degree of random noise in any sampling process.
Start by doing everything you can to reduce electronic noise in the area of the ADC. Then sample at a higher frequency than you want to use, and perform a smoothing algorithm on these results to give the 'values'. Then instead of doing a direct 'compare', perfom a 'delta' test. Basically for each value in the two sets, subtract one from the other, and square this value. Generate a sum of these six values. This then gives you a number corresponding to 'nearness'. Check this total to decide if the values ae 'close'. If for instance, each pair differed by just 1, the sum would be 6. However if two of the pairs differed by 4, the sum would leap up to 36. The number will grow extremely quickly for any major difference, but be fairly small for small differences. If you allow perhaps '20' as an acceptable level for your test, you have a chance of it working. :-)
Best Wishes |
|
|
lym Guest
|
|
Posted: Wed Feb 02, 2005 9:02 am |
|
|
The digital bits varies alot until the LEDs connected at the output can be seen to be blinking until it almost remains at a constant.
The analog input is fine. It's possible to take away the a few of the LSB since it's the internal ADc that I use is the 10bit ADC.
Will thy that. Besides that, any other suggestion?
What I trying to do now is to delay the time of the conversion in order for the signal to be sent at the exact time. But that also is difficult because the signal that is sent is a voice signal amplified by the microphone. So it depends on exaxt the person who is sending the voice into the mic can be. |
|
|
lym Guest
|
|
Posted: Wed Feb 02, 2005 9:19 am |
|
|
One more thing which I tried was to extent the range of the current bits which was to match with the bits stored in the memory. I put it to +200 to -200 approximationbut that also didn't match the data.WhenI increased the range 400 or 500, it showed that all gave a match which wasn't correct. |
|
|
|