Main Site Documentation

Multi analogue pin separation


#1

Hello again folks,

I’m tring to get the Domino to read 2 separate values from the analogue pins at the same time, in this case An0 and An1. The problem I am having is that whichever pin I send voltages to, both pins seem to respond.

Here is the basic code:


            AnalogIn G = new AnalogIn((AnalogIn.Pin)FEZ_Pin.AnalogIn.An0);
            AnalogIn P = new AnalogIn((AnalogIn.Pin)FEZ_Pin.AnalogIn.An1);

            G.SetLinearScale(0, 3300);
            P.SetLinearScale(0, 3300);

             voltage1 = G.Read();
             voltage2 = P.Read();

             counter_string = voltage1.ToString()+" "+voltage2.ToString()+"\r\n";
             Debug.Print(counter_string);

Any ideas as to what I am doing wrong?

Many thanks

TC

PS. I’m logged on to chat if anyone can lend me a hand :slight_smile:


#2

Your voltage must be exceeding 3.3v?


#3

Gus, I assume there is one ADC and a multiplexer in the Domino. If there is high capacitance on the lines being measured than a short delay between measurements might be necessary?


#4

The voltages are less than 3.3v. Do you think it necessary to delay reading; this is not something I would like to do as I need the system to run as fast as it can.

Could there be another issue?

Cheers

TC


#5

Of course it could be another issue. But, we will not know until you try a delay and see if it helps.


#6

Yes there is MUX and voltages signals on a pin may effect other but should be very minimal.

I do not think a delay would change anything but it is easy to try :slight_smile:


#7

Okay tested a delay and (you’re right Gus) it is still causing a problem.
here is my FEZ setup.

[line]
I take 5v from the FEZ and this goes into a board and the voltage is reduced by adding 2 x 100k resistors (in parallel which go straight to ground).
The voltage (then reduced) goes through its circuit and in read back in pin An0.
This voltage varies and on it’s own reads around 5% of a volt.
then I introduce a second voltage, the 3.3v off the FEZ.
This is reduced using a 2 x 100k resistors; bringing the voltage down to just under 3v (constant).
This is read on the An1 pin.
Here is where the problem is at. An1 read the correct value but An0 now also reads it full current.

An1 = 2.965v
An0 = around .3v (that’s zero point 3 of a volt) even when the circuit is broken. Indicating that An0 is reading phantom voltages.

I hope this makes sense.

Any ideas?

Thanks again for all your replies.

TC


#8

First make things simple and see if you are able to read something reasonable from both analog inputs. Tie each input to 3.3 V and take a reading from both. Next connect two 10K resistors in series from 3.3V to DC Common (ground), this makes a voltage divider. Connect the point where the two resistors are ties together to one of the analog inputs (remove the 3.3V of course). Now take a reading from both inputs, the one hooked to the voltage divider should read about 1/2 of the one hooked to 3.3V. Now connect one of the analog inputs to DC Common (ground), it should read very close to zero.


#9

You can’t make a pin an analogue input and leave it floating. This will generate a lot of noise and in turn will cause error in analog values + higher power consumption.

Analog pins must always be connected to some load. Same goes for digital input but in the digital input case we have optional pull up/down resistors that you can use.


#10

What causes the interference? :\

Can I make an Analogue input with constant load and then a Digital Input with a boolean type load, ie either present or not?


#11

Any floating pin causes it. This is normal on any electronic system. Do not set the pin as analog and if you do then make sure it is connected to something.