stewart_bakeruk
Member
Hi,
I am trying to fix a problem with a semi-automatic aerial matching unit for Amateur Radio.
It comprises variable inductors and capacitors driven by DC motors. Position feedback is provided by precision variable resistors (pots) which input to 2 channels of ADC on a 18F4620.
Most of the time the unit works well, however occasionally the ADC feedback system gets spiked and gives a one off value away from the norm. I have spent some time making sure that the hardware is as robust noise wise as possible.
When the spike occurs it upsets the average ADC value that I get from the code below..
What I would like to do is filter out these infrequent LO/HI ADC values without affecting the averaging.
Any thoughts/code please...
Stewart
I am trying to fix a problem with a semi-automatic aerial matching unit for Amateur Radio.
It comprises variable inductors and capacitors driven by DC motors. Position feedback is provided by precision variable resistors (pots) which input to 2 channels of ADC on a 18F4620.
Most of the time the unit works well, however occasionally the ADC feedback system gets spiked and gives a one off value away from the norm. I have spent some time making sure that the hardware is as robust noise wise as possible.
When the spike occurs it upsets the average ADC value that I get from the code below..
Code:
Function ADCGetL(AvgADCL As Byte) As Byte
' Read L ADC and calculate an average reading
'
ADCTemp = 0
'
For i=0 To 7 'take 8 ADC readings
ADCin 2,RawADCL 'get ADC value for L from 2nd channel
ADCTemp = ADCTemp + RawADCL
Next i
'
ADCgetL = ShiftRight(ADCTemp,3) 'shift right 3 places to divide by 8
'and return the averaged L ADC value
'
End Function
What I would like to do is filter out these infrequent LO/HI ADC values without affecting the averaging.
Any thoughts/code please...
Stewart