Haberler:

Eposta uyarılarını yanıtlamayınız ( ! ) https://bit.ly/2J7yi0d

Ana Menü

proton'da hata

Başlatan igolcubasi, 18 Ağustos 2007, 21:25:03

igolcubasi

' The MEDIAN_SAMPLE array declaration and its associated constants (below) should be placed at the end of the DIM list
'
Symbol MEDIAN_SAMPLES_TO_TAKE = 21 ' The amount of samples to take
#IF(MEDIAN_SAMPLES_TO_TAKE > 127)
#ERROR"Constant MEDIAN_SAMPLES_TO_TAKE cannot be greater than 127"
#ENDIF
Symbol MIDDLE_SAMPLE = (MEDIAN_SAMPLES_TO_TAKE / 2) + 1 ' The middle sample of the samples taken
Dim MEDIAN_SAMPLE[MEDIAN_SAMPLES_TO_TAKE] As Word ' Create an array to hold the range samples

bu derlediğim programın bir parçası ve şu hatayı veriyor ve şu satırı gösteriyor  #ERROR"Constant MEDIAN_SAMPLES_TO_TAKE cannot be greater than 127"

hata mesajıda
Cannot assign a Variable to a Numeric Constant!

sorunu çözmeme yardımlarınızı bekliyorum.

z

#ERROR"Constant MEDIAN_SAMPLES_TO_TAKE cannot be greater than 127"

Bunun anlami: 2 ye tumleyen isaretli sayi sisteminde 8 bit ile ifade edilebilecek en buyuk sayi +127 dir. MEDIAN_SAMPLES_TO_TAKE 8 bitlik isaretli sayi tutan degisken ise bu degiskenin 127 den buyuk sayi icermesi mumkun değildir.

Sirf test acisindan karsilastirmadaki 127 degerini 126 yaparsan hatanin kaybolmasi gerekir.

Asil cozum, MEDIAN_SAMPLES_TO_TAKE degiskenini mumkun oluyorsa 16 bit tanimlamak olacaktir.

Bir diger cozum ise eger MEDIAN_SAMPLES_TO_TAKE isaretli sayilar icermeyecekse bunu isaretsiz sayi degiskeni olarak tanimlamaktir.
Bana e^st de diyebilirsiniz.   www.cncdesigner.com

igolcubasi

Include "PROTON18_20.INC"

FLOAT_DISPLAY_TYPE = LARGE ' Use the larger but faster floating point display routine

Dim MEDIAN_SWAP As Word ' Temporary Median Filter variable for swapping
Dim MEDIAN_INDEX As Byte ' Holds the position in the Bubble sort
Dim MEDIAN_SWAP_OCCURED As Bit ' Indicates if the Bubble sort is complete
Dim THERMISTOR_VALUE As Word ' Holds the raw thermistor ADC reading
Dim RESISTANCE As Float ' Holds the resistance of the thermistor for a given temperature
Dim TEMPERATURE As Float ' Holds the floating point temperature in degrees Centigrade
Dim TEMP As Float ' Temporary variable for the thermistor linearisation
Dim LN As Float ' Used to hold the LOG of the thermistor value
'
' The MEDIAN_SAMPLE array declaration and its associated constants (below) should be placed at the end of the DIM list
'
Symbol MEDIAN_SAMPLES_TO_TAKE = 21 ' The amount of samples to take
#IF(MEDIAN_SAMPLES_TO_TAKE > 127)
#ERROR"Constant MEDIAN_SAMPLES_TO_TAKE cannot be greater than 127"
#ENDIF
Symbol MIDDLE_SAMPLE = (MEDIAN_SAMPLES_TO_TAKE / 2) + 1 ' The middle sample of the samples taken
Dim MEDIAN_SAMPLE[MEDIAN_SAMPLES_TO_TAKE] As Word ' Create an array to hold the range samples


Dim AD_RESULT As ADRESL.Word ' Alias the 16-bit ADRESL\H register as AD_RESULT
Symbol GO_DONE = ADCON0.2 ' ADC completion poll bit
'
' Constant values used for the Stein-Hart thermistor linearisation routine
'
Symbol QUANTA = 5000.0 / 1024.0 ' Quatasising constant for ADC reading to Voltage calculation
Symbol T25 = 0.0033540 ' Thermistor's t25 value
Symbol B = 1.0 / 3489.0 ' Thermistor's B value
'
' The Stein-Hart linearising equation below is only suitable for describing a restricted range around
' the rated temperature or resistance with sufficient accuracy.
'
' 1
' Tt = ------------------------
' 1/B * Ln(Rt/R25) + 1/T25
'
' The B values for common NTC thermistors range from 2000K through to 5000K.
' For this application, the popular, and more complicated, Stein-Hart equation is more accurate.
'
' The thermistor used did not provide the B value within its datasheet, but did give the T25 value.
' i.e. resistance at 25 degrees Centigrade.
' To calculate the B value use the equation below.
'
' Tt * T25 R25
' B = ---------- * Ln ------
' Tt - T25 R100
'
' or: -
'
' (25 + 273.13) * (100 + 273.15) R25
' B = -------------------------------- * Ln ------
' 75 R100
'
' giving: -
'
' R25
' B = 1483.4 * Ln ------
' R100
'
' Thus, knowing the resistance at 25 degrees Centigrade and also at 100 degrees Centigrade
' we can use the above calculation to find the value of B for a given thermistor.

'---------------------------------------------------------------------------------------
' THE MAIN DEMO PROGRAM LOOP STARTS HERE

DelayMS 200 ' Wait for things to stabilise
Cls ' Clear the LCD
Print 254,72,%00000110,%00001001,%00001001,%00000110,0,0,0,0 ' Build the LCD degrees symbol in character 1

While 1 = 1 ' Create an infinite loop
GoSub READ_TEMP_SENSOR ' Read and linearise the thermistor
Print At 1,1,DEC1 TEMPERATURE,1,"C " ' Display the result on the LCD
DelayMS 100 ' Wait a while
Wend ' Close the loop

'----------------------------------------------------------------------------------------------------
' Subroutines Start Here
'-----------------------------------------------------------------------------------------------------
' Create a MEDIAN filter to make an educated guess as to what is the true reading from the temperature readings taken.
' The routine below is a BUBBLE SORT, that arranges all the samples in ascending order within the array MEDIAN_SAMPLES.
' The middle sample is then extracted.
' This should eliminate spurious readings from the edges.
' Input : Array MEDIAN_SAMPLE holds "MEDIAN_SAMPLES_TO_TAKE" temperature readings taken
' Output : THERMISTOR_VALUE = the median (middle value) of the samples taken
'
MEDIAN_FILTER:
Repeat
MEDIAN_SWAP_OCCURED = 0 ' Clear flag that indicates swap.
MEDIAN_INDEX = 0
Repeat ' For each cell of the array...
If MEDIAN_SAMPLE[MEDIAN_INDEX] > MEDIAN_SAMPLE[MEDIAN_INDEX + 1] Then ' Move larger values up.
MEDIAN_SWAP = MEDIAN_SAMPLE[MEDIAN_INDEX] ' ..by swapping them.
MEDIAN_SAMPLE[MEDIAN_INDEX] = MEDIAN_SAMPLE[MEDIAN_INDEX + 1]
MEDIAN_SAMPLE[MEDIAN_INDEX + 1] = MEDIAN_SWAP
MEDIAN_SWAP_OCCURED = 1 ' Set bit if swap occurred.
EndIf
Inc MEDIAN_INDEX
Until MEDIAN_INDEX = MEDIAN_SAMPLES_TO_TAKE ' Check out next cell of the array.
Until MEDIAN_SWAP_OCCURED = 0 ' Keep sorting until no more swaps.
THERMISTOR_VALUE = MEDIAN_SAMPLE[MIDDLE_SAMPLE] ' Extract the middle sample's value
Return

'-----------------------------------------------------------------------------------------------------
' Read the thermistor temperature sensor on AN0 (PORTA.0) and linearise the result
' Input : None
' Output : TEMPERATURE = Temperature in degrees Centigrade
' Notes : The thermistor is sampled by the ADC with 10-bit resolution several times
' : based on the constant "MEDIAN_SAMPLES_TO_TAKE".
' : A Median filter is then called to filter out any noise
' : Then the raw (filtered) thermistor value is run through a Stein-Hart calculation
' : which linearises the value into degrees Centigrade.
' : Accuracy depends on the thermistor and its accompanying 10K Ohm resistor.
'
READ_TEMP_SENSOR:
ADCON1 = %10000000 ' Make PORTA and PORTE all analogue and Right justify the ADC result
ADCON0 = %10000001 ' Set ADC: FRC/32 OSC, AN0, GO_DONE = 0, ADC Powered up
For MEDIAN_INDEX = 0 To MEDIAN_SAMPLES_TO_TAKE - 1 ' Form a loop for the amount of temperature readings to take
DelayUS 5 ' Wait for the ADC's internal capacitors to charge
GO_DONE = 1 ' \ Take an ADC reading
Repeat : Until GO_DONE = 0 ' / Wait for the ADC conversion to finish
MEDIAN_SAMPLE[MEDIAN_INDEX] = AD_RESULT ' Add the reading to the median array
Next ' Close the loop
GoSub MEDIAN_FILTER ' Perform a median filter on the temperatures read
'
' Perform a Stein-Hart calculation to linearise the thermistor into degrees Centigrade
'
TEMPERATURE = THERMISTOR_VALUE * QUANTA ' \
TEMP = 5000 - TEMPERATURE ' Find the resistance across the thermistor
RESISTANCE = (TEMPERATURE * 10000) / TEMP ' /
LN = Log (RESISTANCE / 10000) ' \
TEMPERATURE = B * LN + T25 ' / Linearise the result using the stein-hart algorithm
TEMPERATURE = (1 / TEMPERATURE) - 273.15 ' Convert from Kelvin to Centigrade
ADCON1 = 7 ' Make PORTA and PORTE all digital
Return ' Then return from the subroutine

Bunalmış;
sevgili dostum program bu ve sorun devam ediyor

z

Aslini sorarsan ilgilenmedigim bir derleyici uzerine konusuyorum. Sadece mesaj dikkatimi cekti ve o yuzden yaziyorum.

Asagidaki 3 satir anladigim kadariyla derleyiciye ait sahte kod. Bu satirlari rem ile iptal ettiginde sorun kalkiyorsa kaldirmanin zarari yok gorunuyor.

#IF(MEDIAN_SAMPLES_TO_TAKE > 127)
#ERROR"Constant MEDIAN_SAMPLES_TO_TAKE cannot be greater than 127"
#ENDIF
Bana e^st de diyebilirsiniz.   www.cncdesigner.com