Feasible? Simultaneous Analogue Reads on multiple Arduinos

Hi all,

I'm currently looking into a new project where I want to implement a power meter that will measure an AC signal waveform (low voltage) from a signal generator, with the addition of networking between Arduinos.

My main aim here is to be able to sample the voltage and current simultaneously. As the Arduino only features one 10bit ADC, true simultaneous reads cannot be performed as I would have to take a readings of the voltage and current sequentially.

Rather than use an additional external ADC, I'd like to attempt (if feasible) to use multiple Arduinos (yay networking!) to take synchronised simultaneous reads; one sampling the voltage and the other sampling current. The second would then send its data to the first for processing and the calculation of power (real, apparent, pf etc) could be completed and displayed.

My question to you is this... How could I get both microcontrollers synchronized to perform reads at the same instant?

I've been looking through threads detailing SPI comms however I have not managed to find anything quite like this? Would this be possible to implement using SPI? (Or the I2C bus even? despite being a half duplex comm)

Thanks for your time.

Edit: Apologies to the mods if this should really be in the 'Networking' thread.

I don't think it is possible.
You could use an interrupt and a common trigger signal.
TIMER0 is used for the Arduino timing functions, that interrupt could conflict with it. So you would need two dedicated ATmega chips to achieve a maximum of a few us between the samples.

For your project, using a single Arduino is no problem at all.
As far as I remember the analogRead() function uses 110us.
The mains voltage and current are slow. If it has spikes you could filter them and still have a very accurate result.
There is no need for your project the sample the voltage and current with less than 110us between the samples.

If you would have some kind of special lab testing to do, use an external ADC. That is a lot less trouble than using multiple Arduino boards.

If you really insist on doing simulraneous analog read operations, and using two Arduinos to do it, you might want to consider using the AC signal itself to decide when each Arduino reads. If you detect the zero crossings and save the micros() value, you can use that timestamp to time into the next peak (or wherever else on the waveform you want to measure), and do your analog read then. micros() has a resolution of 4 microseconds, so you can get it pretty close.

If, as Caltoa points out, your AC signal is slow enough, you could do sequential reads one after the other. If I were doing sequential reads, I would alternate the order of them on each cycle. ie. measure votage then current, and on the next, read current then voltage. Average the voltage readings, then the current readings for as many measurements as you think necessary, It sould give you pretty good accuracy unless the signal's frequency is too high. Note that AC power readings are meaningless without knowing where on the waveform you are measuring.

Reading this for interest and my learning.

could he connect the AC on 2 inputs 0 an 2 and amps on, say 1 and 3,
then read V on A0
then A on A1
then V in A2
then A on A3

then compare to see what, if any change occurred in the time it took to make a read ?

I am just monitoring pumps going on and off and blowers going on and off, so my needs are in 10's of seconds. nothing fast.

Thanks for the replies everyone. This was the response I was expecting unfortunately.

If you detect the zero crossings and save the micros() value, you can use that timestamp to time into the next peak (or wherever else on the waveform you want to measure), and do your analog read then. micros() has a resolution of 4 microseconds, so you can get it pretty close.

Detecting zero crossing is very important, I found the 'Open Energy Monitor' Project, I must say it is a fantastic site! If I decide to stick with just a single ADC reading both voltage and current, I think implementing phase correction as explained here should work nicely: http://openenergymonitor.org/emon/buildingblocks/explanation-of-the-phase-correction-algorithm

If you would have some kind of special lab testing to do, use an external ADC. That is a lot less trouble than using multiple Arduino boards.

My project is to come up with a design to measure the power of an AC single phase machine. The project is however for 'proof of concept' and hence I wont be handling such high voltage but using a signal generator in lieu of the machine set.

After further research I have thought of a second idea; to use an external ADC with a 'dual sample and hold' capability (thus eliminating the use of the Arduino's ADC) as I believe this would allow true simultaneous sampling.

To extend the project and incorporate 'networking' as mentioned in my original post, I could sample the waveforms over a number of cycles and store the data to the Arduinos' SRAM. The data arrays could then be sent to a second Arduino using a pair of XBEEs (XBee - Wikipedia) where the processing calculations could take place. The idea is only in its infancy...

Are there any feasibility issues you can think of that I might run into with that approach?

Thanks for your time once again.

There are ADCs that will do multiple simultaneous readings, even 6 or 8 at a time IIRC (ADAS3023 for example). But you said you didn't want to use an external ADC.


Rob

You could use an interrupt and a common trigger signal.
TIMER0 is used for the Arduino timing functions, that interrupt could conflict with it. So you would need two dedicated ATmega chips to achieve a maximum of a few us between the samples.

Could you expand on that Caltoa?

If I were to use 2 arduinos for the sampling and a Master to feed the data to for processing, would it be a case of wiring the two slave devices interrupt pins together to the Master? (assuming the two slaves are running at the same clock frequency).

I think so, yes.
You can use only two for that. When one of the two activates the trigger/interrupt signal, both enter the interrupt service routine at the same time.

newb91:
My main aim here is to be able to sample the voltage and current simultaneously.

Can you quantify how close together you need the two measurements? In other words, what is that maximum interval between them that would be acceptable?