PDA

View Full Version : A2D issues on PIC16F876A



earltyso
- 29th July 2008, 23:16
Hello again,
My newest PCB design includes a PIC16F876a monitoring (2) A2D channels while also recieving serial RF from a LINX rf module; I then ouput all this goodness to an LCD.
I am monitoring battery (9V) battery, and RSSI from LINX RXM-433-LR with the (2) A2D channels, I will be using a third channel later down the road.

The RSSI coming in from the module is nice and consistent (compared to other handheld reciever in room, both same distance from transmitter). My readings are a consistently 1.6-1.65 VDC RMS on both handhelds (at this distance 30'). HOWEVER my battery voltage reading (using (2) 4.7k resistors (divider)) is all over the place 2.3~4.3VDC). Keep in mind My reciever is on the table and not changing distance from transmitter.

This is not my first time around the block with A2D's so I hope I will include enough info as to not come across as well.....dumb. But here we go...



DEFINE ADC_BITS 8
ADCON1 = 4 ' AN0,AN1,AN3, are ANALOG, using VDD,VSS, as ref all else digital


Now for the output to LCD...




ADCIN PORTA.0, sig1
ADCIN PORTA.1, VALUE1
PAUSE 1
GOSUB DISPLAYa


DISPLAYa:
HIGH PORTC.0
pause 25
H = ( VALUE1 *100 ) / 51
I = H*4
LCDOUT 254,Row1,"Batt ",DEC1 (I / 100 ),".",DEC2 ( I // 100 )," V"
; syntax- BARgraph Value, Row, Col, Width, Range, Style
@ BARgraph _Value1, 2, 0, 16, 95, lines

Y = ( sig1 *100 ) / 51 'divided down from * 255 / 130
LCDOUT 254,Row3,"Signal ",DEC1 (Y / 100 ),".",DEC2 ( Y // 100 )," V"
; syntax- BARgraph Value, Row, Col, Width, Range, Style
@ BARgraph _sig1, 4, 0, 16, 95, lines
RETURN


What I would like to know is if this is an rf problem (rf inducing a voltage on my A2D trace or a problem with my resistor values being too high...or something else???) If this is an rf problem, wouldn't my RSSI input also be floating all over the place?
Thanks for any help/ experience you can share.

Bruce
- 30th July 2008, 00:20
Noise is noise, and should affect all A/D inputs. What size are your variables H, I and Y?

earltyso
- 30th July 2008, 00:33
they are all WORD length

Bruce
- 30th July 2008, 02:45
The RXM RSSI only outputs ~16mV/dB, so a big noise factor should really make this reading swing all over the page.

Shouldn't this be I=H*2 to show battery voltage?

Darrel Taylor
- 30th July 2008, 04:43
ADCIN PORTA.0, sig1
ADCIN PORTA.1, VALUE1

Should be ...
ADCIN 0, sig1
ADCIN 1, VALUE1

earltyso
- 30th July 2008, 18:36
Bruce,
to answer your question, yep the code should read


I=H*2

However, the voltage level looked like half the amount (3~4.4VDC) floating all over the place instead of a consistent (~8.9VDC) or so. I included I=H*4 for better resolution.

DT,
I will try making the changes to channels,
thanks,
~still stumped.

Bruce
- 30th July 2008, 19:21
Darrels' note on using the correct arguments with ADCIN should cure it. Using the port bit
reference doesn't set it to the correct channel, so that's the major issue.

earltyso
- 31st July 2008, 14:06
Thanks
DT & Bruce,
You were right about the channel numbers, Don't know were I got the idea to use "porta.?" instead of the # itself. Anyway all is well now. thanks again!