Hi guys,
I have a little routine for checking a 3 phase supply that is connected to a transformer. You check the phase rotation using each phase as the reference in turn. If all 3 answers agree then the supply is ok, if any disagree then a phase is down. Here is the code
As you can see i'm no pic genius, and the code is a little messy.Code:mainstest:'check phase rotation, using each phase as the ref, if all fwd or rev 'then supply is ok, if any disagree then a phase is down let rot1 = 0 let rot2 = 0 let rot3 = 0 jmp0: if phase1 = 1 then jmp0 jmp5: if phase1 = 0 then jmp5 'wait for phase to go to beginning of a low cycle jmp6: if phase1 = 1 then jmp6 if phase2 = 1 then let rot1 = 1 ' if next phase is high then rotation is fwd 'now test with phase2 as ref jmp7: if phase2 = 1 then jmp7 jmp8: if phase2 = 0 then jmp8 jmp9: if phase2 = 1 then jmp9 if phase3 = 1 then let rot2 = 1 'now test with phase 3 as ref jmp13: if phase3 = 1 then jmp13 jmp14: if phase3 = 0 then jmp14 jmp15: if phase3 = 1 then jmp15 if phase1 = 1 then rot3 = 1 'now test to see if all 3 rotations are the same let temp = rot1 + rot2 + rot3 'rotations should all be 0 or 1 if (temp = 1) or (temp = 2) then 'so if a phase is down temp will be 1 or 2 high supply 'turn on supply fault led, and go check again pause 100 goto mainstest endif low supply return
The challenge is who can come up with the neatest, most efficient code?
As a prize the winner can give themselves a pat on the back
Regards
Bob...





Bookmarks