Pages: 1 [2]   Go Down
Author Topic: Changing ISR's return address to a function's memory location?  (Read 696 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Tesla Member
Karma: 135
Posts: 7683
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

At 60 Hz there are 16,666 microseconds in an AC cycle.

Another way of looking at this is to wonder why one Arduino wouldn't be plenty fast enough to read voltage and current with successive analogRead()s.


Online Online
Sr. Member
Karma: 17
Posts: 387
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I see this as a solution to the problem of synchronizing ADC readings.  I admit, though, that my understanding of the OP's goal is kind of fuzzy.
  • Set the ADC to auto-trigger on external interrupt 0
  • Set a timer to run at the appropriate frequency
  • Set that timer to deliver a PWM output
  • Connect that PWM pin to external interrupt 0 on both Arduinos
The datasheet says that the ADC prescaler is reset when the ADC is auto-triggered by an event, to assure a fixed delay from the trigger event to the start of conversion.  That will ensure that the samples taken by the two Arduinos are in sync to within what I'd expect to be a couple of system clock cycles, without intervention from the program.  Without some kind of active synchronization of ADC readings, they'll drift apart quite quickly, due to the difference in the frequencies of the two ceramic oscillators.

If the intent is to make power measurements on a single-phase circuit, I think that taking readings of current and voltage alternately on a single Arduino would be accurate enough.  Fiddling with a unity power factor calculation, close to full scale, in Excel, I get an error of about 0.1% by reacting alternate readings as if they were taken simultaneously.  Interpolating one set, I get about the same results.  That seems to be plenty accurate for a metering application, but there's no guarantee that's what the OP is up to.
« Last Edit: May 05, 2014, 04:48:22 pm by tmd3 » Logged

Pages: 1 [2]   Go Up
Jump to: