|
|
View previous topic :: View next topic |
Author |
Message |
dave
Joined: 21 Dec 2003 Posts: 7 Location: Sheffield, South Yorks, UK
|
Old forum posts? and software filtering |
Posted: Sun Dec 21, 2003 3:41 am |
|
|
Have CCS now got rid of the old forum posts altogether??
I was searching for some older articles on software filtering I have a couple that Have been posted on here for mean and median filtering..
Basically what the problem is, I have developed an application for an overhead gantry crane which weighs train bins, now when the operator picks the bin up there is a little bit of bounce and swing, I am using an LTC1298 external a/d chip which is read via the #int_rtcc (using this as a selectable sampler via a key pad, ) so can set the sample rate to cause a reading of the 1298 via the interrupt at say 1,5,10,15,20,50,100,200 mS,
all I'm trying to do is to smooth out the readings....I am using an 18f452 by the way, the signal from the loadcell goes through a loadcell amplifier, then another amplifier on the instrument PCB, there is plenty of hardware filtering in the loadcell amplifier, on the instrument PCB I have desgined the LTC1298 is sat next to the PIC literally to keep down the possibility of onboard noise and the amplifier is sat next to the 1298 again for same reasons, so its just a case of when the gantry crane is moving or has lifted the weight .
Cheers dave. |
|
|
Ttelmah Guest
|
Re: Old forum posts? and software filtering |
Posted: Sun Dec 21, 2003 4:34 am |
|
|
dave wrote: | Have CCS now got rid of the old forum posts altogether??
I was searching for some older articles on software filtering I have a couple that Have been posted on here for mean and median filtering..
Basically what the problem is, I have developed an application for an overhead gantry crane which weighs train bins, now when the operator picks the bin up there is a little bit of bounce and swing, I am using an LTC1298 external a/d chip which is read via the #int_rtcc (using this as a selectable sampler via a key pad, ) so can set the sample rate to cause a reading of the 1298 via the interrupt at say 1,5,10,15,20,50,100,200 mS,
all I'm trying to do is to smooth out the readings....I am using an 18f452 by the way, the signal from the loadcell goes through a loadcell amplifier, then another amplifier on the instrument PCB, there is plenty of hardware filtering in the loadcell amplifier, on the instrument PCB I have desgined the LTC1298 is sat next to the PIC literally to keep down the possibility of onboard noise and the amplifier is sat next to the 1298 again for same reasons, so its just a case of when the gantry crane is moving or has lifted the weight .
Cheers dave. |
The posts largely exist, but can be fun to find, unless you know the subject.
The easiest filter is:
int16 filter(int16 value) {
static int16 forward;
int16 rval;
forward=forward+value;
rval=forward/X;
forward=forward-rval;
return rval;
}
Now you can change the damping amount, by altering 'X'. There are some 'caveats':
Assuming the incoming value is (say) a 10bit value, then the maximum value of 'X' that can be used, is 64, or you need to switch to using 32bit values/arithmetic.
As shown, the division will take a reasonable time. The system can be speeded up massively, by using a shift, rather than a division (so, 'rval=forward>>4' for example). Using a shift like this only works is the numbers are unsigned.
You can also use the approach of doing the division before the addition (if in floating point, or working with the number 'scaled up', before the arithmetic). The advantage of this, is that you can change the factor 'on the fly', increasing the damping for small changes, and reducing it when there is a sudden shift (or vice versa).
Best Wishes |
|
|
Tom-H-PIC
Joined: 08 Sep 2003 Posts: 105 Location: New Castle, DE
|
This is vary interesting please explain more! |
Posted: Sun Dec 21, 2003 8:37 am |
|
|
Hello Ttelmah
I understand the division but I don�t understand �forward or rval�
Is this the same as reading the adc a number of time and adding them all up and dividing by the number of reads?
Tom |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Dec 21, 2003 11:45 am |
|
|
Quote: | Have CCS now got rid of the old forum posts altogether ? |
The posts are there, but when the old forum was appended onto the
new forum, the links that were in many of the old posts were not
updated to point to the new forum.
If you click on a link to an old post and it comes up as a dead link,
then do a search for the post number. For example, here's a
link to the old forum:
http://www.pic-c.com/forum/general/posts/13211.html
But it's a dead link, because the old forum was taken down.
So do a search in this new forum for the post number: 13211
Then you'll find the post:
http://www.ccsinfo.com/forum/viewtopic.php?t=3462
-----------------------------
The reason why a median is better in some applications is because
it can remove data samples from the filtered output, that are grossly
incorrect. For example, suppose you have a handheld tachometer
project. It uses a photocell or other sensor to detect the motion
of a moving object. Sometimes, the user will not aim the tachometer
properly at the moving object. So the tach might not detect one of
the events. Then the waveform coming into your CCP (on the PIC)
will have a missing pulse. The period calculated will be twice as long
as it should be. Also, due to noise, you might somehow get an extra
pulse coming into your CCP. Then you'll get a very short duration
pulse added to your data stream.
If we just use an ordinary filter, all these bad data points will get added
to the output. This is unacceptable for a handheld tachometer.
We'd rather just skip the bad data points and only display the average
of the good ones. A median filter will do this for us. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|