Arduino Forum

Using Arduino => Sensors => Topic started by: olimex on Mar 12, 2013, 08:30 pm

Title: Analog ports disturbed
Post by: olimex on Mar 12, 2013, 08:30 pm
Hi, thank you for your support!
I'm prototiping a sort of control panel for my motor bike, to dim lights, temperature, voltage of the battery and so on. I'm using an arduino uno now but in the final product there will be an Arduino micro.
I'm using 3 of the 5 analog ports on the board and there i a problem. When i actionate the potentiometer (10kohm) on A0, in A1 and A2 the reading is somehow influenced and changes. More precisely, when the potentiometer in at 1024 value (5.00v), the reading on the other two changes of -5%/10% :0
Why?
Title: Re: Analog ports disturbed
Post by: Grumpy_Mike on Mar 12, 2013, 09:43 pm
This can happen if the impedance of the other inputs is high. What are the other inputs?
Title: Re: Analog ports disturbed
Post by: olimex on Mar 13, 2013, 08:15 pm
A0 is the potentiometer
A1 is connected to a couple of resistor (voltage divider from 12v to 5v)
A2 is connected to a lm35 termometer

in recent test i've noticed that when A1 is to 0 (potentiometer completely closed) the reading of the other two ports is perfect and stable. When i activate the potentiometer it goes all crazy
Title: Re: Analog ports disturbed
Post by: robtillaart on Mar 13, 2013, 09:56 pm
you might need introduce an extra read for every analog input to give it more time to stabilize. Behind the 6 pins there is only one ADC that switches between them.

in code:

analogRead(A0);
int p = analogRead(A0);
Title: Re: Analog ports disturbed
Post by: dc42 on Mar 13, 2013, 10:02 pm
What are the values of the resistors in the voltage divider?
Title: Re: Analog ports disturbed
Post by: olimex on Mar 14, 2013, 01:47 pm
the correct value is shown only when the potentiometer is at 0V.

the resistors are 4.3kohm between GND and Vout and 13kohm betwen Vout and Vin
Title: Re: Analog ports disturbed
Post by: dc42 on Mar 14, 2013, 02:35 pm
Something is not right, those 3 devices you have connected to the analog inputs are all low-resistance sources, so there should be no interference. Can you post a photo of your setup?
Title: Re: Analog ports disturbed
Post by: olimex on Mar 14, 2013, 07:15 pm
Here ther is the project with freezing
Title: Re: Analog ports disturbed
Post by: Grumpy_Mike on Mar 14, 2013, 07:22 pm
Quote
Can you post a photo of your setup?

It is not a photo is it?
Title: Re: Analog ports disturbed
Post by: dc42 on Mar 14, 2013, 07:25 pm
Your diagram shows a transistor of some sort connected to digital pin 11. What type is it?
Title: Re: Analog ports disturbed
Post by: MarkT on Mar 14, 2013, 07:56 pm
Sketch?  Are you doing anything with the potentiometer value that might have an impact on the supply voltage?
Title: Re: Analog ports disturbed
Post by: olimex on Mar 14, 2013, 08:20 pm
Sorry, I thought that the wiring was a bit confusing!

The transistor is a TIP121

The potentiometer is connected just like in the sketch!

:)
Title: Re: Analog ports disturbed
Post by: dc42 on Mar 14, 2013, 08:35 pm
One obvious problem is that you are overloading the Arduino digital output by connecting it direct to the base of the TIP121. You need to use a series resistor. 1K is a suitable value.

Your Fritzing diagram doesn't show a connection between the pot and +5V, but from the photo I can see that there is one.
Title: Re: Analog ports disturbed
Post by: olimex on Mar 14, 2013, 09:32 pm
Sorry in the skatch I miss to drag the wire to the edge of the board!  :~

Thank you for the resistor, i really don't know where arduino need those pieces, but this question is off topic!  :smiley-zipper:
Title: Re: Analog ports disturbed
Post by: afremont on Mar 15, 2013, 12:46 am

Sketch?  Are you doing anything with the potentiometer value that might have an impact on the supply voltage?


Ding ding ding, give that man a cigar.  Look at the pot in the fritzling thingy.  It's not wired right, it's pulling the voltage down when adjusted.  It's set up to where it can completely short the power rails if it is adjusted all the way to one side.
Title: Re: Analog ports disturbed
Post by: dc42 on Mar 15, 2013, 01:01 am
The wiring of the pot in the photo looks correct to me, assuming it is a normal pot with the wiper being the middle connection.
Title: Re: Analog ports disturbed
Post by: afremont on Mar 15, 2013, 01:06 am

The wiring of the pot in the photo looks correct to me, assuming it is a normal pot with the wiper being the middle connection.


Ok I'm blind, I magnified it and now I can see that the orange wiper wire extends beyond the power bus and into A1.  What about the red wire on the outer tab of the pot?  It "appears" to be connected to an empty bus strip I think.  Also I see a ground wire connecting the bottom negative bus to the top one, but I don't see a positive wire extending to the bottom bus.
Title: Re: Analog ports disturbed
Post by: olimex on Mar 17, 2013, 10:08 pm
I found the problem. When I store a value from analogRead and then use it in analogWrite, all the other analog ports gets disturbed.

Do you have the same problem?
Title: Re: Analog ports disturbed
Post by: dc42 on Mar 17, 2013, 10:10 pm
If analogWrite interferes with analogRead, this normally means that you have a common ground wire serving your input and output devices, and a dodgy connection in that ground wire.
Title: Re: Analog ports disturbed
Post by: olimex on Mar 17, 2013, 10:28 pm
Yes you are right!!! Thank you so much!!!

But What should I do to solve the problem?
Title: Re: Analog ports disturbed
Post by: Grumpy_Mike on Mar 17, 2013, 11:28 pm
Make the contact secure soldering wires is a good idea.
Or route the grounds separately so they converge at one point on the arduino ground.
Title: Re: Analog ports disturbed
Post by: olimex on Mar 18, 2013, 08:49 am
Now all the GNDs are converging at one pin next to the 5v, are you saying that i should wire them that the pmw Ground ends at the GND next to digital pins?  :smiley-fat:
Title: Re: Analog ports disturbed
Post by: dc42 on Mar 18, 2013, 09:05 am
Best is to use 2 ground pins on the Arduino. Use one to connect the ground side of your analog input devices (the pot, the temp sensor and the voltage divider). Use the other one to connect the ground side of your ourput devices (TIP121 and associated 12V supply), and power to the Arduino if it is not coming from USB.

Did you add that resistor in series with the TIP121 base?
Title: Re: Analog ports disturbed
Post by: olimex on Mar 18, 2013, 09:23 am
Now i'm at school, when I get back home i will let you now!
:smiley-mr-green:
Yes i added it! Excuse me ignorance, but why Arduino needs it?
Title: Re: Analog ports disturbed
Post by: Grumpy_Mike on Mar 18, 2013, 03:11 pm
Quote
but why Arduino needs it?

To limit the base current to a safe level.
Title: Re: Analog ports disturbed
Post by: olimex on Mar 18, 2013, 11:26 pm
My Arduino burned up... I am literally crying. After one year and an half of service. I tried to upload blink sketch and it works but after a while the atmega328 starts to heat... I'am so sad  =(
Title: Re: Analog ports disturbed
Post by: retrolefty on Mar 18, 2013, 11:31 pm

My Arduino burned up... I am literally crying. After one year and an half of service. I tried to upload blink sketch and it works but after a while the atmega328 starts to heat... I'am so sad  =(


Well for about $5-6 you board can enjoy another year and half of service, that's pretty cheap entertainment.

Maybe you weren't storing your board away in a ESD bag or using a grounded wrist strap.  ;)

Lefty
Title: Re: Analog ports disturbed
Post by: dc42 on Mar 19, 2013, 10:23 am
Have you disconnected everything from the Arduino except the USB, and checked that nothing is shorting the underside of the circuit board?

If yes and the atmega328p is still heating up, then probably all you need to do to get it working again is purchase a new atmega328p-pu with bootloader already installed.
Title: Re: Analog ports disturbed
Post by: olimex on Mar 19, 2013, 11:11 am
I Will try! But the sketch Works! Maybe the Voltage regulator that doesn't pushes correct Voltage to to atmega?