Hi,
I am writing a program to fire a six thyristor phase angle controlled bridge rectifier.
This is the sequence for forward rotation.
Fire thyristors 1 & 5, wait 60 degrees, fire 1 & 6, wait 60 degrees, fire 2 & 6, wait 60 degrees, fire 2 & 4, wait 60, fire 3 & 4, wait 60, fire 3 & 5.
There is a similar sequence for reverse, 1-6, 1-5, 2-4, 2-6, 3-5, 3-4.
Also each thyristor is given 5 pulses to make sure it has fired.
My code works fine, but it is very linear, and takes alot of code space.
The above is the code for firing the first two in the sequence of six, for forwards rotation. To fire all six, for both forward, and reverse will take six times as much code.Code:weldingfwd: 'welding routine for forward phase rotation if badweld = 1 then noweld pauseus thirtydeg pauseus angletime 'pause for required delay time low thy1 'fire first pair of thyristors low thy2 pauseus 200 high thy1 high thy2 pauseus 200 low thy1 low thy2 pauseus 200 high thy1 high thy2 pauseus 200 low thy1 low thy2 pauseus 200 high thy1 high thy2 pauseus 200 low thy1 low thy2 pauseus 200 high thy1 high thy2 pauseus 200 low thy1 low thy2 pauseus 200 high thy1 high thy2 temp = sixtydeg - 1800 ' take time firing thyristors from sixtydeg time pauseus temp ' and pause for required time low thy1 'then fire second pair low thy3 pauseus 200 high thy1 high thy3 pauseus 200 low thy1 low thy3 pauseus 200 high thy1 high thy3 pauseus 200 low thy1 low thy3 pauseus 200 high thy1 high thy3 pauseus 200 low thy1 low thy3 pauseus 200 high thy1 high thy3 pauseus 200 low thy1 low thy3 pauseus 200 high thy1 high thy3 return
I am using interrupts (Thanks Darrel) to start the firing sequence. INT0 to be precise.
I was wondering if anyone has any ideas to make the code more efficient, and elegant?
A freind suggested using capture compare, but I am struggling to find any basic information on the concepts of how CCP works.
Kind regards
Bob...
Bookmarks