Basically I would configure each signal input as an interrupt. Timestamp when each positive zero-crossing occurs. The order of triggering will tell you the order of phasing and you can derive frequency from the timestamps.
That should be enough to get you started. If you need the code written, PM me and I can quote you a fixed amount.
wvmarle:
That code contains three infinite loops.
Why don't you describe in detail in words and images what you actually try to accomplish (and use code tags when posting code).
i wanna Arduino check the sequence of a 3 phase system, also check the frequency.
I think i figured how to check the sequence in 50Hz system, now all i wanna do is first find the frequency and then proceed to the rest
#include <LiquidCrystal.h>
LiquidCrystal lcd (12,11,5,4,3,2);
int max1=0,max2=0;
unsigned long period;
long previousmillis = 0;
unsigned long currentmillis,endmillis;
int led=6;
void setup() {
// put your setup code here, to run once:
lcd.begin(16,4);
}
void loop() {
// put your main code here, to run repeatedly:
int phase1=analogRead(A0); // A0 value phase 1 R
int phase2=analogRead(A1); // A1 Value phase 2 Y
int phase3=analogRead(A2); // A2 Value phase 3 B
//Check if sequence is RYB or RBY
//I do that by comparing the Values or R and Values of Y and B after 6.66666 ms (difference of each phase is 120 degrees in 50Hz system)
//The Max Values in A0,A1,A2(3 phases) are 625, equals 3 Vpeak.
lcd.setCursor(0,2);
if (phase1>200)
{
delay(6.666);
if (phase2>200)
{
lcd.print("RIGHT"); //Print RIGHT if phase1>200 and after 6.666ms phase2>200
}
if (phase3>200)
{
lcd.print("LEFT"); //Print Left if phase1>200 and after 6.666ms phase3>200
}
}
for (int r=0;r<250;r++)
{
if(phase1>max2)
{
max2=phase1; //Check the max value readings
}
}
lcd.setCursor(0,0);
lcd.print("Max Value:");
lcd.print(max2);
lcd.setCursor(0,1);
lcd.print("period:");
That's a matter of measuring how long time there is between two zero crossings.
After reading these posts for a while I think the OP is looking for the "rotation" of the phases.
Fairly important in a few situations. I recall when the power company replaced one blown transformer of a set of three and got the phasing wrong. All the IBM tape drives immediately unwound all the 1200 ft. reels of tape we had mounted.
But the phase rotation is only usable if you knew the rotation before the incident.
If you're actually looking for the rotation of the PHASES themselves, that again should easily be doable with the same zero crossing, combined with a reading halfway the crossings to find whether it's a positive or negative half of the cycle.
That's a matter of measuring how long time there is between two zero crossings.
Yeah i have some dificculty doing this any example??
Basic example of frequency reading using zero detection. N_PHASES is the number of phases, probably 3.
Separately feed the three phases through proper voltage divider and offset to analog inputs, halfway the frequency (which should be very constant) read whether you have a positive or negative wave. If you do this exactly halfway (should be easy: frequency should be very constant) and if you know the waveform (sine?) you can even get the RMS and peak voltage values.
Come to think of it: it should be quite easy to get a circuit that produces a high signal during the positive half, and a low signal during negative wave. That way you can measure both frequency and phase rotation through just the digital pins. The edges of the block wave are at the zero crossings and give you the frequency, the high/low part tells you where in the cycle you are.