Hello All,
I am trying to read the analog value of the RSSI pin of an RF receiver. Specifically this one -
http://www.rentron.com/remote_control/RXLC-434LR.htm . The RSSI pin outputs an analog voltage in relationship to the distance to the transmitter. The usual RSSI voltage output that I get is around 2V.
I connected the RSSI pin of the RF receiver to my Axon and I am able to read the RSSI analog values correctly. With the Axon the RSSI works perfectly.
I made my own custom board , with the ATmega168 as its processor, and I am trying to read the Analog value of the RSSI with the ATmega168. I used Admin's Photovore code and had it read the value of the RSSI and output it via HyperTerminal.
while(1) {
RSSI = a2dConvert8bit(1);
SendByte(RSSI);
}
Port Initializations: All of PORTC ( the analog ports) are set to be inputs and pullups are turned off ( admin already did this for me in his Photovore code). Analog pins are initialized by Admins code here:
a2dInit(); // initialize analog to digital converter (ADC)
a2dSetPrescaler(ADC_PRESCALE_DIV32); // configure ADC scaling
a2dSetReference(ADC_REFERENCE_AVCC); // configure ADC reference voltage
Details about my custom board - I attached a basic schematic of the board. Its just RSSI straight to the analog pin. The GND,PWR, and Data pins of the Receiver are not shown in the schematic but they are connected in real life. The receiver and the ATmega168 share a common GND. I can verify the operation of the Receiver because I am able to transmit data over the UART perfectly.
The ATmega168 is running at internal oscillator setting of 8mhz.
One thing I found peculiar was that if I connect my voltmeter to the RSSI pin when the RSSI pin is NOT connected to the circuit I get like 2 volts. But when I take the voltage of the RSSI when it IS connected to the circuit, I get a voltage reading in the millivolts.
Very important fact: When my transmitter is off, the RSSI pin of my receiver is 0. So what I did was as follows. I turned off my transmitter and turned on the custom board with the receiver. The custom board outputted only zeroes via HyperTerminal.
Then I turned on the transmitter and all of the sudden I started seeing that the custom board was outputting 1s and 0s, and not only 0. Here is a segment of the data I received: ( NOTE: data shown are bytes sent over HyperTerminal in Hex format, so for example "01" is one hex byte, and "00" is another single hex byte)
01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 00 00 01 00 01 00 01 00 00 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 00 00 01 00 01 00 01 00 01 00 01 00 00 00 01 00 01 00 01 00 01 00 01 00 01 00 00 00 01 00 00 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 00 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 00 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 00 00 01 00 01 00 01 00 00 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 00 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 00 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 00 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 00 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00
Looking at the numbers I began to see a pattern. A lot of 01, 00 ,01 ,00 .
Can someone help me out to get this A2D conversion working?
Thanks in advance,
Eric
EDIT: I connected a potentiometer to a different analog port on my ATmega168. One outer pin to +5V , other outer pin to GND, and middle pin to ADC0. I looked in HyperTerminal and the highest hex byte I got was 3. But the potentiometer was in fact working. At 0 degrees it was giving out a hex byte of 0 , at 30 degrees it was 1 , at 60 degrees it was 2, and at 90 degrees it was 3.
Whats going on here?