Simultaneously Reading Two Analog Inputs with Arduino

Hi, I am new to Arduino.
Is it possible to read two Analog inputs (2 piezo sensors) at the same time (without any delay, for example not to read A1 just after A0, but simultaneously)
I want to check their signals simultaneously, and I just want to make sure that 1 input will not influence (or interfere with) the other signal.
Thanks

No. An Arduino only has a single analog to digital converter so it can only read from one pin at a time.

What are you trying to sample?

...R

(deleted)

spycatcher2k:
Reported for crossposting

My bad... my first post in Arduino forum... I have now deleted the other post

Robin2:
What are you trying to sample?

I am trying to measure the extent of Imbalance in a rotor using 2 piezo-electric sensors... And I want to check it at 2 different positions (hence 2 sensors)
What I want is to plot the graph of those 2 sensors (and they should be in phase).

Given that you can't read from 2 pins at the same time then what is the maximum amount of time between readings that would be acceptable in order to get useful data?

...R

Robin2:
what is the maximum amount of time between readings that would be acceptable in order to get useful data?

I am not sure, what is the minimum time I can get??

And given that I do get a (very) small delay between readings, then after 20-30 rotations, the values (or graph) of the sensor readings will be far off (definitely will not be in phase)...

AbdulMoizFarooq:
I am not sure, what is the minimum time I can get??

Write a short program to measure the time. I think an analogRead() takes about 100µsecs (see the datasheet) but you may not be able to read two different I/O pins at that rate

And given that I do get a (very) small delay between readings, then after 20-30 rotations, the values (or graph) of the sensor readings will be far off (definitely will not be in phase)...

The gap between the two readings will always be the same. Whether the pair of readings remains in phase with something that is rotating depends on how you sync the readings with the rotation.

...R

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html

What is the rotational speed of the rotor?
If the rotor has any length, what makes you sure the out of balance is going to be in phase?

Do you have a device to measure rotational position?

If so, then measure continuously one sensor and plot it against rotational position, then measure the other sensor the same way.
You can then plot the two together using the position information.

That is how wheel and spindle balancing machines do it.

Tom... :slight_smile:

Robin2:
The gap between the two readings will always be the same. Whether the pair of readings remains in phase with something that is rotating depends on how you sync the readings with the rotation.

Yes, the gap is same for all the rotations. Thank you. But another problem arrives:

TomGeorge:
Do you have a device to measure rotational position?

Yes, I do have an encoder... incremental rotary encoder attached to a plate with 32 teeth (per rotation, i.e every 11.25 degrees)

TomGeorge:
If so, then measure continuously one sensor and plot it against rotational position, then measure the other sensor the same way.

The problem then still arrives... how to sync the encoder with the piezo sensor correctly, without any lag?? In my case, there is a lag, which keeps on increasing every rotation so the values are not perfectly synced...

I have attached the encoder to digital pins and piezo (currently only 1) to the analog pin and compared the graphs...

You could keep reading the values, save them in arrays and then compare both values of the arrays of the same index. Sure, there will be some small delay, but it is an easy solution.

If you need to read 2 sensors simultaneously, then don't read them sequentially with an Arduino in real time. Rather, your circuit should send an enable signal to all of the sensors at once. The sensors' output should be buffered and 'latched', so that it is available when the Arduino gets around to reading it.

AbdulMoizFarooq:
In my case, there is a lag, which keeps on increasing every rotation so the values are not perfectly synced.

You need to post your program so we can see exactly what you are doing.

...R

AbdulMoizFarooq:
Yes, the gap is same for all the rotations. Thank you. But another problem arrives:

Yes, I do have an encoder... incremental rotary encoder attached to a plate with 32 teeth (per rotation, i.e every 11.25 degrees)

The problem then still arrives... how to sync the encoder with the piezo sensor correctly, without any lag?? In my case, there is a lag, which keeps on increasing every rotation so the values are not perfectly synced...

You need to have a sync sensor on the encoder, so you have a clock and sync signal.

Each time the sync point is detected, once every revolution, you start the clock counter at 0.

You need to know the exact location of the spindle as it measures, 32 teeth which gives 64 clock pulses would be good.
64 because you use rising edge as one clock pulse and falling as another.

What is the rotational speed?
Just a suggestion...
Tom... :slight_smile:

AKJ:
keep reading the values, save them in arrays and then compare both values of the arrays of the same index.

That is what I will do

TomGeorge:
You need to know the exact location of the spindle as it measures, 32 teeth which gives 64 clock pulses would be good.
64 because you use rising edge as one clock pulse and falling as another.

Yes, I am using attachinterrupts for Rising only (will try for falling as well, but later)
To know the exact location of the spindle, I have another (incremental) encoder synced with only 1 teeth (or hook, this teeth is not one of those 32) in the whole rotation.
What I am doing is using 2 interrupts, one Rising for incremental encoder, and another Rising for Position Encoder (32 teeth). I am taking the readings on every rise of position encoder (total 32 readings per rotation) and store them in an Array, which later can be compared as @AKJ suggested.
I will also post the code when it is ready.

Thank You for all your help...

AbdulMoizFarooq:

Robin2:
Given that you can't read from 2 pins at the same time then what is the maximum amount of time between readings that would be acceptable in order to get useful data?

I am not sure, what is the minimum time I can get??

The minimum sample rate required is a pretty essential part of specifying any discrete time sampling system. If you're just looking for a fundamental imbalance then twice the rotational rate of your spindle is the lower bound per the Nyquist Theorem. There may be higher order vibrations in a particular system that need be taken into account.

AbdulMoizFarooq:
That is what I will do

Why have you not posted your program ?

Someone may be able to suggest a simple fix.

...R

MrMark:
I am not sure, what is the minimum time I can get??
The minimum sample rate required is a pretty essential part of specifying any discrete time sampling system. If you're just looking for a fundamental imbalance then twice the rotational rate of your spindle is the lower bound per the Nyquist Theorem. There may be higher order vibrations in a particular system that need be taken into account.

The OP needs to read the analog signal on every interrupt to get the positional resolution required.
So 32 or 64 readings per revolution.
Tom.... :slight_smile:

TomGeorge:
The OP needs to read the analog signal on every interrupt to get the positional resolution required.
So 32 or 64 readings per revolution.

Has the OP told us how many readings per second are required? I think not.

...R

The sensors' output should be buffered and 'latched', so that it is available when the Arduino gets around to reading it.

This is a good idea; but, the sensor output is analog signals. Therefore, the signals should be stored in some kind of peak-reader circuit consisting of low-leakage capacitors being interfaced with the ADC through a buffer. The peak-readers have to be discharged before making the next measurements.

I'm very interested in this project as i want to do something very similar to dynamically balance 1/4 inch end mills after i resharpen them. As you and others have said, synchronizing the ADC conversion to the index pulse is going to be quite difficult.

I'd recommend using two identical ADC chips driven off the same digital IO to enable conversion. I'd use the index input to trigger that signal line. And I'd make a bunch of samples at one RPM and a bunch more at a second RPM. Keeping in mind that the sample and hold circuity of the ADC's might have a millisecond or 10 delay from the index pulse and so you'll need to filter those 'flyers' out of the digital data. And then it's w matter of modifying the rotating mass and seeing if you've guessed correctly about how much delay you've got between index pulse and 'sample and hold' capture. The two different rotational speeds should help with that, unless of course you're dealing with some fun harmonics and Nyquist frequency issues.

Dan.