PDA

View Full Version : ADCIN signal conditioning?



droptail
- 12th May 2010, 04:30
I am trying to read a vehicle speed sensor but the LCD output is bouncing all over the place.
My DMM readout is nice and constant. How can I get good readings?

What I have done is slow down the sampling time to 20mS.
Took 25 consecutive samples, and even saved the highest value of the 25, but no help.
How does the DMM do it?

I am using a PIC 16F716 on PORTA.

This is my setup:
ADCON1 =0 'PIC default, sets PORTA to analog
DEFINE OSC 3 '3.56 MHz oscilator
DEFINE ADC_BITS 8 'Result resolution
DEFINE ADC_CLOCK 3 'Sets internal RC clk(2-6us)
DEFINE ADC_SAMPLEUS 20000 'Cap sample time of 5us

I am using this:
ADCIN 0,vss

and I've tried this:
ADC: w2 =0 'Clear var
For b11 = 1 TO 25
ADCIN 0,rpm 'Obtain another ADC value
w2 = w2 max rpm 'save peak vals
Next b11 'Repeat for 10 samples
Return

For a constant DMM reading of say 1.750V, my ADC output bounces between 0 & 186.

Thanks

Charles Linquis
- 12th May 2010, 04:40
Do you have PORTA set up as inputs?
Do you have them set up for analog?
What are you using for your reference (ADCON1) ? Most of the time, Vcc is not good enough.
If you want really good accuracy, you have to use an external, precision reference.

mackrackit
- 12th May 2010, 04:43
Sometimes a capacitor from the ADC pin to VSS will smooth things out.

droptail
- 12th May 2010, 05:20
Do you have PORTA set up as inputs?
Yes, TRISA =255

Do you have them set up for analog?
ADCON1 =0 (as noted in my setup above?)

What are you using for your reference (ADCON1) ?
ADCON1 =0 sets Vdd as thew ref I believe.

Most of the time, Vcc is not good enough.
If you want really good accuracy, you have to use an external, precision reference.
Really good accuracy would be nice. Right now I have no accuracy.

ScaleRobotics
- 12th May 2010, 05:34
You could try Darrel's averaging include file.

http://sites.picbasic.net/index.php?option=com_uhp2&Itemid=6&task=viewpage&user_id=70&pageid=25

droptail
- 12th May 2010, 05:39
Sometimes a capacitor from the ADC pin to VSS will smooth things out.

I'll see what a 0.1uF does.

Thanks

droptail
- 12th May 2010, 05:41
You could try Darrel's averaging include file.

http://sites.picbasic.net/index.php?option=com_uhp2&Itemid=6&task=viewpage&user_id=70&pageid=25

Thanks,
I'll have a look see.

Charles Linquis
- 12th May 2010, 06:45
If your value goes to zero, there is something more wrong than a little noise. I have found some chips that don't work properly with ADCIN (18F2221 for example).

Try the following:



Result = 0
Channel = 1 ; Whichever
Channel = Channel << 3 ; offset the bits

ADCON0 = %11000001 | Channel ; OR the channel into the reg.

For X = 0 to 9

PAUSEUS 10
ADCON0.2 = 1 ; Start conversion
PAUSEUS 2 ; Guarantee min time
WHILE ADCON0.2:WEND ; Wait until done
Result = Result + ADRES
Next X

Result = Result/10



Result is, of course, a WORD var

droptail
- 12th May 2010, 15:55
Charles,

This sensor pulses hi to low. I suspect some of my sampling is reading on the low part of the cycle. Thats why I slowed way down the sampling time to 20ms.

ADC has worked well for me on this PIC.

I will look at your subr.

Thanks

Charles Linquis
- 12th May 2010, 19:32
Charles,

This sensor pulses hi to low. I suspect some of my sampling is reading on the low part of the cycle. Thats why I slowed way down the sampling time to 20ms.



An analog sensor that pulses high to low? I don't understand. What sensor are you using.

droptail
- 13th May 2010, 00:30
I am getting better results using PULSIN since the sensor is pulsing as stated before.
I still need to condition the results, however.

Charles Linquis
- 13th May 2010, 01:21
You mean that you weren't concerned with the analog level of the signal at all? Only its duration?