Code Compatibility Issue


Results 1 to 22 of 22

Threaded View

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


    Did you find this post helpful? Yes | No

    Default

    Let's see if i remove my usual 'code template' from and try to format the code a little bit... i've never read/check it carefully if it make sense so far... at least, no compilation error.
    Code:
    <font color="#000000">        TRISA   = 0
            TRISB   = 2
            CMCON   = 7
            ADCON1  = 15
            ADCON0  = 0
            
            Ground_1    <font color="#000080">VAR </font>PortB.0
            Ground_2    <font color="#000080">VAR </font>PortB.3
            Lame_1      <font color="#000080">VAR </font>PortB.2
            Lame_2      <font color="#000080">VAR </font>PortB.5
            LED_1       <font color="#000080">VAR </font>PortB.6
            LED_2       <font color="#000080">VAR </font>PortB.7
            Off_1       <font color="#000080">VAR </font>PortA.0
            Off_2       <font color="#000080">VAR </font>PortA.2
            On_1        <font color="#000080">VAR </font>PortA.1
            On_2        <font color="#000080">VAR </font>PortA.3
            Positive_1  <font color="#000080">VAR </font>PortB.1
            Positive_2  <font color="#000080">VAR </font>PortB.4
            Speaker     <font color="#000080">VAR </font>PortA.4
            Switch      <font color="#000080">VAR </font>PortA.5
            
            Cal                 <font color="#000080">VAR BYTE
            </font>Ground_Lame_1       <font color="#000080">VAR BIT
            </font>Ground_Lame_2       <font color="#000080">VAR BIT
            </font>Lockout             <font color="#000080">VAR WORD
            </font>Lockout_Cal         <font color="#000080">VAR WORD
            </font>On1_Flag            <font color="#000080">VAR BIT
            </font>Off1_Flag           <font color="#000080">VAR BIT
            </font>On2_Flag            <font color="#000080">VAR BIT
            </font>Off2_Flag           <font color="#000080">VAR BIT
            </font>PG1_Count           <font color="#000080">VAR BYTE
            </font>PG2_Count           <font color="#000080">VAR BYTE
            </font>PL1_Count           <font color="#000080">VAR BYTE
            </font>PL2_Count           <font color="#000080">VAR BYTE
            </font>Positive_Bell_1     <font color="#000080">VAR BIT
            </font>Positive_Bell_2     <font color="#000080">VAR BIT
            </font>Positive_Ground_1   <font color="#000080">VAR BIT
            </font>Positive_Ground_2   <font color="#000080">VAR BIT
            </font>Positive_Lame_1     <font color="#000080">VAR BIT
            </font>Positive_Lame_2     <font color="#000080">VAR BIT
            
            
            </font>Cal=18
            Lockout_Cal=373
            <font color="#000080">HIGH </font>On_1
            <font color="#000080">PAUSE </font>500
            <font color="#000080">LOW </font>On_1
            
            <font color="#000080">HIGH </font>Off_1
            <font color="#000080">PAUSE </font>500
            <font color="#000080">LOW </font>Off_1
    
            <font color="#000080">HIGH </font>Off_2
            <font color="#000080">PAUSE </font>500
            <font color="#000080">LOW </font>Off_2
            
            <font color="#000080">HIGH </font>On_2
            <font color="#000080">PAUSE </font>500
            <font color="#000080">LOW </font>On_2
            
            <font color="#000080">INPUT </font>Lame_1
            <font color="#000080">INPUT </font>Lame_2
            
    Foil:
            <font color="#000080">INPUT </font>Positive_1
            <font color="#000080">INPUT </font>Positive_2
            <font color="#000080">INPUT </font>Ground_1
            <font color="#000080">INPUT </font>Ground_2
            <font color="#000080">HIGH </font>Positive_1
            Positive_Ground_1=Ground_1
            Positive_Lame_1=Lame_2
            Positive_Bell_1=Ground_2
            <font color="#000080">LOW </font>Positive_1
            <font color="#000080">INPUT </font>Positive_1
            <font color="#000080">INPUT </font>Positive_2
            <font color="#000080">INPUT </font>Ground_1
            <font color="#000080">INPUT </font>Ground_2
            <font color="#000080">HIGH </font>Positive_2
            Positive_Ground_2=Ground_2
            Positive_Lame_2=Lame_1
            Positive_Bell_2=Ground_1
            <font color="#000080">LOW </font>Positive_2
            <font color="#000080">INPUT </font>Positive_2
            <font color="#000080">HIGH </font>Ground_1
            Ground_Lame_1=Lame_1
            <font color="#000080">LOW </font>Ground_1
            <font color="#000080">INPUT </font>Ground_1
            <font color="#000080">HIGH </font>Ground_2
            Ground_Lame_2=Lame_2
            <font color="#000080">LOW </font>Ground_2
            
            <font color="#000080">IF </font>(Positive_Ground_1 = 0) <font color="#000080">AND </font>(Positive_Bell_1 = 0) <font color="#000080">THEN
                    </font>PG1_Count = PG1_Count + 1
                    <font color="#000080">ELSE
                        </font>PG1_Count = 0
                    <font color="#000080">ENDIF
            
            IF </font>(Positive_Ground_2 = 0) <font color="#000080">AND </font>(Positive_Bell_2 = 0) <font color="#000080">THEN
                    </font>PG2_Count = PG2_Count + 1
                    <font color="#000080">ELSE
                        </font>PG2_Count = 0
                    <font color="#000080">ENDIF
                    
            IF </font>(Positive_Lame_1 = 1) <font color="#000080">AND </font>(Positive_Ground_1 = 0) <font color="#000080">THEN
                    </font>PL1_Count = PL1_Count + 1
                    <font color="#000080">ELSE
                        </font>PL1_Count = 0
                    <font color="#000080">ENDIF
                    
            IF </font>(Positive_Lame_2 = 1) <font color="#000080">AND </font>(Positive_Ground_2 = 0) <font color="#000080">THEN
                    </font>PL2_Count = PL2_Count + 1
                    <font color="#000080">ELSE
                        </font>PL2_Count = 0
                    <font color="#000080">ENDIF
            
            IF </font>PL1_Count =&gt; Cal <font color="#000080">THEN
                    HIGH </font>On_1 
                    On1_Flag = 1
                    <font color="#000080">ENDIF
                    
            IF </font>PL2_Count =&gt; Cal <font color="#000080">THEN
                    HIGH </font>On_2 
                    On2_Flag = 1
                    <font color="#000080">ENDIF
                    
            IF </font>(PG1_Count =&gt; Cal) <font color="#000080">AND </font>(PL1_Count &lt; Cal) <font color="#000080">THEN
                    HIGH </font>Off_1 : Off1_Flag = 1
                    <font color="#000080">ENDIF
                    
            IF </font>(PG2_Count =&gt; Cal) <font color="#000080">AND </font>(PL2_Count &lt; Cal) <font color="#000080">THEN
                    HIGH </font>Off_2 
                    <font color="#000080">LET </font>Off2_Flag = 1
                    <font color="#000080">ENDIF
                    
            </font>LED_1 = Ground_Lame_1 
            LED_2 = Ground_Lame_2
            
            <font color="#000080">IF </font>(On1_Flag = 1) <font color="#000080">OR </font>(Off2_Flag = 1) <font color="#000080">OR </font>(On2_Flag = 1) <font color="#000080">OR </font>(Off1_Flag = 1) <font color="#000080">THEN
                    </font>Lockout = Lockout + 1
                    <font color="#000080">ELSE
                        </font>Lockout = 0
                    <font color="#000080">ENDIF
            
            IF </font>Lockout =&gt; Lockout_Cal <font color="#000080">THEN
                    PAUSE </font>2000 
                    <font color="#000080">LOW </font>On_1 
                    <font color="#000080">LOW </font>On_2 
                    <font color="#000080">LOW </font>Off_1 
                    <font color="#000080">LOW </font>Off_2 
                    On1_Flag = 0 
                    On2_Flag = 0 
                    Off1_Flag = 0  
                    Off2_Flag = 0        
                    <font color="#000080">ENDIF
            
            GOTO </font>Foil
            <font color="#000080">END
    </font>
    now comments, code section, steps should fit
    Last edited by mister_e; - 6th July 2007 at 19:12.
    Steve

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

Similar Threads

  1. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 21:31
  2. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  3. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  4. Code Issue - select case or 'if' issue - not sure why
    By jamie_s in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 7th October 2007, 08:52
  5. Code Issue? - Pin Labels
    By jamie_s in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 12th July 2006, 16:28

Members who have read this thread : 0

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

Posting Permissions

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