Hot answers tagged

16

The ADC inside the Arduino does not measure voltage, but rather a voltage ratio. Namely the ratio from the voltage at the analog input to the voltage at the Vref pin. In the default configuration, the Vref pin is internally tied to the +5 V line. You can select to use instead an internal reference as Vref: analogReference(INTERNAL); This reference ...


11

This is to be expected. The other pins have nothing connected to it, so their voltage is floating. The Arduino MCU only has a single ADC. To read the different analog pins, it uses a multiplexer to connect the pin you want to read to the single ADC. The ADC inside the MCU have a "sample and hold" capacitor inside it. To read the voltage at the pin, it ...


9

A USB-powered Arduino Nano will have an ADC voltage reference which can't be relied on, due to the +/- 5% tolerance of the incoming USB voltage. On top of that, the Nano has an MBR0520 Schottky diode (D1) that will drop between 0.1 and 0.5 V depending on its own manufacturing tolerances, its temperature, and the current draw of your board. What can you ...


6

Expanding on part of Majenko's answer, you can use an analog multiplexer like the 74HC4051 to turn one analog port into 8. Its cousin, the 74HC4067, will multiplex 16 ports. Now with 6 analog inputs on the Arduino Uno, you could have 6 x 16 inputs = 96. The A/B/C controls signals could be paralleled up. This would let you handle 96 inputs with only 6 extra ...


6

There are two methods of doing what you want: Add more ADC channels Multiplex the existing ADC channels SPI or I2C ADC chips are readily available in a range of resolutions, sampling speeds and number of channels. They are fairly simple to add to any Arduino. For instance the MCP3208 will give 8 channels of 12-bit resolution on SPI, which means 3 pins (...


6

This outputs 8 MHz on pin 9: #ifdef __AVR_ATmega2560__ const byte CLOCKOUT = 11; // Mega 2560 #else const byte CLOCKOUT = 9; // Uno, Duemilanove, etc. #endif void setup () { // set up 8 MHz timer on CLOCKOUT (OC1A) pinMode (CLOCKOUT, OUTPUT); // set up Timer 1 TCCR1A = bit (COM1A0); // toggle OC1A on Compare Match TCCR1B = bit (WGM12) |...


6

The AD converter in the ATMega microcontroller (as used in Arduino) converts an input voltage to a number. This ADC happens to be 10 bit that means 2^10 states which is 1024. The number 0 (zero) means 0 Volt input voltage. The number 1023 means the maximum input voltage. Since 0 is also a value the scale runs from 0 to 1023 making 1024 values. The scale ...


5

If I understand the description correctly, neither side of the resistor is at ground potential. There's a wide gamut of methods of dealing with this, for example using a differential ADC unit, or using an instrumentation amplifier ahead of a single-ended ADC. But perhaps the simplest method is to use two ADC channels, one attached to each end of the ...


5

That water level sensor uses bare metal which is in contact with the water. The PH sensors are sensitive for that kind of voltage in the water, even if it would be 0V. There are isolated PH sensor amplifier modules. On forums are often discussions whether to ground an aquarium or not for a PH sensor. With a isolated PH sensor, you avoid most of those ...


4

In your interrupt handler, ADC_Handler(), you set sample_buffer_full when the buffer is full. I don't see anywhere in the code where sample_buffer_full ever gets reset (cleared) once it's been set. While sample_buffer_full is set, it disables the body of the interrupt handler – ie, the handler's structure is if (!sample_buffer_full) { ...body of handler.....


4

That quote you mention says it all really. It's purpose is to discharge the Sample And Hold capacitor. That capacitor is used (as I'm sure you are aware) to store the incoming voltage while it's being sampled by the ADC. The ADC operated in two main phases: Acquisition Sampling During acquisition the capacitor is connected to the incoming voltage. ...


4

There are a few ways of doing what you want. One would be to use an analog multiplexer as in this answer: Expanding analog inputs to the Arduino Another would be to use digital I/O pins to control the power and ground to the potentiometers. Note that both sides of the pot need to be controlled, not just one, since any connection of one will interfere with ...


4

As far as I understand the analogread() function samples an analog input at 10kHz rate. No, it samples an analog input at once per invocation. This means that if it is run 10000 times within a second (assuming it can be run that many times within a second) then the code is sampling at 10kHz. But if it's run only twice per second then the code is sampling at ...


4

If you have a loop that calls analogRead() to take a reading, and then serialPrint() to send the reading, each pass through the loop will take at least the sum of the time for those two functions calls together. When you first call serialPrint(), it returns in uS, as it doesn't actually send data, but puts it into the 64 deep transmit buffer, to be sent in ...


4

Yes, you can go above VRef. Voltage on any Pin except RESET with respect to Ground ................................-0.5V to VCC+0.5 And as the ADC reference says anything above VREF will give you the maximum value (it will saturate). So powered from 5V you can apply anything from -0.5V to +5.5V safely. That's basically the supply voltage plus one ...


4

According to the datasheet (page 375) the minimum voltage you are allowed to have as a reference voltage for the ADC is 1V.


4

You need: A timer A board that is capable of running fast enough to do what you want. The Nano fits the first criteria, but not the second. At 16MHz you get a clock period of 63ns. That means you get a mere 8 clock ticks (actually gives you 504ns) per interruption from the timer. That's at most 8 assembly instructions that can be executed within that ...


4

Note: this is an attempt to answer the question as asked. This answer is unlikely to be of any use to the original poster, who presumably asked the wrong question. I am writing this only as a way to explore the limits on how fast a modest AVR can sample a port. For an answer that genuinely attempts to address the OP’s problem, see Majenko’s answer. I read ...


4

The datasheet of the Atmega328P does not give a direct answer to this, but Single ended channels that exceed V REF will result in codes close to 0x3FF. (Datasheet Chapter 24.5.2) sounds, as it would not destroy the ADC, but only result in a value very close to the maximum. I also found another side, where this is also stated. They linked to the ...


4

As @dandavis rightly says in the comments, you can't measure the battery voltage from a power bank. This is because the power bank typically includes a step-up converter to turn the batter voltage (3.2 to 4V) into a stable 5V. That 5V will alwaye be 5V (or thereabouts) until the battery runs out and the power bank shuts itself off. To measure the battery ...


3

Sorry, but.. Why integration? Just use a peak detector like this one: The output will "float" to the peak value of the input signal, minus the voltage drop across the diode: The output oscillates between 9.7V and 9.2V, which is a 5% maximum error. If you want to reduce it, sample with a sample rate not multiple of 50Hz and average the measures. The RC ...


3

You misunderstand the meaning of: 1 << ADSC That actually means Bit-shift 1 left by the number of bits specified by the value ADSC. ADSC in this case is 6: #define ADSC 6 So if you did: while(ADSC); you would actually be doing: while(6); Which of course will never end, since 6 is not 0, so is true. Instead you shift 1 left 6 times, which ...


3

You will read 1023. The limit of the voltage is not the reference voltage but the chip supply voltage - so 5v on a 5v board.


3

You can use one of the PWM pins on Arduino to output a PWM signal. If you want a constant clock, you need to set the duty cycle of the PWM to be 0.5, i.e. 50%. Syntax: analogWrite(pin, value) where the parameter "value" is the duty cycle ranges from 0 (always off) to 255 (always on) since it is a 8-bit PWM generator inside Arduino. If you need a PWM wave ...


3

No, it's certainly not possible to directly sample at 500Msps on an Arduino using an external ADC. Simple maths: The Arduino can perform 16 million instructions (best case) per second The ADC performs 500 million samples per second. 500 / 16 = 31.25 Therefore the ADC would be generating 31.25 samples for every clock of the Arduino, so unless you can build ...


3

The ADCs in the ATtiny85 and ATmega2560 (the chip powering the Arduino Mega 2560) are pretty similar, except for the Mega having more inputs. In particular, the way you set the clock prescaler is the same, namely the bits ADPS2:0 in the register ADCSRA. You could use the same code to set the prescaler on both chips, but you probably don't want to unless your ...


3

The datasheet of the ATmega328P (the main chip of the Uno) states: The ADC is optimized for analog signals with an output impedance of approximately 10 kΩ or less. The Thevenin equivalent output impedance of most taps of your voltage ladder is higher than 10 kΩ. You 1 MΩ pulldown is way beyond that limit. Cross talk from previously read ...


3

Use a Teensy 3.x. Those have 13 bit ADCs


3

Rather than trying to update TCNT0, it might be better to track the number of cycles lost to ADC conversions, and in an intermediate routine – eg, omillis() – compensate for those cycles. [Edit: See better alternative, below] In more detail: • At each conversion, add about 128·13 cycles (or perhaps 128·13.5, to account for average prescaler delay) to a ...


3

ADS7835 from Texas Instrument. can be interfaced with Arduino Mega or Raspberry Pi It is interfaced through SPI, 12 bit data, and up to 500kHz throughput rate.


Only top voted, non community-wiki answers of a minimum length are eligible