I’m using a XBee S2C module to make a wireless joystick controller. I have successfully setup the module in End Device AT mode which reads ADC values from the joystick module and sends it to the coordinator XBee module, which is in API mode.
I have interfaced the Joystick output on ADC Pins 19 and 20 on the XBee module. Power is supplied using USB. ADC conversion for all positions of the joystick is as expected and working well. But when the joystick is in the extreme 0 position or when the output of the VRx or VRy from the joystick module is 0, the ADC value shoots up to 1023 (03FF) instead of expected 0 (0000) in the data frame. As the joystick position approaches 0 value, ADC value also approaches 0, as expected, but at 0 voltage, ADC output is 1023. I have also verified the VRx voltage using a multi-meter and it shows 0.
I have tried to connect XBee’s GND directly to AD0 (i.e. Pin 10 and Pin 20 are connected), again the ADC value in the API frame shows 03 FF (1023) instead of 00 00 (0). Also tried disabling the internal pull up/pull down resistors on the XBee (PR), still no luck. Same problem occurs on other XBees as well.
Now, I used an Arduino Uno board and connected it to the same PC and connected the grounds of both the Arduino and XBee (common ground) and now the 0 voltage is interpreted perfectly as 0 at the output and everything works fine.
I also setup this circuit http://www.digi.com/blog/wp-content/uploads/2014/08/XBee-Gateway-Kit-Potentiometer-Circuit_schem.png to check ADC values, and I still get incorrect ADC reading at 0 voltage.
Please correct me and help me understand where I’m going wrong. It seems to be a problem with ADC for 0 voltage. Same problem also occurs when the battery is used as power source as well.