??? 10/23/07 22:01 Read: times |
#146105 - Quantisation Responding to: ???'s previous message |
Christoph Franck said:
(mainly: You do not have the input values for fractional samples). Yes, thats true because my algorithm is time quantised, the filter loses meaning if one makes the filter faster than the actual samples comming in. The general idea, like all quantised systems(fp included), is to make the filter time constant(cr) much longer(say=>1secs) than the actual sample rate(0.35 Secs) so it appears continuous to the end user. Christoph Franck said:
Still, why do you distinguish between charging and discharging ? The following does the same job: It's just the way I've done it, note Dti will always be positive in my code and therefore adc_last=adc_last+Dti....charging, whilst adc_last=adc_last-Dti.... discharging. But you are correct, integers/longs and FP's carry sign, I will modify my code forthwith and save some bytes. Actually, if memory serves me correctly, I was using it with a SAR adc which had a positive common mode voltage, so I was using word(+16bit) data types and biasing half way on a 16 bit word, thus I didn't have an automatic sign. In_filter: Dti = Adc_present - Adc_last ;test charging/discharging Dti = Dti * 0.35 ; calibrate filter to secs Dti = Dti / Fil_time ; fil_time=cr time (adjustable) Adc_last = Adc_last + Dti ; form final output Gosub Disp ; display it Return How would I adjust it as outlined in 1 and 2 using your difference equation? Well, let's look at your equation: Adc_out_new = Adc_out_old + (t_sample / fil_time) * (Adc_in_new - Adc_out_old) It can be rearranged to: Adc_out_new = ( 1 - (t_sample / fil_time) ) * Adc_out_old + (t_sample / fil_time) * Adc_in_new ... from which it is quite easy to see that a in my equation corresponds to (t_sample / fil_time) in yours. You have got to admit, that makes more sense, for me at least anyway, thanks for that, Christoph. Cheers for now Jason |