Menu

Strange Error message from GCBIDE

Help
2016-01-28
2016-01-30
  • Edward LaBudde

    Edward LaBudde - 2016-01-28

    Hi all I am getting an error message that looks like this:
    Internal Error type of Var three times in a row, yet it goes ahead an compiles the file OK. Can someone tell me what to look for? Thanks, Ed.

     
  • Anobium

    Anobium - 2016-01-28

    Not seen this one. Can you post or send me the source?

     
  • Edward LaBudde

    Edward LaBudde - 2016-01-28

    ~~~~
    'Chip model

    chip 18F4455, 40

    'Configure Usart

    define USART_BAUD_RATE 2400

    define USART_BLOCKING 'Used for multiple Bytes -Does not seem to matter if on or off

    INITUSART 'Must be used to enable Interrupt to work

    'Set inital parameters
    InitSer 1, r9600, 1, 8, 1, none, invert 'LCD interface Positive going Standby bit 9600 baud
    'Set Pin directios
    Dir PortA.0 In 'pin19 TGen
    Dir PortA.1 In 'pin2 BATV
    Dir PortA.2 In 'pin21 S1A
    Dir PortA.3 In 'pin22 Vref
    Dir PortA.4 Out 'pin23 LED
    Dir PortA.5 In 'Pin24 S2A
    Dir PortE.0 In 'pin25 WindA
    Dir PortE.1 In 'pin26 TEGA
    Dir PortE.2 In 'pin27 SpareA
    Dir PortC.0 Out 'pin32 Test
    'RD3 41 Spare I/O 'SpareI/o
    Dir PortC.6 Out 'pin44 Tx data
    Dir PortC.7 In 'pin1 RxData
    Dir PortD.5 Out 'pin3 T/r
    Dir PortD.6 Out 'pin4 LCD
    Dir PortB.0 In 'pin8 SpareV
    Dir PortB.2 In 'pin10 RSSI
    Dir PortB.3 In 'pin11 INT_Temp
    Dir PortB.4 In 'pin14 EXT_temp
    Dir PortD.5 Out 'T/R pin #3
    Dir PortC.6 Out 'Tx Data out pin #44
    'Set Dimentions
    Dim Solar1A as word
    Dim Solar2A as word
    Dim WindA as word
    Dim TEGA as word
    Dim BattAVG as word
    Dim ReceiverDelay as word
    Dim S1_Amp as word
    Dim S1_Amp_sample as word
    Dim Solar1A as word
    Dim S2_Amp as word
    Dim S2_amp_sample as word
    Dim Solar2A as word
    Dim WindA_Amp as word
    Dim WindA_Amp_sample as word
    Dim WindA as word
    Dim TEGA_Amp as word
    dim TEGA_amp_sample as word
    Dim TEGA as word
    Dim TGen_V as word
    Dim Tgen_Volt_sample as word
    Dim BattAVG_volt as word
    Dim BattAVG_Volt_sample as word
    Dim BattAVG as word
    Dim SpareV_Volt as word
    Dim SpareV_Volt_sample as word
    Dim ReceiverDelay as word
    Dim ETimeHrs as word
    Dim S1TimeHrs as word
    Dim S2TimeHrs as word
    Dim WindTimeHrs as word
    Dim TEGTimeHrs as word
    Dim INT_Temp as word
    Dim EXT_temp as word
    Dim A_Limit as word
    Dim EXT_Temp_min As word
    Dim EXT_Temp_max as word
    Dim INT_Temp_min As word
    Dim INT_Temp_max as word
    Dim ETS1_hrs as word
    Dim ETS2_hrs as word
    Dim ETW_hrs as word
    Dim ETT_hrs as word

    'set defines

    define SendAHigh Set PORTD.6 Off 'Note Polarity for 4X20 Newhaven display

    define SendALow Set PORTD.6 On

    Define LED PortA.4

    define T/R PortD.5 'Transmitter On/Off High = Receive

    Set T/R = On 'Set to receive

    'Init variables
    ReceiverDelay = 4945 'Must be 4150 >= ReceiverDelay <= 5810, Avg = 4980, Geo = 4910, use 4945
    E_timesec = 0 'Zero Elapsed times
    E_timemin = 0
    E_timehrs = 0
    E_timeDay = 0
    ETS1_sec = 0
    ETS1_min = 0
    ETS1_Hrs = 0
    ETW_sec = 0
    ETW_min = 0
    ETW_hrs = 0
    ETT_sec = 0
    ETT_min = 0
    ETT_hrs = 0
    A_Limit = 100
    INT_Temp_min = 1023
    INT_Temp_max = 0
    EXT_Temp_min = 1023
    EXT_Temp_max = 0
    Temp_OS = 80

    'Read Offset data
    EPRead 251, S1A_OS
    EPRead 252, S2A_OS
    EPRead 253, WA_OS
    EPRead 254, TA_OS
    EPRead 255, SPRA_OS

    Start: 'Main program
    Call Blink 'Blink LED on sample Verified 07-24-09
    Call Sample 'Measure amps and volts Verified 05-05-10
    Call Elapsed_time 'Calculate time from start Verified 07-26-09
    Call Elapsed_time_S1 'ETime solar 1
    Call Elapsed_time_S2 'ETime solar 2
    Call Elapsed_time_Wind 'ETime Wind
    Call Elapsed_time_TEG 'ETime TEG
    Call Scale 'Calulate offset and full scale
    Call Display 'Display data on LCD Verified 05-06-10
    If ETimeHrs = % 6 and ETimesec = 0 then Call Store 'Store data to EEPROM Verified 05-06-10
    If ETimeHrs = % 6 and ETimesec = 0 then Call Send 'Tx data to cabin
    wait 721 ms 'Set sample time Verified 05-07-10
    Goto Start 'start over

    Sub Blink 'Blink on sample
    set LED on
    wait 1 ms
    set LED Off
    Return

    Sub Sample
    'Amps
    S1A_Amp_sample = readAD10(AN2) '(Amps)
    S2A_Amp_sample = readAD10(AN4)
    WindA_Amp_sample = readAD10(AN5)
    SpareA_Amp_Sample =readAD10(AN7)
    TEGA_Amp_sample = readAD10(AN6)
    'Volts
    TGen_Volt_sample = readAD10(AN0) '(Volts)
    BattAvg_Volt_sample = readAD10(AN1)
    SpareV_Volt_sample = readAD10(AN12)
    'Amp calculations
    IF S1A_Amp_sample > A_Limit Then S1A_Amp= (S1A_Amp + S1A_Amp_sample)/2
    If S2A_Amp_sample > A_Limit Then S2A_Amp=(S2A_Amp+ S12_Amp_sample)/2
    If WindA_Amp_sample > A_Limit then WindA_Amp= (WindA_Amp +WindA_Amp_sample)/2
    If TEGA_Amp_sample > A_Limit then TEGA_Amp = (TEGA_Amp + TEGA_Amp_sample)/2
    If TEGA_Amp_sample > A_Limit then TEG_Volt = (TEG_Volt + TEG_Volt_sample)/2
    If SpareA_Amp_sample > A_Limit then SPRA_Amp = (SPRA_Amp +SPAREA_Amp_sample)/2

    'Volt calculations
    If TEGA_Amp_sample > A_Limit then TGen_Volt = (TGen_Volt + TGen_Volt_sample)/2
    BattAvg _Volt = (BattAvg _Volt + BattAvg _Volt_sample)/2
    BattAvg = BattAvg_Volt
    SpareV_Volt = (SpareV_Volt + SpareV_Volt_sample)/2
    ' Temp calculation
    INT_Temp_sample = readAD10(AN9)
    EXT_Temp_sample = readAD10(AN11)
    INT_Temp = (INT_Temp + INT_Temp_sample)/2
    EXT_Temp = (EXT_Temp + EXT_Temp_sample)/2
    If INT_Temp > INT_Temp_max then INT_Temp_max = INT_Temp
    If EXT_Temp > EXT_Temp_max then EXT_Temp_max = EXT_Temp
    If INT_Temp < INT_Temp_Min then INT_Temp_min = INT_Temp
    If EXT_Temp < EXT_Temp_min then EXT_Temp_min = EXT_Temp
    

    Return

    Sub Elapsed_time
    E_timesec += 1 'Seconds
    If E_timesec = 60 then
    E_timesec = 0
    E_timemin += 1 'Minutes
    end if
    If E_timemin = 60 then
    E_timemin = 0
    E_timehrs += 1 'Hours
    end if
    If E_timehrs = 24 then
    E_timehrs = 0
    E_timeday += 1 'Days
    E_timeday_display +=1
    end if
    If E_timeday = 7 then
    E_timeday = 0
    E_timewks += 1 'Weeks max is 255
    end if
    Return

    Sub Elapsed_time_S1
    If S1A_Amp > A_limit Then ETS1_sec +=1
    If ETS1_sec =60 then
    ETS1_sec = 0
    ETS1_min +=1
    End If
    If ETS1_min = 60 then
    ETS1_min = 0
    ETS1_hrs +=1
    End If

    Return

    Sub Elapsed_time_S2
    If S2A_Amp > A_limit Then ETS2_sec +=1
    If ETS2_sec =60 then
    ETS2_sec = 0
    ETS2_min +=1
    End If
    If ETS2_min = 60 then
    ETS2_min = 0
    ETS2_hrs +=1
    End If

    Return

    Sub Elapsed_time_Wind
    If WindA_Amp> A_limit Then ETW_sec +=1
    If ETW_sec =60 then
    ETW_sec = 0
    ETW_min +=1
    End If
    If ETW_min = 60 then
    ETW_min = 0
    ETW_hrs +=1
    End If

    Return

    Sub Elapsed_time_TEG
    If TEGA_Amp> A_limit Then ETT_sec +=1
    If ETT_sec =60 then
    ETT_sec = 0
    ETT_min +=1
    End If
    If ETT_min = 60 then
    ETT_min = 0
    ETT_hrs +=1
    End If

    Return

    Sub Scale
    S1A_Amp = (S1A_Amp - S1A_OS)1023/(1023-S1A_OF)15
    S2A_Amp = (S2A_Amp - S2A_OS)1023/(1023-S2A_OF)15
    WindA_Amp = (WindA_Amp - WA_A_OS)1023/(1023-WA_OF)15
    TEGA_Amp = (TEGA_Amp - TA_OS)1023/(1023-TA_OF)15
    SPRA_Amp = (SPRA_Amp-SPR_OF)1023/(1023-SPRA_OF)15
    ReadTable Tconvert, INT_Temp, AmbientTemp 'Look up temeperature value
    AmbientT = AmbientTemp - Temp_OS 'Correct for lack of negative numbers in table and cal sensor
    ReadTable Tconvert, INT_Temp_max, AmbientTempMax 'Look up temeperature value
    ReadTable Tconvert, INT_Temp_min, INTTemp_min 'Look up temeperature value
    AmbientTmin = INTTemp_min - Temp_OS 'Correct for lack of negative numbers in table and cal sensor
    AmbientTmax = AmbientTempMax - Temp_OS 'Correct for lack of negative numbers in table and cal sensor
    ReadTable Tconvert, EXT_Temp, ExternalTemp 'Look up temeperature value
    ExternalT = ExternalTemp - Temp_OS 'Correct for lack of negative numbers in table and cal sensor
    ReadTable Tconvert, EXT_Temp_min, EXTTemp_min 'Look up temeperature value
    ExternalTT_min= EXTTemp_min - Temp_OS 'Correct for lack of negative numbers in table and cal sensor
    ReadTable Tconvert, EXT_Temp_max, EXTTemp_Max 'Look up temeperature value
    ExternalT_max = EXTTemp_Max - Temp_OS 'Correct for lack of negative numbers in table and cal sensor
    Return

    Sub Send
    Solar1A = S1A_amp
    Solar2A = S2A_amp
    WindA = WindA_Amp
    TEGA = TEGA_Amp
    S1TimeHrs = ETS1_hrs
    S2TimeHrs = ETS2_hrs
    WindTimeHrs = ETW_hrs
    TEGTimeHrs = ETT_hrs
    Call SendData
    Return

    Sub SendData 'Request status in Diag Mode
    Call SendCRC 'Caculate CRC
    Set SPEN = Off 'Turn Usart off
    Set T/R = Off 'Turn Off Rx turn on Tx
    wait 1000 us 'Transmitter delay Typical = 490 us
    pulseout PortC.6, 12 ms 'Init Reciever
    Set SPEN = On 'Turn Usart on
    HserPrint Solar1A_h
    HserPrint Solar1A
    HserPrint Solar2A_h
    HserPrint Solar2A
    HserPrint WindA_h
    HserPrint WindA
    HserPrint TEGA_h
    HserPrint TEGA
    HserPrint BattAVG_h
    HserPrint BattAVG
    HserPrint ETimeHrs_h
    HserPrint ETimeHrs
    HserPrint S1TimeHrs_h
    HserPrint S1TimeHrs
    HserPrint S2TimeHrs_h
    HserPrint S2TimeHrs_h
    HserPrint WindTimeHrs_h
    HserPrint WindTimeHrs
    HserPrint TEGTimeHrs_h
    HserPrint TEGTimeHrs
    HserPrint CRC
    Wait 9890 us 'To allow last two bytes Tx
    Set T/R = On 'Turn off Tx turn on Rx
    set CREN = On 'Turn Receiver On
    wait 400 us 'Receiver delay Typical = 180 us
    Return

    Sub SendCRC
    CRC = 0
    NewCRCByte = Solar1A_h
    Call CRC8
    NewCRCByte = Solar1A
    call CRC8
    NewCRCByte = Solar2A_h
    call CRC8
    NewCRCByte = Solar2
    call CRC8
    NewCRCByte = WindA_h
    call CRC8
    NewCRCByte = WindA
    call CRC8
    NewCRCByte = TEGA_h
    Call CRC8
    NewCRCByte = TEGA
    CAll CRC8
    NewCRCByte = BattAVG_h
    Call CRC8
    NewCRCByte = BattAVG
    Call CRC8
    NewCRCByte = ETimeHrs_h
    Call CRC8
    NewCRCByte = ETimeHrs
    Call CRC8
    NewCRCByte = S1TimeHrs_h
    Call CRC8
    NewCRCByte = S1TimeHrs
    Call CRC8
    NewCRCByte = S2TimeHrs_h
    Call CRC8
    NewCRCByte = S2TimeHrs
    Call CRC8
    NewCRCByte = WindTimeHrs_h
    Call CRC8
    NewCRCByte = WindTimeHrs
    Call CRC8
    NewCRCByte = TEGTimeHrs_h
    Call CRC8
    NewCRCByte = TEGTimeHrs
    Call CRC8

    Return

    Sub CRC8 'CRC calculator
    CRC = CRC XOR NewCRCByte
    Repeat 8 'repeat = 16.18 us CRC = 24 for/next = 20.98 us CRC = 24
    IF CRC.0 = On Then 'is low bit set?
    Set C = Off 'clear carry bit
    Rotate CRC Right
    CRC = CRC XOR h'8C' 'use reflected polynomial
    ELSE
    Set C = Off 'clear carry bit
    Rotate CRC Right
    End If
    End Repeat
    End Sub

    Sub Display
    Call Clear
    serprint 1, "S1A"
    Serprint 1, Solar1A
    serprint 1, "S2A"
    Serprint 1, Solar2A
    serprint 1, " ma"
    Call Second
    serprint 1, "WA"
    serprint 1, WindA
    Serprint 1, " "
    serprint 1, TEGA
    Serprint 1," mA"
    Call third
    serprint 1, "BV"
    serprint 1, BattAVG
    serprint 1, "TV"
    serprint 1, TEG_Volt
    serprint 1, " mV"
    Call Fourth
    serprint 1, "ET"
    serprint 1, ETimeHrs
    serprint 1, " "
    serprint 1, "S1T"
    serprint 1, S1TimeHrs
    serprint 1, " Hr"
    wait 3 s
    Call Clear
    serprint 1, "WT"
    serprint 1, WindTimeHrs
    serprint 1, " "
    serprint 1, "TT"
    serprint 1, TEGTimeHrs
    serprint 1, " Hr"
    Call second
    Serprint 1, "S2T"
    serprint 1, S2TimeHrs
    Serprint 1, " Hr"
    wait 3 s
    Return

    Sub Store
    EPWrite 0 , S1A_Amp_h
    EPWrite 1 , S1A_Amp
    EPWrite 2, S2A_Amp_h
    EPWrite 3, S2A_Amp
    EPWrite 4, WindA_Amp_h
    EPWrite 5, WindA_Amp
    EPWrite 6, TEGA_Amp_h
    EPWrite 7, TEGA_Amp
    EPWrite 8, TEG_Volt_h
    EPWrite 9, TEG_Volt
    EPWrite 10, SPRA_Amp_h
    EPWrite 11, SPRA_Amp
    EPWrite 12, TGen_Volt_h
    EPWrite 13, TGen_Volt
    EPWrite 14, BattAvg _Volt_h
    EPWrite 15, BattAvg _Volt
    EPWrite 16, SpareV_Volt_h
    EPWrite 17, SpareV_Volt
    EPWrite 18, INT_Temp_h
    EPWrite 19, INT_Temp
    EPWrite 20, INT_Temp_max_h
    EPWrite 21, INT_Temp_max
    EPWrite 22, INT_Temp_Min_h
    EPWrite 23, INT_Temp_Min
    EPWrite 24, EXT_Temp_h
    EPWrite 25, EXT_Temp
    EPWrite 26, EXT_Temp_max_h
    EPWrite 27, EXT_Temp_max
    EPWrite 28, EXT_Temp_min_h
    EPWrite 29, EXT_Temp_min
    EPWrite 30, E_timehrs_h
    EPWrite 31, E_timehrs
    EPWrite 32, ETS1_hrs_h
    EPWrite 33, ETS1_hrs
    EPWrite 34, ETS2_hrs_h
    EPWrite 35, ETS2_hrs
    EPWrite 36, ETW_hrs_h
    EPWrite 37, ETW_hrs
    EPWrite 38, ETT_hrs_h
    EPWrite 39, ETT_hrs
    Return

    'Display utilities
    'NewHaven Display utilities
    Sub Clear
    sersend 1, 254 'start CMD
    sersend 1, 81 'clear screen
    Return

    Sub First
    sersend 1, 254 'start CMD
    sersend 1, 69 'First line
    sersend 1, 0
    Return

    Sub Second
    sersend 1, 254 'start CMD
    sersend 1, 69 'second line
    sersend 1, 64
    Return

    Sub Third
    sersend 1, 254 'start CMD
    sersend 1, 69 'Third line
    sersend 1, 20
    Return

    Sub Fourth
    sersend 1, 254 'start CMD
    sersend 1, 69 'Fourth line
    sersend 1, 84
    Return

    Table Tconvert 'GCB can only handle positive values must subtract 80 for correct values
    0
    2
    4
    5
    7
    9
    11
    12
    13
    14
    16
    18
    20
    22
    23
    24
    25
    27
    29
    31
    32
    34
    36
    37
    38
    40
    41
    43
    45
    47
    49
    50
    51
    52
    54
    56
    58
    59
    61
    62
    63
    65
    67
    68
    70
    72
    74
    75
    76
    77
    79
    81
    83
    Temp_OS
    86
    87
    88
    90
    92
    94
    95
    97
    99
    100
    101
    103
    104
    106
    108
    110
    112
    113
    114
    115
    117
    119
    121
    122
    124
    125
    126
    128
    130
    131
    133
    135
    137
    138
    139
    140
    142
    144
    146
    148
    149
    150
    151
    153
    155
    157
    158
    160
    162
    163
    164
    166
    167
    169
    171
    173
    175
    176
    177
    178
    180
    182
    184
    1Temp_OS
    187
    189
    190
    191
    193
    194
    196
    198
    200
    201
    202
    203
    205
    207
    209
    211
    212
    213
    214
    216
    218
    220
    221
    223
    225
    225
    227
    229
    230
    232
    234
    236
    238
    238
    239
    241
    243
    245
    247
    248
    250
    251
    252
    254
    256
    257
    259
    261
    263
    263
    265
    266
    268
    270
    272
    274
    275
    275
    277
    279
    281
    283
    284
    286
    287
    288
    290
    292
    293
    295
    297
    299
    300
    301
    302
    304
    306
    308
    310
    311
    312
    313
    315
    317
    319
    320
    322
    324
    326
    326
    328
    329
    331
    333
    335
    337
    338
    338
    340
    342
    344
    346
    347
    349
    350
    351
    353
    355
    356
    358
    360
    362
    364
    364
    365
    367
    369
    371
    373
    374
    376
    376
    378
    380
    382
    383
    3Temp_OS
    387
    389
    389
    391
    392
    394
    396
    398
    400
    End Table
    ~~~~Evan Thanks, strange it does not write an error file for this error. Ed

     
  • Edward LaBudde

    Edward LaBudde - 2016-01-28

    Evan found the error in the table, somehow got some text in it. Took them out now no errors. Ed.

     
  • mmotte

    mmotte - 2016-01-28

    Ed,
    i have a question. why do you think you need the "INITUSART 'Must be used to enable Interrupt to work". When the program compiles the preprocessor automatically runs the InitUSART which sets up the ports according to the Processor statement "chip 18F4455, 40" and the #Define USART_Baud_Rate & #Define USART_Blocking statements. I don't think it is necessary for you to do it.

    Your comment suggests that you have some question on Blocking.
    ~~~~~~~~~~

    Define USART_Blocking

    ~~~~~~~~~~~

    USART_Blocking blocks for both transmit and receive
    USART_TX_Blocking only blocks for transmit.

    For transmit, Blocking means that the HSerSend waits for the Transmit input register to be empty. It is looking at the TXIF flag. Ohterwise you could "over run" the TxReg and have bytes that are not sent. Sometimes people put in delays to prevent this. But blocking does it so much slicker. The sacrifice is the program is waiting right there and not doing other things. Of course there is overhead in your program of always checking TXIF or making it an interrupt.

    For receive it is similar but it can have three results:
    1) If USART_Blocking is defined then It waits in a short loop for data to be available in the Receive "one byte buffer" by watching the RxIF flag. The sacrifice again is the program is waiting right there and not doing other things. But your guaranteed to get a NEW byte back.
    2) If USART_Blocking is Not defined then It checks if a new byte is available and returns the new byte if it is.
    3) If USART_Blocking is Not defined then It checks if a new byte is available and returns a default value of 255 indicating that this is old data If data is not available.( default value can be defined in the next update). (I am not sure if this statement is in your release)

    I hope I have not gone on too much.

    The help files will be updated soon.

    GL
    Mike

     
  • Edward LaBudde

    Edward LaBudde - 2016-01-28

    Mike, Thanks. I will Look into it. Ed.

     
  • William Roth

    William Roth - 2016-01-29

    Ed,

    While your serial polarity will be correct, the code is not.

    By definition:

    1) "Normal" serial idles high, where a data "1" is high and a data "0" is low
    2) "Inverted" serial idles low, where a data "1" is low and a data "0" is high
    .
    Your device requires "normal" or standard serial.

    The correct way to set up software serial is like below ....

    initser 1,r9600,2,8,1,none, normal '// idle high 
    #define SendAHigh Set GPIO.2 on
    #define SendALow Set GPIO.2  off
    

    William

     
  • Edward LaBudde

    Edward LaBudde - 2016-01-29

    William, Thanks, I will try it. Ed.

     
  • Edward LaBudde

    Edward LaBudde - 2016-01-30

    Evan, the file is posted here. Thanks, Ed.

     
  • Edward LaBudde

    Edward LaBudde - 2016-01-30

    Evan, took your suggestion and it appears to be working OK. Thanks, Ed.

     
  • Anobium

    Anobium - 2016-01-30

    @Edward . I am confused. What is working ok?

     
  • Edward LaBudde

    Edward LaBudde - 2016-01-30

    Evan, the pickit 2 is working correctly I had wrong chip number. Thanks, Ed.

     
  • Anobium

    Anobium - 2016-01-30

    I have a revised programmīng command file that issues a more meaningful message when this happens. Send me a personal message and I can let you try it.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.