??? 10/23/07 19:36 Read: times |
#146102 - Equations Responding to: ???'s previous message |
but we don't even have do that and infact we can run a differential equation(ODE) directly in software with a little thought.
Treating a digital filter as a numeric simulation of an analog filter is certainly possible, but I think I've mentioned why this might not be the best approach and why more "advanced" ODE solvers (basically, anything other than the explicit Euler method) are completely unsuited for signal processing applications (mainly: You do not have the input values for fractional samples). In_filter: Dti = Adc_present - Adc_last ;test charging/discharging If Dti < 0 Then ; if neg. then exec. following code Dti = Adc_last - Adc_present 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 End If Dti = Dti * 0.35 ; if discharging then go here Dti = Dti / Fil_time Adc_last = Adc_last + Dti Gosub Disp Return Still, why do you distinguish between charging and discharging ? The following does the same job: 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. |