Re: Making code more efficient, any ideas please?
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.
How about a different approach...... sort of in pseudo code as I havent touched PicBasic for about 3 years and am a tad rusty to say the least !!!
If all the thyristors are on the same port, and you always need to fire two of the 6 at any time, then assuming 1-6 are connected to port.0 to port.5 repectively, you could write to the whole port in one hit
FwdStep 1 00010001 = 11H (Thys 5 + 1) = 17
FwdStep 2 00100001 = 21H (Thys 6 + 1) = 33
FwdStep 3 00100010 = 22H (Thys 6 + 2) = 34
FwdStep 4 00001010 = 0AH (Thys 4 + 2) = 10
FwdStep 5 00001100 = 0CH (Thys 4 + 3) = 12
FwdStep 6 00010100 = 14H (Thys 5 + 3) = 20
RevStep 1 00100001 = 21H (Thys 6 + 1) = 33
RevStep 2 00010001 = 11H (Thys 5 + 1) = 17
RevStep 3 00001010 = 0AH (Thys 4 + 2) = 10
RevStep 4 00100010 = 22H (Thys 6 + 2) = 34
RevStep 5 00010100 = 14H (Thys 5 + 3) = 20
RevStep 6 00001100 = 0CH (Thys 4 + 3) = 12
All thyristors off = 00000000 = 00H = 0
All you would need would be two arrays to hold the ON values for driving the thyristors
Forward 17,33,34,10,12,20
Reverse 33,17,10,34,20,12
Read the value for the current step and store it in a variable "portvalue" then a short loop to send the fire pulses
For Fire = 0 to 4
Port = portvalue ' set the respective pins high
pauseus 200
Port = 0 ' set all the pins low
pauseus 200
Next
get the next value from the array and repeat
This method also ensures that the 4 unused thyristors dont get a fire pulse.
Hopefully I understood what you want to do and that you understand what I am trying to say LOL
Keith
www.diyha.co.uk
www.kat5.tv
Bookmarks