28x1 - Readadc10 gives readings with no Input.

Michael V

Senior Member
I have set up a Picaxe 28xi to measure differential pressure, read from 2 x 0-5V output pressure transducers. I'm reading at around 10% of the range of the transducers (bought cheap), so keen to use ReadADC10 rather than muck around with op amps, the final result will be accurate enough for my purposes.

This has been causing me no end of grief. I have been wrestling with the code to find a flaw in the calculation, but after a day of frustration that does not appear to have been it. I had a simple calculation that subtracted the higher value from the lower one, but kept getting significant readings showing up for the lower transducer, when there was nothing connected to it.

I am currently simulating the higher pressure reading with a 10K potentiometer across 5V as a voltage divider.

I finally simplified my code to the following,

Code:
symbol data3 = b3
symbol dataw1 = w1  '(b2 + b3)
symbol dataw2 = w2 '(b4 + b5)
symbol dataw3 = w3     '(b6 + b7)

Main:	
	readadc10 0,w1	'Pressure Tank, temporary variable
	pause 30
	readadc10 1,w2	'Pressure Return Manifold
	pause 30
	sertxd (#dataw1," ",#dataw2, " ",13,10)	

pause 500
goto main
I still ended up getting readings back when there is absolutely nothing connected, and the multimeter shows 0V on the input. Same garbage via I2C to the LCD display. The readings for the unconnected port show about 1/3 of the one with the potentiometer. When at about 4.5V on the potentiometer going into one port, the SERTXD reading gives me about 900 - 1000 as expected (Word Variable) and the other unconnected pot, showing 0.0V on the multimeter, with nothing connected gives about 300. Roughly the same ratio accrosss the range. Same thing happens when i switch the potentiometer over to the other port. The size of the values is just too great and too consistent to be due to a spurious reading.

I suspected that the Picaxe may have been previously damaged due to overvoltage on the input (a previous embarrassing thread) but i swapped the picaxes, and had the same result on the uncooked one as the cooked one.

What is happening?

Is there a fix?
 

inglewoodpete

Senior Member
What does the ADC input read when you tie the pin to 0v with a 4.7k resistor? I suspect you have the input 'floating' and are reading static/induced voltages.
 

BeanieBots

Moderator
What you are seeing is correct and expected.
An input with "nothing" connected will be floating about up and down in voltage. Usually at the same frequency as your local mains supply.
If you want ReadADC10 to return a value of zero, you must pull the "unused" input to 0v with a 10k resistor.
 

hippy

Technical Support
Staff member
As to the "The readings for the unconnected port show about 1/3 of the one with the potentiometer" is usually a clue you are reading an ADC with nothing connected. The chip's internal sample and hold capacitor gets charged by the first ADC then it switches to the next channel, but there's nothing to pull the capacitor up or down, what you read is the residual voltage on the capacitor which will slowly decay due to internal resistance and will also wobble up and down with any noise pickup there may be.
 

Michael V

Senior Member
Residual Charge Causing Spurious Data - Success

Well i can see you guys have seen this before.

You were absolutely right, a 4.7K or 10K resistor inserted across the unused input returned a consistent 6 or 7 (out of 1024) on readadc10 which is less than 1%, effectively zero. This was over the whole potentiometer range. Problem fixed.

I'd been over the Manual Part 3 Interfacing circuit looking for a clue, making sure i had transducers connected right, which i had. However, there is no clue on reading a vacant space. I guess it is not a "not interfacing" manual. It is quite possible that a something like a 28X1 or any other picaxe may be set up in the field with analog transducer points available but only one or two used, but one set of code to cover all circumstances. Spurious data would confuse everyone, but zero values would be more definitive, therefore desirable. If a wire breaks (another embarrassing thread) you may not pick it up and go on believing the data.

So, next question, what happens if i leave the 10K resistor in place while there is a transducer in place? will it affect the readings or accuracy? If nothing, is it a good idea to always have such a resistor in place on an analogue input?

Thanks once again for your valuable assistance.

Michael
 

moxhamj

New Member
It depends on the output impedence of the transducer, but generally there are two types - bridge transducers which need an op amp and which need to be amplified 30-50 times, and transducers where the output has already been amplified to give a range 0-5V or 0-10V or whatever. These latter ones have plenty of output grunt so a 10k to ground won't upset them.

As for the general question about a broken wire - this is something to design into the working system. For instance I have a tank level sensor and all sorts of faults happen. I've had lightning zap the unit (reads zero), flat batteries (rising values), pump not working (static values when should be rising), a cow chew through a wire (random values) and a cow chew through the pipe (falling values as the water all runs out!). I never thought of these when I first built the system but I've now got code looking for each one. The latest one was moisture on the sensor wires on a very misty day (fixed by potting the device in epoxy).

I'd pull down unused inputs with 10k. With digital logic it is also convention to pull down unused inputs eg on AND or Inverter gates.
 

Michael V

Senior Member
Sounds good to me!

Thanks DrAc,
Sounds good to me. If a few 10K resistors won't upset amplified transducers, then that will be the way to go.

No cows at these coal mines though, maybe a few really big mozzies but that's it. Hmm - a Picaxe mozzie zapper?


Michael
 
Top