Analog Input Problems

I'm trying to make a 2.4Ghz computer transmitter and receiver system using the nrf24l01+ modules. On the transmitter side I have an Arduino Micro connected to the module and 3 analog inputs; a 12 button array and 2 pots. These inputs are all powered by the 5v pin. So they're in parallel. However, the position of the wiper in the pots affects the input of the button array. For example, setting one of the pots to center would give an input of about 512 but would also cause the button array to input say 156 when it should read 0. I checked to make sure I didn't have any shorts and didn't find any. Also, when the pot input wires are disconnected from the Arduino their position doesn't affect button array at all. So what could be the cause of the problem? Do I need independent power sources for each input device?

This is my circuit.

Do you have any other connections to the Arduino? Ground or power, for example? If the only connection is the three analog inputs then that isn't going to work.

Could be interference, it looks like all 3 wires are connected to analog inputs, what happened to GND and POWER? Also, you should have a pull up/down resistor.

Maybe that will help. With a bit of calculations, it also makes analog inputs stable.

When one input seems to follow another one, then the following input is probably floating.

R17 acts as a pull down resistor for the button array and V1 is the arduino's 5v pin and ground pin. Do I need to add pull down resistors to the pots?

The circuit looks credible and would not produce the symptoms you describe if it worked as expected. I wouldn't expect the pot positions to make any difference on the button analog readings unless the pots were somehow pulling down the voltage at the right hand end of R17. Can check with a meter whether any of the voltages anywhere except on the pot wipers are altering when you move the pots? Check with one of the button switches closed, as well as with it open.

Can you give resistance values for the resistors?

I suggest you post your code, so that we can see what you're doing to the analog inputs.

By suggesting that there is a separate power supply your diagram is misleading, but that's a problem with your diagram and not with the circuit.

Hi, what value are your components, your cad package should let you include resistor values on the diagram.

Tom.... :slight_smile:

the inputs of any processor has a resistance the uno is about 10kohms.
when the source has more then 10 kohms it means influence. you can test this in your circuit by putting a resistor of 10 kohm to the input and simulate it.

The data sheet for the 328 specifies the analog input resistance to be 100 M ohms (page 323). Where does 10k ohms come from?

Alrighty, here's the circuit again with values and the subroutines that get the analog input.

void throttleChannel()
{
  byte thRev = EEPROM.read(1);
  byte thTravelRev = EEPROM.read(2);
  byte thTravelFwd = EEPROM.read(3);
  int thTrim = int((EEPROM.read(4)<<8) + EEPROM.read(5));
  byte thRate = EEPROM.read(6);
  
  //Set endpoints
  int thEndRev = 768 - (512 * (thTravelRev/100.00) * (thRate/100.00));
  int thEndFwd = 767 + (512 * (thTravelFwd/100.00) * (thRate/100.00));
  int thOutput;
  int thInput = analogRead(A3);
  
  //Reverse input if thRev is high (1)
  if (thRev == 1)
  {
    thInput = (0 - thInput) + 1023;
  }
  
  //Apply endpoints and trim
  thOutput = scaleOut(thInput, thTrim, thEndRev, thEndFwd);
    
  packet[2] = highByte(thOutput);
  packet[3] = lowByte(thOutput);

}//end of throttleChannel()
//////////////////////////////////////////////////////////////////////////////////////////////////


void steeringChannel()
{
  byte stRev = EEPROM.read(7);
  byte stTravelLeft = EEPROM.read(8);
  byte stTravelRight = EEPROM.read(9);
  int stTrim = EEPROM.read(10);
  byte stRate = EEPROM.read(12);
  
  //Set endpoints
  int stEndLeft = 768 - (512 * (stTravelLeft/100.00) * (stRate/100));
  int stEndRight = 767 + (512 * (stTravelRight/100.00) * (stRate/100));
  int stOutput;
  int stInput = analogRead(A1);
  
  //Reverse input if thRev is high (1)
  if (stRev == 1)
  {
    stInput = (0 - stInput) + 1023;
  }
  
  //Apply endpoints and trim
  stOutput = scaleOut(stInput, stTrim, stEndLeft, stEndRight);
  
  packet[4] = highByte(stOutput);
  packet[5] = lowByte(stOutput);

}//end of steeringChannel()
//////////////////////////////////////////////////////////////////////////////////////////////////


byte analogButton(byte buttons)
{
  byte buttonNumber = 0;
  int value = analogRead(A5);
  byte i;
  
  Serial.println(value);

  for(i=1; i<= buttons; i++)
  {
    if(value <= buttonConfig[i][0] && value >= buttonConfig[i][1])
    {
      buttonNumber = i;
    }

    else if(i > buttons)
    {
      buttonNumber = 0;
    }
  }

  return buttonNumber;
}//end of analogButton()

Isn't R17 rather high?

47k * 12 = 564k. I don't have any 600k resistors. The only thing I could find was an 820k.

Hi, the button array looks like you are using too high a value resistor. Noise could be your problem.
Any reason for not using a 4x3 matrix, and digital I/O.
How are you powering the RF units?

  • Try putting .01uF or 1.0uF capacitors on each of the analogue inputs to ground,
  • Measure the 5V supply to the resistor array as you adjust the pots to see what is happening to the supply.
  • Measure A5 input voltage while you do these adjustments.[\li]

Tom... :slight_smile:

TomGeorge:
Any reason for not using a 4x3 matrix, and digital I/O.

It's called "analog buttons".

I think the resistor values (R5-17) used are way too high - by a factor of 10.

adding links
http://tronixstuff.com/2011/01/11/tutorial-using-analog-input-for-multiple-buttons/
Multiple button inputs using Arduino analog pin « RAYSHOBBY.NET
Rêxpirando: Controlling multiple buttons with only one Arduino's analog port

And it is what is used on a lot of consumer devices, such as the buttons on LCD displays, little MP3 players and the like, so that they only actually use one or two input pins and save on wiring.

It is in consequence, extremely unreliable and among the most common sorts of failure of these devices - a bit of leakage due to moisture or lubricant degradation in the buttons, or ESD damage causing leakage in the chip, and you get firstly, unreliable operation of the device, buttons doing what another button is supposed to do and then "ciphers" - the device "takes off", randomly and persistently responding to non-existent button presses.

I am sure many of us have observed such behaviour (I surely can't be the only one), and usually found it impractical to repair.

Try connecting a capacitor of between 0.01uF and 0.1uF in parallel with R17. That should deal with any noise pickup you are getting, and also deal with the crosstalk you get when analog inputs are driven from a high resistance source.

You could also reduce R17 somewhat, e.g. to 470K.

It seems to be stable now. I put a .022uF capacitor in parallel with R17. Thanks for the help!