Temp variables exceeding LastTvar "Increase the MaxTvars constant"


+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,973

    Default Temp variables exceeding LastTvar "Increase the MaxTvars constant"

    I get that error with this IF:

    Code:
        IF (UsartFlag = 1)            and _
           (RecvData[0] = UsartRight) and _
           (RecvData[1] = UsartSlave) and _
           (RecvData[2] = Usart0)     and _
           (RecvData[3] = UsartC)     and _
           (RecvData[4] = Usart2)     then
            GOSUB DisplayCOM1
            UsartFlag = 0
        endif

    The error goes away if I bump up MaxTvars to 6 in ReEnterPBP.bas.

    Was that the proper thing to do? Or will that cause more problems down the road?

    (I would think not, but just making sure)
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,514


    Did you find this post helpful? Yes | No

    Default Re: Temp variables exceeding LastTvar "Increase the MaxTvars constant"

    try array read

    Code:
       
     IF (UsartFlag = 1) then        
             ARRAYREAD RecvData,5,ndisp,[wait(UsartRight,UsartSlave,Usart0,UsartC,Usart2)]
             GOSUB DisplayCOM1
             ndisp:
             UsartFlag = 0
     endif
    Warning I'm not a teacher

  3. #3
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,973


    Did you find this post helpful? Yes | No

    Default Re: Temp variables exceeding LastTvar "Increase the MaxTvars constant"

    Quote Originally Posted by richard View Post
    try array read ...
    Thanks, it works perfect with MaxTvars CON 4 now.


    Code:
        IF (UsartFlag = 1) then        
             ARRAYREAD RecvData,5,MainloopContinue1,[wait(UsartRight,UsartSlave,Usart0,UsartC,Usart2)]
             GOSUB DisplayCOM1
             UsartFlag = 0
           MainloopContinue1:
        endif
    
        IF (UsartFlag = 1) then        
             ARRAYREAD RecvData,5,MainloopContinue2,[wait(UsartRight,UsartSlave,Usart0,UsartC,Usart3)]
             GOSUB DisplayCOM1_Standby
             UsartFlag = 0
           MainloopContinue2:
        endif
    
        IF (UsartFlag = 1) then        
             ARRAYREAD RecvData,5,MainloopContinue3,[wait(UsartRight,UsartSlave,Usart0,UsartE,Usart2)]
             GOSUB DisplayCOM2
             UsartFlag = 0
           MainloopContinue3:
        endif
    
        IF (UsartFlag = 1) then        
             ARRAYREAD RecvData,5,MainloopContinue4,[wait(UsartRight,UsartSlave,Usart0,UsartE,Usart3)]
             GOSUB DisplayCOM2_Standby
             UsartFlag = 0
           MainloopContinue4:
        endif
    
        IF (UsartFlag = 1) then        
             ARRAYREAD RecvData,5,MainloopContinue5,[wait(UsartRight,UsartSlave,Usart0,UsartD,Usart2)]
             GOSUB DisplayNAV1
             UsartFlag = 0
           MainloopContinue5:
        endif
    
        IF (UsartFlag = 1) then        
             ARRAYREAD RecvData,5,MainloopContinue6,[wait(UsartRight,UsartSlave,Usart0,UsartD,Usart3)]
             GOSUB DisplayNAV1_Standby
             UsartFlag = 0
           MainloopContinue6:
        endif
    
        IF (UsartFlag = 1) then        
             ARRAYREAD RecvData,5,MainloopContinue7,[wait(UsartRight,UsartSlave,Usart0,UsartF,Usart2)]
             GOSUB DisplayNAV2
             UsartFlag = 0
           MainloopContinue7:
        endif
    
        IF (UsartFlag = 1) then        
             ARRAYREAD RecvData,5,MainloopContinue8,[wait(UsartRight,UsartSlave,Usart0,UsartF,Usart3)]
             GOSUB DisplayNAV2_Standby
             UsartFlag = 0
           MainloopContinue8:
        endif
    (add another PBP command to the list of stuff I never tried before).
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  4. #4
    Join Date
    May 2013
    Location
    australia
    Posts
    2,514


    Did you find this post helpful? Yes | No

    Default Re: Temp variables exceeding LastTvar "Increase the MaxTvars constant"

    it could simplify further

    Code:
     IF (UsartFlag = 1) then  
            ARRAYREAD RecvData,5,itsadud,[wait(UsartRight,UsartSlave,Usart0)]
     select case RecvData[3]
     case UsartC
        IF RecvData[4] == Usart2 THEN
          GOSUB  GOSUB DisplayCOM1
          else
          GOSUB  GOSUB DisplayCOM1_Standby
        endif
    case UsartD
        IF RecvData[4] == Usart2 THEN
          GOSUB  GOSUB DisplayCOM2
          else
          GOSUB  GOSUB DisplayCOM2_Standby
        endif
    case UsartE
        IF RecvData[4] == Usart2 THEN
          GOSUB  GOSUB DisplayNAV1
          else
          GOSUB  GOSUB DisplayNAV1_Standby
        endif
    case UsartF
        IF RecvData[4] == Usart2 THEN
          GOSUB  GOSUB DisplayNAV2
          else
          GOSUB  GOSUB DisplayNAV2_Standby
        endif
    end select
    itsadud: 
    UsartFlag = 0
    endif
    Warning I'm not a teacher

  5. #5
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,973


    Did you find this post helpful? Yes | No

    Default Re: Temp variables exceeding LastTvar "Increase the MaxTvars constant"

    Quote Originally Posted by richard View Post
    it could simplify further...
    Definitely, but I'm not finished adding conditions.

    I really like your original ArrayRead suggestion; it'll be easy to keep expanding new record layouts (sorry, old mainframe habits ).
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  6. #6
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,988


    Did you find this post helpful? Yes | No

    Default Re: Temp variables exceeding LastTvar "Increase the MaxTvars constant"

    Quote Originally Posted by richard View Post
    try array read

    Code:
       
     IF (UsartFlag = 1) then        
             ARRAYREAD RecvData,5,ndisp,[wait(UsartRight,UsartSlave,Usart0,UsartC,Usart2)]
             GOSUB DisplayCOM1
             ndisp:
             UsartFlag = 0
     endif
    Can't help it. Very clever programming!

    Ioannis

  7. #7
    Join Date
    May 2013
    Location
    australia
    Posts
    2,514


    Did you find this post helpful? Yes | No

    Default Re: Temp variables exceeding LastTvar "Increase the MaxTvars constant"

    I really like your original ArrayRead suggestion; it'll be easy to keep expanding new record layouts (sorry, old mainframe habits ).
    i did a little test , your way is 4 times bigger code and executes upto 10 times slower

    Code:
    #CONFIG    __config _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT32 & _CLKOUTEN_OFF & _CSWEN_OFF & _FCMEN_ON
        __config _CONFIG2, _MCLRE_ON & _PWRTE_OFF & _LPBOREN_OFF & _BOREN_ON & _BORV_LO & _ZCD_OFF & _PPS1WAY_OFF & _STVREN_ON & _DEBUG_OFF
        __config _CONFIG3, _WDTCPS_WDTCPS_11 & _WDTE_ON & _WDTCWS_WDTCWS_7 & _WDTCCS_LFINTOSC
        __config _CONFIG4, _WRT_OFF & _SCANE_available & _LVP_ON
        __config _CONFIG5, _CP_OFF & _CPD_OFF
    #ENDCONFIG
     DEFINE OSC 32
     include "codesize.pbp"
        define Measure 1
        DEFINE DEBUG_REG PORTB
        DEFINE DEBUG_BIT 7
        DEFINE DEBUG_BAUD 9600
        DEFINE DEBUG_MODE 0
        PORTB.7 = 1 
        trisb=%01100111
        anselb=0
     
     UsartFlag    var byte
     RecvData     var byte[5]
     CNTr VAR BYTE
     UsartRight   con 1
     UsartSlave   con 2
     Usart0       con 3
     UsartC       con 1
     UsartE       con 2
     UsartD       con 3
     UsartF       con 4
     Usart2       con 0
     Usart3       con 5
     
     cntr=10
     RecvData[0]=UsartRight
     RecvData[1]=UsartSlave
     RecvData[2]=Usart0 
     DEBUG 13,10,"go" 
       
     LOOOP:
     pause 500
     UsartFlag = 1
     RecvData[3]= cntr dig 1
     RecvData[4]= cntr dig 0
     cntr=cntr+5
     if  cntr = 50 then  cntr=10
     DEBUG 13,10, #cntr 
     latb.4=1
     @ StartSize(rc)
    '    IF (UsartFlag = 1) then  
    '        ARRAYREAD RecvData,5,itsadud,[wait(UsartRight,UsartSlave,Usart0)]
    '        select case RecvData[3]
    '            case UsartC
    '                IF RecvData[4] == Usart2 THEN
    '                    GOSUB   DisplayCOM1
    '                else
    '                    GOSUB   DisplayCOM1_Standby
    '                endif
    '            case UsartD
    '                IF RecvData[4] == Usart2 THEN
    '                    GOSUB   DisplayCOM2
    '                else
    '                    GOSUB   DisplayCOM2_Standby
    '                endif
    '            case UsartE
    '                IF RecvData[4] == Usart2 THEN
    '                    GOSUB   DisplayNAV1
    '                else
    '                    GOSUB   DisplayNAV1_Standby
    '                endif
    '            case UsartF
    '                IF RecvData[4] == Usart2 THEN
    '                    GOSUB   DisplayNAV2
    '                else
    '                    GOSUB   DisplayNAV2_Standby
    '                endif
    '        end select
    '        itsadud: 
    '        UsartFlag = 0
    '    endif
         
        IF (UsartFlag = 1) then        
             ARRAYREAD RecvData,5,MainloopContinue1,[wait(UsartRight,UsartSlave,Usart0,UsartC,Usart2)]
             GOSUB DisplayCOM1
             UsartFlag = 0
           MainloopContinue1:
        endif
    
    
        IF (UsartFlag = 1) then        
             ARRAYREAD RecvData,5,MainloopContinue2,[wait(UsartRight,UsartSlave,Usart0,UsartC,Usart3)]
             GOSUB DisplayCOM1_Standby
             UsartFlag = 0
           MainloopContinue2:
        endif
    
    
        IF (UsartFlag = 1) then        
             ARRAYREAD RecvData,5,MainloopContinue3,[wait(UsartRight,UsartSlave,Usart0,UsartE,Usart2)]
             GOSUB DisplayCOM2
             UsartFlag = 0
           MainloopContinue3:
        endif
    
    
        IF (UsartFlag = 1) then        
             ARRAYREAD RecvData,5,MainloopContinue4,[wait(UsartRight,UsartSlave,Usart0,UsartE,Usart3)]
             GOSUB DisplayCOM2_Standby
             UsartFlag = 0
           MainloopContinue4:
        endif
    
    
        IF (UsartFlag = 1) then        
             ARRAYREAD RecvData,5,MainloopContinue5,[wait(UsartRight,UsartSlave,Usart0,UsartD,Usart2)]
             GOSUB DisplayNAV1
             UsartFlag = 0
           MainloopContinue5:
        endif
    
    
        IF (UsartFlag = 1) then        
             ARRAYREAD RecvData,5,MainloopContinue6,[wait(UsartRight,UsartSlave,Usart0,UsartD,Usart3)]
             GOSUB DisplayNAV1_Standby
             UsartFlag = 0
           MainloopContinue6:
        endif
    
    
        IF (UsartFlag = 1) then        
             ARRAYREAD RecvData,5,MainloopContinue7,[wait(UsartRight,UsartSlave,Usart0,UsartF,Usart2)]
             GOSUB DisplayNAV2
             UsartFlag = 0
           MainloopContinue7:
        endif
    
    
        IF (UsartFlag = 1) then        
             ARRAYREAD RecvData,5,MainloopContinue8,[wait(UsartRight,UsartSlave,Usart0,UsartF,Usart3)]
             GOSUB DisplayNAV2_Standby
             UsartFlag = 0
           MainloopContinue8:
        endif
    @ EndSize(rc) 
    latb.4=0
    GOTO LOOOP   
        
    DisplayCOM1: 
    DisplayCOM1_Standby:
    DisplayCOM2: 
    DisplayCOM2_Standby:    
    DisplayNAV1: 
    DisplayNAV1_Standby: 
    DisplayNAV2: 
    DisplayNAV2_Standby:
       DEBUG  " ",#RecvData[3]," ",#RecvData[4]
    RETURN
    Warning I'm not a teacher

  8. #8
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,973


    Did you find this post helpful? Yes | No

    Default Re: Temp variables exceeding LastTvar "Increase the MaxTvars constant"

    Quote Originally Posted by richard View Post
    i did a little test , your way is 4 times bigger code and executes upto 10 times slower...
    Note to self, revisit this thread later.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  9. #9
    Join Date
    May 2013
    Location
    australia
    Posts
    2,514


    Did you find this post helpful? Yes | No

    Default Re: Temp variables exceeding LastTvar "Increase the MaxTvars constant"

    timestamps as used on mainframes/unix etc are imho the simplest,easiest and most efficient way to measure time periods accurately. they work marvelously on pic micros too, i have tried to demonstrate their usage on this and the other forum many times. the amount of interest generated was approximately nil.
    see this [read through to end]

    https://support.melabs.com/forum/pic...ond-pass/page2

    timestamps can take whatever form required to suit your needs and are infinitely adaptable
    Warning I'm not a teacher

Similar Threads

  1. "Stretching" a byte variable into two byte variables?
    By CuriousOne in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 25th October 2021, 00:48
  2. How to do the "SerIN" and "SerOut " for the usb ?
    By vicce67 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 13th March 2015, 03:01
  3. Replies: 0
    Last Post: - 14th November 2013, 04:32
  4. Replies: 3
    Last Post: - 15th October 2012, 09:06
  5. Message (Temp variables exceeding T7) ?
    By circuitpro in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 31st December 2011, 19:54

Members who have read this thread : 7

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