News:

Let's find out together what makes a PIC Tick!

Main Menu

is there any code for 3 phases sequence?

Started by hitronics, Nov 30, 2022, 12:22 PM

Previous topic - Next topic

hitronics

I want to get sequence of 3 phases also want to get correction of RYB if connected by mistake

shantanu@india

Simple.
Connect three phases to three pins which have interrupt on change after converting to square wave. I used to use the built-in protection diodes of the PIC pins with a 10M series resistor to do the job
Regards
Shantanu

hitronics

Quote from: shantanu@india on Nov 30, 2022, 05:15 PMSimple.
Connect three phases to three pins which have interrupt on change after converting to square wave. I used to use the built-in protection diodes of the PIC pins with a 10M series resistor to do the job

@shantanu@india do you have code to test?

shantanu@india

Regards
Shantanu

Stephen Moss

Quote from: hitronics on Nov 30, 2022, 12:22 PMI want to get sequence of 3 phases also want to get correction of RYB if connected by mistake

Would be interesting to see what the solution for that is as initially it looks a lot harder than you might think, for example if the phases are wired in the correct order but out of sequence, i.e.
YBR instead of RYB, whatever they are driving should still operate (although possibly in the wrong direction) as the phase angle and voltages between the phases would still be correct (120 degree @ 415V) thus looking at that alone probably would not suffice.

If you have a known correctly wired reference connection to use as well as the connection under test you could perhaps try dropping the voltage down and putting the voltage pair for each phase (R, Y & B) into the inputs of a differential Amplifier. As the phase difference is constant the resulting output voltage from the amplifier should also be constant so it does not matter at what point in the phase you sample it.

Then it is simply a matter measuring the phase mismatch voltage for each phase using the PIC's ADC. If the test and reference phase match the output will be 0 as they are in phase, whereas for a miss match the output will be different depending where the error is, i.e. a R/Y mismatch may output 5V whereas a R/B mismatch may output 2.5V.
Where all three phases are in the correct sequence (relative to each other, not the reference) the the miss match voltage or all three phases would be the same, again whether that was by say 2.5V or 5V should indicate if the the miss match sequence is YBR or BYR.

Also, not sure where you are or where you are intending the item to be used but about 10 years ago to bring the 3 phase colour scheme in line with the single phase for domestic mains power RYB was changed for the UK and as I recall the EU to Brown, Black, Grey with Blue as Neutral.

Gamboa

Hi,

See PDF. Your PIC can check the relay to see if any parameter is not in order.

Regards,
Gamboa
Long live for you

shantanu@india

I found the following code which I wrote 7 years ago. I'm reproducing all of it.

'24.4.15 Single phasing detection logic changed
'23.4.15 Here the 3 individual angles are  logged
'the zero crossing IOC of the reference phase 'R' periodically resets the timer1 count which is free running in the backgound @ 1usec instruction clock
'the zero crossing IOC of the other 2 phases captures the value of timer1 & stores them in registers. The main program loop checks the value of the registers
'@ 2 secs & compares with 6330 & 12660 with a acceptable tolerance level. The values 6330 & 12660 are derived from 120deg electrical angles for a 3-phase/50Hz
'system. 
'the phase difference between the other 2 phases are calculated & when found to be approximately 120 deg , it is assumed to be a balanced 3-phase system
;-------------------------------------------------------------------------------
;**** Added by Fuse Configurator ****
; Use the Fuse Configurator plug-in to change these settings

Device = 12F675

Config FOSC_INTRCIO, WDTE_ON, PWRTE_ON, MCLRE_OFF, BOREN_ON, CP_ON, CPD_ON

;**** End of Fuse Configurator Settings ****
;-------------------------------------------------------------------------------

Reminders =0
Warnings=0 

'variables   
 
 Dim    timer1      As TMR1L.Word 'timer1 addresses the 16bit TMR1
                                  'as a word variable       
 Dim    tick          As Word   
 Dim    ydelay        As Word
 Dim    bdelay        As Word
 Dim    portprev      As Byte
 Dim    portcurr      As Byte
 Dim    check          As Bit
'******************************************************************
'hardware details
'r-phase 0-xing to GPIO.0 , y-phase 0-xing to GPIO.1 , b-phase 0-xing to GPIO.2
Symbol  led      GPIO.5
Symbol  relay    GPIO.4
Symbol  switch    GPIO.3
Symbol  rphase    GPIO.0
Symbol  yphase    GPIO.1
Symbol  bphase    GPIO.2
Symbol  sequence  GPIO.3
'******************************************************************
GoTo main
'***********************************************************************************
'INTERRUPT ROUTINES
On_Hardware_Interrupt GoTo int_routine

int_routine:                                                                                                     

Context Save                                                                               
             
              If INTCON.0=1 Then                    'IOC 
                    portcurr=GPIO                  'read to clear mismatch                                     
                    INTCON.0=0                      'clear flag
                    If portcurr.0=1 And portprev.0=0 Then timer1=0      'clear timer1 on positive edge of R
                    If portcurr.1=1 And portprev.1=0 Then ydelay=timer1  'latch value of timer on positive edge of Y   
                    If portcurr.2=1 And portprev.2=0 Then bdelay=timer1  'latch value of timer on positive edge of B 
                    portprev=portcurr                                    'save port status for next IOC                       
            EndIf             
               
           
     
Context Restore

'*******************************************************************************************


main:
    DelayMS 200
    tick=0
    ydelay=0
    bdelay=0
    check=0
    CMCON=7
    ANSEL=0            'digital I/O   
    GPIO=0              'reset inputs
    IOC=%00000111      'interrupt on change on GPIO0/1/2
    TRISIO=%00001111    'GPIO.4 & 5 are relay & led respectively , rest are inputs
    timer1=0   
    INTCON=%10001000    'enable IOC & general interrupt 
    T1CON=%00000001    'start timer with 1:1 prescaler   
     
'********************************************************************** 
 
run_mode:     
   
    While 1 = 1
        Clrwdt
        DelayMS 1
        If tick <10000 Then                          'check @ 2.0 secs
            Inc tick
        ElseIf tick=10000 Then
          check=1
          tick=0
        EndIf
        If check=1 Then
          INTCON.7=0
          check=0
          If ydelay=0 Then
                relay=0
                led=1
          ElseIf bdelay=0 Then
                relay=0
                led=1
          ElseIf ydelay=bdelay Then
                relay=0
                led=1
          ElseIf ydelay<>bdelay Then
                relay=1
                led=0
          EndIf
'          If Abs(ydelay-bdelay)>6000 And Abs(ydelay-bdelay)<7000 Then          'check phase difference
'                relay=1
'                led=0
'          Else
'                relay=0
'                led=1
'          EndIf
          timer1=0                                'reset for next calculation
          ydelay=0
          bdelay=0
          INTCON.7=1
        EndIf
           
    Wend         
'*******************************************************************************************
Regards
Shantanu

hitronics

@shantanuindia I have a question your code can work within 45HZ to 53HZ?

shantanu@india

Of course. It is meant for power frequency application
Regards
Shantanu

Stephen Moss

I am not sure that solves the original request which appeared to be asking for a method to both identify which phase is which and identify to which connector terminal each phase is connected so as to identify if and how any connector has been miss wired, or have I misunderstood the original request?

Consequently, I may have missed something but as far as I can tell the soultion offered by shantanu@india would identify if any two phases are in the wrong order relative to each other by the phase difference between them, but I don't see how it can positively identify which phase is which as it assumes that the Red phase is connected to GPIO.0, Yellow to GPIO.1 and Blue to GPIO.2.
And so as I alluded to earlier where a connector has been miss wired in the order YBR or BRY instead of RYB, I think it would produce a "correct" looking result because the phases are wired correctly with respect to each other but not correctly to where they should be. Thus if the aim is to not only to identify if the phases are out of sequence with respect to each other but to also identify which phase is connected to which pin of a particular connector then I am not sure that goal could be achieved by measuring phase angle alone.
 
If your could isolate the three phase wiring from the grid you may be able to send a different signal down each phase (i.e. R=1KHz, Y=2KHz, B=3KHz) from a transmitter inserted into one connector and plug a receiver into the other connectors. You would not necessarily know which phase is R, Y and B but at least you can check that all connectors are wired identically by which signal is picked up on a particular connector pin.   

hitronics

@shantanu@india
by the way, how to indicate the order of RYB or RBY or YBR etc...?
I mean I want to use lcd then want to know the order of RYB connections

Yasin

Actually, RYB and YBR have the same direction of rotation.

hitronics

#12
we have now three square wave so how to know where is R & Y & B then if make mistake by connection so want to know by display on LCD or by LED
the aim of this function is to know the correct connections in respect because some times the order of phases changed from electricity station when they do maintenance 

shantanu@india

Quote from: Stephen Moss on Dec 02, 2022, 09:17 AMI am not sure that solves the original request which appeared to be asking for a method to both identify which phase is which and identify to which connector terminal each phase is connected so as to identify if and how any connector has been miss wired, or have I misunderstood the original request?

Consequently, I may have missed something but as far as I can tell the soultion offered by shantanu@india would identify if any two phases are in the wrong order relative to each other by the phase difference between them, but I don't see how it can positively identify which phase is which as it assumes that the Red phase is connected to GPIO.0, Yellow to GPIO.1 and Blue to GPIO.2.
And so as I alluded to earlier where a connector has been miss wired in the order YBR or BRY instead of RYB, I think it would produce a "correct" looking result because the phases are wired correctly with respect to each other but not correctly to where they should be. Thus if the aim is to not only to identify if the phases are out of sequence with respect to each other but to also identify which phase is connected to which pin of a particular connector then I am not sure that goal could be achieved by measuring phase angle alone.
 
If your could isolate the three phase wiring from the grid you may be able to send a different signal down each phase (i.e. R=1KHz, Y=2KHz, B=3KHz) from a transmitter inserted into one connector and plug a receiver into the other connectors. You would not necessarily know which phase is R, Y and B but at least you can check that all connectors are wired identically by which signal is picked up on a particular connector pin.   
In industrial applications, reverse motor rotation can damage machines. Single phasing can cause excessive current in the healthy phases and damage the motor winding. Both the above two conditions can have disastrous consequences.
The 12F675 based phase failure relay is "taught" the proper phase sequence during machine commissioning so that it does not trip. In case of phase failure or phase reversal it trips.
This is simply a low cost  "Single Phasing Preventor".
Regards
Shantanu

hitronics

Quote from: shantanu@india on Dec 02, 2022, 03:09 PMIn industrial applications, reverse motor rotation can damage machines. Single phasing can cause excessive current in the healthy phases and damage the motor winding. Both the above two conditions can have disastrous consequences.
The 12F675 based phase failure relay is "taught" the proper phase sequence during machine commissioning so that it does not trip. In case of phase failure or phase reversal it trips.
This is simply a low cost  "Single Phasing Preventor".

sure, it is important
so, next step we need to check connections for RYB and display them on led or lcd is there any example code?

shantanu@india

Sorry no. I developed this for Indian Railways as a back of panel module with a LED to indicate trip/healthy. The 'switch' input (not in code) can be used as sequence change input.
For display you need a bigger microcontroller
Regards
Shantanu

hitronics

I just want this part of code that MCU will know what phases that connected in any order and send result as serial data

hitronics

Which positions of three phases will be correct:

R-S-T
R-T-S
T-S-R
T-R-S
S-R-T
S-T-R

keytapper

IIRC is the first. But the fourth is just the same, only rotated one position.
Ignorance comes with a cost

shantanu@india

There can be only two phase sequences creating rotating magnetic fields in opposite directions
Regards
Shantanu