Go Down

Topic: Reading analog values (Read 128 times) previous topic - next topic

AaronSilas

Ok I have a strange Problem with a project of mine. Im trying to do an analogRead on A1. The voltage I want to read is DC that can vary from roughly 0 to 5V(The DC is quite linear its produced from an PWM Signal and an 100 uF Capacitor. Ive looked at it with an Oscilloscope and it seems fine)
I want to do a simple if the analogRead is over this value then do this if its under that value then do that. The code works fine when I have the USB cable connected. But when I remove the USB Cable and power the whole thing externally shit just goes haywire. It randomly seems to switch between values. The strange thing is that the voltage the arduino gets while externally powered is also 5V (Ive checked with a multimeter) So the reference voltage should be the same.

wildbill

Sounds like you lack a ground connection.

Ron_Blain

#2
Feb 25, 2020, 06:54 pm Last Edit: Feb 25, 2020, 07:05 pm by Ron_Blain
When you power the Arduino Externally using the external power jack it requires approx 7 ~ 12 volts. If you want to use an external power supply of 5.0 volts you would connect to the 5 V pin between the 3.3 V and Ground pins. That what you are doing?

Ron

AaronSilas

Nope it has a common ground with the power supply.
Im powering the Arduino through the Vin Pin

gilshultz

I hope you have some resistance between the Arduino PWM pin and the capacitor, if not you are overloading the port pin. This could be causing problems with your 5V and reference.  Capacitors need current to charge an discharge. You might look up low pass filters, that is what you have.
This response is to help you get started in solving your problem, not solve it for you.
Good Luck & Have Fun!
Gil

Ron_Blain

#5
Feb 26, 2020, 12:42 am Last Edit: Feb 26, 2020, 12:45 am by Ron_Blain
Nope it has a common ground with the power supply.
Im powering the Arduino through the Vin Pin
If you are powering through the Vin pin that is close to the same as using the external power connector. The following is a read from https://store.arduino.cc/usa/arduino-uno-rev3 where Power is discussed.

Power The Arduino Uno board can be powered via the USB connection or with an external power supply. The power source is selected automatically. External (non-USB) power can come either from an AC-to-DC adapter (wall-wart) or battery. The adapter can be connected by plugging a 2.1mm center-positive plug into the board's power jack. Leads from a battery can be inserted in the GND and Vin pin headers of the POWER connector. The board can operate on an external supply from 6 to 20 volts. If supplied with less than 7V, however, the 5V pin may supply less than five volts and the board may become unstable. If using more than 12V, the voltage regulator may overheat and damage the board. The recommended range is 7 to 12 volts. The power pins are as follows:

Vin. The input voltage to the Arduino/Genuino board when it's using an external power source (as opposed to 5 volts from the USB connection or other regulated power source). You can supply voltage through this pin, or, if supplying voltage via the power jack, access it through this pin.

5V.This pin outputs a regulated 5V from the regulator on the board. The board can be supplied with power either from the DC power jack (7 - 12V), the USB connector (5V), or the VIN pin of the board (7-12V). Supplying voltage via the 5V or 3.3V pins bypasses the regulator, and can damage your board. We don't advise it.
3V3. A 3.3 volt supply generated by the on-board regulator. Maximum current draw is 50 mA.
GND. Ground pins.
IOREF. This pin on the Arduino/Genuino board provides the voltage reference with which the microcontroller operates. A properly configured shield can read the IOREF pin voltage and select the appropriate power source or enable voltage translators on the outputs to work with the 5V or 3.3V.


If you want to apply a regulated 5.0 volt external power use the 5V pin. You can use the Vin but need more than 5 volts. Right now my board is powered using the external connector. I am applying 10.15 volts and if I measure the voltage on the Vin pin I get 9.41 which is expected since I get a 0.74 volt drop across an internal diode.

Ron

wvmarle

Symptoms as described suggest a floating pin.

That's all that can be said without complete schematic (including of whatever it is that produces this PWM signal you're trying to read).
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

Go Up