I don't know if i am posting this in the right place... I hope it is! (I am new in this site)
I'm working on a copper bar folding machine. The main idea is to "sense" the folded degrees by using a slide pot. I'm doing this with an Arduino Nano and an Oled. The voltage applied to the pot is 12Vdc. The sketch is already debugged and i got the system working. I'm reading the voltage of the pot with the Nano and at the same time with a multimeter.
The problem i came across is that sometimes the voltage of the pot increases 1 or 2 tenths while it is "static". Once, the pot "behaved well" up to 5V and then it only increased very little until it reached the extreme, the multimeter read 5,5V. This affects a lot to my reading causing an error in the conversion(the one i do in the Nano) of the folded degrees. This "increase" seems to be randomly. I thought about the 12V source, but it is not the problem. I am using a 4 pin very generic pot. Maybe thats the problem. I don't know.
Circuit?, code? The details are very necessary for tracking down problems.
A pot used as a sensor would normally be powered from the Arduino Vcc so its ratiometric - using 12V is immediately creating a set of problems (not the least being the fact Arduino inputs are damaged by excess voltage).
I have checked the code and the Arduino electronics a few times and i even probed them apart with a rotary potentiometer, it worked perfectly. So I assumed the Nano was not the problem, that's why I didn´t upload the code.
I attached the circuit summarized pic for the slide pot.
The copper bar folding machine was working with contactors (and other electrical stuff) and a Novus 1200 to control a motor. I had to design the electronics of control with the "pre existent stuff" with the objective of replacing the Novus (because the arduino was more precise and better for the user interface). That means i only added the Nano, a relay and a 5V source. The only thing powered with 12V is the pot.
The other source of 4,3V you can see in the pic is the voltage reference i get from a preset pot.
An important factor i forgot to write about is that the arduino is very close to the "electrical control machine station" i commented above. However, the only problem i got from the EMI was the arduino reset. But that only happened with the sparks of a switch. I have already fixed that, but i don't discard the EMI in the pot voltage.
I attached the circuit summarized pic for the slide pot.
You can't feed 0 to 12V into an Arduino analogue input. You are trying to compare 12V with 4V3, which won't work, and you are feeding a voltage into the Arduino well above the maximum.
You need to do as MarkT suggested and feed it form Vcc.
You need a voltage divider (8.2k ohm to 12V, 5.6k (one side to the other end of the 8.2k which becomes the
voltage divider output, and other end of 5.6k to GND.
I only need to sense up to 4,3V. That's why my reference is 4,3V (actually is because the protection diode in Vin, i guess). I know that more than 5V could cause troubles but in my system the pot will never get that higher.
MarkT:
A pot used as a sensor would normally be powered from the Arduino Vcc so its ratiometric - using 12V is immediately creating a set of problems (not the least being the fact Arduino inputs are damaged by excess voltage).
+1
Let me repeat that.
You must power the pot from the Nano's 5volt pin, otherwise you will have instability.
Forget about reference voltages (don't use any).
If you want to know why, then read up about ratiometric sensors and ratiometric A/Ds.
Or, the reference voltage must come from the 12volt supply of the pot (not from the Nano supply).
In that case you need a voltage divider on the pot as well as for the reference.
Both pot and Aref must be dropped equally (same resistor values), and well below the supply of the Nano.
That could be 1-3volt. Exact voltage is NOT important, because of the ratiometric setup.
Don't forget to set Aref to EXTERNAL in setup().
Leo..
Ok i'll do as you say.
However, I measured the supply of the pot when it (the pot voltage) increased and it didn't change compared to "normal" pot voltage.
It seems like this "increase" is due to the pot. I mean, i think that what you're saying about ratiometric sensors depends on the "stability" of the pot power supply, that it is in fact very stable. Maybe i'm wrong and do not entirely understand the ratiometric topic.
But i'll try what you say.
This increase happens wheather the arduino is on or off. I mean it is not a problem of conversion, in fact that´s why i'm using a multimeter at the same time, to check if the nano is doing well the conversion and it does.
When I realized the voltage drop of the pot was increasing 0.1V i turned off the arduino and focus on why does this increase happening and i dindn't find an answer.
It seems like this "increase" is due to the pot. I mean, i think that what you're saying about ratiometric sensors depends on the "stability" of the pot power supply, that it is in fact very stable. Maybe i'm wrong and do not entirely understand the ratiometric topic.
It means that if you use the same power supply for both the reference and thing you are measuring, in this case a pot, variations in the voltage don't matter. If, for example, the pot is at 2/3 of its travel then it will output 2/3 of the supply voltage. As the reference sees the same supply voltage as the pot it will see 2/3 of that voltage at the input to A2D and generate the appropriate output. The exact voltages no longer matter, just the ratio between the reference and the thing being measured.
This increase happens whether the Arduino is on or off.
Have I misunderstood something? The Arduino is not going to be measuring anything if it's off! Also, if by 'off' you mean power removed be aware that if the pot is connected to the input while it is off then most likely current will flow into the protection diodes from the pot and change the voltage.
Never turn off the power to an arduino while
analog /digital Input pins ate connected to
ANY voltage because it wil backfeed through
the protection doodes to the Vcc pin and
power the arduino (as stated at end of last posr)
Yes, that means you have to powerdown the
system you are monitoring/controlling BEFORE
powering down the arduino, a fact lost on 75%
of all newbies.
When i said i "turned it off" i was meaning i've taken it apart from the system and only testing the pot voltage (sorry if i didn't explain it well). Although the forum describes me as a newbie i think i have a basic knowledge haha.
I'm very curious about this problem cause it doesn't happen in the arduino conversion. In fact when the pot voltage "increases" the arduino reads the "new voltage" very precisely. I mean the voltage conversion i'm doing works perfectly, i'm 99% sure. That's why i decided to take apart the arduino from the system and only focus in testing the pot.
I understand what you are saying Perry but i still do not think that's the problem. Anyway to not leaving any doubts i will feed the pot and the nano with the same source.
It suddenly rises up 0.1V. Randomly.
Updating this, I fed the pot with de arduino 5v pin, nothing changed. Randomly the voltage got higher or lower. Then I realize that it might be one pin of the potentiometer. I touched the pin and the voltage value on the multimeter changed. I'm still testing it.
I am using a 4 pin very generic pot. Maybe thats the problem. I don't know.
My money is on the pot and the pot's ability to repeat. I have watched the outputs of the lower cost slide pots jump around, especially if you just lightly tap the pot. Also, for what it's worth the lower cost versions are not well enclosed allowing dirt, especially in an industrial environment, to get in. Then you see the symptoms you describe. My best suggestion would be remove the existing pot and replace with a known good high quality pot.
Updating this, I fed the pot with de arduino 5v pin, nothing changed.
A pot connected to an Arduino on default Aref does not necessarily return an exact voltage.
It returns a ratio (x/1024) of the power supply.
Being a Nano, 'voltage' could depend on how you power it.
Did you connect three pins of the pot to the Nano v3 (not a different Nano I assume).
Ground is equally important as VCC.
Is the (80k ?) pot a 'B' (linear) type, not 'A' (audio taper) or 'C' (log).
Being 80k (I only know 100k pots), did you analogRead the pot twice (recommended if >10k).
If you had posted everything, according to the Forum guidelines, we wouldn't have to ask so many questions.
Details matter.
Leo..
Ron_Blain:
My money is on the pot and the pot's ability to repeat. I have watched the outputs of the lower cost slide pots jump around, especially if you just lightly tap the pot. Also, for what it's worth the lower cost versions are not well enclosed allowing dirt, especially in an industrial environment, to get in. Then you see the symptoms you describe. My best suggestion would be remove the existing pot and replace with a known good high quality pot.
Ron
Full ack.
If the usage intended is potentially heavy I would not use a potentiometer, but an optical rotary encoder, eventually with its own arduino locally to give the values and the limits.
Anything with conventional commercial grade potentionmeters will fail miserably and cost much, much more in maintenance than the hardware.
RIN67630:
Full ack.
If the usage intended is potentially heavy I would not use a potentiometer, but an optical rotary encoder, eventually with its own arduino locally to give the values and the limits.
Anything with conventional commercial grade potentionmeters will fail miserably and cost much, much more in maintenance than the hardware.
I agree if whatever the configuration is, an optical encoder can be incorporated that is a good way to go. I have no clue what constraints (budget) the design is under. I used BEI Motion Encoders but also had the benefit of deep pockets. I also used some very expensive string pots which ran for decades before I retired.