Making code more efficient, any ideas please?


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: Making code more efficient, any ideas please?

    Like Bruce said, be careful when using successive High/Lows on adjacent pins. If they're not adjacent, maybe you could find some interesting of DT Virtual Port?

    A Lookup table in codespace or EEPROM is probably the mosty efficient solution.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  2. #2
    Join Date
    Feb 2003
    Posts
    432


    Did you find this post helpful? Yes | No

    Default 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

  3. #3
    Join Date
    Feb 2005
    Location
    Holmfirth England
    Posts
    116


    Did you find this post helpful? Yes | No

    Default Re: Making code more efficient, any ideas please?

    Hi,

    Thank you all for your replies. This gives me something to work on.

    Regards
    Bob.

Members who have read this thread : 0

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts